/* ── SNI Reporting Hebdo — Styles ────────────────────────────────────────── */

:root {
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --border: #e0e3e8;
  --primary: #1e2a3a;
  --accent: #3b82f6;
  --green: #16a34a;
  --orange: #ea580c;
  --red: #dc2626;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

header {
  background: var(--primary);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

header h1 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; }
.subtitle  { font-size: 0.8rem; opacity: 0.7; }

.header-controls {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.control-group label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.6;
}

.control-group select {
  padding: 5px 10px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
}

.control-group select:focus { border-color: var(--accent); }

.control-group select option { color: var(--text); background: #fff; }

.week-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.week-nav-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s;
}

.week-nav-btn:hover { background: rgba(255,255,255,0.22); }
.week-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }

header button {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  width: 34px; height: 34px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

header button:hover { background: rgba(255,255,255,0.22); }

/* ── Brand tabs ──────────────────────────────────────────────────────────── */

.brand-tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  overflow: visible;
  position: relative;
}

.tab {
  padding: 11px 22px;
  border: none;
  background: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.tabs-list {
  display: flex;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--accent); }

/* ── Loading / Error ─────────────────────────────────────────────────────── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.loading.hidden { display: none; }

.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-state { opacity: 0.4; pointer-events: none; transition: opacity 0.2s; }

.error-bar {
  background: #fef2f2;
  color: var(--red);
  padding: 10px 24px;
  font-size: 0.82rem;
  border-bottom: 1px solid #fecaca;
}

.error-bar.hidden { display: none; }

/* ── Main content ────────────────────────────────────────────────────────── */

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 20px 40px;
}

/* ── KPI sections ────────────────────────────────────────────────────────── */

.kpi-section {
  background: var(--card-bg);
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 14px;
  overflow: hidden;
}

.kpi-section h2 {
  font-size: 0.9rem;
  font-weight: 650;
  padding: 12px 18px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
}

table { width: 100%; border-collapse: collapse; }

thead th {
  text-align: left;
  padding: 9px 16px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

thead th:not(:first-child) { text-align: right; }

tbody td {
  padding: 9px 16px;
  font-size: 0.88rem;
  border-bottom: 1px solid #f3f4f6;
}

tbody tr:last-child td { border-bottom: none; }

tbody td:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.kpi-label { font-weight: 500; color: var(--text); }
.kpi-value { font-weight: 600; }

/* Status colors — % atteinte */
.status-green  { color: var(--green);  font-weight: 700; }
.status-orange { color: var(--orange); font-weight: 700; }
.status-red    { color: var(--red);    font-weight: 700; }

/* Variation column colors */
.delta-good    { color: var(--green);  font-weight: 600; }
.delta-bad     { color: var(--red);    font-weight: 600; }
.delta-neutral { color: var(--text-muted); font-weight: 500; }

/* Light gray background on "vs" columns */
th.col-vs,
td.col-vs {
  background: #f7f8fa;
}

/* Ensure sticky first-child still overrides */
.table-wrap thead th:first-child { background: #fafbfc; }
.table-wrap td:first-child       { background: var(--card-bg); }

.placeholder {
  color: var(--text-muted);
  font-style: italic;
  text-align: center !important;
  font-weight: 400;
}

/* ── Notice panel ───────────────────────────────────────────────────────── */

.notice-panel.hidden { display: none; }

.notice-source {
  padding: 0 18px 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

.notice-conventions {
  padding: 8px 18px 14px;
}

.notice-conventions ul {
  list-style: disc;
  padding-left: 22px;
  font-size: 0.85rem;
  line-height: 1.75;
}

.notice-conventions code {
  background: #f1f3f5;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.8em;
}

.notice-filter {
  padding: 8px 18px;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
}

.notice-filter label {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.notice-table th { white-space: nowrap; }
.notice-table td { font-size: 0.8rem; vertical-align: top; }
.notice-table code {
  background: #f1f3f5;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.85em;
  white-space: pre-wrap;
  word-break: break-word;
}

.notice-endpoint {
  max-width: 200px;
  font-size: 0.72rem;
  color: var(--text-muted);
  word-break: break-all;
}

tr.notice-placeholder td {
  opacity: 0.55;
  font-style: italic;
}

.hidden { display: none; }

/* ── KPI Tooltip (i) ────────────────────────────────────────────────────── */

.kpi-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px; height: 15px;
  margin-left: 5px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 700;
  font-style: italic;
  cursor: help;
  position: relative;
  vertical-align: middle;
  flex-shrink: 0;
}

.kpi-info::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 400;
  line-height: 1.4;
  white-space: normal;
  width: max-content;
  max-width: 300px;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Desktop: hover */
.kpi-info:hover::after {
  opacity: 1;
}

/* Mobile: click (toggled via JS) */
.kpi-info.tooltip-active::after {
  opacity: 1;
}

/* ── Sub-rows (dont xxx) ────────────────────────────────────────────────── */

.kpi-sub {
  padding-left: 28px !important;
  font-weight: 400 !important;
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.row-placeholder td {
  border-bottom-color: transparent;
}

/* ── Screenshot title (injecté temporairement pour la capture) ────────────── */

.screenshot-title {
  text-align: center;
  padding: 12px 0 18px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.screenshot-title h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.01em;
  margin-bottom: 3px;
}

.screenshot-title span {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */

footer {
  text-align: center;
  padding: 18px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ── Print ───────────────────────────────────────────────────────────────── */

@media print {
  @page { margin: 12mm; }
  body { background: #fff; }
  header { background: #fff; color: var(--text); padding: 8px 0; }
  .header-controls button { display: none; }
  .brand-tabs { border: none; padding: 0; }
  .tab:not(.active) { display: none; }
  .tab.active { border-bottom: none; padding-left: 0; }
  .loading, .error-bar { display: none !important; }
  main { max-width: 100%; padding: 0; }
  .kpi-section { box-shadow: none; break-inside: avoid; border: 1px solid #ccc; }
  footer { font-size: 0.65rem; }
}

/* ── Burger menu (hidden on desktop) ────────────────────────────────────── */

.burger-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text);
  padding: 8px 10px;
  line-height: 1;
}

.brand-current {
  display: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  padding: 10px 0;
}

/* ── Sticky first column ────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap table {
  min-width: 900px;
}

.table-wrap th:first-child,
.table-wrap td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--card-bg);
}

.table-wrap thead th:first-child {
  background: #fafbfc;
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  header { padding: 12px 14px; }
  header h1 { font-size: 1.05rem; }
  .header-controls { width: 100%; gap: 8px; }
  .control-group select { font-size: 0.78rem; }
  main { padding: 10px 10px 30px; }
  .kpi-section h2 { font-size: 0.82rem; padding: 10px 12px; }
  thead th, tbody td { padding: 7px 8px; font-size: 0.78rem; }

  /* Burger menu visible on mobile */
  .burger-btn { display: block; }
  .brand-current { display: block; }

  .brand-tabs {
    padding: 0 10px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    border-bottom: 1px solid var(--border);
  }

  .tabs-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    flex-direction: column;
    z-index: 100;
  }

  .tabs-list.open { display: flex; }

  .tabs-list .tab {
    padding: 12px 18px;
    border-bottom: none;
    text-align: left;
    font-size: 0.85rem;
  }

  .tabs-list .tab.active {
    background: #f0f5ff;
    border-bottom: none;
  }

  /* Sticky col shadow hint on scroll */
  .table-wrap th:first-child,
  .table-wrap td:first-child {
    min-width: 130px;
    box-shadow: 2px 0 4px rgba(0,0,0,0.04);
  }
}
