/* ============================================================
   scanner.css — Interface kiosque ArcelorMittal Scanner
   Design ArcelorMittal — Gradient orange → magenta
   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:        #F5821F;
    --color-success:        #2ecc71;
    --color-error:          #e74c3c;
    --color-warning:        #f39c12;
    --color-overlay:        rgba(0, 0, 0, 0.85);
    --color-debug-bg:       #111;
    --header-height:        90px;
    --nav-height:           50px;
}

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

body.scanner-kiosk {
    margin:      0;
    overflow:    hidden;
    height:      100vh;
    background:  var(--color-bg);
    color:       var(--color-text);
    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;
}

/* ── En-tête gradient ArcelorMittal ──────────────────────────── */
#top-bar {
    height:          var(--header-height);
    display:         flex;
    align-items:     center;
    justify-content: center;
    padding:         0 24px;
    background:      linear-gradient(to right, var(--color-gradient-start), var(--color-gradient-end));
    flex-shrink:     0;
    position:        relative;
}

#am-logo {
    height:      56px;
    width:       auto;
    flex-shrink: 0;
}

#btn-debug {
    position:      absolute;
    right:         16px;
    top:           50%;
    transform:     translateY(-50%);
    background:    transparent;
    border:        none;
    color:         rgba(255, 255, 255, 0.6);
    font-size:     1.4rem;
    cursor:        pointer;
    padding:       4px 8px;
    border-radius: 4px;
    transition:    color 0.2s;
    line-height:   1;
}

#btn-debug:hover {
    color: #fff;
}

/* ── Barre de navigation ──────────────────────────────────────── */
#nav-bar {
    height:          var(--nav-height);
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    padding:         0 32px;
    background:      var(--color-surface);
    border-bottom:   1px solid #E0E0E0;
    flex-shrink:     0;
}

#nav-left {
    font-size: 0.95rem;
    color:     var(--color-text);
}

#nav-right {
    display:     flex;
    align-items: center;
    gap:         16px;
    font-size:   0.95rem;
    color:       var(--color-text);
}

#display-gate {
    font-size:   0.95rem;
    font-weight: bold;
    color:       var(--color-text);
}

#display-site {
    font-size: 0.85rem;
    color:     var(--color-muted);
}

/* ── Indicateur connexion ────────────────────────────────────── */
#connection-status {
    display:     flex;
    align-items: center;
    gap:         6px;
    font-size:   0.8rem;
    color:       var(--color-muted);
}

#connection-status::before {
    content:       '';
    display:       inline-block;
    width:         10px;
    height:        10px;
    border-radius: 50%;
    background:    var(--color-muted);
    flex-shrink:   0;
}

#connection-status.online::before {
    background: var(--color-success);
}

#connection-status.offline::before {
    background: var(--color-error);
}

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

/* ── Zone de scan principale ─────────────────────────────────── */
#scan-zone {
    flex:            1;
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    justify-content: center;
    gap:             48px;
    padding:         40px;
    text-align:      center;
    background:      var(--color-bg);
}

/* Champ scan — visible pour saisie manuelle */
#scanner-input {
    opacity:          1;
    position:         relative;
    background-color: var(--color-surface);
    width:            420px;
    height:           auto;
    border:           2px solid #CCC;
    border-radius:    10px;
    outline:          revert;
    padding:          14px 20px;
    font-size:        1.6rem;
    color:            var(--color-text);
    text-align:       center;
}

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

#scan-message.success {
    font-size:   2.5rem;
    color:       #155724;
    background:  #D4EDDA;
    border:      1px solid #C3E6CB;
    text-align:  center;
    font-weight: bold;
}

#scan-message.error {
    font-size:   2.5rem;
    color:       #721C24;
    background:  #F8D7DA;
    border:      1px solid #F5C6CB;
    text-align:  center;
    font-weight: bold;
}

/* ── Spinner ─────────────────────────────────────────────────── */
#scan-spinner {
    width:            64px;
    height:           64px;
    border:           6px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--color-primary);
    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 (page principale) ───────────── */
#scan-assistance {
    font-size:      1.6rem;
    color:          var(--color-muted);
    text-align:     center;
    font-style:     italic;
    letter-spacing: 0.5px;
}

/* ── Scan Ready ──────────────────────────────────────────────── */
#scan-ready {
    display:        flex;
    flex-direction: column;
    align-items:    center;
    gap:            28px;
    color:          var(--color-muted);
}

#scan-ready-icon {
    font-size:      9rem;
    letter-spacing: 20px;
    opacity:        0.5;
    animation:      pulse 2s ease-in-out infinite;
    color:          var(--color-primary);
}

#scan-ready-text {
    font-size:      2.4rem;
    text-transform: uppercase;
    letter-spacing: 6px;
    color:          var(--color-muted);
}

@keyframes pulse {
    0%, 100% { opacity: 0.3; }
    50%       { opacity: 0.75; }
}

/* ── Panneau Auto-Exit ───────────────────────────────────────── */
#auto-exit-panel {
    position:        fixed;
    inset:           0;
    background:      var(--color-overlay);
    z-index:         100;
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    padding:         0 40px 32px;
}

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

/* Bloc bleu + assistance — ancrés en bas */
#ae-bottom {
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    gap:             16px;
    width:           100%;
    max-width:       700px;
}

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

#ae-employee-company {
    font-size:  1.8rem;
    color:      #DDD;
    text-align: center;
}

#ae-btn-more-cards {
    padding:       18px 56px;
    font-size:     1.5rem;
    font-weight:   bold;
    background:    linear-gradient(to right, var(--color-gradient-start), var(--color-gradient-end));
    color:         #FFF;
    border:        none;
    border-radius: 8px;
    cursor:        pointer;
    transition:    opacity 0.2s;
    opacity:       0.85;
}

#ae-btn-more-cards:hover {
    opacity: 1;
}

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

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

#ae-passenger-scan {
    width:         100%;
    padding:       14px 18px;
    font-size:     1.4rem;
    background:    rgba(255, 255, 255, 0.1);
    border:        2px solid var(--color-success);
    border-radius: 8px;
    color:         #FFF;
    outline:       none;
}

#ae-passenger-scan::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

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

.passenger-entry {
    display:       flex;
    align-items:   center;
    gap:           10px;
    font-size:     1.3rem;
    padding:       10px 16px;
    background:    rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color:         #FFF;
    flex-wrap:     wrap;
}

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

.passenger-company {
    font-size:  1.1rem;
    color:      rgba(255, 255, 255, 0.7);
    font-style: italic;
}

#ae-api-message {
    font-size:     1.8rem;
    font-weight:   bold;
    text-align:    center;
    padding:       18px 36px;
    border-radius: 8px;
    max-width:     700px;
}

#ae-api-message.success {
    color:      #155724;
    background: #D4EDDA;
    border:     1px solid #C3E6CB;
}

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

#ae-waiting-banner {
    width:         100%;
    max-width:     700px;
    background:    linear-gradient(to right, #1565C0, #0288D1);
    color:         #FFF;
    font-size:     1.6rem;
    font-weight:   bold;
    text-align:    center;
    padding:       18px 28px;
    border-radius: 8px;
    animation:     fadeIn 0.3s ease-in;
}

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

#ae-countdown {
    font-size:   3rem;
    font-weight: bold;
    color:       #FFF;
}

#ae-btn-terminer {
    padding:       18px 56px;
    font-size:     1.5rem;
    font-weight:   bold;
    background:    linear-gradient(to right, var(--color-gradient-start), var(--color-gradient-end));
    color:         #FFF;
    border:        none;
    border-radius: 8px;
    cursor:        pointer;
    transition:    opacity 0.2s;
    margin-top:    8px;
}

#ae-btn-terminer:hover:not(:disabled) {
    opacity: 0.85;
}

#ae-btn-terminer:disabled {
    opacity: 0.4;
    cursor:  default;
}

/* ── 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:             200;
    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;
}

#scanner-error h2 {
    font-size: 2rem;
    color:     var(--color-error);
}

#scanner-error p {
    font-size: 1.1rem;
    color:     var(--color-muted);
}

#error-code {
    margin-top:    16px;
    padding:       8px 24px;
    background:    rgba(0, 0, 0, 0.05);
    border:        1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    font-size:     1.2rem;
    color:         var(--color-text);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1280px) {
    #scan-message,
    #scan-message.success,
    #scan-message.error {
        font-size: 2rem;
    }
    #ae-employee-name {
        font-size: 2rem;
    }
    #scan-ready-icon {
        font-size: 7rem;
    }
    #scan-ready-text {
        font-size: 2rem;
    }
}

@media (max-width: 1024px) {
    :root {
        --header-height: 70px;
    }
    #am-logo {
        height: 44px;
    }
    #scan-message,
    #scan-message.success,
    #scan-message.error {
        font-size: 1.6rem;
    }
    #scan-ready-icon {
        font-size:      5rem;
        letter-spacing: 14px;
    }
    #scan-ready-text {
        font-size:      1.6rem;
        letter-spacing: 4px;
    }
    #scanner-input {
        width:     320px;
        font-size: 1.3rem;
    }
    #scan-assistance {
        font-size: 1.2rem;
    }
    #debug-console {
        width:  60vw;
        height: 50vh;
    }
}
