/* Interface d'exploitation ANPR — charte reprise de la page de démonstration
   (sombre, verre dépoli) pour que le produit et la démo se ressemblent. */

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-glass: rgba(255, 255, 255, 0.05);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);
    --border-glass: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-dim: #6e6e6e;
    --accent: #ffffff;
    --accent-glow: rgba(255, 255, 255, 0.2);
    --success: #00ff88;
    --success-dim: rgba(0, 255, 136, 0.12);
    --error: #ff3a3a;
    --error-dim: rgba(255, 58, 58, 0.12);
    --warning: #ffb300;
    --warning-dim: rgba(255, 179, 0, 0.12);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 24px;
    --sidebar: 258px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed; inset: 0; z-index: -1;
    background:
        radial-gradient(circle at 15% 85%, rgba(40, 40, 40, 0.25) 0%, transparent 50%),
        radial-gradient(circle at 85% 15%, rgba(30, 30, 30, 0.25) 0%, transparent 50%);
}

a { color: inherit; text-decoration: none; }

/* ---------- Structure ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar);
    flex-shrink: 0;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    border-right: 1px solid var(--border-glass);
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(20px);
    position: sticky; top: 0; height: 100vh;
}

.brand { display: flex; align-items: center; gap: 13px; }
.brand-icon {
    width: 44px; height: 44px; flex-shrink: 0;
    background: var(--accent); color: var(--bg-primary);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 19px; font-weight: 700;
}
.brand-text { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; line-height: 1.25; }
.brand-text small { display: block; font-size: 11px; font-weight: 500; color: var(--text-dim);
                    letter-spacing: 0.4px; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-label {
    font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-dim); margin: 14px 0 6px 12px; font-weight: 600;
}
.nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: var(--radius-sm);
    color: var(--text-secondary); font-size: 14.5px; font-weight: 500;
    transition: background .18s, color .18s;
}
.nav a i { width: 18px; text-align: center; font-size: 15px; }
.nav a:hover { background: var(--bg-glass); color: var(--text-primary); }
.nav a.active { background: var(--accent); color: var(--bg-primary); font-weight: 600; }

.sidebar-footer { border-top: 1px solid var(--border-glass); padding-top: 16px; }
.user-chip { display: flex; align-items: center; gap: 11px; margin-bottom: 10px; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    background: var(--bg-glass); border: 1px solid var(--border-glass);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px;
}
.user-chip div { min-width: 0; }
.user-chip strong { display: block; font-size: 14px; white-space: nowrap;
                    overflow: hidden; text-overflow: ellipsis; }
.user-chip span { font-size: 12px; color: var(--text-dim); }

.main { flex: 1; min-width: 0; padding: 28px 34px 60px; }

.page-head {
    display: flex; justify-content: space-between; align-items: flex-end;
    gap: 20px; flex-wrap: wrap; margin-bottom: 26px;
}
.page-head h1 { font-size: 27px; font-weight: 700; letter-spacing: -0.6px; }
.page-head p { color: var(--text-secondary); font-size: 14px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Cartes ---------- */
.card {
    /* min-width: 0 — sans cela, un élément de grille ou de flex refuse de se contracter
       sous la largeur de son contenu (défaut « auto ») : un tableau large élargit alors
       toute la page au lieu de défiler dans son propre cadre. */
    min-width: 0;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-head {
    padding: 18px 22px; border-bottom: 1px solid var(--border-glass);
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
}
.card-head h2 { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.card-head h2 i { color: var(--text-dim); }
.card-body { padding: 22px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 20px; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-main { grid-template-columns: 1fr 380px; align-items: start; }

/* ---------- Statistiques ---------- */
.stat {
    background: var(--bg-glass); backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass); border-radius: var(--radius);
    padding: 20px 22px; transition: transform .25s, background .25s;
}
.stat:hover { transform: translateY(-3px); background: var(--bg-glass-hover); }
.stat-value { font-size: 32px; font-weight: 700; line-height: 1.15; letter-spacing: -1px; }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.9px;
              color: var(--text-dim); font-weight: 600; margin-top: 4px; }
.stat.ok .stat-value { color: var(--success); }
.stat.ko .stat-value { color: var(--error); }
.stat.warn .stat-value { color: var(--warning); }

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    padding: 11px 20px; border: 1px solid var(--border-glass); border-radius: var(--radius-sm);
    background: var(--bg-glass); color: var(--text-primary);
    font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background .2s, transform .2s, box-shadow .2s;
}
.btn:hover { background: var(--bg-glass-hover); transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: var(--bg-primary); border-color: var(--accent); }
.btn-primary:hover { background: #e9e9e9; box-shadow: 0 6px 18px var(--accent-glow); }
.btn-success { background: var(--success); color: #062; border-color: var(--success); font-weight: 700; }
.btn-success:hover { background: #22ff9b; box-shadow: 0 6px 18px rgba(0, 255, 136, .25); }
.btn-danger { color: var(--error); border-color: rgba(255, 58, 58, .35); }
.btn-danger:hover { background: var(--error-dim); }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-icon { padding: 8px 11px; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
    text-align: left; padding: 13px 18px; font-size: 11.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.9px; color: var(--text-dim);
    border-bottom: 1px solid var(--border-glass); white-space: nowrap;
}
tbody td { padding: 13px 18px; border-bottom: 1px solid rgba(255, 255, 255, .05);
           vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: rgba(255, 255, 255, .03); }
td.actions { text-align: right; white-space: nowrap; }
td.actions form { display: inline; }

.plate {
    font-family: 'Courier New', monospace; font-weight: 700; font-size: 15px;
    letter-spacing: 1.4px; white-space: nowrap;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 11px; border-radius: 40px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge i { font-size: 10px; }
.badge-ok { background: var(--success-dim); color: var(--success); }
.badge-ko { background: var(--error-dim); color: var(--error); }
.badge-warn { background: var(--warning-dim); color: var(--warning); }
.badge-mute { background: var(--bg-glass); color: var(--text-dim); }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block;
       background: var(--error); flex-shrink: 0; }
.dot.on { background: var(--success); box-shadow: 0 0 9px var(--success); }
.dot.warn { background: var(--warning); }

/* ---------- Formulaires ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.field .hint { font-size: 12px; color: var(--text-dim); line-height: 1.45; }

input[type=text], input[type=password], input[type=date], input[type=time],
input[type=number], input[type=search], select, textarea {
    width: 100%; padding: 11px 14px;
    background: rgba(0, 0, 0, .35); color: var(--text-primary);
    border: 1px solid var(--border-glass); border-radius: var(--radius-sm);
    font-family: inherit; font-size: 14.5px; transition: border-color .2s, background .2s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: rgba(255, 255, 255, .4); background: rgba(0, 0, 0, .5);
}
input::placeholder { color: var(--text-dim); }
textarea { resize: vertical; min-height: 82px; }
select option { background: var(--bg-secondary); }

.switch { display: flex; align-items: center; gap: 11px; cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 44px; height: 25px; border-radius: 40px;
                background: rgba(255, 255, 255, .13); position: relative; cursor: pointer;
                transition: background .22s; flex-shrink: 0; }
.switch input::after {
    content: ''; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px;
    border-radius: 50%; background: #fff; transition: transform .22s;
}
.switch input:checked { background: var(--success); }
.switch input:checked::after { transform: translateX(19px); }
.switch span { font-size: 14px; }

.days { display: flex; gap: 7px; flex-wrap: wrap; }
.days label {
    position: relative; cursor: pointer;
}
.days input { position: absolute; opacity: 0; }
.days span {
    display: flex; align-items: center; justify-content: center;
    width: 42px; height: 38px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-glass); background: rgba(0, 0, 0, .3);
    font-size: 13px; font-weight: 600; color: var(--text-secondary); transition: all .18s;
}
.days input:checked + span { background: var(--accent); color: var(--bg-primary);
                             border-color: var(--accent); }

.form-actions {
    display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap;
    padding-top: 20px; margin-top: 4px; border-top: 1px solid var(--border-glass);
}

/* ---------- Filtres ---------- */
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { flex: 1 1 150px; gap: 5px; }
.filters .field label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .7px;
                        color: var(--text-dim); }

/* ---------- Messages ---------- */
.flashes { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.flash {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 18px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-glass); background: var(--bg-glass);
    font-size: 14px; animation: slideIn .35s ease;
}
.flash i { margin-top: 2px; }
.flash-success { border-color: rgba(0, 255, 136, .3); background: var(--success-dim); }
.flash-success i { color: var(--success); }
.flash-error { border-color: rgba(255, 58, 58, .3); background: var(--error-dim); }
.flash-error i { color: var(--error); }
.flash-warning { border-color: rgba(255, 179, 0, .3); background: var(--warning-dim); }
.flash-warning i { color: var(--warning); }

.notice {
    display: flex; gap: 13px; padding: 15px 18px; border-radius: var(--radius-sm);
    background: var(--bg-glass); border: 1px solid var(--border-glass);
    font-size: 13.5px; color: var(--text-secondary); line-height: 1.55;
}
.notice i { color: var(--text-dim); margin-top: 3px; }
.notice.warn { border-color: rgba(255, 179, 0, .3); background: var(--warning-dim); }
.notice.warn i { color: var(--warning); }

/* ---------- États vides ---------- */
.empty { text-align: center; padding: 54px 24px; color: var(--text-dim); }
.empty i { font-size: 42px; opacity: .35; display: block; margin-bottom: 16px; }
.empty p { font-size: 15px; }
.empty small { display: block; margin-top: 6px; font-size: 13px; }

/* ---------- Caméras ---------- */
.cam-card { display: flex; gap: 15px; align-items: flex-start; padding: 17px 19px; }
.cam-icon {
    width: 42px; height: 42px; border-radius: var(--radius-sm); flex-shrink: 0;
    background: var(--bg-glass); border: 1px solid var(--border-glass);
    display: flex; align-items: center; justify-content: center; color: var(--text-secondary);
}
.cam-info { flex: 1; min-width: 0; }
.cam-info strong { display: flex; align-items: center; gap: 9px; font-size: 15px; }
.cam-url {
    font-size: 12px; color: var(--text-dim); font-family: 'Courier New', monospace;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
}
.cam-meta { font-size: 12.5px; color: var(--text-secondary); margin-top: 6px; }

/* ---------- Graphique horaire ---------- */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 130px; padding-top: 10px; }
.chart .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
              gap: 2px; height: 100%; position: relative; }
.chart .bar i {
    display: block; width: 100%; border-radius: 3px 3px 0 0; background: var(--success);
    min-height: 2px; transition: height .4s;
}
.chart .bar i.ko { background: rgba(255, 58, 58, .55); }
.chart .bar b { font-size: 9px; color: var(--text-dim); text-align: center; font-weight: 500;
                margin-top: 5px; }
.chart-legend { display: flex; gap: 18px; font-size: 12px; color: var(--text-secondary);
                margin-top: 12px; }
.chart-legend span { display: flex; align-items: center; gap: 7px; }
.chart-legend em { width: 11px; height: 11px; border-radius: 3px; background: var(--success); }
.chart-legend em.ko { background: rgba(255, 58, 58, .55); }

/* ---------- Pagination ---------- */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 16px;
         padding: 16px 22px; border-top: 1px solid var(--border-glass); flex-wrap: wrap; }
.pager span { font-size: 13px; color: var(--text-dim); }
.pager div { display: flex; gap: 8px; }

/* ---------- Photo de plaque ---------- */
.thumb {
    height: 34px; border-radius: 5px; border: 1px solid var(--border-glass);
    cursor: zoom-in; display: block; background: #000;
}
.lightbox {
    position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .88);
    display: none; align-items: center; justify-content: center; padding: 30px;
    backdrop-filter: blur(6px);
}
.lightbox.on { display: flex; }
.lightbox img { max-width: 92vw; max-height: 86vh; border-radius: var(--radius);
                box-shadow: var(--shadow-lg); }

/* ---------- Connexion ---------- */
.login-page { display: flex; align-items: center; justify-content: center;
              min-height: 100vh; padding: 24px; }
.login-box { width: 100%; max-width: 410px; }
.login-box .card-body { padding: 30px; }
.login-head { text-align: center; margin-bottom: 26px; }
.login-head .brand-icon { width: 58px; height: 58px; font-size: 24px; margin: 0 auto 16px; }
.login-head h1 { font-size: 22px; font-weight: 700; }
.login-head p { font-size: 13.5px; color: var(--text-dim); }

@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }
.fade-in { animation: slideIn .4s ease; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .28); }

/* ---------- Écrans étroits ---------- */
@media (max-width: 1150px) {
    .grid-main, .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; min-width: 0; height: auto; position: static; flex-direction: row;
               align-items: center; gap: 16px; padding: 14px 18px; overflow-x: auto; }
    .nav { min-width: 0; }
    .main { min-width: 0; }
    .nav { flex-direction: row; flex: 1; gap: 6px; }
    .nav-label { display: none; }
    .nav a span { display: none; }
    .nav a { padding: 11px 13px; }
    .sidebar-footer { border: none; padding: 0; }
    .user-chip div { display: none; }
    .sidebar-footer .btn span { display: none; }
    .main { padding: 20px 16px 50px; }
}
@media (max-width: 660px) {
    .grid-2, .grid-3, .grid-4, .grid-main, .form-grid { grid-template-columns: 1fr; }
    .page-head h1 { font-size: 22px; }
    .card-body { padding: 17px; }
}
