/* ============================================
   PROSPERITY DIFFUSION DASHBOARD
   Dark Theme Professional Styling
   ============================================ */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-panel: #151d2e;
  --bg-card: #1a2332;
  --bg-hover: #1e293b;
  --border-color: #1e3a5f;
  --border-subtle: #1a2744;
  --accent-cyan: #00d4ff;
  --accent-teal: #00b4d8;
  --accent-green: #10b981;
  --accent-yellow: #f59e0b;
  --accent-orange: #f97316;
  --accent-red: #ef4444;
  --accent-pink: #ec4899;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
}

#app {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================
   HEADER
   ============================================ */
#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
  flex-shrink: 0;
  height: 52px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-teal));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: var(--bg-primary);
  letter-spacing: -0.5px;
}

.title-group h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.subtitle {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

#year-display {
  font-size: 42px;
  font-weight: 800;
  color: var(--accent-cyan);
  line-height: 1;
  letter-spacing: -1px;
  text-shadow: 0 0 30px rgba(0, 212, 255, 0.3);
}

.data-source {
  font-size: 9px;
  color: var(--text-muted);
  text-align: right;
  line-height: 1.4;
}

/* ============================================
   MAIN LAYOUT
   ============================================ */
#main {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ============================================
   MAP
   ============================================ */
#map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
}

#map .country {
  stroke: #0a0e17;
  stroke-width: 0.4;
  cursor: pointer;
  transition: opacity 0.15s;
}

#map .country:hover {
  opacity: 0.85;
  stroke: var(--accent-cyan);
  stroke-width: 1;
}

#map .graticule {
  fill: none;
  stroke: #1a2332;
  stroke-width: 0.3;
  stroke-opacity: 0.5;
}

#map .hub-circle {
  cursor: pointer;
  filter: drop-shadow(0 0 6px rgba(0, 212, 255, 0.5));
}

#map .hub-label {
  font-family: var(--font);
  font-size: 9px;
  font-weight: 500;
  fill: var(--text-secondary);
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

#map .network-line {
  fill: none;
  stroke-linecap: round;
}

/* Tooltip */
#tooltip {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px 18px;
  pointer-events: none;
  z-index: 100;
  min-width: 220px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
}

#tooltip.hidden {
  display: none;
}

#tooltip .tt-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 2px;
}

#tooltip .tt-year {
  font-size: 12px;
  color: var(--accent-cyan);
  font-weight: 600;
  margin-bottom: 10px;
}

#tooltip .tt-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 2px 0;
}

#tooltip .tt-label {
  color: var(--text-secondary);
}

#tooltip .tt-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Poverty Legend */
#poverty-legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: rgba(21, 29, 46, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 14px;
  backdrop-filter: blur(6px);
}

.legend-title {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.legend-colors {
  display: flex;
  gap: 2px;
}

.legend-colors span {
  width: 28px;
  height: 10px;
  border-radius: 2px;
}

.legend-labels {
  display: flex;
  gap: 2px;
  margin-top: 3px;
}

.legend-labels span {
  width: 28px;
  font-size: 7px;
  color: var(--text-muted);
  text-align: center;
}

/* Hub Legend */
#hub-legend {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: rgba(21, 29, 46, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 14px;
  backdrop-filter: blur(6px);
}

.hub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.hub-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.hub-dot.core {
  background: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
}

.hub-dot.regional {
  background: var(--accent-yellow);
  box-shadow: 0 0 6px var(--accent-yellow);
}

.hub-dot.emerging {
  background: var(--accent-orange);
  box-shadow: 0 0 6px var(--accent-orange);
}

.hub-line-info {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

/* ============================================
   SIDEBAR
   ============================================ */
#sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

#sidebar::-webkit-scrollbar {
  width: 4px;
}

#sidebar::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.panel {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.panel h3 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.accent-bar {
  width: 3px;
  height: 14px;
  background: var(--accent-cyan);
  border-radius: 2px;
  display: inline-block;
}

/* Scenario Buttons */
.scenario-buttons {
  display: flex;
  gap: 6px;
}

.scenario-btn {
  flex: 1;
  padding: 8px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  line-height: 1.3;
}

.scenario-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-cyan);
}

.scenario-btn.active {
  background: rgba(0, 212, 255, 0.12);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* Growth Drivers */
.drivers-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.driver-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.driver-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.driver-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
}

.driver-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.driver-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--bg-card);
  border-radius: 4px;
  outline: none;
}

.driver-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent-cyan);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.4);
  transition: transform 0.15s;
}

.driver-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.driver-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent-cyan);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.4);
}

.driver-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-cyan);
  min-width: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Policy Interventions */
.policy-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.policy-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.policy-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
}

.policy-name {
  flex: 1;
  color: var(--text-secondary);
}

.climate-label {
  color: var(--accent-red) !important;
}

/* Toggle Switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  transition: all 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all 0.3s;
}

.toggle input:checked + .toggle-slider {
  background: rgba(0, 212, 255, 0.2);
  border-color: var(--accent-cyan);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(16px);
  background: var(--accent-cyan);
}

/* ============================================
   METRICS BAR
   ============================================ */
#metrics-bar {
  display: flex;
  gap: 1px;
  background: var(--border-color);
  flex-shrink: 0;
  height: 100px;
}

.metric-card {
  flex: 1;
  background: var(--bg-secondary);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.structural-card {
  min-width: 200px;
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.metric-title {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.metric-trend {
  font-size: 10px;
}

.metric-trend.down {
  color: var(--accent-green);
}

.metric-trend.up-good {
  color: var(--accent-green);
}

.metric-trend.up-bad {
  color: var(--accent-red);
}

.metric-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.sparkline {
  flex: 1;
  width: 100%;
  min-height: 0;
}

/* Structure bar */
.structure-bar-container {
  margin: 6px 0 4px;
  height: 8px;
  background: var(--bg-card);
  border-radius: 4px;
  overflow: hidden;
}

.structure-bar {
  height: 100%;
  display: flex;
  border-radius: 4px;
  overflow: hidden;
}

.structure-bar .seg-agri {
  background: var(--accent-green);
  transition: width 0.5s;
}

.structure-bar .seg-ind {
  background: var(--accent-cyan);
  transition: width 0.5s;
}

.structure-bar .seg-svc {
  background: var(--accent-pink);
  transition: width 0.5s;
}

.structure-labels {
  display: flex;
  gap: 10px;
  font-size: 10px;
}

.struct-label {
  font-weight: 500;
}

.struct-label.agri { color: var(--accent-green); }
.struct-label.ind { color: var(--accent-cyan); }
.struct-label.svc { color: var(--accent-pink); }

/* ============================================
   TIMELINE BAR
   ============================================ */
#timeline-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  height: 46px;
}

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

#play-btn {
  padding: 5px 14px;
  background: rgba(0, 212, 255, 0.12);
  border: 1px solid var(--accent-cyan);
  border-radius: 6px;
  color: var(--accent-cyan);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

#play-btn:hover {
  background: rgba(0, 212, 255, 0.2);
}

.speed-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

#speed-display {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 22px;
  text-align: center;
}

#speed-btn {
  width: 24px;
  height: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

#speed-btn:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.timeline-slider-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#timeline-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: linear-gradient(to right, var(--accent-cyan) 0%, var(--bg-card) 0%);
  border-radius: 6px;
  outline: none;
  cursor: pointer;
}

#timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent-cyan);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

#timeline-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--accent-cyan);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.timeline-ticks {
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
}

.timeline-ticks span {
  font-size: 9px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 1200px) {
  #sidebar {
    width: 240px;
  }
}

@media (max-width: 900px) {
  #sidebar {
    display: none;
  }
  .metric-card:nth-child(n+5) {
    display: none;
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes pulse-glow {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.hub-circle.core {
  animation: pulse-glow 3s ease-in-out infinite;
}

/* Loading state */
#app.loading #map-container::after {
  content: 'Loading map data...';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  color: var(--text-muted);
}
