/* WeatherApp frontend styles */
:root {
  --bg: #0b0f14;
  --panel: #101825;
  --panel2: #0f1722;
  --text: #e8eef6;
  --muted: #9fb0c2;
  --border: rgba(255,255,255,0.08);
  --btn: #1a2a40;
  --btnHover: #223654;
  --sidebar-width: 420px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }

#app { display: flex; height: 100vh; }

#sidebar {
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  overflow: auto;
  padding: 14px;
  width: var(--sidebar-width);
  resize: horizontal;
  min-width: 320px;
  max-width: 600px;
}

.brand { padding: 8px 10px 14px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.brand-title { font-size: 20px; font-weight: 700; }
.brand-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 12px;
  background: rgba(255,255,255,0.02);
}

.panel-title {
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.panel-toggle {
  background: rgba(255,255,255,0.06);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
}
.panel-toggle:hover { background: rgba(255,255,255,0.12); }
.panel.is-collapsed .panel-body { display: none; }

.subpanel {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.subpanel-title { font-weight: 700; font-size: 12px; margin-bottom: 6px; color: var(--text); }

.row { display: flex; gap: 8px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 12px; }
code { color: #d3e1ff; }
input[type="text"], input[type="number"], select {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
}

.btn {
  background: var(--btn);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 12px;
}
.btn:hover { background: var(--btnHover); }
.btn.btn-small { padding: 5px 8px; font-size: 11px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(90,140,255,0.2);
  border: 1px solid rgba(90,140,255,0.4);
  font-size: 11px;
  color: #cfe0ff;
}
.badge-muted {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
  color: var(--muted);
}
.badge--grid { background: rgba(90,140,255,0.2); border-color: rgba(90,140,255,0.4); color: #cfe0ff; }
.badge--station { background: rgba(90,200,140,0.2); border-color: rgba(90,200,140,0.45); color: #d6f5e7; }
.badge--pin { background: rgba(255,200,90,0.2); border-color: rgba(255,200,90,0.45); color: #ffe8b6; }
.badge--tracked { background: rgba(120,200,210,0.2); border-color: rgba(120,200,210,0.45); color: #d4f7ff; }

.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; }
.check input { transform: scale(1.1); }
.check.subcheck { margin-left: 20px; font-size: 12px; }

.pre {
  margin: 8px 0 0;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.3);
  white-space: pre-wrap;
  font-size: 11px;
  max-height: 180px;
  overflow: auto;
}

.tableWrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  max-height: 220px;
  background: rgba(0,0,0,0.25);
}
.tableWrap.is-collapsed {
  max-height: 0;
  overflow: hidden;
  border-color: transparent;
  background: transparent;
}
.tableWrap.is-collapsed table {
  visibility: hidden;
}

.hourly-chart {
  position: relative;
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px;
  align-items: stretch;
  height: 132px;
  margin: 6px 0 10px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0,0,0,0.2);
}
.hourly-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
}
.hourly-bars {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 4px;
  align-items: end;
  width: 100%;
}
.hourly-bar {
  width: 100%;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, rgba(90,160,255,0.95), rgba(90,160,255,0.35));
  position: relative;
}
.hourly-bar.now { outline: 2px solid rgba(255,200,75,0.8); }
.hourly-bar span {
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--muted);
}

.poi-list { display: flex; flex-direction: column; gap: 6px; }
.poi-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.poi-item.is-selected { outline: 1px solid rgba(255,200,90,0.6); border-radius: 8px; padding: 4px 6px; background: rgba(255,200,90,0.08); }
.poi-item .poi-meta { font-size: 12px; }
.poi-actions { display: flex; gap: 6px; }

table { border-collapse: collapse; width: 100%; font-size: 11px; }
thead th {
  position: sticky;
  top: 0;
  background: rgba(15, 23, 34, 0.95);
  color: var(--muted);
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 7px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.weather-history-table th,
.weather-history-table td {
  padding: 6px 6px;
  font-size: 10.5px;
}
.now-row { color: #ffd074; font-weight: 700; }

.kv {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 6px 10px;
  font-size: 12px;
  align-items: center;
}
.kv .key { color: var(--muted); font-size: 11px; }

.ml-weather-wrap { max-height: none; }
.ml-weather-table thead th { font-size: 11px; vertical-align: bottom; }
.ml-weather-table tbody th {
  width: 90px;
  color: var(--muted);
  font-weight: 600;
}
.ml-weather-table tbody td { font-weight: 600; }
.ml-weather-col-title { font-size: 11px; font-weight: 600; color: var(--text); }
.ml-weather-col-date { font-size: 11px; color: var(--muted); margin-top: 2px; }

.api-health { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.api-health-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; }
.api-health-name { font-weight: 600; font-size: 12px; }
.api-health-meta { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.badge--status { text-transform: uppercase; font-size: 10px; letter-spacing: 0.2px; }
.badge--ok { background: rgba(90,200,140,0.2); border-color: rgba(90,200,140,0.45); color: #d6f5e7; }
.badge--degraded { background: rgba(255,200,90,0.2); border-color: rgba(255,200,90,0.45); color: #ffe8b6; }
.badge--down { background: rgba(255,90,90,0.2); border-color: rgba(255,90,90,0.45); color: #ffd2d2; }
.badge--no-data { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); color: var(--muted); }
.badge--unknown { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.25); color: var(--muted); }

.selected-header { align-items: center; }
.selected-note { margin: 2px 0 6px; font-size: 11px; }
.selected-note:empty { display: none; }
.hourly-actions { justify-content: space-between; }
.hourly-actions .muted { flex: 1; }

.history-chart-label { margin-top: 6px; font-size: 11px; }
.history-chart {
  height: 140px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0,0,0,0.2);
  padding: 6px;
  margin: 6px 0 10px;
  position: relative;
}
.history-chart canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.history-chart .empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: 11px;
}

.chart-crosshair-x,
.chart-crosshair-y {
  position: absolute;
  pointer-events: none;
  background: rgba(255,255,255,0.15);
  display: none;
}
.chart-crosshair-x { height: 1px; width: 100%; left: 0; }
.chart-crosshair-y { width: 1px; height: 100%; top: 0; }
.chart-hover .chart-crosshair-x,
.chart-hover .chart-crosshair-y { display: block; }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(6, 10, 18, 0.92);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
  display: none;
  z-index: 5;
}
.chart-hover .chart-tooltip { display: block; }

.ml-forecast-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 11px;
  color: var(--muted);
  margin: 4px 0 6px;
}
.ml-forecast-legend .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ml-forecast-legend .legend-line {
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: rgba(255,255,255,0.6);
}
.ml-forecast-legend .legend-line.min { background: rgba(120,180,255,0.9); }
.ml-forecast-legend .legend-line.max { background: rgba(255,90,90,0.9); }
.ml-forecast-legend .legend-line.mean { background: rgba(0,0,0,0.9); }
.ml-forecast-legend .legend-line.nws {
  background: rgba(160,200,255,0.75);
  background-image: linear-gradient(90deg, rgba(160,200,255,0.75) 0 50%, transparent 50% 100%);
  background-size: 6px 2px;
}

.pin-marker {
  width: 12px;
  height: 12px;
  background: #f5c84b;
  transform: rotate(45deg);
  border: 1px solid rgba(0,0,0,0.45);
  border-radius: 2px;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.15);
}

.legend-panel .legend-block { margin-top: 10px; }
.legend-panel .legend-block:first-of-type { margin-top: 0; }
.legend-title { font-weight: 700; font-size: 12px; margin-bottom: 6px; color: var(--text); }
.legend-note { margin-top: 6px; }
.legend-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }

.legend-swatch {
  width: 18px;
  height: 12px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.35);
  display: inline-block;
}
.legend-swatch.temp-cold { background: rgba(80,160,255,0.85); }
.legend-swatch.temp-cool { background: rgba(100,210,220,0.85); }
.legend-swatch.temp-mild { background: rgba(255,200,90,0.85); }
.legend-swatch.temp-hot { background: rgba(255,120,90,0.85); }

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.45);
  display: inline-block;
}
.legend-dot.gridpoint { background: rgba(130,180,255,0.85); }
.legend-dot.station { background: rgba(120,210,220,0.85); }
.legend-dot.tracked { background: rgba(240,210,90,0.9); }

.legend-diamond {
  width: 12px;
  height: 12px;
  transform: rotate(45deg);
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.45);
  display: inline-block;
}
.legend-diamond.tracked { background: rgba(240,210,90,0.9); }
.legend-diamond.pinned { background: #f5c84b; }

.legend-square {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.45);
  display: inline-block;
  background: rgba(130,180,255,0.85);
}

.legend-pin {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #f5c84b;
  border: 1px solid rgba(0,0,0,0.45);
  display: inline-block;
  position: relative;
}
.legend-pin::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 2px;
  height: 6px;
  background: rgba(0,0,0,0.45);
  transform: translateX(-50%);
}

.legend-area {
  width: 18px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}
.legend-area.alert {
  background: rgba(255,90,90,0.28);
  border: 1px solid rgba(255,90,90,0.8);
}

.legend-bar {
  width: 80px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.35);
  display: inline-block;
}
.legend-bar.temp {
  background: linear-gradient(90deg, rgba(80,160,255,0.85), rgba(255,200,90,0.85), rgba(255,120,90,0.9));
}
.legend-bar.precip {
  background: linear-gradient(90deg, rgba(90,160,255,0.2), rgba(90,160,255,0.8));
}

#mapWrap { position: relative; }
#mapWrap { flex: 1; }
#map { width: 100%; height: 100%; }

.maplibregl-popup-content {
  color: #0b0f14;
  font-size: 12px;
}

.hud {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: rgba(0,0,0,0.45);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12px;
  pointer-events: none;
}

.footer { margin-top: 8px; padding: 10px; }
