/* ╔══════════════════════════════════════════════════════════════════╗
   ║  dashboard.f4fti.fr — Live 24 h (thème clair)                    ║
   ║  Minimaliste : 6 KPIs, 1 graph, 1 feed, 2 barres.                ║
   ╚══════════════════════════════════════════════════════════════════╝ */

:root {
  --bg-app:        #F9FAFB;
  --bg-card:       #FFFFFF;
  --bg-muted:      #F3F4F6;
  --bg-row-hover:  #F8FAFC;

  --text-primary:   #0F172A;
  --text-secondary: #475569;
  --text-muted:     #94A3B8;

  --accent-blue:   #0284C7;
  --accent-green:  #16A34A;
  --accent-purple: #7C3AED;
  --accent-teal:   #0D9488;
  --accent-orange: #EA580C;
  --accent-amber:  #D97706;

  --border:         #E5E7EB;
  --shadow-sm:      0 1px 2px rgba(15, 23, 42, 0.04);

  --band-160m: #991B1B;
  --band-80m:  #92400E;
  --band-40m:  #B45309;
  --band-30m:  #15803D;
  --band-20m:  #065F46;
  --band-17m:  #0E7490;
  --band-15m:  #1E40AF;
  --band-12m:  #3730A3;
  --band-10m:  #5B21B6;
  --band-6m:   #86198F;
  --band-2m:   #0F766E;
  --band-70cm: #1E3A5F;

  --r-sm:  6px;
  --r-md:  10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.font-mono { font-family: 'IBM Plex Mono', 'SF Mono', Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }

/* ── Topbar ──────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 22px; height: 22px; color: var(--accent-blue); }
.brand-title {
  font-weight: 700; font-size: 15px; color: var(--text-primary);
  letter-spacing: -0.01em;
}
.brand-operator {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700; font-size: 13px;
  color: var(--accent-blue);
  padding: 3px 8px; border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--accent-blue) 10%, transparent);
}
.topbar-right {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-secondary);
}
.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 6px color-mix(in srgb, var(--accent-green) 60%, transparent);
  animation: pulse 2s ease-in-out infinite;
}
.status-dot[data-state="error"]   { background: #DC2626; box-shadow: 0 0 6px rgba(220,38,38,0.6); }
.status-dot[data-state="loading"] { background: var(--accent-amber); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ── Layout ──────────────────────────────────────────────────────── */
.layout {
  display: flex; flex-direction: column; gap: 14px;
  padding: 14px 20px 24px;
  max-width: 1400px; margin: 0 auto;
}
/* `display: flex` du .layout outclasse l'UA-style `[hidden] { display: none }`,
   ce qui empêche le routeur de masquer une vue. On force la priorité. */
[hidden] { display: none !important; }

/* ── KPIs (6 tuiles) ─────────────────────────────────────────────── */
.kpi-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.kpi {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.kpi-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted);
}
.kpi-value {
  font-size: 28px; font-weight: 700; line-height: 1.1;
  color: var(--text-primary);
}
.kpi-value[data-accent="blue"]   { color: var(--accent-blue); }
.kpi-value[data-accent="green"]  { color: var(--accent-green); }
.kpi-value[data-accent="purple"] { color: var(--accent-purple); }
.kpi-value[data-accent="teal"]   { color: var(--accent-teal); }
.kpi-value[data-accent="orange"] { color: var(--accent-orange); }
.kpi-value[data-accent="amber"]  { color: var(--accent-amber); }

/* ── Cards génériques ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.card-title { margin: 0; font-size: 13px; font-weight: 700; color: var(--text-primary); }
.card-badge { font-size: 11px; color: var(--text-muted); }
.card-body  { padding: 12px 14px; flex: 1; min-height: 0; }

/* ── Split chart/feed ──────────────────────────────────────────────── */
.split {
  display: grid; gap: 14px;
  grid-template-columns: 3fr 2fr;
}
.chart-card .card-body { padding: 10px 10px 14px; }
.chart-wrap { position: relative; width: 100%; height: 260px; }

/* ── Carte Leaflet ──────────────────────────────────────────────────── */
.map-card .card-body { padding: 0 !important; position: relative; min-height: 360px; }
.map-body { position: relative; min-height: 360px; }
/* Hauteur forcée en !important : Leaflet exige une hauteur non-zéro au moment
   de l'init, et les layouts flex/grid parents peuvent rabattre à 0 sans ça. */
.leaflet-map {
  width: 100% !important;
  height: 360px !important;
  min-height: 360px;
  background: var(--bg-muted);
  z-index: 0;
}

/* Popup Leaflet en cohérence avec le thème clair */
.leaflet-popup-content-wrapper {
  border-radius: var(--r-sm);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
}
.leaflet-popup-content {
  margin: 8px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 12px; line-height: 1.4;
  color: var(--text-primary);
}
.leaflet-popup-content .pop-call {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700; font-size: 13px;
  color: var(--accent-blue);
  letter-spacing: 0.04em;
}
.leaflet-popup-content .pop-meta {
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Feed ──────────────────────────────────────────────────────────── */
.feed-body { padding: 0; }
.feed-list {
  list-style: none; margin: 0; padding: 0;
  max-height: 260px; overflow-y: auto;
}
.feed-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px; align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  transition: background 0.12s;
}
.feed-item:hover { background: var(--bg-row-hover); }
.feed-item:last-child { border-bottom: none; }
.feed-item .time {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text-muted);
  font-size: 11px;
}
.feed-item .callsign {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700; font-size: 13px;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}
.feed-item .dxcc {
  font-size: 11px; color: var(--text-secondary);
  max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.feed-item .band-pill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px; font-weight: 700; color: white;
  padding: 2px 7px; border-radius: 999px;
  text-align: center; min-width: 42px;
}
.feed-item .mode-pill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px; font-weight: 600;
  color: var(--text-secondary);
  padding: 2px 7px; border-radius: 999px;
  background: var(--bg-muted);
}
.feed-empty {
  padding: 24px 14px; text-align: center;
  color: var(--text-muted); font-size: 12px; font-style: italic;
}

/* ── Bars (breakdown) ──────────────────────────────────────────────── */
.breakdown-grid {
  display: grid; gap: 14px;
  grid-template-columns: 1fr 1fr;
}
.bar-list { display: flex; flex-direction: column; gap: 6px; }
.bar-row {
  display: grid; grid-template-columns: 56px 1fr 44px; align-items: center;
  gap: 10px;
  font-size: 12px;
}
.bar-label {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600; color: var(--text-secondary);
}
.bar-track {
  position: relative; height: 18px;
  background: var(--bg-muted);
  border-radius: 4px; overflow: hidden;
}
.bar-fill {
  position: absolute; inset: 0 auto 0 0;
  background: var(--accent-blue);
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.bar-count {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700; color: var(--text-primary);
  text-align: right;
}
.bar-fill[data-band="160m"] { background: var(--band-160m); }
.bar-fill[data-band="80m"]  { background: var(--band-80m);  }
.bar-fill[data-band="40m"]  { background: var(--band-40m);  }
.bar-fill[data-band="30m"]  { background: var(--band-30m);  }
.bar-fill[data-band="20m"]  { background: var(--band-20m);  }
.bar-fill[data-band="17m"]  { background: var(--band-17m);  }
.bar-fill[data-band="15m"]  { background: var(--band-15m);  }
.bar-fill[data-band="12m"]  { background: var(--band-12m);  }
.bar-fill[data-band="10m"]  { background: var(--band-10m);  }
.bar-fill[data-band="6m"]   { background: var(--band-6m);   }
.bar-fill[data-band="2m"]   { background: var(--band-2m);   }
.bar-fill[data-band="70cm"] { background: var(--band-70cm); }

/* ── Footer ────────────────────────────────────────────────────────── */
.footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px 20px;
  color: var(--text-muted); font-size: 11px;
  max-width: 1400px; margin: 0 auto;
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-grid--logbook { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .split          { grid-template-columns: 1fr; }
  .breakdown-grid { grid-template-columns: 1fr; }
  .chart-wrap     { height: 200px; }
  .kpi-grid--logbook { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters-grid   { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 12px; }
  .layout { padding: 10px 12px 20px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi-grid--logbook { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 10px 12px; }
  .kpi-value { font-size: 22px; }
  .feed-list { max-height: 300px; }
  .feed-item { grid-template-columns: auto 1fr auto; }
  .feed-item .dxcc { display: none; }
  .filters-grid { grid-template-columns: 1fr; }
  .tab { font-size: 12px; padding: 10px 14px; }
}

/* ╔══════════════════════════════════════════════════════════════════╗
   ║  ONGLET LOGBOOK COMPLET                                          ║
   ╚══════════════════════════════════════════════════════════════════╝ */

/* ── Barre d'onglets (sous le header, pleine largeur) ─────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  padding: 0 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 49px; z-index: 9;
  /* `top` aligné sur la hauteur réelle de la topbar pour que les deux barres
     restent collées en sticky. Si la topbar grandit, ajuster ici. */
}
.tab {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
  letter-spacing: 0.01em;
}
.tab:hover { color: var(--text-primary); }
.tab[aria-selected="true"] {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
}
.tab:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: -4px;
  border-radius: 4px;
}

/* ── En-tête vue logbook (titre + indicatifs) ─────────────────────── */
.logbook-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 4px 2px 0;
}
.logbook-title h2 {
  margin: 0; font-size: 18px; font-weight: 700;
  color: var(--text-primary); letter-spacing: -0.01em;
}
.logbook-subtitle {
  display: block; margin-top: 2px;
  font-size: 12px; color: var(--text-secondary);
}
/* ── KPIs logbook (5 tuiles au lieu de 6) ─────────────────────────── */
.kpi-grid--logbook {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

/* ── Panneau filtres (mode compact) ───────────────────────────────── */
.filters-card .card-header {
  padding: 5px 12px;
  gap: 8px;
}
.filters-card .card-title { font-size: 12px; }
.btn-ghost {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font: inherit; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.btn-ghost:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.filters-grid {
  display: grid; gap: 4px 8px;
  /* 5 colonnes : avec dates masquées et 9 champs visibles → 2 rangées. */
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.card-body.filters-grid { padding: 6px 10px; }
.filter-field {
  display: flex; flex-direction: column; gap: 1px;
  font-size: 11px;
}
.filter-search { grid-column: span 2; }
.filter-label {
  font-size: 8px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.3;
}
.filter-field input,
.filter-field select {
  font: inherit; font-size: 11px;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  transition: border-color 0.12s, box-shadow 0.12s;
  line-height: 1.2;
}
.filter-field input:focus,
.filter-field select:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-blue) 18%, transparent);
}
/* Multi-select : aligné sur la hauteur d'un select simple. La sélection
   multi reste possible (Ctrl/Cmd-clic) ; les options invisibles défilent. */
.filter-field select[multiple] {
  height: auto; min-height: 0;
  padding: 1px 5px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
}
.filter-field input[type="date"] { font-family: 'IBM Plex Mono', monospace; }

/* ── Tableau logbook ──────────────────────────────────────────────── */
.lb-table-wrap {
  padding: 0;
  overflow-x: auto;
  /* tbody sera scrollable verticalement via le wrapper si la page devient grande,
     mais on laisse la pagination contrôler ça → pas de max-height ici. */
}
.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.lb-table thead th {
  position: sticky; top: 0;
  background: var(--bg-card);
  z-index: 1;
  text-align: left;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.lb-table thead th.num { text-align: right; }
.lb-table thead th.sortable {
  cursor: pointer;
  user-select: none;
}
.lb-table thead th.sortable:hover { color: var(--text-primary); }
.lb-table thead th[data-sort-active] {
  color: var(--accent-blue);
}
.lb-table thead th[data-sort-active]::after {
  content: " ↓"; font-size: 11px;
}
.lb-table thead th[data-sort-active="asc"]::after {
  content: " ↑";
}

.lb-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.lb-table tbody tr:hover { background: var(--bg-row-hover); }
.lb-table tbody td {
  padding: 8px 12px;
  vertical-align: middle;
  white-space: nowrap;
}
.lb-table .col-call {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700; font-size: 13px;
  color: var(--text-primary);
  letter-spacing: 0.04em;
}
.lb-table .col-date {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text-secondary);
  font-size: 11px;
}
.lb-table .col-rst {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; color: var(--text-secondary);
}
.lb-table .col-dxcc { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.lb-table .col-cont {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; color: var(--text-secondary);
}
.lb-table .col-locator {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; color: var(--text-secondary);
}
.lb-table .col-dist {
  text-align: right;
  font-family: 'IBM Plex Mono', monospace;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}
.lb-table .band-pill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px; font-weight: 700; color: white;
  padding: 2px 7px; border-radius: 999px;
  display: inline-block; min-width: 42px; text-align: center;
}
.lb-table .mode-pill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px; font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-muted);
  padding: 2px 7px; border-radius: 999px;
  display: inline-block;
}
.lb-table .act-pill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px; font-weight: 700;
  color: white;
  padding: 2px 7px; border-radius: 999px;
  display: inline-block;
  background: var(--accent-orange);
}
.lb-table .act-pill[data-act="sota"] { background: #B45309; }
.lb-table .act-pill[data-act="wwff"] { background: var(--accent-green); }
.lb-table .act-pill[data-act="iota"] { background: var(--accent-teal); }

.lb-empty td {
  padding: 32px 14px;
  text-align: center;
  color: var(--text-muted); font-style: italic; font-size: 13px;
}

/* Pills bandes : couleurs identiques à la vue live (réutilise CSS plus haut). */
.lb-table .band-pill[data-band="160m"] { background: var(--band-160m); }
.lb-table .band-pill[data-band="80m"]  { background: var(--band-80m);  }
.lb-table .band-pill[data-band="40m"]  { background: var(--band-40m);  }
.lb-table .band-pill[data-band="30m"]  { background: var(--band-30m);  }
.lb-table .band-pill[data-band="20m"]  { background: var(--band-20m);  }
.lb-table .band-pill[data-band="17m"]  { background: var(--band-17m);  }
.lb-table .band-pill[data-band="15m"]  { background: var(--band-15m);  }
.lb-table .band-pill[data-band="12m"]  { background: var(--band-12m);  }
.lb-table .band-pill[data-band="10m"]  { background: var(--band-10m);  }
.lb-table .band-pill[data-band="6m"]   { background: var(--band-6m);   }
.lb-table .band-pill[data-band="2m"]   { background: var(--band-2m);   }
.lb-table .band-pill[data-band="70cm"] { background: var(--band-70cm); }

/* ── Pagination ───────────────────────────────────────────────────── */
.lb-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  flex-wrap: wrap;
}
.lb-page-info {
  color: var(--text-secondary);
  font-family: 'IBM Plex Mono', monospace;
}
.lb-page-info strong {
  color: var(--text-primary);
  font-weight: 700;
}
.lb-page-controls {
  display: flex; align-items: center; gap: 4px;
  flex-wrap: wrap;
}
.lb-page-btn {
  appearance: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font: inherit; font-family: 'IBM Plex Mono', monospace;
  font-size: 12px; font-weight: 600;
  min-width: 32px; padding: 5px 9px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.lb-page-btn:hover:not(:disabled) {
  background: var(--bg-muted);
  color: var(--text-primary);
  border-color: var(--text-muted);
}
.lb-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.lb-page-btn[aria-current="page"] {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}
.lb-page-ellipsis {
  padding: 0 4px;
  color: var(--text-muted);
}
.lb-page-size {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-secondary);
}
.lb-page-size select {
  font: inherit;
  font-family: 'IBM Plex Mono', monospace;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-card);
  color: var(--text-primary);
}

/* ── Responsive logbook ───────────────────────────────────────────── */
@media (max-width: 1100px) {
  .filters-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .filter-search { grid-column: span 2; }
}
@media (max-width: 800px) {
  .filters-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-search { grid-column: span 3; }
  .logbook-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 520px) {
  .filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-search { grid-column: span 2; }
  .lb-table thead th { padding: 8px 10px; }
  .lb-table tbody td { padding: 6px 10px; }
}
