/* ============================================================
   SMS Stats · SekiaFlow Analytics — feuille de style
   ============================================================ */

:root {
  color-scheme: dark;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: #0b1120;
  color: #e2e8f0;
}

/* Accessibilité : focus visible cohérent */
:focus-visible {
  outline: 2px solid rgba(14, 165, 233, 0.9);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Scrollbars sombres */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: #0b1120;
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 8px;
  border: 2px solid #0b1120;
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* ---------- Composants récurrents ---------- */

.card {
  background: #101a30;
  border: 1px solid #1e293b;
  border-radius: 1rem;
}

.card:hover {
  border-color: #263449;
}

.card-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #cbd5e1;
  letter-spacing: 0.01em;
}

.card-hover {
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.card-hover:hover {
  border-color: #334155;
  transform: translateY(-2px);
  box-shadow: 0 12px 32px -14px rgba(0, 0, 0, 0.55);
}

.eyebrow {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #64748b;
}

/* Navigation latérale */
.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  border-radius: 0.65rem;
  color: #94a3b8;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-btn:hover {
  background: #1e293b;
  color: #e2e8f0;
}
.nav-btn.active {
  background: linear-gradient(90deg, rgba(14, 165, 233, 0.22), rgba(14, 165, 233, 0.08));
  color: #e0f2fe;
  box-shadow: inset 0 0 0 1px rgba(14, 165, 233, 0.35);
}
.nav-btn.active svg {
  color: #38bdf8;
}
.nav-btn svg {
  flex: none;
}

/* Champs de formulaire */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field > span {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}
.field input,
.field select {
  background: #0d1428;
  border: 1px solid #1e293b;
  color: #e2e8f0;
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input {
  min-width: 148px;
}
.field input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.16);
}
select.field,
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* Interrupteur "Comparer période précédente" */
.tgl {
  cursor: pointer;
}
.tgl-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tgl-text {
  font-size: 11.5px;
  font-weight: 600;
  color: #94a3b8;
  line-height: 1.2;
  text-transform: none;
  letter-spacing: 0;
}
.tgl-track {
  flex: none;
  width: 34px;
  height: 19px;
  border-radius: 999px;
  background: #1e293b;
  border: 1px solid #334155;
  position: relative;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.tgl-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #94a3b8;
  transition: transform 0.15s ease, background 0.15s ease;
}
.tgl input:checked + .tgl-wrap .tgl-track {
  background: #0ea5e9;
  border-color: #0ea5e9;
}
.tgl input:checked + .tgl-wrap .tgl-track::after {
  transform: translateX(15px);
  background: #083344;
}
.tgl input:focus-visible + .tgl-wrap .tgl-track {
  outline: 2px solid rgba(14, 165, 233, 0.9);
  outline-offset: 2px;
}
.tgl:hover .tgl-text {
  color: #cbd5e1;
}

/* Boutons */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #151f3a;
  border: 1px solid #1e293b;
  color: #cbd5e1;
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 13px;
  border-radius: 10px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.btn-ghost:hover {
  background: #1e293b;
  color: #f1f5f9;
  border-color: #334155;
}
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: #151f3a;
  border: 1px solid #1e293b;
  color: #cbd5e1;
  border-radius: 10px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn-icon:hover {
  background: #1e293b;
  color: #ffffff;
  border-color: #334155;
}
#btnRefresh.loading svg {
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- KPIs ---------- */

.kpi-value {
  font-size: 1.4rem;
  line-height: 1.15;
  font-weight: 800;
  color: #f8fafc;
  word-break: break-word;
}

.kpi-label {
  font-size: 0.66rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 3px;
}

.unit-chip {
  font-size: 0.58rem;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: 0.04em;
  vertical-align: super;
  margin-left: 4px;
  white-space: nowrap;
}

.delta-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: none;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 2.5px 7px;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
}

.delta-label {
  display: inline-flex;
  align-items: center;
  font-size: 0.6rem;
  font-weight: 600;
  color: #64748b;
  background: rgba(148, 163, 184, 0.09);
  border: 1px solid rgba(148, 163, 184, 0.25);
  padding: 2.5px 7px;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 200px;
}

/* Sparklines */
.spark {
  display: block;
  width: 100%;
  height: 26px;
  margin-top: 8px;
}

/* ---------- Graphiques ---------- */

.chart-box {
  position: relative;
  height: 285px;
}
@media (min-width: 768px) {
  .chart-box {
    height: 300px;
  }
}
.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  min-height: 120px;
  color: #64748b;
  font-size: 0.85rem;
}

/* ---------- Alertes ---------- */

.alert-row {
  display: flex;
  gap: 10px;
  padding: 0.6rem 0.75rem;
  border-radius: 0.7rem;
  font-size: 0.8rem;
  line-height: 1.45;
}
.alert-row .a-title {
  font-weight: 700;
}
.alert-info {
  background: rgba(14, 165, 233, 0.08);
  border: 1px solid rgba(14, 165, 233, 0.22);
  color: #7dd3fc;
}
.alert-warn {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: #fcd34d;
}
.alert-danger {
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.25);
  color: #fda4af;
}
.alert-row .a-msg {
  color: rgba(226, 232, 240, 0.72);
}

/* ---------- Tableaux ---------- */

.table {
  width: 100%;
  font-size: 0.8rem;
  border-collapse: collapse;
}
.table thead th {
  text-align: left;
  color: #64748b;
  font-weight: 700;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid #1e293b;
  white-space: nowrap;
}
.table tbody td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid #16223a;
  color: #cbd5e1;
  vertical-align: top;
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.table tbody tr:hover td {
  background: #15203a;
}

/* Cellule numérique naïvement mieux alignée */
.table td.num,
.table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- Skeleton de chargement ---------- */

.skeleton {
  position: relative;
  overflow: hidden;
  background: #16223a;
  border-radius: 0.9rem;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background-image: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.14), transparent);
  animation: shimmer 1.6s infinite;
}
@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

/* ---------- Cartes département (overview) ---------- */

.dept-card {
  cursor: pointer;
  user-select: none;
}
.dept-card .dept-open {
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.dept-card:hover .dept-open {
  opacity: 1;
  transform: translateX(0);
}

/* ---------- Impression / PDF ---------- */

@page {
  margin: 12mm;
}

@media print {
  body {
    background: #ffffff !important;
    color: #0f172a !important;
  }
  #sidebar,
  #menuBtn,
  #mobileOverlay,
  #filterBar,
  #errorBanner,
  #closeDrawer {
    display: none !important;
  }
  #main {
    margin-left: 0 !important;
    padding: 0 !important;
  }
  .card {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    border-radius: 10px !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .card-title,
  h1,
  h2 {
    color: #0f172a !important;
  }
  .kpi-value {
    color: #0f172a !important;
  }
  .kpi-label,
  .eyebrow,
  .field > span {
    color: #475569 !important;
  }
  .unit-chip {
    color: #0284c7 !important;
  }
  .table thead th {
    color: #334155 !important;
    border-bottom-color: #cbd5e1 !important;
  }
  .table tbody td {
    color: #334155 !important;
    border-bottom-color: #e2e8f0 !important;
  }
  .table tbody tr:hover td {
    background: #ffffff !important;
  }
  .alert-info,
  .alert-warn,
  .alert-danger {
    color: #0f172a !important;
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
  }
  .delta-badge {
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
    background: #f1f5f9 !important;
  }
  .delta-label {
    background: #f1f5f9 !important;
    color: #475569 !important;
    border-color: #cbd5e1 !important;
  }
  .chart-box {
    height: 320px !important;
    min-height: 320px;
  }
  canvas {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}