/* ============================================================================
   PeerWeather – Design-Grundlage
   Dark Mode: Tiefschwarz bis Dunkelblau, dezente blaue Akzente.
   ============================================================================ */

:root {
  --bg-deep: #04070e;
  --bg-base: #070d18;
  --bg-panel: #0c1424;
  --surface: #111c2f;
  --surface-raised: #16243a;
  --surface-hover: #1b2c46;
  --line: #1e2f49;
  --line-soft: #172337;

  --text: #e9eff9;
  --text-soft: #a8b8d0;
  --text-muted: #74879f;

  --accent: #4ea1ff;
  --accent-strong: #2f81f7;
  --accent-dim: #1d4d80;
  --accent-glow: rgba(78, 161, 255, 0.16);

  --good: #3ecf8e;
  --ok: #7bb7f5;
  --warn: #f0b429;
  --bad: #ff6f6f;

  --radius-lg: 18px;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.85), 0 2px 8px -4px rgba(0, 0, 0, 0.6);
  --shadow-soft: 0 10px 26px -20px rgba(0, 0, 0, 0.8);

  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
  --space-6: 32px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: "SF Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur: 260ms;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 620px at 82% -12%, rgba(47, 129, 247, 0.16), transparent 62%),
    radial-gradient(900px 500px at 8% 0%, rgba(30, 80, 140, 0.16), transparent 60%),
    linear-gradient(180deg, var(--bg-base), var(--bg-deep) 70%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #223450; border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: #2d4667; }

.app-shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ------------------------------- Topbar ---------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding: 14px clamp(14px, 3vw, 34px);
  background: rgba(7, 13, 24, 0.82);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line-soft);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 190px; }
.brand-logo svg { display: block; filter: drop-shadow(0 4px 12px rgba(78, 161, 255, 0.35)); }
.brand-sun { fill: #ffd27a; opacity: 0.9; }
.brand-cloud { fill: #2f81f7; opacity: 0.85; }
.brand-rain { stroke: #7fd0ff; stroke-width: 1.6; stroke-linecap: round; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 1.06rem; letter-spacing: 0.04em; }
.brand-text small { color: var(--text-muted); font-size: 0.76rem; letter-spacing: 0.06em; text-transform: uppercase; }

.main-nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-pill);
  background: rgba(12, 20, 36, 0.75);
  overflow-x: auto;
  scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }

.nav-btn {
  appearance: none;
  border: 0;
  border-radius: var(--radius-pill);
  padding: 9px 16px;
  color: var(--text-soft);
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.nav-btn:hover { color: var(--text); background: rgba(78, 161, 255, 0.08); }
.nav-btn.is-active {
  color: #eaf4ff;
  background: linear-gradient(180deg, rgba(78, 161, 255, 0.26), rgba(47, 129, 247, 0.16));
  box-shadow: inset 0 0 0 1px rgba(78, 161, 255, 0.35);
}

.topbar-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }

/* ------------------------------ Suche ------------------------------------ */

.place-search { position: relative; display: flex; gap: 8px; align-items: center; }

.search-input {
  min-width: 230px;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: rgba(10, 18, 32, 0.9);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 320px;
  overflow-y: auto;
  z-index: 50;
  animation: rise var(--dur) var(--ease);
}
.search-results li { padding: 0; }
.search-results button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
}
.search-results button:hover { background: var(--surface-hover); }
.search-results .result-meta { color: var(--text-muted); font-size: 0.78rem; white-space: nowrap; }

/* ---------------------------- Statusleiste ------------------------------- */

.statusline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px clamp(14px, 3vw, 34px);
  font-size: 0.8rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(9, 15, 27, 0.6);
}
.place-caption { color: var(--text-soft); font-weight: 600; }
.status-sep { color: var(--line); }
.status-item { display: inline-flex; align-items: center; gap: 6px; }
.status-item::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 10px rgba(62, 207, 142, 0.7);
}
.status-item--error { color: var(--bad); }
.status-item--error::before { background: var(--bad); box-shadow: 0 0 10px rgba(255, 111, 111, 0.6); }

/* ------------------------------ Views ------------------------------------ */

.view-stack { flex: 1; padding: clamp(14px, 2.4vw, 28px) clamp(14px, 3vw, 34px) 40px; }

.view[hidden] { display: none; }
.view { animation: fade-up 320ms var(--ease); }

.view-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.view-head h2 { margin: 0; font-size: clamp(1.3rem, 2.4vw, 1.7rem); letter-spacing: -0.01em; }
.view-sub { margin: 6px 0 0; color: var(--text-muted); font-size: 0.88rem; max-width: 70ch; }
.view-head-actions { display: flex; gap: 8px; align-items: center; }

/* ------------------------------ Karten ----------------------------------- */

.card {
  position: relative;
  background: linear-gradient(180deg, var(--surface-raised), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
  overflow: hidden;
}
.card:hover { border-color: #27405f; }
.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 var(--space-3);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.card-title .hint { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 0.78rem; }

.grid { display: grid; gap: var(--space-3); }
.grid--overview { grid-template-columns: repeat(12, 1fr); }
.grid--overview > * { grid-column: span 4; }
.grid--overview .card-hero { grid-column: span 5; }
.grid--overview .card--wide { grid-column: span 12; }
.grid--overview #metrics-card { grid-column: span 7; }
.grid--overview #sun-card { grid-column: span 5; }
.grid--overview #warnings-card { grid-column: span 7; }

.grid--bike { grid-template-columns: repeat(12, 1fr); }
.grid--bike > * { grid-column: span 6; }
.grid--bike .card--wide { grid-column: span 12; }

/* ------------------------- Buttons / Controls ---------------------------- */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: 10px 18px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 550;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform 120ms var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  color: #04101f;
  background: linear-gradient(180deg, #6fb3ff, var(--accent-strong));
  box-shadow: 0 10px 26px -14px rgba(78, 161, 255, 0.85);
}
.btn-primary:hover { background: linear-gradient(180deg, #85c0ff, #3f8ffb); }
.btn-ghost {
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--line);
}
.btn-ghost:hover { color: var(--text); border-color: #2c4568; background: rgba(78, 161, 255, 0.08); }
.btn-sm { padding: 7px 12px; font-size: 0.8rem; }
.btn-icon { padding: 9px 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.control-group {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgba(8, 14, 26, 0.8);
}
.seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8rem;
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active {
  color: #eaf4ff;
  background: linear-gradient(180deg, rgba(78, 161, 255, 0.24), rgba(47, 129, 247, 0.12));
}
.segmented { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: var(--space-3); }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--text-soft); cursor: pointer; }
.switch input { accent-color: var(--accent); width: 16px; height: 16px; }

.select, .field input[type="search"], .field input[type="number"], .field input[type="time"], .field input[type="date"], .field input[type="file"] {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(8, 14, 26, 0.9);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  padding: 9px 12px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.select:focus, .field input:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 4px var(--accent-glow);
}
.select--sm { padding: 7px 10px; font-size: 0.8rem; }
.select option { background: #0c1424; color: var(--text); }

.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 180px; }
.field > span { font-size: 0.76rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.field--sm { min-width: 150px; }
.field-row { display: flex; gap: var(--space-3); align-items: flex-end; flex-wrap: wrap; margin-bottom: var(--space-3); }
.field-row--wrap { align-items: flex-end; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 0.86rem; color: var(--text-soft); padding-bottom: 8px; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-soft);
  font-size: 0.76rem;
  letter-spacing: 0.03em;
}
.chip-live { border-color: rgba(62, 207, 142, 0.35); color: #9ff0c8; }
.chip-live::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  animation: pulse 2.4s var(--ease) infinite;
}

.form-note { font-size: 0.78rem; color: var(--text-muted); }
.form-error {
  margin: var(--space-3) 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 111, 111, 0.35);
  background: rgba(255, 111, 111, 0.08);
  color: #ffc9c9;
  font-size: 0.85rem;
}
.bike-actions { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-2); }

/* ----------------------- Ladezustände / Fehler --------------------------- */

.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04));
  background-size: 300% 100%;
  animation: shimmer 1.5s linear infinite;
}
.skeleton--hero { height: 220px; }
.skeleton--lines { height: 180px; }
.skeleton--strip { height: 150px; }
.skeleton--list { height: 240px; }

.state-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: var(--space-3);
  border-radius: var(--radius);
  border: 1px dashed var(--line);
  color: var(--text-muted);
  font-size: 0.86rem;
}
.state-box strong { color: var(--text-soft); font-weight: 600; }
.state-box--error { border-color: rgba(255, 111, 111, 0.4); color: #ffc9c9; }

/* Hinweis, wenn die HTML-Datei direkt geöffnet wurde statt über den Server. */
.file-notice {
  margin: 0 0 var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--accent-dim);
  background: linear-gradient(180deg, var(--surface-raised), var(--bg-panel));
  box-shadow: var(--shadow);
}
.file-notice h2 { font-size: 1.15rem; margin: 0 0 10px; color: var(--text); }
.file-notice p { margin: 0 0 8px; color: var(--text-soft); font-size: 0.92rem; line-height: 1.55; }
.file-notice p:last-child { margin-bottom: 0; }

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(78, 161, 255, 0.25);
  border-top-color: var(--accent);
  animation: spin 800ms linear infinite;
}

/* ------------------------------- Footer ---------------------------------- */

.footer {
  border-top: 1px solid var(--line-soft);
  padding: 16px clamp(14px, 3vw, 34px) 26px;
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 0.78rem;
  background: rgba(6, 11, 20, 0.7);
}
.footer-sources { display: flex; flex-direction: column; gap: 6px; max-width: 90ch; }
.footer-note { color: #6f849f; }
.footer-legal { max-width: 40ch; text-align: right; }

/* -------------------------------- Toasts --------------------------------- */

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 900;
  max-width: min(420px, 92vw);
}
.toast {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(20, 32, 52, 0.96);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  color: var(--text-soft);
  animation: rise 260ms var(--ease);
}
.toast--error { border-color: rgba(255, 111, 111, 0.45); color: #ffd2d2; }
.toast--info { border-color: rgba(78, 161, 255, 0.4); }
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity 260ms var(--ease), transform 260ms var(--ease); }

/* --------------------------- Leaflet-Feinschliff ------------------------- */

.leaflet-container {
  background: #060b14;
  font-family: var(--font);
  border-radius: var(--radius);
}
.leaflet-control-attribution {
  background: rgba(6, 11, 20, 0.82) !important;
  color: #8ea3bd !important;
  font-size: 0.68rem !important;
  border-radius: 8px 0 0 0;
}
.leaflet-control-attribution a { color: #9fc6ff !important; }
.leaflet-bar a, .leaflet-control-zoom a {
  background: rgba(15, 26, 44, 0.95) !important;
  color: #dfe9f6 !important;
  border-color: var(--line) !important;
}
.leaflet-bar a:hover { background: rgba(28, 45, 72, 0.95) !important; }
.leaflet-control-scale-line {
  background: rgba(6, 11, 20, 0.8) !important;
  color: #cbd8e8 !important;
  border-color: #3b5f88 !important;
}

/* --------------------------- Keyframes / Motion -------------------------- */

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes shimmer {
  from { background-position: 150% 0; }
  to { background-position: -150% 0; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.82); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ----------------------------- Responsive -------------------------------- */

@media (max-width: 1180px) {
  .grid--overview .card-hero { grid-column: span 6; }
  .grid--overview #metrics-card { grid-column: span 6; }
  .grid--overview #sun-card, .grid--overview #warnings-card { grid-column: span 12; }
}

@media (max-width: 900px) {
  .topbar { gap: var(--space-3); }
  .main-nav { order: 3; width: 100%; }
  .topbar-tools { flex: 1; justify-content: flex-end; }
  .grid--overview > *, .grid--overview .card-hero, .grid--overview #metrics-card { grid-column: span 12; }
  .grid--bike > *, .grid--bike .card--wide { grid-column: span 12; }
  .search-input { min-width: 180px; }
  .footer-legal { text-align: left; }
}

@media (max-width: 560px) {
  .brand-text small { display: none; }
  .topbar-tools { width: 100%; }
  .place-search { flex: 1; }
  .search-input { width: 100%; min-width: 0; }
  .view-sub { font-size: 0.82rem; }
}
