/* ============================================================
   scanner.css — Interface kiosque ArcelorMittal Scanner
   Design : fond navy sombre + panneau auto-exit blanc
   Cible principale : 1920×1080 et 1280×1024
   ============================================================ */

/* ── Variables ───────────────────────────────────────────────── */
:root {
    --color-gradient-start: #F5821F;
    --color-gradient-end:   #BE1070;
    --color-bg:             #F2F2F2;
    --color-surface:        #FFFFFF;
    --color-text:           #1A1A1A;
    --color-muted:          #777777;
    --color-primary:        #1976D2;
    --color-success:        #43A047;
    --color-error:          #e53935;
    --color-warning:        #f39c12;
    --color-dark-start:     #15233b;
    --color-dark-mid:       #1a2a4a;
    --color-dark-end:       #1e3460;
    --color-debug-bg:       #111;
    --header-height:        72px;
    --nav-height:           88px;
}

/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin:  0;
    padding: 0;
}

body.scanner-kiosk {
    margin:      0;
    overflow:    hidden;
    height:      100vh;
    background:  var(--color-dark-start);
    color:       #fff;
    font-family: 'Segoe UI', Arial, sans-serif;
    user-select: none;
}

/* ── Utilitaire ──────────────────────────────────────────────── */
.hidden {
    display: none !important;
}

/* ── App principale ──────────────────────────────────────────── */
#scanner-app {
    height:         100vh;
    display:        flex;
    flex-direction: column;
    align-items:    stretch;
    background:     var(--color-dark-start);
    position:       relative;
    padding-top:    var(--header-height);
}

/* ── Zone 1 : En-tête blanc — logo ArcelorMittal couleurs réelles ─ */
#top-bar {
    position:        fixed;
    top:             0;
    left:            0;
    right:           0;
    height:          var(--header-height);
    display:         flex;
    align-items:     center;
    justify-content: flex-end;
    padding:         0 36px;
    background:      #ffffff;
    border-bottom:   1px solid rgba(0, 0, 0, 0.08);
    box-shadow:      0 2px 10px rgba(0, 0, 0, 0.10);
    flex-shrink:     0;
    z-index:         200;
    pointer-events:  none;
}

#am-logo {
    height:         52px;
    width:          auto;
    flex-shrink:    0;
    pointer-events: auto;
}

#btn-debug {
    pointer-events: auto;
    background:     transparent;
    border:         none;
    color:          rgba(0, 0, 0, 0.25);
    font-size:      1.1rem;
    cursor:         pointer;
    padding:        4px 8px;
    border-radius:  4px;
    transition:     color 0.2s;
    line-height:    1;
    margin-left:    12px;
    position:       static;
    transform:      none;
}

#btn-debug:hover {
    color: rgba(0, 0, 0, 0.60);
}

/* ── Zone 2 : Barre Succursale + Porte — bleu foncé ──────────── */
#nav-bar {
    min-height:      var(--nav-height);
    display:         flex;
    align-items:     center;
    justify-content: center;
    flex-direction:  column;
    gap:             6px;
    padding:         20px 32px;
    background:      linear-gradient(180deg, var(--color-dark-start) 0%, var(--color-dark-mid) 100%);
    border-bottom:   1px solid rgba(255, 255, 255, 0.06);
    flex-shrink:     0;
    position:        relative;
}

#nav-left {
    display:        flex;
    flex-direction: column;
    align-items:    center;
    gap:            4px;
    width:          100%;
    text-align:     center;
}

#display-gate {
    font-size:      3rem;
    font-weight:    900;
    color:          #fff;
    text-transform: uppercase;
    letter-spacing: 7px;
    text-align:     center;
    line-height:    1.1;
    text-shadow:    0 2px 16px rgba(0, 0, 0, 0.4);
}

#display-site {
    font-size:      0.95rem;
    font-weight:    400;
    color:          rgba(255, 255, 255, 0.48);
    text-align:     center;
    letter-spacing: 1px;
}

#nav-right {
    position:    absolute;
    right:       32px;
    top:         50%;
    transform:   translateY(-50%);
    display:     flex;
    align-items: center;
    gap:         10px;
    font-size:   0.8rem;
    color:       rgba(255, 255, 255, 0.38);
}

/* ── Indicateur connexion ────────────────────────────────────── */
#connection-status {
    display:     flex;
    align-items: center;
    gap:         5px;
    font-size:   0.75rem;
    color:       rgba(255, 255, 255, 0.38);
}

#connection-status::before {
    content:       '';
    display:       inline-block;
    width:         8px;
    height:        8px;
    border-radius: 50%;
    background:    rgba(255, 255, 255, 0.22);
    flex-shrink:   0;
    transition:    background 0.3s;
}

#connection-status.online::before {
    background: var(--color-success);
    box-shadow: 0 0 6px rgba(67, 160, 71, 0.6);
}

#connection-status.offline::before {
    background: var(--color-error);
    box-shadow: 0 0 6px rgba(229, 57, 53, 0.6);
}

#connection-status[data-status]::after {
    content: attr(data-status);
}

/* ── Zone 3 : Zone de scan — bleu progressif (clair → foncé) ─── */
#scan-zone {
    flex:            1;
    display:         flex;
    flex-direction:  row;
    align-items:     center;
    justify-content: center;
    gap:             56px;
    padding:         40px 60px;
    background:      linear-gradient(180deg, #1e5fa8 0%, #144898 40%, #0e3278 75%, #091f58 100%);
    color:           #fff;
}

/* Icône scan — à gauche de la fenêtre d'entrée */
#scan-icon-left {
    display:     flex;
    align-items: center;
    flex-shrink: 0;
    color:       rgba(255, 255, 255, 0.55);
    animation:   pulse 2.4s ease-in-out infinite;
}

/* Zone centrale : état + input + assistance + messages */
#scan-main {
    display:        flex;
    flex-direction: column;
    align-items:    center;
    gap:            32px;
    flex:           1;
    max-width:      560px;
    text-align:     center;
    transform:      translateX(-55px);
}

/* Champ scan — visible pour saisie manuelle */
#scanner-input {
    opacity:          1;
    position:         relative;
    background-color: rgba(255, 255, 255, 0.95);
    width:            440px;
    height:           auto;
    border:           2px solid rgba(255, 255, 255, 0.25);
    border-radius:    14px;
    outline:          revert;
    padding:          16px 24px;
    font-size:        1.6rem;
    color:            var(--color-text);
    text-align:       center;
    box-shadow:       0 8px 32px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.2);
    transition:       box-shadow 0.2s, border-color 0.2s;
}

#scanner-input:focus {
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow:   0 8px 40px rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.12);
}

/* ── Messages ────────────────────────────────────────────────── */
#scan-message {
    font-size:      2.5rem;
    font-weight:    bold;
    text-align:     center;
    line-height:    1.3;
    max-width:      900px;
    padding:        24px 40px;
    border-radius:  16px;
    animation:      fadeIn 0.2s ease-in;
    color:          #fff;
}

#scan-message.success {
    font-size:       2.5rem;
    color:           #fff;
    background:      rgba(67, 160, 71, 0.88);
    border:          1px solid rgba(67, 160, 71, 0.4);
    text-align:      center;
    font-weight:     bold;
    backdrop-filter: blur(6px);
}

#scan-message.error {
    font-size:       2.5rem;
    color:           #fff;
    background:      rgba(229, 57, 53, 0.88);
    border:          1px solid rgba(229, 57, 53, 0.4);
    text-align:      center;
    font-weight:     bold;
    backdrop-filter: blur(6px);
}

/* ── Spinner ─────────────────────────────────────────────────── */
#scan-spinner {
    width:            64px;
    height:           64px;
    border:           6px solid rgba(255, 255, 255, 0.12);
    border-top-color: rgba(255, 255, 255, 0.8);
    border-radius:    50%;
    animation:        rotate 0.8s linear infinite;
}

@keyframes rotate {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Message assistance intercom ─────────────────────────────── */
#scan-assistance {
    font-size:      1.4rem;
    color:          rgba(255, 255, 255, 0.38);
    text-align:     center;
    font-style:     italic;
    letter-spacing: 0.5px;
}

/* ── Scan Ready ──────────────────────────────────────────────── */
#scan-ready {
    display:     flex;
    align-items: center;
    color:       rgba(255, 255, 255, 0.70);
}

#scan-ready-text {
    font-size:      1.5rem;
    text-transform: uppercase;
    letter-spacing: 5px;
    color:          rgba(255, 255, 255, 0.70);
    text-align:     center;
}

@keyframes pulse {
    0%, 100% { opacity: 0.22; }
    50%       { opacity: 0.60; }
}

/* ── Panneau Auto-Exit — fond blanc ──────────────────────────── */
#auto-exit-panel {
    position:        fixed;
    top:             var(--header-height);
    left:            0;
    right:           0;
    bottom:          0;
    background:      linear-gradient(180deg, #1e5fa8 0%, #144898 40%, #0e3278 75%, #091f58 100%);
    z-index:         100;
    display:         flex;
    flex-direction:  column;
    align-items:     stretch;
    overflow-y:      auto;
    color:           #fff;
}

/* Header : fond bleu foncé — nom + compagnie du visiteur */
#ae-header {
    background:     linear-gradient(180deg, var(--color-dark-start) 0%, var(--color-dark-mid) 100%);
    border-bottom:  1px solid rgba(255, 255, 255, 0.06);
    display:        flex;
    flex-direction: column;
    align-items:    center;
    gap:            10px;
    padding:        40px 40px 32px;
    flex-shrink:    0;
}

/* Contenu principal centré verticalement */
#ae-main-content {
    flex:            1;
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    justify-content: center;
    gap:             20px;
    width:           100%;
    padding:         40px;
}

/* Bloc inférieur */
#ae-bottom {
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    gap:             12px;
    width:           100%;
    padding:         0 40px 32px;
}

#ae-employee-name {
    font-size:   3rem;
    font-weight: bold;
    color:       var(--color-success);
    text-align:  center;
}

#ae-employee-company {
    font-size:   1.8rem;
    color:       rgba(255, 255, 255, 0.80);
    text-align:  center;
    font-weight: 400;
}

#ae-btn-more-cards {
    display:       flex;
    align-items:   center;
    gap:           18px;
    padding:       18px 28px;
    font-size:     1.4rem;
    font-weight:   500;
    background:    rgba(255, 255, 255, 0.12);
    color:         #fff;
    border:        2px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    cursor:        pointer;
    transition:    background 0.18s, border-color 0.18s, box-shadow 0.18s;
    width:         100%;
    max-width:     520px;
    text-align:    left;
    box-shadow:    0 1px 6px rgba(0, 0, 0, 0.15);
}

#ae-btn-more-cards:hover {
    background:   rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.45);
    box-shadow:   0 3px 12px rgba(0, 0, 0, 0.22);
}

#ae-assistance {
    font-size:  1rem;
    color:      rgba(255, 255, 255, 0.55);
    text-align: center;
    font-style: italic;
    max-width:  600px;
}

#ae-additional-section {
    display:        flex;
    flex-direction: column;
    align-items:    stretch;
    gap:            14px;
    width:          100%;
    max-width:      520px;
}

#ae-passenger-scan {
    width:         100%;
    padding:       14px 18px;
    font-size:     1.4rem;
    background:    var(--color-surface);
    border:        2px solid var(--color-success);
    border-radius: 10px;
    color:         var(--color-text);
    outline:       none;
    box-shadow:    0 2px 10px rgba(67, 160, 71, 0.15);
    transition:    box-shadow 0.2s, border-color 0.2s;
}

#ae-passenger-scan:focus {
    border-color: #2e7d32;
    box-shadow:   0 2px 10px rgba(67, 160, 71, 0.25), 0 0 0 3px rgba(67, 160, 71, 0.12);
}

#ae-passenger-scan::placeholder {
    color: #BDBDBD;
}

#ae-passengers-list {
    width:          100%;
    display:        flex;
    flex-direction: column;
    gap:            8px;
    max-height:     240px;
    overflow-y:     auto;
}

.passenger-entry {
    display:       flex;
    align-items:   center;
    gap:           12px;
    font-size:     1.2rem;
    padding:       12px 18px;
    background:    rgba(255, 255, 255, 0.12);
    border:        1px solid rgba(255, 255, 255, 0.20);
    border-radius: 10px;
    color:         #fff;
    flex-wrap:     wrap;
}

.passenger-name {
    font-weight: 600;
}

.passenger-company {
    font-size:  1rem;
    color:      var(--color-muted);
    font-style: italic;
}

#ae-api-message {
    font-size:     1.7rem;
    font-weight:   bold;
    text-align:    center;
    padding:       18px 36px;
    border-radius: 12px;
    max-width:     680px;
    width:         100%;
    animation:     fadeIn 0.25s ease-in;
}

#ae-api-message.success {
    color:      #fff;
    background: var(--color-success);
    border:     none;
    box-shadow: 0 4px 16px rgba(67, 160, 71, 0.3);
}

#ae-api-message.success::before {
    content: '✓  ';
}

#ae-api-message.error {
    color:      #721C24;
    background: #F8D7DA;
    border:     1px solid #F5C6CB;
}

#ae-waiting-banner {
    width:         100%;
    max-width:     680px;
    background:    rgba(255, 255, 255, 0.15);
    border:        2px solid rgba(255, 255, 255, 0.30);
    color:         #FFF;
    font-size:     1.5rem;
    font-weight:   bold;
    text-align:    center;
    padding:       18px 28px;
    border-radius: 12px;
    animation:     fadeIn 0.3s ease-in;
    box-shadow:    0 4px 16px rgba(0, 0, 0, 0.15);
}

#ae-reminder {
    font-size:  1rem;
    color:      rgba(255, 255, 255, 0.65);
    text-align: center;
    max-width:  600px;
}

#ae-countdown {
    font-size:   3.5rem;
    font-weight: bold;
    color:       #fff;
}

#ae-btn-terminer {
    padding:       18px 56px;
    font-size:     1.5rem;
    font-weight:   700;
    background:    var(--color-success);
    color:         #FFF;
    border:        none;
    border-radius: 12px;
    cursor:        pointer;
    transition:    opacity 0.2s, transform 0.15s, box-shadow 0.2s;
    margin-top:    8px;
    width:         100%;
    max-width:     420px;
    box-shadow:    0 4px 16px rgba(67, 160, 71, 0.35);
    letter-spacing: 1px;
}

#ae-btn-terminer:hover:not(:disabled) {
    opacity:    0.92;
    transform:  translateY(-2px);
    box-shadow: 0 6px 24px rgba(67, 160, 71, 0.45);
}

#ae-btn-terminer:disabled {
    opacity: 0.38;
    cursor:  default;
    box-shadow: none;
    transform: none;
}

/* ── Console de debug ────────────────────────────────────────── */
#debug-console {
    position:            fixed;
    bottom:              0;
    right:               0;
    width:               40vw;
    height:              40vh;
    background:          var(--color-debug-bg);
    color:               #EEE;
    font-family:         monospace;
    font-size:           0.78rem;
    overflow-y:          scroll;
    z-index:             300;
    border-top-left-radius: 8px;
    border-left:         2px solid #333;
    border-top:          2px solid #333;
    padding:             8px 8px 40px;
}

#debug-log {
    display:        flex;
    flex-direction: column;
    gap:            1px;
}

.debug-entry {
    padding:       2px 4px;
    border-bottom: 1px solid #1A1A1A;
    word-break:    break-all;
}

.debug-entry.INFO    { color: #FFF; }
.debug-entry.SUCCESS { color: var(--color-success); }
.debug-entry.ERROR   { color: var(--color-error); }
.debug-entry.WARNING { color: var(--color-warning); }

#debug-close,
#debug-clear {
    position:      sticky;
    bottom:        0;
    padding:       4px 14px;
    font-size:     0.78rem;
    background:    #2A2A2A;
    color:         #EEE;
    border:        1px solid #444;
    border-radius: 4px;
    cursor:        pointer;
    margin-right:  6px;
    margin-top:    6px;
}

#debug-close:hover,
#debug-clear:hover {
    background: #3A3A3A;
}

/* ── Page erreur Code Porte ──────────────────────────────────── */
#scanner-error {
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    justify-content: center;
    flex:            1;
    gap:             16px;
    text-align:      center;
    padding:         40px;
    color:           #fff;
}

#scanner-error h2 {
    font-size: 2rem;
    color:     #ff6b6b;
}

#scanner-error p {
    font-size: 1.1rem;
    color:     rgba(255, 255, 255, 0.55);
}

#error-code {
    margin-top:    16px;
    padding:       8px 24px;
    background:    rgba(255, 255, 255, 0.08);
    border:        1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    font-size:     1.2rem;
    color:         rgba(255, 255, 255, 0.85);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1280px) {
    #scan-message,
    #scan-message.success,
    #scan-message.error {
        font-size: 2rem;
    }
    #ae-employee-name {
        font-size: 2.2rem;
    }
    #scan-icon-left svg {
        width:  80px;
        height: 90px;
    }
    #scan-ready-text {
        font-size:      1.3rem;
        letter-spacing: 4px;
    }
    #display-gate {
        font-size:      2.4rem;
        letter-spacing: 5px;
    }
}

@media (max-width: 1024px) {
    :root {
        --header-height: 60px;
        --nav-height:    72px;
    }
    #am-logo {
        height: 42px;
    }
    #scan-zone {
        gap:     32px;
        padding: 30px 32px;
    }
    #scan-icon-left svg {
        width:  60px;
        height: 70px;
    }
    #scan-main {
        transform: translateX(-30px);
    }
    #scan-message,
    #scan-message.success,
    #scan-message.error {
        font-size: 1.6rem;
    }
    #scan-ready-text {
        font-size:      1.2rem;
        letter-spacing: 3px;
    }
    #scanner-input {
        width:     340px;
        font-size: 1.3rem;
    }
    #scan-assistance {
        font-size: 1.1rem;
    }
    #display-gate {
        font-size:      1.9rem;
        letter-spacing: 4px;
    }
    #debug-console {
        width:  60vw;
        height: 50vh;
    }
}

@media (max-width: 768px) {
    #scan-zone {
        flex-direction: column;
        gap:            24px;
    }
    #scan-icon-left {
        display: none;
    }
    #scan-main {
        transform: none;
    }
}
