@charset "UTF-8";

/* ============================================================
   DESIGN TOKENS — Bochum Design Language (Blueprint)
   ============================================================ */
:root {
  /* Bochum brand colors */
  --cyan: #0AB4FF;
  --blue: #0F2864;
  --orange: #F49100;
  --green: #76B729;
  --red: #E61937;
  --yellow: #EAB308;

  /* Surface & text */
  --bg: #F6F6F6;
  --card-bg: #FFFFFF;
  --surface: #FAFAFA;
  --text: #1A1A1A;
  --text-secondary: #4a5568;
  --text-muted: #94A3B8;
  --line: #E2E8F0;

  /* Shadows */
  --shadow-card: 0 2px 16px rgba(0, 0, 0, 0.08);
  --shadow-card-hover: 0 8px 32px rgba(0, 0, 0, 0.14);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.10);

  /* Radii */
  --radius-card: 10px;
  --radius-control: 8px;
  --radius-pill: 999px;

  /* Typography */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Migration aliases */
  --primary: var(--cyan);
  --primary-hover: #0099e0;
  --primary-light: rgba(0, 180, 255, 0.10);
  --border: var(--line);
  --border-light: #f1f5f9;
  --radius: var(--radius-card);
  --radius-sm: var(--radius-control);
  --radius-xs: 6px;
  --radius-full: var(--radius-pill);

  /* Status colors */
  --color-online: var(--green);
  --color-stale: var(--orange);
  --color-error: var(--red);
}

/* Dark mode */
[data-theme="dark"] {
  --bg: #0B1220;
  --card-bg: #111827;
  --surface: #1A2332;
  --text: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --line: rgba(148, 163, 184, 0.22);
  --border-light: rgba(148, 163, 184, 0.14);
}

/* ============================================================
   RESET / BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.3s, color 0.3s;
}
h1, h2, h3, h4 { font-family: var(--font-sans); font-weight: 700; line-height: 1.25; }
a { color: var(--primary); text-decoration: none; }

/* ============================================================
   APP SHELL
   ============================================================ */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Luft zwischen Inhalt und Footer. Der Abstand haengt am Inhalt und
   nicht am Footer, weil dessen margin-top: auto ihn bei kurzen Seiten
   nach unten druecken soll — ein fester margin-top dort wuerde das
   aushebeln. Ein padding-top im Footer wiederum waere cyan eingefaerbt.
   Neue Tab-Ansichten brauchen deshalb ebenfalls die Klasse .view. */
.view { padding-bottom: 32px; }

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: 70px;
  background: var(--cyan);
  border-bottom: 0;
  margin-bottom: 16px;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  width: 100vw;
  margin-left: calc(-50vw + 50%);
}
.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 16px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.header-left { display: flex; align-items: center; gap: 20px; }
.header-logo { height: 36px; width: auto; display: block; }
.header-left h1, .header-title { font-size: 1.3rem; font-weight: 700; color: #000; letter-spacing: -0.01em; }
.header-right { display: flex; align-items: center; gap: 12px; }
/* Der Header ist cyan mit dunkler Schrift wie der Titel daneben. Die
   Regel stand vorher auf Weiss und war nur durch Inline-Styles im
   erzeugten Markup ueberdeckt — ohne die waere es Weiss auf Cyan. */
.header-meta { font-size: 0.8rem; color: #1A1A1A; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.header-sensors strong { font-weight: 700; }
.header-refresh { color: rgba(26, 26, 26, 0.7); }
.header-loading { display: flex; align-items: center; gap: 6px; }

/* Theme toggle */
.theme-toggle {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--radius-control);
  background: rgba(255,255,255,0.15);
  color: #fff; cursor: pointer;
  transition: background 0.2s;
}
.theme-toggle:hover { background: rgba(255,255,255,0.25); }
.theme-icon { width: 20px; height: 20px; }

/* ============================================================
   FORECAST PANEL
   ============================================================ */
.forecast-panel {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-light);
  margin-bottom: 16px;
  overflow: hidden;
}
.forecast-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.forecast-title { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.forecast-model {
  font-size: 0.65rem; font-weight: 600; color: var(--primary);
  background: var(--primary-light); padding: 2px 8px; border-radius: var(--radius-pill);
  margin-left: 6px; vertical-align: middle;
}
.forecast-meta { font-size: 0.75rem; color: var(--text-muted); }
.forecast-body { padding: 16px; }
.forecast-loading { display: flex; align-items: center; justify-content: center; padding: 30px; }
.forecast-chart { position: relative; height: 180px; margin-bottom: 16px; }
.forecast-days { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.forecast-day {
  background: var(--surface);
  border-radius: var(--radius-control);
  padding: 12px;
  border: 1px solid var(--border-light);
}
.forecast-day-date { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.forecast-day-weather { font-size: 1.1rem; margin: 4px 0; }
.forecast-day-temp { font-size: 1.2rem; font-weight: 600; color: var(--text); }
.forecast-day-rain { font-size: 0.8rem; color: var(--primary); font-weight: 600; }
.forecast-day-wind { font-size: 0.75rem; color: var(--text-muted); }
.forecast-day--alert { border-left: 3px solid var(--yellow); }
.forecast-day--critical { border-left: 3px solid var(--red); }
.forecast-warning {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-control);
  font-size: 0.82rem;
}
.forecast-warning--yellow { background: rgba(234, 179, 8, 0.1); border-left: 3px solid var(--yellow); color: var(--text); }
.forecast-warning--red { background: rgba(230, 25, 55, 0.1); border-left: 3px solid var(--red); color: var(--text); }

@media (max-width: 768px) {
  .forecast-days { grid-template-columns: 1fr; }
}

/* ============================================================
   TABS
   ============================================================ */
.app-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  max-width: 520px;
  gap: 8px;
  margin-bottom: 16px;
  width: max-content;
}
.tab-button {
  height: 38px;
  padding: 0 18px;
  width: 100%;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.tab-button:hover { color: var(--text); }
.tab-button.active {
  background: var(--cyan);
  color: #fff;
}
[data-theme="dark"] .tab-button.active { color: #1A1A1A; }

@media (max-width: 768px) {
  .app-tabs { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Placeholder-Karte (Personen-Tab) */
.placeholder-card {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-light);
  padding: 60px 40px;
  text-align: center;
}
.placeholder-icon { font-size: 3rem; margin-bottom: 12px; }
.placeholder-card h2 { font-size: 1.2rem; margin-bottom: 10px; color: var(--text); }
.placeholder-card p { max-width: 560px; margin: 0 auto 8px; color: var(--text-secondary); font-size: 0.9rem; line-height: 1.6; }
.placeholder-note { color: var(--text-muted); font-size: 0.8rem; }

/* ============================================================
   MAIN GRID
   ============================================================ */
.main-grid {
  display: grid;
  /* Feste Breite fuer den Alarm-Feed statt 3fr 1fr: mit dem Bruchteil
     wuchs die Spalte auf breiten Schirmen unnoetig mit, obwohl der
     Inhalt schmal bleibt. Die Karte bekommt den Rest. */
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
}
.map-card, .feed-card {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-light);
  overflow: hidden;
}
.map-card { position: relative; }

/* Map controls */
.map-controls {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
  font-size: 0.78rem; font-weight: 500; color: var(--text-secondary);
  flex-wrap: wrap;
}
.map-controls-title { font-weight: 700; color: var(--text); }
.layer-toggle-label { display: flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; }
.layer-toggle-label input { cursor: pointer; }
.layer-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.layer-dot--rain { background: var(--cyan); }
.layer-dot--water { background: var(--blue); }
.layer-dot--weather { background: var(--green); }

/* The weather map's layer switcher sits on the map without changing the map height. */
.map-controls--layers {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 900;
  width: min(238px, calc(100% - 68px));
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 7px;
  padding: 11px 12px;
  border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  border-radius: var(--radius-control);
  background: color-mix(in srgb, var(--card-bg) 94%, transparent);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
}
.map-controls-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.map-controls-group + .map-controls-group {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}
.map-controls--layers .map-controls-title {
  margin-bottom: 1px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.map-controls--layers .layer-toggle-label,
.layer-legend-item { line-height: 1.25; }
.layer-legend-item--static {
  padding-left: 20px;
  color: var(--text-secondary);
}

/* Kartenhoehe wie bei Gewaesser und Mikromobilitaet: mitwachsend
   statt fest 520px, mit 420px Untergrenze. */
#map { height: min(64vh, 680px); min-height: 420px; width: 100%; }
.leaflet-container { font-family: var(--font-sans); }
.station-marker { position: relative; width: 36px; height: 36px; padding: 4px; }
.rain-class-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border: 1.5px solid #fff;
  border-radius: var(--radius-pill);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 12px;
  text-align: center;
}

/* Alert feed */
.feed-card { display: flex; flex-direction: column; height: auto; align-self: stretch; }
.feed-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  font-weight: 700; font-size: 0.9rem; color: var(--text);
  display: flex; align-items: center; justify-content: space-between;
}
.feed-count {
  font-size: 0.72rem; font-weight: 600; color: var(--text-muted);
  background: var(--surface); padding: 2px 10px; border-radius: var(--radius-pill);
}
.feed-body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }

/* Zeitraumfilter ueber dem Alarm-Feed. Segmentierte Schalter statt
   Dropdown: die fuenf Stufen sollen auf einen Blick sichtbar sein,
   inklusive der gerade aktiven. */
.feed-filter {
  display: flex; gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
}
.feed-filter-btn {
  flex: 1;
  padding: 4px 0;
  font-size: 0.72rem; font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-control);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.feed-filter-btn:hover { background: var(--surface); color: var(--text); }
.feed-filter-btn.is-active {
  background: var(--cyan); border-color: var(--cyan); color: #1A1A1A;
}
/* Hinweis am Fuss des Feeds, wenn der Filter etwas verbirgt — sonst
   sieht es aus, als gaebe es die aelteren Meldungen gar nicht. */
.feed-hidden-note {
  font-size: 0.72rem; color: var(--text-muted);
  text-align: center; padding: 6px 0 2px;
}

.alert-item {
  border-radius: var(--radius-control);
  padding: 10px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.alert-item:hover { box-shadow: var(--shadow-card); }
.alert-item--red { background: rgba(230, 25, 55, 0.08); border-left: 3px solid var(--red); }
.alert-item--yellow { background: rgba(234, 179, 8, 0.08); border-left: 3px solid var(--yellow); }
.alert-item--green { background: rgba(118, 183, 41, 0.08); border-left: 3px solid var(--green); }
.alert-item--gray { background: var(--surface); border-left: 3px solid var(--text-muted); }
.alert-item-title { font-weight: 600; color: var(--text); }
.alert-item-reason { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }
.alert-item-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }
.feed-empty { text-align: center; color: var(--green); font-weight: 500; padding: 40px 0; }

/* ============================================================
   DETAIL PANEL
   ============================================================ */
.detail-panel {
  margin-top: 16px;
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-light);
  overflow: hidden;
}
.detail-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.detail-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.detail-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.detail-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none; color: var(--text-muted);
  font-size: 1.5rem; cursor: pointer; border-radius: var(--radius-control);
}
.detail-close:hover { background: var(--surface); color: var(--text); }
.detail-body {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.chart-card {
  background: var(--surface);
  border-radius: var(--radius-control);
  padding: 14px;
  border: 1px solid var(--border-light);
}
.chart-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 10px;
}
.chart-card-heading { min-width: 0; flex: 1; }
.chart-card-title { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.chart-card-id { font-size: 0.7rem; color: var(--text-muted); }
.detail-period-pills { display: flex; width: max-content; max-width: 100%; gap: 3px; margin: 7px 0 0 auto; padding: 2px; overflow-x: auto; overscroll-behavior-x: contain; background: var(--card-bg); border: 1px solid var(--border-light); border-radius: var(--radius-pill); }
.detail-period-pill { flex: 0 0 auto; min-height: 24px; padding: 2px 8px; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--text-muted); font: inherit; font-size: 0.7rem; font-weight: 700; line-height: 1; white-space: nowrap; cursor: pointer; transition: background 0.12s, color 0.12s, box-shadow 0.12s; }
.detail-period-pill:hover { color: var(--text); background: var(--surface); }
.detail-period-pill:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.detail-period-pill.is-active { color: #1A1A1A; background: var(--cyan); box-shadow: 0 1px 2px rgba(15, 40, 100, 0.16); }
.chart-body { position: relative; height: 180px; }
/* Kombinierte heavyRAIN-Wochenkarte (P153): deutlich größer, volle Breite */
.chart-card--heavy-rain { grid-column: 1 / -1; }
.chart-card--heavy-rain .chart-body { height: 360px; min-height: 360px; }
.chart-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner--small { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Utility */
.hidden { display: none !important; }

/* ============================================================
   FOOTER
   ============================================================ */
/* Cyaner Footer mit dunkler Schrift wie auf den uebrigen Dashboards.
   Der Hintergrund hat hier gefehlt, obwohl die Dark-Mode-Regel weiter
   unten schon von dunklem Text auf dem Footer ausgeht. */
.app-footer {
  margin-top: auto;
  padding: 24px 0;
  background: var(--cyan);
  border-top: 0;
  flex-shrink: 0;
  width: 100vw;
  margin-left: calc(-50vw + 50%);
}
.footer-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.footer-main { font-size: 0.85rem; color: #1A1A1A; text-align: center; }
.footer-brand { font-weight: 700; }
.footer-data { display: block; font-size: 0.78rem; margin-top: 2px; color: rgba(26, 26, 26, 0.75); }
.footer-links { font-size: 0.78rem; margin-top: 4px; }
/* Ohne diese Regel greift global a { color: var(--primary) } — Cyan auf
   Cyan. Betrifft Impressum und den FROST-Link im Fliesstext. */
.footer-links a { color: #1A1A1A; text-decoration: underline; }
.footer-links a:hover { color: rgba(26, 26, 26, 0.7); }
.hint-banner {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.78rem; color: var(--text-secondary);
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-control);
  padding: 8px 14px; max-width: 680px; line-height: 1.4;
}


/* Dark-Mode Komponenten (wie Nahmobilität) */
[data-theme="dark"] .app-header,
[data-theme="dark"] .app-footer {
  color: #1A1A1A;
}

[data-theme="dark"] .theme-toggle {
  background: rgba(255, 255, 255, 0.15);
  color: #1A1A1A;
}
[data-theme="dark"] .theme-toggle:hover { background: rgba(255, 255, 255, 0.25); }

[data-theme="dark"] .map-card,
[data-theme="dark"] .feed-card,
[data-theme="dark"] .detail-panel,
[data-theme="dark"] .forecast-panel,
[data-theme="dark"] .chart-card,
[data-theme="dark"] .forecast-day {
  background: var(--card-bg);
}

[data-theme="dark"] .leaflet-tile {
  filter: brightness(0.6) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) brightness(0.7);
}

[data-theme="dark"] .leaflet-container {
  background: #0F172A;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .main-grid { grid-template-columns: 1fr; }
  .detail-body { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  #app { padding: 0 12px; }
  .header-left h1 { font-size: 1.1rem; }
  #map { height: 380px; }
  .feed-card { height: 400px; }
}
@media (max-width: 480px) {
  .chart-card-header { flex-wrap: wrap; gap: 8px; }
  .chart-card-heading { flex-basis: 100%; }
  .chart-card-id { flex: 0 0 auto; }
  .map-controls--layers {
    top: 8px;
    left: 8px;
    width: calc(100% - 60px);
    gap: 6px;
    padding: 9px 10px;
    font-size: 0.72rem;
  }
}

/* SVG-Icons in Alert-Titeln */
.alert-item-title svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 2px; }
.alert-item-title span { display: inline-flex; }

/* Der Markenlink im Footer darf die Footer-Farbe nicht verlieren:
   global gilt `a { color: var(--primary) }`. Hover ueber Deckkraft,
   damit es im Dark-Mode mitgeht. */
.footer-main a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.footer-main a:hover { color: rgba(26, 26, 26, 0.7); }
