@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bs-font-sans-serif: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-heading: 'Space Grotesk', var(--bs-font-sans-serif);
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --bs-body-bg: #f7f8fa;
  --bs-body-color: #1c1f27;
  --bs-secondary-color: #6b7280;
  --bs-border-color: #e3e6ec;
  --bs-border-radius: 0.6rem;
  --bs-border-radius-sm: 0.45rem;
  --bs-border-radius-lg: 0.85rem;

  --color-indigo: #2b3a67;
  --color-indigo-hover: #24315689;
  --color-amber: #e8a93b;

  --bs-primary: #2b3a67;
  --bs-primary-rgb: 43, 58, 103;
  --bs-link-color: #2b3a67;
  --bs-link-color-rgb: 43, 58, 103;
  --bs-link-hover-color: #1f2a4d;

  --status-frei: #2fa36b;
  --status-frei-bg: #e9f7f0;
  --status-fast-voll: #e8a93b;
  --status-fast-voll-bg: #fcf1de;
  --status-voll: #d14343;
  --status-voll-bg: #fbe9e9;
  --status-gesperrt: #9aa1ac;
  --status-gesperrt-bg: #eef0f2;

  --betrieb-geoeffnet: #2b3a67;
  --betrieb-geoeffnet-bg: #e8eaf1;
  --betrieb-geschlossen: #9aa1ac;
  --betrieb-geschlossen-bg: #eef0f2;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow-md: 0 6px 16px rgba(15, 23, 42, .08);

  --sidebar-width: 52px;
}

body {
  letter-spacing: -0.005em;
}

h1, h2, h3, h4, h5, .navbar-brand, .app-heading {
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.font-mono, .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* --- Sidebar (Desktop) --- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: var(--sidebar-width);
  flex: none;
  background: var(--color-indigo);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  padding: .9rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.app-sidebar .sidebar-logo {
  color: #fff;
  font-size: 1.3rem;
  margin-bottom: .75rem;
  text-decoration: none;
}

.app-sidebar a.sidebar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--bs-border-radius-sm);
  color: rgba(255, 255, 255, .65);
  text-decoration: none;
  font-size: 1.1rem;
  transition: background-color .12s ease, color .12s ease;
}

.app-sidebar a.sidebar-icon:hover {
  background: rgba(255, 255, 255, .12);
  color: #fff;
}

.app-sidebar a.sidebar-icon.active {
  background: rgba(255, 255, 255, .18);
  color: #fff;
}

.app-sidebar a.sidebar-icon.disabled {
  opacity: .35;
  pointer-events: none;
}

.app-sidebar .sidebar-spacer {
  flex: 1;
}

.app-content {
  flex: 1;
  min-width: 0;
}

@media (min-width: 768px) {
  .app-sidebar { display: flex; }
  .app-topbar-mobile { display: none !important; }
}

/* --- Top bar (Mobile fallback + inner page headers) --- */

.app-navbar {
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(8px);
  padding-top: .8rem;
  padding-bottom: .8rem;
  border-bottom: 1px solid var(--bs-border-color) !important;
}

/* --- Cards / Panels --- */

.card {
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius-lg);
  box-shadow: var(--shadow-sm);
}

/* --- Buttons --- */

.btn {
  border-radius: var(--bs-border-radius-sm);
  font-weight: 500;
  transition: filter .12s ease, background-color .12s ease, border-color .12s ease;
}

.btn-primary {
  border: none;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover, .btn-primary:focus {
  filter: brightness(1.12);
}

.btn-outline-secondary {
  border-color: var(--bs-border-color);
  color: var(--bs-body-color);
}

.btn-outline-secondary:hover {
  background-color: #f1f2f5;
  border-color: var(--bs-border-color);
  color: var(--bs-body-color);
}

/* --- Form controls --- */

.form-control, .form-select {
  border-color: var(--bs-border-color);
  border-radius: var(--bs-border-radius-sm);
}

.form-control:focus, .form-select:focus {
  border-color: var(--color-indigo);
  box-shadow: 0 0 0 0.2rem rgba(43, 58, 103, .14);
}

/* --- Dot-Badges (Typ, Status, Betrieb) --- */

.dot-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .28rem .7rem;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 600;
  white-space: nowrap;
}

.dot-badge .dot {
  display: inline-block;
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  flex: none;
}

.chip, .dot-badge.chip {
  font-weight: 500;
  background: #eef0f4;
  color: #4b5563;
}

.status-pill.frei, .dot-badge.frei       { background: var(--status-frei-bg);      color: var(--status-frei); }
.status-pill.fast_voll, .dot-badge.fast_voll  { background: var(--status-fast-voll-bg); color: var(--status-fast-voll); }
.status-pill.voll, .dot-badge.voll       { background: var(--status-voll-bg);      color: var(--status-voll); }
.status-pill.gesperrt, .dot-badge.gesperrt   { background: var(--status-gesperrt-bg);  color: var(--status-gesperrt); }

.dot-badge.geoeffnet   { background: var(--betrieb-geoeffnet-bg);   color: var(--betrieb-geoeffnet); }
.dot-badge.geschlossen { background: var(--betrieb-geschlossen-bg); color: var(--betrieb-geschlossen); }

.status-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .28rem .7rem; border-radius: 999px; font-size: .76rem; font-weight: 600; white-space: nowrap; }

.status-dot, .dot {
  display: inline-block;
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  flex: none;
}

.status-dot.frei, .dot.frei { background: var(--status-frei); }
.status-dot.fast_voll, .dot.fast_voll { background: var(--status-fast-voll); }
.status-dot.voll, .dot.voll { background: var(--status-voll); }
.status-dot.gesperrt, .dot.gesperrt { background: var(--status-gesperrt); }
.dot.geoeffnet { background: var(--betrieb-geoeffnet); }
.dot.geschlossen { background: var(--betrieb-geschlossen); }

/* --- Map --- */

#map {
  width: 100%;
  height: 60vh;
  min-height: 320px;
  border-radius: var(--bs-border-radius-lg);
  border: 1px solid var(--bs-border-color);
  box-shadow: var(--shadow-sm);
}

.parkflaeche-card { height: 100%; }
.parkflaeche-card.is-geschlossen { opacity: .5; }

.marker-geschlossen { opacity: .45; filter: grayscale(60%); }

.progress {
  height: .4rem;
  border-radius: 999px;
  background-color: #eef0f4;
}

.progress-bar {
  background-color: var(--color-indigo);
}

/* --- Statuskacheln --- */

.stat-tile {
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius-lg);
  background: #fff;
  padding: .9rem 1rem;
  box-shadow: var(--shadow-sm);
}

.stat-tile .stat-value {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1;
}

.stat-tile .stat-label {
  font-size: .76rem;
  color: var(--bs-secondary-color);
  margin-top: .35rem;
}

.stat-group-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--bs-secondary-color);
  font-weight: 600;
  margin-bottom: .5rem;
}

/* --- Bordered list rows (statt Card-Grid, Desktop-Liste) --- */

.list-row {
  border-top: 1px solid var(--bs-border-color);
  padding: .85rem .25rem;
}

.list-row:first-child { border-top: none; }

/* --- Clean tables (Admin + Kapazitätstabelle) --- */

.table-clean {
  --bs-table-bg: transparent;
  margin-bottom: 0;
}

.table-clean thead th {
  text-transform: uppercase;
  font-size: .7rem;
  letter-spacing: .05em;
  font-weight: 600;
  color: var(--bs-secondary-color);
  border-bottom: 1px solid var(--bs-border-color);
  padding-bottom: .65rem;
}

.table-clean td {
  border-bottom: 1px solid var(--bs-border-color);
  padding-top: .7rem;
  padding-bottom: .7rem;
  vertical-align: middle;
}

.table-clean tr:last-child td {
  border-bottom: none;
}

.table-clean tbody tr:hover {
  background-color: #fafafa;
}

/* --- Gestrichelte Log-Zeilen (Änderungshistorie / Zählungen) --- */

.log-row {
  border-top: 1px dashed var(--bs-border-color);
  padding: .6rem .1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: .85rem;
}

.log-row:first-child { border-top: none; }

/* --- Auth pages (Login/Passwort ändern) --- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(60% 50% at 15% 10%, rgba(43, 58, 103, .08), transparent),
    var(--bs-body-bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-brand {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  margin-bottom: .25rem;
}

@media (max-width: 575.98px) {
  #map { height: 50vh; }
}

/* --- Dark mode --- */

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bs-body-bg: #0f1115;
    --bs-body-color: #e5e7eb;
    --bs-secondary-color: #9aa0aa;
    --bs-border-color: #262a33;

    --status-frei-bg: rgba(47, 163, 107, .16);
    --status-fast-voll-bg: rgba(232, 169, 59, .18);
    --status-voll-bg: rgba(209, 67, 67, .18);
    --status-gesperrt-bg: rgba(154, 161, 172, .2);
    --betrieb-geoeffnet-bg: rgba(107, 128, 197, .22);
    --betrieb-geschlossen-bg: rgba(154, 161, 172, .2);
  }

  .app-navbar {
    background: rgba(15, 17, 21, .85);
  }

  .card, .stat-tile {
    background-color: #161922;
  }

  .form-control, .form-select {
    background-color: #161922;
    color: var(--bs-body-color);
    border-color: var(--bs-border-color);
  }

  .btn-outline-secondary:hover {
    background-color: #1d212b;
  }

  .table-clean tbody tr:hover {
    background-color: #171a22;
  }

  .chip {
    background: #1d212b;
    color: #c7cad1;
  }

  .auth-shell {
    background:
      radial-gradient(60% 50% at 15% 10%, rgba(107, 128, 197, .16), transparent),
      var(--bs-body-bg);
  }
}
