/* Modern Premium Styling - TerraClimate */

:root {
  --bg-color: #030712;
  --panel-bg: rgba(10, 15, 30, 0.65);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-glow: rgba(0, 0, 0, 0.5);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --accent-color: #10b981; /* Emerald green for selection/markers */
  --accent-glow: rgba(16, 185, 129, 0.3);
  
  --primary-btn: #3b82f6; /* Blue for primary interactions */
  --primary-btn-hover: #2563eb;
  
  --warm-color: #f43f5e; /* Rose/Red for heating */
  --cool-color: #0ea5e9; /* Light blue for cooling */
  --precip-color: #60a5fa; /* Blue for precipitation */
  
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --card-radius: 16px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-primary);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Globe Container */
.globe-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
}

/* Dashboard UI Layout */
.dashboard-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none; /* Let clicks pass through to globe */
  display: grid;
  grid-template-columns: 360px 1fr 400px;
  grid-template-rows: auto 1fr auto;
  gap: 20px;
  padding: 24px;
}

/* Allow UI interactions in panels */
.glass-card {
  pointer-events: auto;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  box-shadow: 0 8px 32px 0 var(--panel-glow);
  border-radius: var(--card-radius);
  padding: 20px;
  transition: var(--transition-smooth);
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.6);
}

/* Top-Left Panel: Title and presets */
.panel-top-left {
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: start;
  max-height: calc(100vh - 150px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-area h1 {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #f3f4f6 30%, #a1a1aa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.globe-icon-spin {
  font-size: 1.8rem;
  color: var(--accent-color);
  text-shadow: 0 0 10px var(--accent-glow);
  animation: slow-spin 20s linear infinite;
}

@keyframes slow-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 2px;
}

.instructions-section {
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
  padding: 12px;
  border-radius: 8px;
  border-left: 3px solid var(--accent-color);
}

.info-icon {
  color: var(--accent-color);
  margin-right: 4px;
}

.hotspots-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hotspot-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.btn {
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition-smooth);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.05);
  text-align: left;
  justify-content: flex-start;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.spot-emoji {
  font-size: 1.1rem;
}

.cache-status-section {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 14px;
  margin-top: auto;
}

.cache-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-clear-cache:hover {
  color: var(--warm-color);
}

/* Top-Right Panel: Global anomaly chart */
.panel-top-right {
  grid-column: 3;
  grid-row: 1;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-top-right h2 {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-icon {
  color: var(--primary-btn);
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
}

.badge-warm {
  background: rgba(244, 63, 94, 0.15);
  color: var(--warm-color);
  border: 1px solid rgba(244, 63, 94, 0.2);
}

.badge-cache {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-color);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.panel-top-right .description {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

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

.global-stats-summary {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

.stat-box {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 8px 12px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 2px;
}

.temp-warm { color: var(--warm-color); }
.temp-cool { color: var(--cool-color); }

/* Bottom-Right Panel: Regional Climate Details */
.panel-bottom-right {
  grid-column: 3;
  grid-row: 2;
  align-self: start;
  position: relative;
  min-height: 250px;
  max-height: calc(100vh - 430px);
  overflow-y: auto;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.panel-bottom-right.active {
  opacity: 1;
  transform: translateY(0);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 200px;
  color: var(--text-muted);
  gap: 12px;
}

.empty-icon {
  font-size: 2.2rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 0.8rem;
  max-width: 250px;
  line-height: 1.4;
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--panel-bg);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  border-radius: var(--card-radius);
  gap: 16px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.location-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.location-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.location-icon {
  color: var(--warm-color);
}

.coordinates {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.location-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.loc-stat {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 10px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
}

.loc-stat-val {
  font-size: 1.25rem;
  font-weight: 700;
}

.text-temp { color: var(--warm-color); }
.text-precip { color: var(--precip-color); }

.loc-stat-lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  font-weight: 600;
}

.api-attribution {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 10px;
  font-style: italic;
}

/* Bottom-Center Panel: Year Slider and playback */
.panel-bottom-center {
  grid-column: 1 / span 3;
  grid-row: 3;
  justify-self: center;
  width: 600px;
  max-width: 90vw;
  padding: 14px 20px;
  margin-bottom: 8px;
}

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

.play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-btn);
  color: var(--text-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.play-btn:hover {
  background: var(--primary-btn-hover);
  transform: scale(1.05);
}

.slider-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.active-year-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-color);
  background: rgba(16, 185, 129, 0.1);
  padding: 1px 10px;
  border-radius: 10px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.timeline-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  transition: background 0.3s;
}

.timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-color);
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-glow);
  transition: transform 0.1s;
}

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

.timeline-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-color);
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-glow);
  border: none;
  transition: transform 0.1s;
}

.timeline-slider::-moz-range-thumb:hover {
  transform: scale(1.2);
}

/* 3D Label/Marker Styles on Globe */
.globe-marker-label {
  color: #10b981;
  font-family: var(--font-family);
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* Impact Risks */
.impact-risks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.risk-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.risk-high {
  background: rgba(249, 115, 22, 0.15);
  border-color: rgba(249, 115, 22, 0.3);
  color: #fb923c;
}

.risk-extreme {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
  animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Milestone Toast */
.milestone-toast {
  position: absolute;
  bottom: 85px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent-color);
  border-radius: 12px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5), 0 0 15px rgba(16, 185, 129, 0.2);
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  width: max-content;
  max-width: 400px;
  z-index: 20;
}

.milestone-toast.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.milestone-year {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-color);
  background: rgba(16, 185, 129, 0.1);
  padding: 5px 10px;
  border-radius: 8px;
}

.milestone-content h4 {
  margin: 0 0 4px 0;
  font-size: 1rem;
  color: #f8fafc;
}

.milestone-content p {
  margin: 0;
  font-size: 0.8rem;
  color: #94a3b8;
  line-height: 1.3;
}

/* Responsiveness adjustments */
@media (max-width: 1200px) {
  .dashboard-wrapper {
    grid-template-columns: 320px 1fr 340px;
  }
  .panel-bottom-center {
    width: 500px;
  }
}

@media (max-width: 900px) {
  .dashboard-wrapper {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    pointer-events: auto; /* Allow direct scrolling on mobile */
  }
  .glass-card {
    width: 100% !important;
    position: relative !important;
    left: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
  }
  .globe-container {
    opacity: 0.4; /* dim globe on small screens so text is legible */
  }
}

/* Tabs Selector inside Regional Panel */
.panel-tabs {
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.2);
  padding: 3px;
  border-radius: 8px;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.tab-btn {
  flex: 1;
  font-family: var(--font-family);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 2px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: var(--transition-smooth);
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Custom Text Colors for Stats */
.text-soil { color: #10b981; }
.text-evap { color: #eab308; }
.text-wind { color: #0ea5e9; }
.text-snow { color: #a5f3fc; }

/* API Quota Gauge Styling */
.quota-gauge-container {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.quota-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.quota-percent {
  font-weight: 700;
  font-size: 0.8rem;
}

.quota-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.quota-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.quota-subtext {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Cached Spot Sidebar Preset Buttons */
.cached-spot {
  background: rgba(16, 185, 129, 0.08) !important;
  border-color: rgba(16, 185, 129, 0.25) !important;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.12);
}

.cached-spot:hover {
  background: rgba(16, 185, 129, 0.15) !important;
  border-color: rgba(16, 185, 129, 0.4) !important;
}

/* Dynamic Selected Year Summary Card */
.regional-year-summary {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 10px 14px 2px 14px;
  margin-bottom: 12px;
}

.summary-year-badge {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Long-term historical trend grid */
.trend-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 12px 0 8px 0;
}

.trend-divider::before, .trend-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.trend-divider:not(:empty)::before {
  margin-right: .5em;
}

.trend-divider:not(:empty)::after {
  margin-left: .5em;
}

.trend-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.trend-item {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid rgba(255, 255, 255, 0.03);
  padding: 6px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: var(--transition-smooth);
}

.trend-item.active {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.trend-lbl {
  font-size: 0.6rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
}

.trend-val {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.trend-item.active .trend-val {
  color: var(--accent-color);
}

.trend-item.active .trend-lbl {
  color: var(--text-primary);
}
