/* ===========================================================
   E-TRAK — thème industriel sombre
   Palette : fond #1A1A1A, cartes #2A2A2A, accent #0062CC/#3B82F6,
   bandeau #085591, texte clair, grille technique.
   =========================================================== */

:root {
  --bg:        #1A1A1A;
  --bg-grid:   #222;
  --card:      #2A2A2A;
  --card-2:    #323232;
  --border:    #3a3a3a;
  --accent:    #0062CC;
  --accent-2:  #3B82F6;
  --band:      #085591;
  --text:      #E6E9ED;
  --text-dim:  #9aa3ad;
  --ok:        #2FBF71;
  --warn:      #E0A800;
  --danger:    #E0392B;
  --radius:    8px;
  --sidebar:   #141414;
  --topbar:    #1d1d1d;
  --hover:     #1f1f1f;
  --tag:       #333333;
  --input:     #1f1f1f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: -1px -1px;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===========================================================
   Shell : nav latérale (style portail télématique) + zone principale
   =========================================================== */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px; flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .logo {
  display: block; padding: 20px 22px 18px;
  border-bottom: 1px solid var(--border); margin-bottom: 10px;
}
.sidebar .logo img { width: 150px; max-width: 100%; height: auto; display: block; }
.sidebar .logo-sub {
  padding: 2px 22px 18px; font-size: 11px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-dim);
  border-bottom: 1px solid var(--border); margin-bottom: 10px;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px 16px;
  flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.sidebar nav::-webkit-scrollbar { width: 8px; }
.sidebar nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 6px;
  color: var(--text-dim); font-size: 14px; font-weight: 500;
  text-decoration: none; transition: background .12s, color .12s;
}
.nav-item svg { width: 19px; height: 19px; fill: currentColor; flex-shrink: 0; }
.nav-item:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: rgba(59,130,246,.14); color: #fff; box-shadow: inset 3px 0 0 var(--accent-2); }
.nav-item.disabled { opacity: .5; cursor: default; }
.nav-item.disabled::after {
  content: "bientôt"; margin-left: auto;
  font-size: 9px; text-transform: uppercase; letter-spacing: .5px;
  background: var(--tag); color: var(--text-dim); padding: 2px 6px; border-radius: 3px;
}
.nav-item.disabled:hover { background: transparent; color: var(--text-dim); }
.nav-item .nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px;
  font-weight: 700; font-style: normal; min-width: 18px; height: 18px; line-height: 18px; text-align: center;
  border-radius: 9px; padding: 0 5px; }

/* ---- Alertes ---- */
.danger-text { color: var(--danger) !important; }
.warn-text { color: var(--warn) !important; }
.alert-banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 8px;
  margin-bottom: 16px; background: rgba(224,57,43,.12); border: 1px solid rgba(224,57,43,.35); color: #ffb3ab; }
.alert-banner.warn { background: rgba(224,168,0,.10); border-color: rgba(224,168,0,.3); color: #f0c85a; }
.alert-banner a { color: #fff; font-weight: 600; margin-left: auto; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---- Top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; height: 60px;
  background: var(--topbar);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 500;
}
.topbar .spacer { flex: 1; }
.topbar .page-context { font-size: 14px; color: var(--text-dim); }
.topbar .user { display: flex; align-items: center; gap: 10px; }
.topbar .user-name { color: var(--text); font-size: 14px; font-weight: 600; }
.topbar .user-role { color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  border: 1px solid var(--border); border-radius: 4px; padding: 2px 7px; }
.topbar .logout { display: flex; color: var(--text-dim); }
.topbar .logout svg { width: 18px; height: 18px; fill: currentColor; }
.topbar .logout:hover { color: var(--accent-2); }

/* ---- Contenu ---- */
.content { padding: 24px; max-width: 1400px; width: 100%; }

@media (max-width: 820px) {
  .sidebar { width: 64px; }
  .sidebar .logo, .sidebar .logo-sub, .nav-item span, .nav-item.disabled::after { display: none; }
  .nav-item { justify-content: center; }
}
.page-title { font-size: 22px; font-weight: 600; margin: 0 0 16px; }
.muted { color: var(--text-dim); }

/* ---- Cartes & grille ---- */
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); }

.kpi .value { font-size: 30px; font-weight: 700; }
.kpi .unit { font-size: 14px; color: var(--text-dim); margin-left: 4px; }
.kpi .label { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.kpi .value.accent { color: var(--accent-2); }

/* ---- Tableaux ---- */
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { color: var(--text-dim); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .5px; }
table.data tbody tr:hover { background: var(--card-2); cursor: pointer; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.badge.ok { background: rgba(47,191,113,.15); color: var(--ok); }
.badge.warn { background: rgba(224,168,0,.15); color: var(--warn); }
.badge.danger { background: rgba(224,57,43,.15); color: var(--danger); }

.chart { width: 100%; height: 300px; }
#map { width: 100%; height: 380px; border-radius: var(--radius); }

/* ---- Boutons / formulaires ---- */
.btn {
  display: inline-block; background: var(--accent); color: #fff; border: none;
  padding: 10px 18px; border-radius: 6px; font-size: 14px; cursor: pointer;
  transition: background .15s ease;
}
.btn:hover { background: var(--accent-2); }
input, select {
  width: 100%; padding: 10px 12px; background: var(--input); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
}
input:focus, select:focus { outline: none; border-color: var(--accent-2); }
label { display: block; margin: 14px 0 6px; color: var(--text-dim); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }

/* ---- Login ---- */
.login-wrap { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card {
  width: 360px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px; box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.login-card .brand { text-align: center; margin-bottom: 6px; }
.login-card .brand img { width: 200px; max-width: 80%; height: auto; }
.login-card .sub { text-align: center; color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }
.login-card .btn { width: 100%; margin-top: 20px; }
.error { background: rgba(224,57,43,.12); color: #ff8b80; border: 1px solid rgba(224,57,43,.3); padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }

/* ---- Rapport : filtres ---- */
.filters .filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.filters label { margin: 0 0 5px; }
.filters .filter-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--card-2); border-color: var(--accent-2); }
.pager { margin-top: 14px; display: flex; gap: 10px; align-items: center; }
table.data th a { color: var(--text-dim); }
table.data th a:hover { color: var(--accent-2); text-decoration: none; }

/* ---- Admin ---- */
.admin-tabs { display: flex; gap: 4px; align-items: center; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.admin-tabs a { padding: 10px 16px; color: var(--text-dim); font-size: 14px; font-weight: 600;
  border-bottom: 2px solid transparent; text-decoration: none; }
.admin-tabs a:hover { color: var(--text); }
.admin-tabs a.on { color: #fff; border-bottom-color: var(--accent-2); }
.admin-tabs .admin-ctx { margin-left: auto; color: var(--text-dim); font-size: 13px; }
.flash { padding: 11px 14px; border-radius: 6px; font-size: 14px; margin-bottom: 16px; }
.flash.ok  { background: rgba(47,191,113,.14); color: #7ee2a8; border: 1px solid rgba(47,191,113,.3); }
.flash.err { background: rgba(224,57,43,.12); color: #ff8b80; border: 1px solid rgba(224,57,43,.3); }
.flash.token { background: rgba(59,130,246,.12); color: #cfe0ff; border: 1px solid rgba(59,130,246,.35); }
.flash.token code { display: block; margin-top: 8px; padding: 10px; background: #111; border-radius: 6px;
  color: #6ee7ff; font-size: 14px; word-break: break-all; user-select: all; }

/* ---- Barre de part (productivité) ---- */
.share { display: inline-block; width: 120px; height: 8px; background: #1f1f1f; border-radius: 4px; overflow: hidden; vertical-align: middle; margin-right: 8px; }
.share span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* Deltas de comparaison de période (dashboard) */
.trend { font-size: 12px; font-weight: 600; margin-left: 6px; white-space: nowrap; }
.trend.up { color: var(--ok); }
.trend.down { color: var(--danger); }
.trend.muted { color: var(--text-dim); }

/* Barres de proportion (classements / utilisation) */
.bar-track { background: rgba(255,255,255,.07); border-radius: 4px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 4px; }

/* Mini tableau clé/valeur (santé) */
.mini-kv { width: 100%; font-size: 13px; }
.mini-kv td { padding: 3px 0; }
.mini-kv td:first-child { color: var(--text-dim); }
.mini-kv td:last-child { text-align: right; font-weight: 600; }

/* Anneau de score (santé de la flotte) */
.score-ring { --p: 0; width: 88px; height: 88px; border-radius: 50%; flex: 0 0 88px;
  display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--ring) calc(var(--p) * 1%), rgba(255,255,255,.08) 0); }
.score-ring::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--card); }
.score-ring span { position: relative; font-size: 22px; font-weight: 700; }
.score-ring.ok { --ring: var(--ok); }
.score-ring.warn { --ring: var(--warn); }
.score-ring.danger { --ring: var(--danger); }

/* Pastille de couleur (zones) */
.dot { display:inline-block; width:10px; height:10px; border-radius:50%; margin-right:7px; vertical-align:middle; }

/* ===========================================================
   Thème clair (bascule via le bouton de la topbar, persistant)
   =========================================================== */
html[data-theme="light"] {
  --bg:        #EEF1F5;
  --bg-grid:   #E4E8EE;
  --card:      #FFFFFF;
  --card-2:    #F1F4F8;
  --border:    #D4DAE2;
  --accent:    #0062CC;
  --accent-2:  #1D6FE0;
  --band:      #0A5FA8;
  --text:      #1A2330;
  --text-dim:  #5B6675;
  --ok:        #1E9E5A;
  --warn:      #B7860B;
  --danger:    #C5281C;
  --sidebar:   #FFFFFF;
  --topbar:    #FFFFFF;
  --hover:     #EEF2F7;
  --tag:       #E2E7EE;
  --input:     #FFFFFF;
}
html[data-theme="light"] body { background-color: var(--bg); }
html[data-theme="light"] .bar-track { background: rgba(0,0,0,.08); }
html[data-theme="light"] .topbar .theme-toggle { color: var(--text); }
/* Ombres douces pour distinguer les surfaces blanches sur fond clair */
html[data-theme="light"] .card { box-shadow: 0 1px 2px rgba(16,24,40,.06); }
html[data-theme="light"] .sidebar { box-shadow: 1px 0 0 var(--border); }
html[data-theme="light"] .topbar { box-shadow: 0 1px 3px rgba(16,24,40,.05); }
html[data-theme="light"] .nav-item.active { color: var(--accent); }
html[data-theme="light"] input, html[data-theme="light"] select { box-shadow: inset 0 1px 2px rgba(16,24,40,.04); }
/* Bannières / flash : texte lisible sur fond clair (au lieu des tons pâles du thème sombre) */
html[data-theme="light"] .alert-banner { color: var(--danger); }
html[data-theme="light"] .alert-banner.warn { color: #8a6d00; }
html[data-theme="light"] .alert-banner a { color: var(--accent); }
html[data-theme="light"] .error, html[data-theme="light"] .flash.err { color: var(--danger); }
html[data-theme="light"] .flash.ok { color: #137a43; }
html[data-theme="light"] .flash.token { color: #0a4ea8; }
html[data-theme="light"] .flash.token code { background: #0f1b2d; color: #6ee7ff; }

/* Bouton bascule de thème */
.theme-toggle { background: none; border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); width: 34px; height: 34px; cursor: pointer; display: grid;
  place-items: center; }
.theme-toggle:hover { border-color: var(--accent-2); color: var(--accent-2); }
.theme-toggle svg { width: 18px; height: 18px; fill: currentColor; }
.theme-toggle .icon-sun { display: none; }
html[data-theme="light"] .theme-toggle .icon-sun { display: block; }
html[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* Cluster de contrôles de la topbar (langue · unité · thème) — tailles homogènes */
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-btn { height: 34px; min-width: 34px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: transparent; color: var(--text);
  font-size: 13px; font-weight: 600; cursor: pointer; display: grid; place-items: center; }
.topbar-btn:hover { border-color: var(--accent-2); color: var(--accent-2); }
.topbar-select { display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card-2); cursor: pointer; }
.topbar-select:hover { border-color: var(--accent-2); }
.topbar-select .ts-cap { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); }
.topbar-select select { appearance: none; -webkit-appearance: none; background: transparent; border: none;
  outline: none; color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; padding-right: 16px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238a93a3' stroke-width='3'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right center; background-size: 10px; }
.topbar-select option { color: #1F2937; }

/* Onglets de vue (hubs Analyse, Activité…) */
.viewtabs { display: flex; gap: 6px; margin: 0 0 16px; flex-wrap: wrap; }
.viewtabs a { padding: 9px 18px; border-radius: var(--radius); text-decoration: none; font-weight: 600;
  font-size: 14px; border: 1px solid var(--border); color: var(--text); background: var(--surface, var(--card-2)); }
.viewtabs a.on { background: #135090; border-color: #135090; color: #fff; }

/* Recherche : box topbar + liste de résultats */
.topbar-search { display: flex; align-items: center; gap: 6px; background: var(--card-2);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 10px; min-width: 220px; }
.topbar-search svg { width: 16px; height: 16px; fill: var(--text-dim); flex: 0 0 16px; }
.topbar-search input { background: none; border: none; color: var(--text); outline: none; width: 100%; font-size: 13px; }
.topbar-search input::placeholder { color: var(--text-dim); }
.search-list { list-style: none; margin: 0; padding: 0; }
.search-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.search-list li:last-child { border-bottom: 0; }
@media (max-width: 720px) { .topbar-search { display: none; } }

/* Mode kiosque : plein écran sans navigation */
html.kiosk .sidebar, html.kiosk .topbar { display: none; }
html.kiosk .content { max-width: none; padding: 18px; }
