﻿/* ═══════════════════════════════════════════════════════════════════════
   ScannerWriteStation.css
   Reprend exactement la charte graphique existante :
   - Variables CSS du projet (--primary-blue, --success-color, etc.)
   - Classes réutilisées : card-header, scanner-col-header, scanner-row,
     scanner-chip, write-antenna-anim, write-instruction-*, scan-indicator…
   - Fond blanc / gris clair, ombres légères, radius 12px
   - Police Montserrat héritée du body
═══════════════════════════════════════════════════════════════════════ */

/* ── Page ──────────────────────────────────────────────────────────────── */
.sw-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg-primary);
    font-family: 'Montserrat', Arial, sans-serif;
}

/* ── Header (réutilise .card-header du projet) ─────────────────────────── */
.sw-header {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 200;
    /* card-header fournit déjà le gradient + padding */
}

.sw-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.sw-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.sw-header-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sw-header-icon-wrap {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    flex-shrink: 0;
}

.sw-header-h1 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--white);
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.sw-header-sub {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 2px;
    font-weight: 500;
}

.sw-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* Stats badges — étend .rfid-stat du projet */
.rfid-stat--success {
    background: rgba(16, 185, 129, 0.25) !important;
    border-color: rgba(16, 185, 129, 0.3) !important;
}

.rfid-stat--warn {
    background: rgba(245, 158, 11, 0.25) !important;
    border-color: rgba(245, 158, 11, 0.3) !important;
}

/* ── Body scroll area ──────────────────────────────────────────────────── */
.sw-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

/* ── Layout 2 colonnes ─────────────────────────────────────────────────── */
.sw-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    padding: 20px 24px 32px;
    max-width: 1320px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    align-items: start;
}

@media (max-width: 1024px) {
    .sw-layout {
        grid-template-columns: 1fr;
    }

    .sw-sidebar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }
}

@media (max-width: 640px) {
    .sw-layout {
        padding: 12px 14px 24px;
        gap: 12px;
    }

    .sw-sidebar {
        grid-template-columns: 1fr;
    }
}

.sw-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.sw-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── États centrés (loading / done) ────────────────────────────────────── */
.sw-state-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 60px 24px;
    text-align: center;
}

.sw-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: sw-spin 0.75s linear infinite;
}

@keyframes sw-spin {
    to {
        transform: rotate(360deg);
    }
}

.sw-state-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.sw-state-h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
}

.sw-state-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ── Carte article en cours ─────────────────────────────────────────────── */
.sw-article-card {
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.sw-article-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.sw-article-card-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex-wrap: wrap;
}

.sw-article-card-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.sw-article-name {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
    letter-spacing: -0.01em;
}

/* ── Corps 2 colonnes ──────────────────────────────────────────────────── */
.sw-article-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 320px;
}

@media (max-width: 768px) {
    .sw-article-body {
        grid-template-columns: 1fr;
    }
}

/* ── Panneau infos ──────────────────────────────────────────────────────── */
.sw-article-info {
    padding: 20px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

@media (max-width: 768px) {
    .sw-article-info {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
}

.sw-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.825rem;
}

.sw-info-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    min-width: 90px;
    flex-shrink: 0;
}

.sw-info-val {
    color: var(--text-primary);
    font-weight: 600;
}

/* ── Box EPC cible ─────────────────────────────────────────────────────── */
.sw-epc-box {
    background: var(--bg-accent);
    border: 1.5px solid rgba(0, 119, 182, 0.18);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}

.sw-epc-box-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary-blue);
    margin-bottom: 6px;
}

.sw-epc-box-val {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-blue);
    letter-spacing: 0.12em;
    word-break: break-all;
    line-height: 1.4;
}

/* ── Zone scan ──────────────────────────────────────────────────────────── */
.sw-scan-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 20px;
    transition: background 0.3s ease;
    min-height: 280px;
}

.sw-scan-zone--idle {
    background: var(--gray-50);
}

.sw-scan-zone--scanning {
    background: linear-gradient(135deg, rgba(0,119,182,0.03), rgba(0,180,216,0.05));
}

.sw-scan-zone--selected {
    background: rgba(16, 185, 129, 0.04);
}

.sw-scan-zone--writing {
    background: linear-gradient(135deg, rgba(0,119,182,0.05), rgba(0,180,216,0.08));
}

.sw-scan-zone--success {
    background: rgba(16, 185, 129, 0.06);
}

.sw-scan-zone--error {
    background: rgba(239, 68, 68, 0.04);
}

.sw-scan-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

/* Variantes antenna icon selon état */
.sw-antenna-icon--off {
    background: var(--gray-200) !important;
    box-shadow: none !important;
    color: var(--gray-400) !important;
}

.sw-antenna-icon--selected {
    background: linear-gradient(135deg, var(--success-color), #059669) !important;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.35) !important;
}

/* Rings désactivées quand off */
.sw-rings--off .write-ring {
    border-color: var(--gray-200) !important;
    animation-play-state: paused !important;
}

/* Rings vertes quand selected */
.sw-rings--selected .write-ring {
    border-color: rgba(16, 185, 129, 0.5) !important;
}

/* Accélération animation en écriture */
.sw-anim--writing .write-ring {
    animation-duration: 1s !important;
}

/* Textes dans zone scan */
.write-writing-info h3 {
    color: var(--text-primary);
}

.sw-success-title {
    color: var(--success-color) !important;
}

.sw-error-title {
    color: var(--danger-color) !important;
}

/* ── Footer actions article ─────────────────────────────────────────────── */
.sw-article-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--gray-50);
    flex-wrap: wrap;
}

/* ── Boutons ────────────────────────────────────────────────────────────── */
.sw-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.825rem;
    font-weight: 700;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: all 0.18s ease;
    white-space: nowrap;
    font-family: inherit;
    letter-spacing: -0.01em;
    text-decoration: none;
}

    .sw-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
        transform: none !important;
        box-shadow: none !important;
    }

/* Primary — gradient bleu comme les modales */
.sw-btn--primary {
    background: var(--gradient-primary);
    color: var(--white);
    border-color: transparent;
    box-shadow: var(--shadow-colored);
}

    .sw-btn--primary:not(:disabled):hover {
        transform: translateY(-1px);
        box-shadow: 0 8px 20px rgba(0, 119, 182, 0.28);
    }

/* Secondary */
.sw-btn--secondary {
    background: var(--white);
    color: var(--text-primary);
    border-color: var(--border-color);
    box-shadow: var(--shadow-sm);
}

    .sw-btn--secondary:not(:disabled):hover {
        background: var(--gray-50);
        border-color: var(--gray-300);
    }

/* Outline */
.sw-btn--outline {
    background: transparent;
    color: var(--primary-blue);
    border-color: var(--primary-blue);
}

    .sw-btn--outline:not(:disabled):hover {
        background: var(--bg-accent);
    }

/* Ghost / skip */
.sw-btn--ghost {
    background: transparent;
    color: var(--warning-color);
    border-color: rgba(245, 158, 11, 0.4);
}

    .sw-btn--ghost:not(:disabled):hover {
        background: rgba(245, 158, 11, 0.08);
        border-color: var(--warning-color);
    }

/* Encode — vert succès */
.sw-btn--encode {
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: var(--white);
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

    .sw-btn--encode:not(:disabled):hover {
        transform: translateY(-1px);
        box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4);
    }

/* ── Panneau tags détectés ──────────────────────────────────────────────── */
.sw-detected-card {
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Barre d'avertissement (réutilise styles du projet) */
.sw-warning-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(245, 158, 11, 0.07);
    border-top: 1px solid rgba(245, 158, 11, 0.2);
    font-size: 0.78rem;
    font-weight: 600;
    color: #92400e;
}

/* ── Sidebar : file d'attente ───────────────────────────────────────────── */
.sw-queue-card,
.sw-done-list-card {
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.sw-done-list-body {
    max-height: 220px;
}

/* ── Override h4 du projet (il force color:primary) ────────────────────── */
.sw-page h4 {
    color: var(--text-primary);
    border-bottom: none;
    font-size: 0.78rem;
    font-weight: 700;
    margin: 0;
    padding: 0;
}

/* ── Override write-instruction-header icon color ──────────────────────── */
.write-instruction-header i,
.write-instruction-header svg {
    color: var(--primary-blue);
}

/* Forcer bonne couleur h3 dans zone scan (le projet force h3 color:white) */
.sw-scan-zone h3,
.write-writing-info h3,
.write-done-title {
    color: var(--text-primary) !important;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sw-header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .sw-header-right {
        width: 100%;
        justify-content: space-between;
    }

    .sw-article-name {
        max-width: 200px;
    }

    .sw-article-footer {
        flex-direction: column;
        gap: 8px;
    }

        .sw-article-footer .footer-left,
        .sw-article-footer .footer-right {
            width: 100%;
            justify-content: stretch;
        }

    .sw-btn {
        flex: 1;
        justify-content: center;
    }

    .sw-state-center {
        padding: 40px 16px;
    }
}

@media (max-width: 480px) {
    .sw-article-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .sw-article-card-header-right {
        width: 100%;
    }
}
