/* ═══════════════════════════════════════════
   ODLT Fire Intelligence — Style
   Dark utilitarian + amber/red fire palette
   ═══════════════════════════════════════════ */

:root {
  --bg: #0f1117;
  --surface: #181b23;
  --surface2: #1e2230;
  --border: #2a2f3e;
  --text: #e2e4ea;
  --text-dim: #8b8fa4;
  --text-muted: #5c6178;
  --accent: #60a5fa;
  --fire-low: #22c55e;
  --fire-mod: #eab308;
  --fire-high: #f97316;
  --fire-vhigh: #ef4444;
  --fire-extreme: #dc2626;
  --lightning: #facc15;
  --precip: #38bdf8;
  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --sidebar-w: 340px;
  --sidebar-min: 280px;
  --sidebar-max: 50vw;
  --banner-h: 44px;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ═══════ THREAT BANNER ═══════ */
#threat-banner {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--banner-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  z-index: 200;
  border-bottom: 1px solid var(--border);
  transition: background .4s;
}
#threat-banner.threat-low    { background: linear-gradient(90deg, #14532d 0%, var(--bg) 40%); }
#threat-banner.threat-mod    { background: linear-gradient(90deg, #713f12 0%, var(--bg) 40%); }
#threat-banner.threat-high   { background: linear-gradient(90deg, #7c2d12 0%, var(--bg) 40%); }
#threat-banner.threat-vhigh  { background: linear-gradient(90deg, #7f1d1d 0%, var(--bg) 40%); }
#threat-banner.threat-extreme{ background: linear-gradient(90deg, #991b1b 0%, var(--bg) 40%); }

.banner-left { display: flex; align-items: baseline; gap: 8px; }
.org-name {
  font-size: 15px; font-weight: 700; letter-spacing: .03em;
  color: var(--accent);
}
.org-label { font-size: 12px; color: var(--text-dim); letter-spacing: .06em; text-transform: uppercase; }

.banner-center { text-align: center; }
.threat-label {
  display: block; font-size: 9px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-muted);
}
.threat-value {
  font-family: var(--mono); font-size: 14px; font-weight: 600;
  letter-spacing: .08em;
}

.banner-right { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }

/* ═══════ SIDEBAR ═══════ */
#sidebar {
  position: fixed;
  top: var(--banner-h); left: 0; bottom: 0;
  width: var(--sidebar-w);
  min-width: var(--sidebar-min);
  max-width: var(--sidebar-max);
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow-y: auto; overflow-x: hidden;
  z-index: 100;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#sidebar::-webkit-scrollbar { width: 5px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ═══════ RESIZE HANDLE ═══════ */
#resize-handle {
  position: fixed;
  top: var(--banner-h); bottom: 0;
  left: var(--sidebar-w);
  width: 6px;
  cursor: col-resize;
  z-index: 150;
  background: transparent;
  transition: background .15s;
}
#resize-handle::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 2px; height: 32px;
  border-radius: 1px;
  background: var(--border);
  transition: background .15s, height .15s;
}
#resize-handle:hover { background: rgba(96,165,250,.08); }
#resize-handle:hover::after { background: var(--accent); height: 48px; }
body.resizing #resize-handle { background: rgba(96,165,250,.12); }
body.resizing #resize-handle::after { background: var(--accent); height: 64px; }
body.resizing { cursor: col-resize !important; user-select: none !important; }
body.resizing * { cursor: col-resize !important; user-select: none !important; }

.panel {
  border-bottom: 1px solid var(--border);
}
.panel-head {
  padding: 10px 14px;
  font-size: 11px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-dim);
  display: flex; align-items: center; gap: 6px;
  background: var(--surface);
}
.panel-icon { font-size: 12px; }
.panel-body { padding: 10px 14px 14px; }

/* Property select */
#property-select {
  width: calc(100% - 28px); margin: 0 14px 10px;
  padding: 7px 10px; border-radius: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-family: var(--font); font-size: 13px;
  cursor: pointer; outline: none;
}
#property-select:focus { border-color: var(--accent); }
#property-select option { background: var(--surface); }

/* Metric grid */
.metric-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.metric {
  background: var(--surface); border-radius: 6px; padding: 8px 10px;
}
.metric.full-width { grid-column: 1 / -1; }
.metric-label {
  display: block; font-size: 10px; letter-spacing: .04em;
  color: var(--text-muted); margin-bottom: 2px;
}
.metric-value {
  font-family: var(--mono); font-size: 16px; font-weight: 500;
  color: var(--text);
}

/* FWI panel */
.fwi-main {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 10px;
}
.fwi-score {
  font-family: var(--mono); font-size: 36px; font-weight: 700;
  line-height: 1;
}
.fwi-rating {
  font-size: 12px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; padding: 3px 8px;
  border-radius: 4px;
}

.fwi-bar-container {
  height: 8px; border-radius: 4px; background: var(--surface);
  overflow: hidden; margin-bottom: 6px; position: relative;
}
.fwi-bar {
  height: 100%; border-radius: 4px; transition: width .6s ease, background .4s;
  width: 0%;
}
.fwi-bar-labels {
  display: flex; justify-content: space-between;
  font-size: 9px; color: var(--text-muted); margin-bottom: 10px;
}

.fwi-breakdown {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.fwi-sub {
  flex: 1 1 45%; display: flex; justify-content: space-between;
  background: var(--surface); border-radius: 4px; padding: 5px 8px;
  font-size: 11px;
}
.fwi-sub span:first-child { color: var(--text-dim); font-weight: 500; }
.fwi-sub span:last-child { font-family: var(--mono); font-weight: 500; }

/* Fuel status */
.fuel-status {
  margin-top: 8px; padding: 6px 10px; border-radius: 4px;
  font-size: 11px; font-weight: 500; text-align: center;
  background: var(--surface); border-left: 3px solid var(--fire-low);
}
.fuel-status.critical { border-left-color: var(--fire-vhigh); color: var(--fire-vhigh); }
.fuel-status.warning  { border-left-color: var(--fire-mod); color: var(--fire-mod); }
.fuel-status.ok       { border-left-color: var(--fire-low); color: var(--fire-low); }

/* Precip bar */
.precip-bar-container {
  height: 8px; border-radius: 4px; background: var(--surface);
  overflow: hidden; margin-top: 8px;
}
.precip-bar {
  height: 100%; border-radius: 4px; transition: width .8s ease;
  background: var(--precip); width: 0%;
}

/* Lightning status */
.ltg-status {
  margin-top: 8px; padding: 6px 10px; border-radius: 4px;
  font-size: 11px; text-align: center; background: var(--surface);
  color: var(--text-dim);
}
.ltg-status.active { border-left: 3px solid var(--lightning); color: var(--lightning); }

/* Burn note */
.burn-note {
  margin-top: 8px; font-size: 10px; color: var(--text-muted);
  line-height: 1.4;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 14px;
  font-size: 9px; color: var(--text-muted); line-height: 1.6;
  text-align: center; letter-spacing: .02em;
}

/* ═══════ MAP ═══════ */
#map {
  position: fixed;
  top: var(--banner-h); left: var(--sidebar-w); right: 0; bottom: 0;
}

/* ═══════ LEGEND ═══════ */
#legend {
  position: fixed;
  bottom: 16px; right: 16px;
  background: rgba(15,17,23,.88);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px;
  z-index: 100;
}
.legend-title {
  font-size: 10px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-dim);
  margin-bottom: 6px;
}
.legend-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text); margin-bottom: 4px;
}
.legend-swatch {
  width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0;
}
.legend-swatch.fire-proximity {
  background: repeating-linear-gradient(45deg, #ef4444, #ef4444 2px, transparent 2px, transparent 4px);
  border: 1px solid #ef4444;
}

/* ═══════ MAPBOX OVERRIDES ═══════ */
.mapboxgl-popup-content {
  background: var(--surface) !important;
  color: var(--text) !important;
  font-family: var(--font);
  font-size: 13px;
  padding: 10px 14px !important;
  border-radius: 8px !important;
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,.4) !important;
  max-width: 280px !important;
}
.mapboxgl-popup-tip { border-top-color: var(--surface) !important; }
.mapboxgl-popup-close-button { color: var(--text-dim) !important; font-size: 16px; }
.mapboxgl-ctrl-group { background: var(--surface) !important; border: 1px solid var(--border) !important; }
.mapboxgl-ctrl-group button { color: var(--text) !important; }
.mapboxgl-ctrl-group button + button { border-top: 1px solid var(--border) !important; }

/* Hover popup weather mini-grid */
.hover-wx {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 4px; margin-top: 6px;
  padding-top: 6px; border-top: 1px solid rgba(255,255,255,.08);
}
.hover-wx-item {
  text-align: center;
}
.hover-wx-label {
  display: block; font-size: 9px; color: #8b8fa4;
  letter-spacing: .03em; text-transform: uppercase;
}
.hover-wx-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; font-weight: 500;
}

/* ═══════ RESPONSIVE ═══════ */
@media (max-width: 768px) {
  :root { --sidebar-w: 100vw; --sidebar-min: 100vw; --sidebar-max: 100vw; }
  #sidebar { bottom: auto; max-height: 50vh; }
  #map { top: calc(var(--banner-h) + 50vh); left: 0; }
  #resize-handle { display: none; }
  #legend { bottom: 8px; right: 8px; }
}

/* ═══════ ANIMATION ═══════ */
@keyframes pulse-strike {
  0%   { transform: scale(1);   opacity: 1; }
  100% { transform: scale(2.5); opacity: 0; }
}
