/* ============================================================
   AeroClimate GSK - Design System
   Premium Environmental Monitoring Dashboard
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---- CSS Custom Properties ---- */
:root {
  /* Color Palette - Dark Mode First */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #1a1f35;
  --bg-card-hover: #222842;
  --bg-glass: rgba(26, 31, 53, 0.7);
  --bg-input: #151a2e;
  --border-color: rgba(99, 115, 171, 0.15);
  --border-glow: rgba(99, 179, 237, 0.3);

  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-heading: #f1f5f9;

  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-violet: #8b5cf6;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  /* AQI Colors */
  --aqi-good: #22c55e;
  --aqi-moderate: #eab308;
  --aqi-usg: #f97316;
  --aqi-unhealthy: #ef4444;
  --aqi-very-unhealthy: #a855f7;
  --aqi-hazardous: #991b1b;

  /* Gradients */
  --gradient-hero: linear-gradient(135deg, #0a0e1a 0%, #1a1f35 50%, #111827 100%);
  --gradient-card: linear-gradient(145deg, rgba(26, 31, 53, 0.9), rgba(17, 24, 39, 0.8));
  --gradient-accent: linear-gradient(135deg, #3b82f6, #06b6d4);
  --gradient-glow: radial-gradient(ellipse at 50% 0%, rgba(59, 130, 246, 0.15) 0%, transparent 70%);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.1);

  /* Spacing & Sizing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light mode overrides */
[data-theme="light"] {
  --bg-primary: #f0f4f8;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-glass: rgba(255, 255, 255, 0.8);
  --bg-input: #f1f5f9;
  --border-color: rgba(148, 163, 184, 0.2);
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-heading: #0f172a;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- Background Effects ---- */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--gradient-glow);
  pointer-events: none;
  z-index: 0;
}

/* ---- Navbar ---- */
.navbar-aero {
  background: rgba(10, 14, 26, 0.85) !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-color);
  padding: 0.6rem 0;
  transition: var(--transition);
  z-index: 1050;
}

.navbar-brand {
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -0.5px;
}

.navbar-brand .brand-gradient {
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.navbar-brand .brand-sub {
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-muted);
  display: block;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.nav-link {
  color: var(--text-secondary) !important;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.5rem 1rem !important;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
  color: var(--accent-blue) !important;
  background: rgba(59, 130, 246, 0.1);
}

/* ---- Hero AQI Card ---- */
.hero-aqi-section {
  padding: 2rem 0;
  position: relative;
}

.hero-aqi-card {
  background: var(--gradient-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-lg);
}

.hero-aqi-card::before {
  content: '';
  position: absolute;
  top: -50%; right: -20%;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.aqi-value-display {
  font-size: 5rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -3px;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 40px currentColor;
  transition: var(--transition);
}

.aqi-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.5px;
  border: 1px solid rgba(255,255,255,0.15);
}

.aqi-meta {
  display: flex;
  gap: 2rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.aqi-meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.aqi-meta-label {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.aqi-meta-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-heading);
}

/* ---- Station Selector ---- */
.station-selector {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.station-btn {
  padding: 0.4rem 1rem;
  border-radius: 50px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.station-btn:hover, .station-btn.active {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

/* ---- Modern Cards ---- */
.glass-card {
  background: var(--gradient-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.glass-card:hover {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.glass-card .card-header-custom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title i {
  color: var(--accent-blue);
}

/* ---- Weather Panel ---- */
.weather-card {
  text-align: center;
  padding: 1.25rem;
}

.weather-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  line-height: 1;
}

.weather-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.2;
}

.weather-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 0.25rem;
}

.weather-unit {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-secondary);
}

/* ---- Pollutant Cards ---- */
.pollutant-card {
  padding: 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.pollutant-card:hover {
  border-color: var(--border-glow);
}

.pollutant-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pollutant-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-heading);
  margin: 0.25rem 0;
}

.pollutant-ispu {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.pollutant-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--bg-input);
  margin-top: 0.5rem;
  overflow: hidden;
}

.pollutant-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.8s ease;
}

/* ---- Map Container ---- */
.map-container {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
  height: 450px;
}

.map-container .leaflet-container {
  height: 100%;
  background: var(--bg-secondary);
}

/* ---- Sensor Status ---- */
.sensor-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.sensor-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}

.sensor-dot.online { background: var(--aqi-good); box-shadow: 0 0 8px var(--aqi-good); }
.sensor-dot.delayed { background: var(--aqi-moderate); box-shadow: 0 0 8px var(--aqi-moderate); }
.sensor-dot.offline { background: var(--aqi-unhealthy); animation: none; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ---- Alert Banner ---- */
.alert-banner {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.05));
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  animation: slideDown 0.5s ease;
}

.alert-banner.hidden { display: none; }

.alert-banner-icon {
  font-size: 1.5rem;
  color: var(--aqi-unhealthy);
  animation: shake 1s ease infinite;
}

@keyframes shake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(5deg); }
  75% { transform: rotate(-5deg); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Chart Containers ---- */
.chart-container {
  min-height: 300px;
  position: relative;
}

.chart-filter-group {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-input);
  border-radius: 50px;
  padding: 0.2rem;
}

.chart-filter-btn {
  padding: 0.3rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
}

.chart-filter-btn.active, .chart-filter-btn:hover {
  background: var(--accent-blue);
  color: #fff;
}

/* ---- Insight Cards ---- */
.insight-item {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border-left: 3px solid;
  margin-bottom: 0.75rem;
  transition: var(--transition);
}

.insight-item.success { border-color: var(--aqi-good); }
.insight-item.warning { border-color: var(--aqi-moderate); }
.insight-item.danger { border-color: var(--aqi-unhealthy); }
.insight-item.info { border-color: var(--accent-blue); }

.insight-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.insight-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ---- Dark Mode Toggle ---- */
.theme-toggle {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 1rem;
}

.theme-toggle:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

/* ---- Section Headers ---- */
.section-header {
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-title::before {
  content: '';
  width: 4px; height: 24px;
  background: var(--gradient-accent);
  border-radius: 2px;
}

.section-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  padding-left: 1.25rem;
}

/* ---- Last Updated ---- */
.last-updated {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.live-indicator {
  width: 6px; height: 6px;
  background: var(--aqi-good);
  border-radius: 50%;
  animation: pulse-dot 1.5s infinite;
}

/* ---- Footer ---- */
.footer-aero {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 2rem 0;
  margin-top: 3rem;
}

.footer-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---- Notification Panel ---- */
.notification-panel {
  position: fixed;
  top: 70px; right: 20px;
  width: 360px;
  max-height: 500px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 1100;
  display: none;
  animation: slideDown 0.3s ease;
}

.notification-panel.show { display: block; }

.notification-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 0.9rem;
}

.notification-item {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  transition: var(--transition);
}

.notification-item:hover { background: var(--bg-card-hover); }

.notif-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--accent-rose);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Loading Skeleton ---- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .aqi-value-display { font-size: 3.5rem; }
  .hero-aqi-card { padding: 1.5rem; }
  .aqi-meta { gap: 1rem; }
  .station-selector { gap: 0.35rem; }
  .station-btn { font-size: 0.7rem; padding: 0.3rem 0.75rem; }
  .map-container { height: 300px; }
  .notification-panel { width: calc(100% - 40px); right: 20px; }
}

@media (max-width: 576px) {
  .aqi-value-display { font-size: 3rem; }
  .section-title { font-size: 1.1rem; }
  .glass-card { padding: 1rem; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- Leaflet Dark Override ---- */
.leaflet-tile-pane { filter: brightness(0.7) contrast(1.1) saturate(0.8); }
[data-theme="light"] .leaflet-tile-pane { filter: none; }

/* ---- Admin Specific ---- */
.admin-sidebar { background: var(--bg-secondary); min-height: 100vh; border-right: 1px solid var(--border-color); padding: 1.5rem 0; }
.admin-nav-link { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 1.25rem; color: var(--text-secondary); font-size: 0.85rem; text-decoration: none; transition: var(--transition); }
.admin-nav-link:hover, .admin-nav-link.active { color: var(--accent-blue); background: rgba(59, 130, 246, 0.1); }
.stat-card { text-align: center; }
.stat-card .stat-value { font-size: 2rem; font-weight: 800; background: var(--gradient-accent); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.stat-card .stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ---- Export Form ---- */
.export-form .form-control, .export-form .form-select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
}
.export-form .form-control:focus, .export-form .form-select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.export-form .form-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

/* ---- Buttons ---- */
.btn-aero {
  background: var(--gradient-accent);
  color: #fff;
  border: none;
  padding: 0.6rem 1.5rem;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.85rem;
  transition: var(--transition);
  cursor: pointer;
}
.btn-aero:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
  color: #fff;
}

.btn-outline-aero {
  background: transparent;
  color: var(--accent-blue);
  border: 1px solid var(--accent-blue);
  padding: 0.5rem 1.25rem;
  border-radius: 50px;
  font-weight: 500;
  font-size: 0.8rem;
  transition: var(--transition);
}
.btn-outline-aero:hover {
  background: var(--accent-blue);
  color: #fff;
}

/* ---- Forecast specific ---- */
.forecast-card { border-left: 3px solid var(--accent-violet); }
.forecast-value { font-size: 1.3rem; font-weight: 700; }
.forecast-label { font-size: 0.7rem; color: var(--text-muted); }
.confidence-bar { height: 4px; background: var(--bg-input); border-radius: 2px; margin-top: 0.5rem; }
.confidence-fill { height: 100%; background: var(--accent-violet); border-radius: 2px; transition: width 0.5s ease; }

/* ---- Login Page ---- */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-hero);
}
.login-card {
  background: var(--gradient-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg);
}
.login-card .form-control {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
}
