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

:root {
  --bg: #0d1117;
  --panel-bg: #161b22;
  --border: #30363d;
  --text: #c9d1d9;
  --muted: #8b949e;
  --accent: #58a6ff;
  --bus: #f78166;
  --train: #4a90e2;
  --ferry: #26c6da;
  --flight: #e6edf3;
  --vessel: #a78bfa;
  --alert: #d29922;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 14px; }

#app { display: flex; flex-direction: column; height: 100vh; }

/* Top bar */
#topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 14px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 1000;
}

#sidebar-toggle {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
}
#sidebar-toggle:hover { color: var(--text); background: var(--border); }

#wordmark {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--accent);
}

#status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

#status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.3s;
}
#status-dot.live { background: #3fb950; }
#status-dot.error { background: #f85149; }

/* Main area */
#main { display: flex; flex: 1; overflow: hidden; }

/* Sidebar */
#sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.2s ease, padding 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 0;
}

#sidebar.collapsed { width: 0; }

.panel-section {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.panel-section h2 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  white-space: nowrap;
}

/* Layer toggles */
#layer-controls { display: flex; flex-direction: column; gap: 2px; }

.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  border-radius: 5px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.layer-row:hover { background: rgba(255,255,255,0.04); }

.layer-row input[type=checkbox] { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }

.type-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.layer-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.9;
}

.layer-name { flex: 1; font-size: 13px; }
.layer-count { font-size: 12px; color: var(--muted); min-width: 20px; text-align: right; }

/* Alerts */
#alert-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--alert);
  margin-left: 4px;
}

#alerts-list { display: flex; flex-direction: column; gap: 8px; }

.alert-card {
  background: rgba(210, 153, 34, 0.08);
  border-left: 3px solid var(--alert);
  padding: 8px 10px;
  border-radius: 0 4px 4px 0;
  font-size: 12px;
  line-height: 1.5;
}
.alert-card .alert-header { font-weight: 600; margin-bottom: 3px; color: var(--text); }
.alert-card .alert-body   { color: var(--muted); }
.alert-card .alert-routes { margin-top: 4px; color: var(--accent); font-size: 11px; }

/* Zoom presets */
#zoom-presets { display: flex; gap: 5px; }

.zoom-btn {
  flex: 1;
  padding: 5px 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.zoom-btn:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.zoom-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(88,166,255,0.1); }

.muted { color: var(--muted); font-size: 12px; }

/* Map */
#map { flex: 1; z-index: 1; }

/* Leaflet overrides */
.leaflet-container { background: #0d1117; }

.leaflet-popup-content-wrapper {
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
}
.leaflet-popup-tip-container { display: none; }
.leaflet-popup-content { margin: 10px 12px; font-size: 13px; min-width: 150px; }

.leaflet-control-zoom a {
  background: var(--panel-bg) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover { background: var(--border) !important; }

.leaflet-control-attribution {
  background: rgba(13,17,23,0.7) !important;
  color: var(--muted) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--muted) !important; }

/* Vehicle markers are rendered with inline styles in app.js */

/* Popup content helpers */
.pop-title  { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.pop-row    { display: flex; justify-content: space-between; gap: 12px; margin-top: 3px; }
.pop-label  { color: var(--muted); font-size: 11px; }
.pop-value  { font-size: 12px; font-weight: 500; }
.pop-ground { color: var(--bus); font-size: 11px; margin-top: 4px; }

.hidden { display: none !important; }

/* Weather radar timeline */
#radar-timeline {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 8px 22px;
}

.tl-btn {
  background: var(--border);
  border: none;
  color: var(--text);
  width: 26px;
  height: 22px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: inherit;
}
.tl-btn:hover { background: rgba(255,255,255,0.1); }

#radar-time {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Approaching bus banner */
#approach-banner {
  position: fixed;
  top: 56px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 3000;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bus);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  white-space: nowrap;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

#approach-banner.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-14px);
}
