/* ============================================================
   MausamNow — Unified Theme System
   3 themes: Storm (dark), Daylight (light), Monsoon (teal-dark)
   ============================================================ */

/* ---------- THEME: STORM (default dark) ---------- */
:root, [data-theme="storm"] {
  --bg:        #0b1120;
  --bg-alt:    #0f172a;
  --surface:   #1a2236;
  --surface2:  #293548;
  --surface3:  #3a4a60;
  --border:    rgba(148,163,184,0.12);
  --text:      #f0f4f8;
  --text-mid:  #c5cdd8;
  --text-dim:  #8896a8;
  --accent:    #38bdf8;
  --accent-bg: rgba(56,189,248,0.08);
  --accent-border: rgba(56,189,248,0.22);
  --green:     #34d399;
  --yellow:    #fbbf24;
  --orange:    #fb923c;
  --red:       #f87171;
  --radius:    10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow:    0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
  --font:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  /* Model colors */
  --c-mausam:    #60a5fa;
  --c-mosdac:    #f472b6;
  --c-gfs:       #fb923c;
  --c-ecmwf:     #34d399;
  --c-graphcast: #a78bfa;
  --c-lpi:       #fbbf24;
  /* Scrollbar */
  --scrollbar-bg: var(--surface);
  --scrollbar-thumb: var(--surface3);
}

/* ---------- THEME: DAYLIGHT (light) ---------- */
[data-theme="daylight"] {
  --bg:        #f4f7fb;
  --bg-alt:    #ffffff;
  --surface:   #ffffff;
  --surface2:  #e8edf4;
  --surface3:  #d0d8e4;
  --border:    rgba(0,0,0,0.08);
  --text:      #1a2236;
  --text-mid:  #3a4a60;
  --text-dim:  #6b7d94;
  --accent:    #0284c7;
  --accent-bg: rgba(2,132,199,0.06);
  --accent-border: rgba(2,132,199,0.18);
  --green:     #16a34a;
  --yellow:    #ca8a04;
  --orange:    #ea580c;
  --red:       #dc2626;
  --shadow:    0 1px 3px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);
  --scrollbar-bg: var(--surface2);
  --scrollbar-thumb: var(--surface3);
}

/* ---------- THEME: MONSOON (teal-dark) ---------- */
[data-theme="monsoon"] {
  --bg:        #0a1a1a;
  --bg-alt:    #0f2424;
  --surface:   #13302e;
  --surface2:  #1e4240;
  --surface3:  #2a5654;
  --border:    rgba(94,234,212,0.1);
  --text:      #e8f5f0;
  --text-mid:  #a8d4c8;
  --text-dim:  #6ba898;
  --accent:    #2dd4bf;
  --accent-bg: rgba(45,212,191,0.08);
  --accent-border: rgba(45,212,191,0.2);
  --green:     #34d399;
  --yellow:    #fbbf24;
  --orange:    #fb923c;
  --red:       #f87171;
  --shadow:    0 1px 3px rgba(0,0,0,0.4);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.5);
  --scrollbar-bg: var(--surface);
  --scrollbar-thumb: var(--surface3);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--scrollbar-bg); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }

/* ============================================================
   HEADER — shared across all pages
   ============================================================ */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 1100;
  box-shadow: var(--shadow);
}

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

.logo {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.logo-tagline {
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 0.01em;
  margin-left: 2px;
}
.logo:hover { text-decoration: none; opacity: 0.85; }

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

/* Location controls in header */
.loc-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.loc-select, .loc-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s;
}
.loc-select:focus, .loc-input:focus { border-color: var(--accent); }
.loc-select { cursor: pointer; appearance: auto; min-width: 130px; }
.loc-input { width: 150px; }
.loc-input::placeholder { color: var(--text-dim); }

.btn-search {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-search:hover { opacity: 0.85; }

/* Nav links */
.nav-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  transition: all 0.15s;
  white-space: nowrap;
}
.nav-link:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.nav-link.active {
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
  background: var(--accent-bg);
}

/* Theme switcher */
.theme-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.72rem;
  cursor: pointer;
  appearance: auto;
  outline: none;
}

/* ============================================================
   LAYOUT — Map + Content (used by forecast & now pages)
   ============================================================ */
.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  height: calc(100vh - 52px);
  transition: grid-template-columns 0.3s ease;
}
.layout.map-collapsed { grid-template-columns: 260px 1fr; }


.map-pane { position: relative; overflow: hidden; }
.map-pane #map { width: 100%; height: 100%; min-height: 160px; }

.map-toggle {
  position: absolute;
  top: 10px;
  left: 50px;
  z-index: 1001;
  background: rgba(11,17,32,0.88);
  backdrop-filter: blur(8px);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.2s;
}
.map-toggle:hover { background: var(--accent); color: var(--bg); }

.map-search {
  position: absolute;
  top: 10px;
  left: 170px;
  right: 50px;
  z-index: 1001;
  display: flex;
  gap: 0;
}
.layout.map-collapsed .map-search { display: none; }

.map-search-input {
  flex: 1;
  min-width: 100px;
  background: rgba(11,17,32,0.88);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  padding: 5px 10px;
  color: var(--text);
  font-size: 0.78rem;
  font-family: var(--font);
  outline: none;
}
.map-search-input:focus { border-color: var(--accent); }
.map-search-input::placeholder { color: var(--text-dim); font-size: 0.72rem; }

.map-search-btn {
  background: rgba(11,17,32,0.88);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-dim);
  padding: 5px 10px;
  cursor: pointer;
  font-size: 0.78rem;
}
.map-search-btn:hover { color: var(--accent); border-color: var(--accent); }

.map-search-results {
  position: absolute;
  top: 34px;
  left: 0;
  right: 0;
  background: rgba(11,17,32,0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  display: none;
  z-index: 1002;
}
.map-search-results .result-item {
  padding: 7px 10px;
  font-size: 0.76rem;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.map-search-results .result-item:hover { background: var(--accent-bg); color: var(--text); }
.map-search-results .result-item:last-child { border-bottom: none; }
.map-search-results .result-name { color: var(--text); font-weight: 500; }

.map-overlay {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  z-index: 1000;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.location-badge {
  background: rgba(11,17,32,0.88);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.78rem;
  color: var(--text);
  border: 1px solid var(--border);
}
.location-badge .area { font-weight: 600; color: var(--accent); }
.location-badge .grid { color: var(--text-dim); font-size: 0.68rem; }

/* Content panel (right side of layout, or single-column pages) */
.content-panel {
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============================================================
   CARDS — unified card component
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.card-flat {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card-accent {
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.card h3, .card-flat h3 {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 8px;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.page-subtitle {
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.6;
  margin-bottom: 16px;
}
.section-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.text-accent { color: var(--accent); }
.text-dim { color: var(--text-dim); }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.75rem; }
.text-bold { font-weight: 600; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  text-align: center;
  padding: 40px;
  gap: 10px;
}
.empty-state .icon { font-size: 2.5rem; }
.empty-state p { font-size: 0.95rem; max-width: 280px; line-height: 1.5; }

/* Spinner */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--surface2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   WARNING BARS
   ============================================================ */
.warning-bar {
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.warning-bar.green  { background: rgba(34,197,94,0.08);  border: 1px solid rgba(34,197,94,0.2);  color: var(--green); }
.warning-bar.yellow { background: rgba(234,179,8,0.08);  border: 1px solid rgba(234,179,8,0.2);  color: var(--yellow); }
.warning-bar.orange { background: rgba(249,115,22,0.08); border: 1px solid rgba(249,115,22,0.2); color: var(--orange); }
.warning-bar.red    { background: rgba(248,113,113,0.08);border: 1px solid rgba(248,113,113,0.2);color: var(--red); }

/* ============================================================
   SOURCE FOOTER
   ============================================================ */
.source-footer {
  color: var(--text-dim);
  font-size: 0.72rem;
  text-align: center;
  padding: 8px 16px;
}
.source-footer a { color: var(--accent); }

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */

/* Tablet */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 200px minmax(0, 1fr);
    height: auto;
    min-height: calc(100vh - 52px);
  }
  .layout.map-collapsed {
    display: block;        /* Drop grid — let content flow naturally */
    height: auto;
    min-height: calc(100vh - 52px);
  }
  .layout.map-collapsed .map-pane { display: none; }
  .layout.map-collapsed .content-panel {
    overflow-y: visible;   /* No scroll container — page scrolls naturally */
    min-height: calc(100vh - 120px);
  }
  .map-search { left: 120px; }
}

/* Phone */
@media (max-width: 600px) {
  .header {
    padding: 8px 10px;
    gap: 6px;
  }
  .header-left { gap: 8px; }
  .logo { font-size: 0.95rem; }
  .loc-controls { width: 100%; }
  .loc-select {
    min-width: 0;
    flex: 1;
    font-size: 0.78rem;
    padding: 8px 8px;
  }
  .loc-input {
    width: 0;
    flex: 1;
    font-size: 0.78rem;
    padding: 8px 8px;
  }
  .btn-search {
    padding: 8px 12px;
    font-size: 0.78rem;
  }
  .header-right { width: 100%; justify-content: flex-end; }
  .nav-link {
    font-size: 0.72rem;
    padding: 8px 10px;
  }
  .theme-select { font-size: 0.68rem; padding: 6px 4px; }

  .layout {
    grid-template-rows: 160px minmax(0, 1fr);
  }
  .map-toggle {
    left: 10px;
    padding: 8px 10px;
    font-size: 0.68rem;
  }
  .map-search {
    left: 100px;
    right: 10px;
  }
  .map-search-input {
    padding: 8px 8px;
    font-size: 0.72rem;
  }
  .map-search-btn {
    padding: 8px 8px;
    font-size: 0.72rem;
  }
  .location-badge {
    font-size: 0.72rem;
    padding: 5px 8px;
  }

  .content-panel {
    padding: 10px;
    gap: 8px;
  }
  .card, .card-flat, .card-accent {
    padding: 10px 12px;
  }
  .card h3, .card-flat h3 {
    font-size: 0.85rem;
  }
  .page-title { font-size: 1.1rem; }
  .page-subtitle { font-size: 0.8rem; margin-bottom: 10px; }

  .warning-bar {
    font-size: 0.8rem;
    padding: 8px 12px;
  }

  .empty-state { padding: 20px; }
  .empty-state .icon { font-size: 2rem; }
  .empty-state p { font-size: 0.85rem; }
}

/* Small phone */
@media (max-width: 380px) {
  .header-left { flex-direction: column; align-items: flex-start; gap: 4px; }
  .loc-controls { gap: 4px; }
  .loc-select { font-size: 0.72rem; }
  .loc-input { font-size: 0.72rem; }
  .nav-link { font-size: 0.68rem; padding: 6px 8px; }
}

/* PWA Install Banner */
.pwa-install-banner {
  position: fixed;
  bottom: -80px;
  left: 0; right: 0;
  z-index: 9999;
  padding: 0 12px 12px;
  transition: bottom 0.3s ease;
}
.pwa-install-banner.visible { bottom: 0; }
.pwa-install-content {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  margin: 0 auto;
}
.pwa-install-icon { width: 40px; height: 40px; border-radius: 8px; }
.pwa-install-text { flex: 1; min-width: 0; }
.pwa-install-title { font-size: 0.85rem; font-weight: 700; color: var(--text); }
.pwa-install-desc { font-size: 0.72rem; color: var(--text-dim); }
.pwa-install-btn {
  background: var(--accent);
  color: #0f172a;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.pwa-install-btn:hover { opacity: 0.9; }
.pwa-install-dismiss {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
}
.pwa-install-dismiss:hover { color: var(--text); }
