/* ==========================================================================
   WORLD INFLATION TRACKER — JUPITER HEAVY SPACE DATA VISUALIZATION
   ========================================================================== */

:root {
  --color-bg-deep: #080705;
  --color-panel-bg: rgba(14, 19, 32, 0.85);
  --color-border: rgba(235, 175, 55, 0.35);
  --color-border-glow: rgba(235, 175, 55, 0.6);
  --color-gold: #ebaf37;
  --color-cyan: #00f2ff;
  --color-red: #ff4444;
  --color-text-main: #f0f4f8;
  --color-text-dim: #94a3b8;
  
  /* Threshold Colors */
  --color-deflation: #2563EB;
  --color-target: #16A34A;
  --color-moderate: #CA8A04;
  --color-high: #DC2626;
  --color-extreme: #881337;
  --color-nodata: #4B5563;

  --font-hud: 'Orbitron', sans-serif;
  --font-body: 'Outfit', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;
}

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

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--color-bg-deep);
  color: var(--color-text-main);
  font-family: var(--font-body);
}

/* Background Effects */
#map-starfield {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #101626 0%, #050608 85%);
  z-index: -2;
}

#map-scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.12) 50%);
  background-size: 100% 4px;
  z-index: 1000;
  pointer-events: none;
}

#dataviz-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* --- HEADER HUD NAVIGATION --- */
#hud-nav {
  height: 64px;
  background: rgba(8, 7, 5, 0.92);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-link {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.brand-logo {
  height: 40px;
  width: 40px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(235, 175, 55, 0.6));
  transition: transform 0.2s ease, filter 0.2s ease;
}

.brand-logo:hover {
  transform: scale(1.08);
  filter: drop-shadow(0 0 12px rgba(235, 175, 55, 0.9));
}

.back-link {
  font-family: var(--font-hud);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-cyan);
  text-decoration: none;
  letter-spacing: 2px;
  padding: 6px 14px;
  background: rgba(0, 242, 255, 0.08);
  border: 1px solid rgba(0, 242, 255, 0.3);
  border-radius: 4px;
  transition: all 0.2s ease;
}

.back-link:hover {
  background: rgba(0, 242, 255, 0.2);
  box-shadow: 0 0 12px rgba(0, 242, 255, 0.4);
}

.brand-divider {
  width: 1px;
  height: 24px;
  background: var(--color-border);
}

.brand-title {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.title-with-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-title h1 {
  font-family: var(--font-hud);
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--color-gold);
  text-shadow: 0 0 10px rgba(235, 175, 55, 0.4);
}

.version-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--color-cyan);
  background: rgba(0, 242, 255, 0.12);
  border: 1px solid rgba(0, 242, 255, 0.4);
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 1px;
  box-shadow: 0 0 8px rgba(0, 242, 255, 0.2);
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 1.5px;
  color: var(--color-text-dim);
}

/* Live API Status Pill */
.status-indicator {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  padding: 5px 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(22, 163, 74, 0.12);
  border: 1px solid rgba(22, 163, 74, 0.4);
  color: #4ade80;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #22c55e;
  box-shadow: 0 0 8px #22c55e;
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.hud-controls-top {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Search Box */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0 12px;
}

.search-icon {
  font-size: 0.8rem;
  margin-right: 8px;
  opacity: 0.6;
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.8rem;
  width: 180px;
  padding: 7px 0;
}

.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--color-panel-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.8);
}

.search-dropdown.hidden {
  display: none;
}

.search-result-item {
  padding: 8px 12px;
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.search-result-item:hover {
  background: rgba(0, 242, 255, 0.15);
  color: var(--color-cyan);
}

/* Buttons */
.btn-group {
  display: flex;
  gap: 6px;
}

.hud-btn {
  font-family: var(--font-hud);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--color-border);
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hud-btn:hover {
  background: rgba(235, 175, 55, 0.2);
  border-color: var(--color-gold);
}

.btn-accent {
  background: rgba(0, 242, 255, 0.1);
  border-color: rgba(0, 242, 255, 0.4);
  color: var(--color-cyan);
}

.btn-accent:hover {
  background: rgba(0, 242, 255, 0.25);
  box-shadow: 0 0 10px rgba(0, 242, 255, 0.4);
}

/* --- MAP CANVAS & OVERLAYS --- */
#map-wrapper {
  position: relative;
  flex: 1;
  width: 100%;
  height: calc(100vh - 64px);
}

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

#world-map {
  width: 100%;
  height: 100%;
  cursor: grab;
}

#world-map:active {
  cursor: grabbing;
}

/* Country Path Styles */
.country-path {
  stroke: rgba(15, 23, 42, 0.8);
  stroke-width: 0.6px;
  transition: fill 0.2s ease, stroke 0.2s ease, stroke-width 0.2s ease;
  cursor: pointer;
}

.country-path:hover {
  stroke: var(--color-cyan) !important;
  stroke-width: 1.8px !important;
  filter: drop-shadow(0 0 8px rgba(0, 242, 255, 0.6));
}

.country-path.dimmed {
  opacity: 0.25;
}

.country-path.highlighted {
  stroke: var(--color-gold) !important;
  stroke-width: 2.2px !important;
  filter: drop-shadow(0 0 12px rgba(235, 175, 55, 0.8));
}

/* --- FLOATING LEGEND OVERLAY --- */
#legend-overlay {
  position: absolute;
  bottom: 24px;
  left: 24px;
  width: 260px;
  background: var(--color-panel-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}

.hud-card .card-header h3 {
  font-family: var(--font-hud);
  font-size: 0.85rem;
  letter-spacing: 2px;
  color: var(--color-gold);

}

.legend-subtitle {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--color-text-dim);
  display: block;
  margin-bottom: 12px;
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.legend-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.legend-item.active {
  background: rgba(0, 242, 255, 0.15);
  outline: 1px solid var(--color-cyan);
}

.color-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  box-shadow: 0 0 6px rgba(0,0,0,0.5);
  flex-shrink: 0;
}

.legend-label {
  color: var(--color-text-main);
  font-weight: 500;
}

/* --- SUMMARY TELEMETRY PANEL --- */
#summary-panel {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 320px;
  max-height: calc(100vh - 120px);
  background: var(--color-panel-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 18px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  z-index: 90;
}

.panel-icon {
  font-size: 0.9rem;
  margin-right: 6px;
}

.summary-panel .card-header h2 {
  font-family: var(--font-hud);
  font-size: 0.95rem;
  letter-spacing: 2px;
  color: var(--color-gold);
}

.panel-subtitle {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--color-cyan);
  display: block;
  margin-top: 2px;
  margin-bottom: 14px;
}

.stats-overview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 10px;
  text-align: center;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--color-text-dim);
  letter-spacing: 1px;
  display: block;
  margin-bottom: 4px;
}

.stat-value {
  font-family: var(--font-hud);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.tabs-container {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 12px;
}

.tab-btn {
  flex: 1;
  padding: 8px 0;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--color-text-dim);
  font-family: var(--font-hud);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  color: var(--color-gold);
  border-bottom-color: var(--color-gold);
}

.rankings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 280px;
  padding-right: 4px;
}

.rank-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 10px;
  border-radius: 4px;
  border-left: 3px solid transparent;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.rank-item:hover {
  background: rgba(0, 242, 255, 0.12);
}

.rank-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rank-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-dim);
  width: 16px;
}

.rank-country {
  font-weight: 600;
  color: #fff;
}

.rank-rate {
  font-family: var(--font-hud);
  font-size: 0.8rem;
  font-weight: 700;
}

/* --- DYNAMIC HOVER TOOLTIP --- */
.hud-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 300;
  background: rgba(14, 19, 32, 0.95);
  border: 1px solid var(--color-cyan);
  border-radius: 6px;
  padding: 12px 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.8), 0 0 12px rgba(0, 242, 255, 0.3);
  width: 220px;
  transform: translate(-50%, -120%);
  transition: opacity 0.15s ease;
}

.hud-tooltip.hidden {
  opacity: 0;
  visibility: hidden;
}

.tooltip-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 6px;
}

#tooltip-flag {
  font-size: 1.1rem;
}

#tooltip-country {
  font-family: var(--font-hud);
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.code-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--color-cyan);
}

.tooltip-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.val-highlight {
  font-family: var(--font-hud);
  font-size: 0.9rem;
  font-weight: 700;
}

.cat-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: bold;
}

.val-dim {
  color: var(--color-text-dim);
  font-family: var(--font-mono);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.2);
}
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 2px;
}

/* Light Mode Theme Overrides */
body.light-mode {
  --color-bg-deep: #f8fafc;
  --color-panel-bg: rgba(255, 255, 255, 0.96);
  --color-border: rgba(203, 213, 225, 0.8);
  --color-border-glow: rgba(14, 165, 233, 0.4);
  --color-text-main: #0f172a;
  --color-text-dim: #475569;
  background-color: #f8fafc !important;
  color: #0f172a !important;
}

body.light-mode #map-starfield {
  background: radial-gradient(circle at center, #e2e8f0 0%, #cbd5e1 85%) !important;
}

body.light-mode #map-scanlines {
  display: none !important;
}

body.light-mode #hud-nav,
body.light-mode .hud-card,
body.light-mode #summary-panel,
body.light-mode #legend-overlay {
  background: rgba(255, 255, 255, 0.96) !important;
  border-color: rgba(203, 213, 225, 0.8) !important;
  color: #0f172a !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
}

body.light-mode .stat-value,
body.light-mode .rank-country,
body.light-mode #tooltip-country,
body.light-mode .hud-btn,
body.light-mode .search-box input {
  color: #0f172a !important;
}

body.light-mode .search-box {
  background: rgba(241, 245, 249, 0.9) !important;
  border-color: rgba(203, 213, 225, 0.8) !important;
}

body.light-mode .search-dropdown {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: rgba(203, 213, 225, 0.8) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15) !important;
}

body.light-mode .search-result-item {
  color: #0f172a !important;
  border-bottom-color: rgba(226, 232, 240, 0.8) !important;
}

body.light-mode .search-result-item:hover {
  background: rgba(14, 165, 233, 0.1) !important;
}

body.light-mode .stat-box {
  background: rgba(241, 245, 249, 0.9) !important;
  border-color: rgba(203, 213, 225, 0.8) !important;
}

body.light-mode .rank-item {
  background: rgba(241, 245, 249, 0.9) !important;
}

body.light-mode .rank-item:hover {
  background: rgba(14, 165, 233, 0.12) !important;
}

body.light-mode .rank-num,
body.light-mode .stat-label,
body.light-mode .legend-subtitle,
body.light-mode .hud-subtitle,
body.light-mode .val-dim {
  color: #475569 !important;
}

body.light-mode .hud-title,
body.light-mode .summary-panel .card-header h2,
body.light-mode .hud-card .card-header h3 {
  color: #b45309 !important;
}

body.light-mode .hud-tooltip {
  background: rgba(255, 255, 255, 0.96) !important;
  color: #0f172a !important;
  border-color: #0284c7 !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15) !important;
}

body.light-mode .country-path {
  stroke: rgba(255, 255, 255, 0.9);
}

