/* ============================================================
   AMIENS 2ND TOUR — ELECTION DASHBOARD
   Dark theme optimized for large screen projection at QG
   ============================================================ */

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

:root {
  /* Palette — dark, serious, political */
  --bg: #0c0e13;
  --surface: #141720;
  --surface-2: #1a1e2a;
  --surface-3: #212636;
  --border: #2a3040;
  --border-accent: #3a4560;

  /* Text */
  --text: #e8eaf0;
  --text-muted: #8b92a8;
  --text-faint: #5a6280;

  /* Candidate colors */
  --color-toumi: #1e3a8a;
  --color-fauvet: #dc2626;
  --color-jenlis: #60a5fa;
  --color-bellina: #F0BE23;

  /* Julia accent */
  --julia-glow: rgba(240, 190, 35, 0.12);
  --julia-border: rgba(240, 190, 35, 0.4);

  /* Flash / live */
  --live-red: #ef4444;
  --live-red-glow: rgba(239, 68, 68, 0.3);

  /* Progress bar */
  --progress-bg: #1e2235;
  --progress-fill: linear-gradient(90deg, #F0BE23, #f5d066);

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;

  /* Font */
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Transitions */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   DASHBOARD LAYOUT — Full viewport, no scroll
   ============================================================ */
.dashboard {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  padding: var(--sp-4);
  gap: var(--sp-4);
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-6);
  padding: var(--sp-4) var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-shrink: 0;
}

.header-badge {
  background: var(--color-bellina);
  color: #000;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  white-space: nowrap;
}

.header-badge sup {
  font-size: 9px;
  vertical-align: super;
}

h1 {
  font-size: clamp(16px, 1.6vw, 24px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.header-subtitle {
  font-size: clamp(11px, 1vw, 14px);
  color: var(--text-muted);
  margin-top: 2px;
}

.header-right {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 340px;
}

.kpi-cluster {
  display: flex;
  gap: var(--sp-6);
}

.kpi {
  display: flex;
  align-items: baseline;
  gap: var(--sp-1);
}

.kpi-value {
  font-size: clamp(18px, 1.8vw, 28px);
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--text);
}

.kpi-label {
  font-size: clamp(11px, 0.9vw, 13px);
  color: var(--text-muted);
  white-space: nowrap;
}

.progress-bar-container {
  height: 6px;
  background: var(--progress-bg);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--progress-fill);
  border-radius: 3px;
  transition: width 800ms var(--ease);
}

/* ============================================================
   MAIN CONTENT — Chart + Info Panel
   ============================================================ */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--sp-4);
  min-height: 0;
}

/* CHART SECTION */
.chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.chart-container {
  width: 100%;
  height: 100%;
  position: relative;
}

/* INFO PANEL */
.info-panel {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  min-height: 0;
}

/* Seats Card — Compact Donut */
.seats-card {
  background: var(--surface);
  border: 1px solid var(--julia-border);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5);
  box-shadow: 0 0 30px var(--julia-glow);
  flex-shrink: 0;
}

.seats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-2);
}

.seats-header span:first-child {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.seats-total {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.seats-donut-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.seats-donut-wrapper {
  position: relative;
  width: 110px;
  height: 110px;
  flex-shrink: 0;
}

.seats-donut-wrapper canvas {
  width: 110px !important;
  height: 110px !important;
}

.seats-donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

.seats-donut-big {
  display: block;
  font-size: 26px;
  font-weight: 700;
  color: var(--color-bellina);
  line-height: 1;
  font-variant-numeric: tabular-nums lining-nums;
}

.seats-donut-label {
  display: block;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.seats-legend-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.seats-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1.3;
}

.seats-legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  flex-shrink: 0;
}

.seats-legend-name {
  flex: 1;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seats-legend-value {
  font-weight: 700;
  color: var(--text);
  min-width: 20px;
  text-align: right;
}

.seats-legend-item.is-bellina .seats-legend-name {
  color: var(--color-bellina);
  font-weight: 700;
}
.seats-legend-item.is-bellina .seats-legend-value {
  color: var(--color-bellina);
}

/* Flash Card */
.flash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5);
  flex: 1;
  min-height: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
}

.flash-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 11px;
  font-weight: 700;
  color: var(--live-red);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--sp-2);
  flex-shrink: 0;
}

.flash-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live-red);
  animation: flash-pulse 1.5s ease-in-out infinite;
}

@keyframes flash-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--live-red-glow); }
  50% { opacity: 0.4; box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.flash-bureau-name {
  font-size: clamp(14px, 1.2vw, 18px);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
  flex-shrink: 0;
}

.flash-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
  font-variant-numeric: tabular-nums lining-nums;
  flex-shrink: 0;
}

.flash-results {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  flex: 1;
  min-height: 0;
}

.flash-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: clamp(12px, 1.1vw, 15px);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-variant-numeric: tabular-nums lining-nums;
}

.flash-row.is-julia {
  background: rgba(240, 190, 35, 0.1);
  border: 1px solid rgba(240, 190, 35, 0.25);
}

.flash-color-bar {
  width: 4px;
  align-self: stretch;
  border-radius: 2px;
  flex-shrink: 0;
}

.flash-rank {
  font-weight: 700;
  width: 22px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

.flash-row.is-julia .flash-rank { color: var(--color-bellina); font-weight: 700; }

.flash-name {
  flex: 1;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flash-row.is-julia .flash-name { color: var(--color-bellina); font-weight: 700; }

.flash-voix {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  min-width: 45px;
  text-align: right;
}

.flash-pct {
  font-weight: 700;
  color: var(--text);
  min-width: 50px;
  text-align: right;
  font-size: 15px;
}

.flash-pct-bar-container {
  width: 100%;
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  margin-top: var(--sp-2);
  overflow: hidden;
}

.flash-pct-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 600ms var(--ease);
}



/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
  font-size: 11px;
  color: var(--text-faint);
}

.footer a {
  color: var(--text-faint);
  text-decoration: none;
  transition: color 200ms var(--ease);
}

.footer a:hover { color: var(--text-muted); }

.footer-sep { opacity: 0.4; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.seats-card, .flash-card {
  animation: fadeInUp 600ms var(--ease) both;
}

.flash-card { animation-delay: 100ms; }

/* ============================================================
   RESPONSIVE — adapt for smaller screens if needed
   ============================================================ */
@media (max-width: 900px) {
  .main-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .info-panel {
    flex-direction: row;
    gap: var(--sp-3);
  }

  .seats-card, .flash-card {
    flex: 1;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-right {
    min-width: 100%;
  }
}
