/* DKTECHNIQUE - Dashboard SECHOIR12 / ELIS Blanchisserie
   Charte ELIS : bleu marine #1F3461 + rouge #DC2127 */

:root {
  --elis-blue:        #1F3461;   /* bleu marine ELIS - primaire */
  --elis-blue-dark:   #15264A;   /* hover, gradient profondeur */
  --elis-blue-light:  #4A6CA8;   /* highlights doux */
  --elis-blue-50:     #EAEEF5;   /* fond zone tinted */
  --elis-red:         #DC2127;   /* rouge ELIS - accent */
  --elis-red-dark:    #A8181D;
  --elis-red-50:      #FCEBEC;

  /* alias compat (ancien nom green) -> map sur blue pour transition douce */
  --elis-green:       var(--elis-blue);
  --elis-green-dark:  var(--elis-blue-dark);
  --elis-green-light: var(--elis-blue-light);
  --elis-green-50:    var(--elis-blue-50);

  --bg:           #F5F6F8;
  --card:         #FFFFFF;
  --ink:          #1F2937;
  --ink-muted:    #6B7280;
  --border:       #E5E7EB;
  --shadow:       0 2px 6px rgba(0,0,0,0.06);
  --shadow-lg:    0 8px 24px rgba(0,0,0,0.10);
  --ok:           #16A34A;
  --warn:         #F59E0B;
  --err:          #DC2127;       /* aligne sur rouge ELIS */
  --info:         #0EA5E9;
  --radius:       10px;
  --radius-sm:    6px;
  --gap:          16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--elis-blue); text-decoration: none; }
a:hover { color: var(--elis-blue-dark); text-decoration: underline; }

/* ===== HEADER + NAV ===== */
.dkt-header {
  background: linear-gradient(135deg, var(--elis-blue) 0%, var(--elis-blue-dark) 100%);
  color: #fff;
  padding: 0;
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 100;
}
.dkt-header-inner {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 20px; flex-wrap: wrap;
}
.dkt-brand {
  display: flex; align-items: baseline; gap: 10px;
}
.dkt-brand .logo {
  font-weight: 800; font-size: 1.15em; letter-spacing: 1px;
  color: #fff;
}
.dkt-brand .accent {
  color: var(--elis-red); font-weight: 800;
}
.dkt-brand .sub {
  font-size: 0.78em; opacity: 0.85; font-weight: 400;
}
.dkt-nav {
  display: flex; gap: 4px; flex: 1; justify-content: center;
}
.dkt-nav a {
  color: rgba(255,255,255,0.85);
  padding: 9px 18px; border-radius: 6px;
  font-weight: 600; font-size: 0.93em;
  transition: all 0.15s; text-decoration: none;
}
.dkt-nav a:hover {
  background: rgba(255,255,255,0.12); color: #fff; text-decoration: none;
}
.dkt-nav a.active {
  background: rgba(0,0,0,0.18); color: #fff;
  box-shadow: inset 0 -3px 0 var(--elis-red);
}
.dkt-status {
  display: flex; align-items: center; gap: 14px;
  font-size: 0.85em;
}
.dkt-status .dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--err); margin-right: 5px;
  box-shadow: 0 0 0 0 rgba(255,255,255,0.5);
  animation: pulse 2s infinite;
}
.dkt-status .dot.ok { background: #FFFFFF; box-shadow: 0 0 0 0 rgba(255,255,255,0.6); }
.dkt-status .clock { font-variant-numeric: tabular-nums; opacity: 0.9; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,255,255,0.4); }
  70%  { box-shadow: 0 0 0 8px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}

/* ===== LAYOUT ===== */
main {
  max-width: 1400px; margin: 0 auto;
  padding: 20px;
}
h1.page-title {
  font-size: 1.5em; color: var(--ink);
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 12px;
}
h1.page-title::before {
  content: ""; width: 4px; height: 22px; background: var(--elis-red);
  border-radius: 2px;
}
h2.section-title {
  font-size: 0.78em; color: var(--elis-blue);
  text-transform: uppercase; letter-spacing: 1.2px;
  margin: 22px 0 10px; font-weight: 700;
  border-bottom: 1px solid var(--border); padding-bottom: 6px;
}

/* ===== GRID + CARDS ===== */
.grid {
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card.hero {
  background: linear-gradient(135deg, var(--elis-blue) 0%, var(--elis-blue-dark) 100%);
  color: #fff; border: none;
}
.card.hero-red {
  background: linear-gradient(135deg, var(--elis-red) 0%, var(--elis-red-dark) 100%);
  color: #fff; border: none;
}
.card.hero-red .card-label { color: rgba(255,255,255,0.9); }
.card.hero-red .card-value { color: #fff; }
.card.hero .card-label { color: rgba(255,255,255,0.85); }
.card.hero .card-value { color: #fff; }
.card .card-label {
  font-size: 0.72em; color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: 1px;
  font-weight: 700; margin-bottom: 6px;
}
.card .card-value {
  font-size: 1.85em; font-weight: 800;
  color: var(--ink); font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.card .card-unit {
  font-size: 0.55em; opacity: 0.7; font-weight: 600; margin-left: 4px;
}
.card .card-sub {
  font-size: 0.78em; color: var(--ink-muted); margin-top: 4px;
}

/* ===== BADGES + STATUS ===== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 12px;
  font-size: 0.72em; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge.ok    { background: #DCFCE7; color: #15803D; }
.badge.warn  { background: #FEF3C7; color: #92400E; }
.badge.err   { background: #FEE2E2; color: #991B1B; }
.badge.info  { background: #DBEAFE; color: #1E40AF; }
.badge.muted { background: #F3F4F6; color: var(--ink-muted); }
.badge.green { background: var(--elis-blue); color: #fff; }
.badge.red   { background: var(--elis-red); color: #fff; }
.badge.elis  { background: var(--elis-blue); color: #fff; }
.badge .dot {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}

/* ===== BUTTONS ===== */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--elis-blue); color: #fff;
  border: none; padding: 8px 16px;
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: 0.88em; font-weight: 600;
  font-family: inherit;
  transition: all 0.15s;
  text-decoration: none;
}
button:hover, .btn:hover {
  background: var(--elis-blue-dark); transform: translateY(-1px);
  text-decoration: none; color: #fff;
}
button:active, .btn:active { transform: translateY(0); }
button:disabled, .btn:disabled {
  background: #9CA3AF; cursor: not-allowed; opacity: 0.6; transform: none;
}
.btn.ghost {
  background: transparent; color: var(--elis-blue);
  border: 1px solid var(--elis-blue);
}
.btn.ghost:hover { background: var(--elis-blue-50); color: var(--elis-blue-dark); }
.btn.danger, .btn.red {
  background: var(--elis-red);
}
.btn.danger:hover, .btn.red:hover { background: var(--elis-red-dark); }
.btn.warn { background: var(--warn); color: #1F2937; }
.btn.warn:hover { background: #D97706; color: #1F2937; }
.btn.sm { padding: 5px 11px; font-size: 0.8em; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== TABLES ===== */
table {
  width: 100%; border-collapse: collapse;
  background: var(--card); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
th {
  background: var(--elis-blue-50); color: var(--elis-blue-dark);
  text-align: left; padding: 10px 14px;
  font-size: 0.72em; text-transform: uppercase; letter-spacing: 0.6px;
  font-weight: 700;
}
td {
  padding: 9px 14px; font-size: 0.88em;
  border-top: 1px solid var(--border); color: var(--ink);
  font-variant-numeric: tabular-nums;
}
tbody tr:hover td { background: var(--elis-blue-50); }
.table-wrap { overflow-x: auto; }

/* ===== INPUTS ===== */
input, select, textarea {
  width: 100%;
  padding: 8px 12px;
  background: #fff; color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.9em; font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--elis-blue);
  box-shadow: 0 0 0 3px var(--elis-blue-50);
}
label.field {
  display: block; margin-bottom: 12px;
}
label.field span.lbl {
  display: block; font-size: 0.78em; color: var(--ink-muted);
  font-weight: 600; margin-bottom: 4px;
}
.toggle {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 0.9em;
}
.toggle input { width: auto; }

/* ===== STREAM / MEDIA ===== */
.stream-wrap {
  background: #000; border-radius: var(--radius); overflow: hidden;
  position: relative; aspect-ratio: 16 / 9;
}
.stream-wrap img { width: 100%; height: 100%; object-fit: contain; display: block; }
.stream-wrap .stream-label {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,0.65); color: #fff;
  padding: 4px 10px; border-radius: 4px; font-size: 0.78em;
  font-weight: 600;
}

/* ===== JOURNAL / LOG ===== */
.journal {
  background: var(--elis-blue-dark); color: #E5E7EB;
  font-family: 'Consolas', 'Courier New', monospace; font-size: 0.78em;
  padding: 12px; border-radius: var(--radius);
  max-height: 400px; overflow-y: auto;
  white-space: pre-wrap; line-height: 1.5;
}
.journal .ts { color: #9CA3AF; }
.journal .err { color: #FCA5A5; }
.journal .warn { color: #FDE68A; }
.journal .ok { color: #86EFAC; }

/* ===== ALERTES ===== */
.alert-list .alert {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 14px; border-radius: var(--radius-sm);
  margin-bottom: 8px; background: var(--card);
  border-left: 4px solid var(--border);
}
.alert.active { border-color: var(--err); background: #FEF2F2; }
.alert.ok { border-color: var(--ok); }
.alert .name { font-weight: 700; flex: 1; font-size: 0.9em; }
.alert .meta { font-size: 0.8em; color: var(--ink-muted); }

/* ===== GRAPHE TENDANCE ===== */
.chart-wrap {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
  border: 1px solid var(--border);
  height: 280px; position: relative;
}

/* ===== UTILITIES ===== */
.hidden { display: none !important; }
.muted { color: var(--ink-muted); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-err { color: var(--err); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.spacer { flex: 1; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex.between { justify-content: space-between; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; } .mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; }

/* ===== FOOTER ===== */
.dkt-footer {
  text-align: center; padding: 30px 20px 20px;
  font-size: 0.78em; color: var(--ink-muted);
}
.dkt-footer .logo {
  color: var(--elis-blue); font-weight: 700;
}
.dkt-footer .logo .accent { color: var(--elis-red); }

/* ===== RESPONSIVE — TABLETTE (< 900px) ===== */
@media (max-width: 900px) {
  main { padding: 12px; }
  h1.page-title { font-size: 1.25em; }
  .grid, .grid.cols-2, .grid.cols-3, .grid.cols-4 {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important;
    gap: 10px;
  }
  .card { padding: 12px; }
  .card .card-value { font-size: 1.5em; }
}

/* ===== RESPONSIVE — MOBILE (< 720px) ===== */
@media (max-width: 720px) {
  html, body { font-size: 13px; }
  /* Header compact */
  .dkt-header-inner { padding: 8px 10px; gap: 8px; }
  .dkt-brand { gap: 6px; flex-wrap: wrap; }
  .dkt-brand .logo { font-size: 0.95em; letter-spacing: 0.5px; }
  .dkt-brand .sub { font-size: 0.7em; }
  /* Nav full-width sous le brand */
  .dkt-nav {
    order: 3;
    flex-basis: 100%;
    justify-content: stretch;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .dkt-nav a {
    flex: 1 0 auto;
    text-align: center;
    padding: 10px 8px;
    font-size: 0.85em;
    min-height: 44px;
    white-space: nowrap;
    display: flex; align-items: center; justify-content: center;
  }
  .dkt-status { font-size: 0.78em; gap: 8px; }
  .dkt-status .clock { font-size: 0.95em; }
  /* Main */
  main { padding: 10px; max-width: 100%; }
  h1.page-title { font-size: 1.15em; gap: 8px; margin-bottom: 10px; }
  h1.page-title::before { width: 3px; height: 18px; }
  h2.section-title { font-size: 0.78em; margin: 16px 0 6px; }
  /* Cards : 1 colonne par defaut, sauf KPI 2x2 */
  .grid, .grid.cols-2, .grid.cols-3, .grid.cols-4 {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }
  .card {
    padding: 12px;
    border-radius: 8px;
  }
  .card .card-label { font-size: 0.7em; }
  .card .card-value { font-size: 1.6em; line-height: 1.05; }
  .card .card-sub { font-size: 0.78em; }
  /* Forcer KPI en 2 colonnes (compact) sur mobile */
  .grid.kpi-mobile-2col {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .grid.kpi-mobile-2col .card { padding: 10px; }
  .grid.kpi-mobile-2col .card .card-value { font-size: 1.4em; }
  .grid.kpi-mobile-2col .card .card-sub { font-size: 0.7em; }
  /* Tableaux : scroll horizontal natif (table-wrap ET tables dans cards) */
  .table-wrap, .card > table, .card div > table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -2px;
    display: block;
    max-width: 100%;
  }
  table { font-size: 0.78em; }
  th, td { padding: 6px 8px; white-space: nowrap; }
  /* Boutons : tactiles */
  button, .btn {
    min-height: 42px;
    padding: 10px 14px;
    font-size: 0.92em;
  }
  .btn.sm { min-height: 34px; padding: 6px 10px; }
  .btn-row { gap: 6px; }
  .btn-row .btn { flex: 1 1 calc(50% - 6px); justify-content: center; }
  /* Inputs */
  input, select, textarea {
    padding: 10px 12px;
    font-size: 16px;  /* >= 16px pour eviter le zoom iOS */
    min-height: 42px;
  }
  /* Voyants : chips compacts */
  #voyants-grid .card { padding: 10px 12px; }
  #voyants-grid .card .card-value { font-size: 1.1em; }
  /* Streams cameras : scale full-width */
  .stream-wrap { aspect-ratio: 16/9; max-width: 100% !important; }
  .stream-wrap img { width: 100%; height: auto; }
  /* Journal compact */
  .journal { font-size: 0.72em; padding: 8px; max-height: 240px; }
  /* Chart wrap */
  .chart-wrap { height: 220px; padding: 10px; }
  /* Footer */
  .dkt-footer { padding: 16px 10px 12px; font-size: 0.72em; }
  /* Cacher elements deco non essentiels */
  .stream-label { font-size: 0.7em; padding: 3px 7px; }
}

/* ===== RESPONSIVE — TRES PETIT MOBILE (< 380px) ===== */
@media (max-width: 380px) {
  .dkt-brand .sub, .dkt-status > span:first-child { display: none; }
  h1.page-title { font-size: 1.05em; }
  .card .card-value { font-size: 1.4em; }
  .grid.kpi-mobile-2col { grid-template-columns: 1fr !important; }
  .btn-row .btn { flex: 1 1 100%; }
}
