/* ═══════════════════════════════════════════════════════════════════════════
   CIVILIZATIONAL PATHWAYS — World Map Dashboard Simulator
   Dark-theme professional GIS/analytics aesthetic
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg-deep: #080c14;
  --bg-panel: #0d1220;
  --bg-card: #111827;
  --bg-hover: #1a2332;
  --border: #1e2d3d;
  --border-light: #2a3a4e;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-gold: #f0b429;
  --accent-teal: #2dd4bf;
  --accent-blue: #60a5fa;
  --accent-red: #f87171;
  --accent-orange: #fb923c;
  --accent-green: #4ade80;
  --accent-purple: #a78bfa;
  --phase-red: #e53e3e;
  --phase-orange: #dd6b20;
  --phase-green: #38a169;
  --phase-blue: #3182ce;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* ── HEADER ──────────────────────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 20px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  position: relative;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  font-family: var(--font-sans);
}

.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  font-family: var(--font-mono);
}

.header-right {
  display: flex;
  gap: 8px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
}

.kpi-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.kpi-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-gold);
  font-family: var(--font-mono);
}

.kpi-warn .kpi-value { color: var(--accent-orange); }

/* ── DASHBOARD LAYOUT ────────────────────────────────────────────────── */

.dashboard {
  display: flex;
  height: calc(100vh - 56px - 80px); /* header 56 + timeline 80 */
  overflow: hidden;
}

.map-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.map-header {
  height: 36px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.metric-selector {
  display: flex;
  gap: 4px;
}

.metric-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font-sans);
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.metric-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.metric-btn.active { background: var(--accent-teal); color: var(--bg-deep); border-color: var(--accent-teal); }

.map-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.map-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-primary);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 10;
  max-width: 220px;
}

.map-tooltip.visible { opacity: 1; }

.map-tooltip .tt-name { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.map-tooltip .tt-stat { font-size: 11px; color: var(--text-secondary); }
.map-tooltip .tt-stat span { color: var(--accent-gold); font-family: var(--font-mono); }

/* ── PANELS (Right Sidebar) ──────────────────────────────────────────── */

.panels {
  width: 400px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--bg-panel);
  overflow-y: auto;
  overflow-x: hidden;
}

.panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
}

.panel:last-child { border-bottom: none; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.panel-header h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.1px;
}

.panel-badge {
  font-size: 9px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: 3px;
}

.panel-body {
  flex: 1;
  position: relative;
  min-height: 0;
}

.panel-body svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── TIMELINE ────────────────────────────────────────────────────────── */

.timeline-bar {
  height: 80px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0 20px;
}

.timeline-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
}

.tl-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
  width: 36px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}

.tl-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.tl-play {
  background: var(--accent-teal);
  color: var(--bg-deep);
  border-color: var(--accent-teal);
  font-size: 12px;
}

.tl-play:hover { background: #5eeadb; }
.tl-play.paused { background: var(--accent-gold); border-color: var(--accent-gold); }

.tl-speed {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 8px;
}

.timeline-track {
  flex: 1;
  position: relative;
}

#timeline-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.phase-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

#phase-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.phase-bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  position: relative;
  overflow: hidden;
}

/* ── CHART ELEMENTS ──────────────────────────────────────────────────── */

.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { opacity: 0.12; }
.chart-grid line { stroke: var(--border); stroke-opacity: 0.5; }
.chart-grid path { stroke: none; }
.chart-axis text { fill: var(--text-muted); font-size: 10px; font-family: var(--font-mono); }
.chart-axis line, .chart-axis path { stroke: var(--border); }
.chart-label { fill: var(--text-secondary); font-size: 10px; font-family: var(--font-mono); }
.chart-threshold { stroke-dasharray: 4 3; stroke-opacity: 0.6; }
.chart-phase-bg { opacity: 0.04; }
.chart-year-line { stroke: var(--accent-gold); stroke-width: 1; stroke-opacity: 0.8; stroke-dasharray: 3 2; }

/* ── MAP ELEMENTS ────────────────────────────────────────────────────── */

.map-country {
  stroke: var(--bg-deep);
  stroke-width: 0.5;
  transition: fill 0.3s;
}

.map-country:hover {
  stroke: var(--accent-gold);
  stroke-width: 1;
}

/* ── RESPONSIVE ──────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .dashboard { flex-direction: column; }
  .panels { width: 100%; flex-direction: row; overflow-x: auto; max-height: 300px; }
  .panel { flex: 0 0 280px; }
  .header-right { gap: 4px; }
  .kpi-card { min-width: 60px; padding: 4px 8px; }
  .kpi-value { font-size: 14px; }
}
