/* Design-Tokens und Basis-Komponenten aus docs/spec-design.md ("Modernist"-Guide, wörtlich übernommen). */

@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../fonts/archivo-variable.woff2") format("woff2");
}

:root {
  --color-bg: #f3f2f2;
  --color-surface: #eae9e9;
  --color-text: #201e1d;
  --color-accent: #ec3013;
  --color-accent-2: #e15b47;
  --color-divider: color-mix(in srgb, #201e1d 40%, transparent);

  --color-neutral-100: #f8f4f4;
  --color-neutral-200: #eae7e7;
  --color-neutral-300: #d7d3d3;
  --color-neutral-400: #bab6b6;
  --color-neutral-500: #9b9797;
  --color-neutral-600: #7d7979;
  --color-neutral-700: #605d5d;
  --color-neutral-800: #444141;
  --color-neutral-900: #2d2b2b;

  --color-accent-100: #fff2ef;
  --color-accent-200: #ffe0d9;
  --color-accent-300: #ffc4b8;
  --color-accent-400: #ff9783;
  --color-accent-500: #ff563c;
  --color-accent-600: #dd2b0f;
  --color-accent-700: #ae1800;
  --color-accent-800: #7c1405;
  --color-accent-900: #4d170e;

  --color-accent-2-100: #fff2ef;
  --color-accent-2-200: #ffe0da;
  --color-accent-2-300: #ffc4b9;
  --color-accent-2-400: #ff9784;
  --color-accent-2-500: #ef6853;
  --color-accent-2-600: #c94b39;
  --color-accent-2-700: #9e3526;
  --color-accent-2-800: #71261b;
  --color-accent-2-900: #471d16;

  --font-heading: "Archivo", system-ui, sans-serif;
  --font-heading-weight: 800;
  --font-body: "Archivo", system-ui, sans-serif;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;

  --radius-sm: 0px;
  --radius-md: 0px;
  --radius-lg: 0px;

  --shadow-sm: 0 1px 2px color-mix(in srgb, #2d2b2b 14%, transparent);
  --shadow-md: 0 3px 10px color-mix(in srgb, #2d2b2b 16%, transparent);
  --shadow-lg: 0 12px 32px color-mix(in srgb, #2d2b2b 22%, transparent);

  --sidebar-width: 220px;
}

/* Darkmode: exakte Werte im gelieferten Guide nicht enthalten (s. docs/spec-design.md) — hier
   pragmatisch aus den Neutral-/Accent-Ramps abgeleitet, Akzentton bleibt bewusst identisch. */
:root[data-theme="dark"] {
  --color-bg: var(--color-neutral-900);
  --color-surface: #383535;
  --color-text: var(--color-neutral-100);
  --color-divider: color-mix(in srgb, var(--color-neutral-100) 24%, transparent);
}

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

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 400;
}

/* Jede Klasse, die selbst "display" setzt (z. B. .btn: inline-flex, .notif-badge: flex), ist eine
   normale Autoren-Regel und schlaegt damit IMMER die normale User-Agent-Regel "[hidden] { display:
   none }", unabhaengig von Spezifitaet -- das HTML-Attribut hidden wuerde sonst stillschweigend
   wirkungslos bleiben (am RC-Ueberspringen-Button und beim Notification-Badge real beobachtet). */
[hidden] { display: none !important; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 var(--space-2);
}
h1 { font-size: 42px; }
h2 { font-size: 32px; }
h3 { font-size: 25px; }
h4 { font-size: 20px; }
h5 { font-size: 16px; }
h6 { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }
p { margin: 0 0 var(--space-3); }
a { color: var(--color-accent); text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
.text-muted { color: color-mix(in srgb, var(--color-text) 55%, transparent); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }
.tabular-nums { font-variant-numeric: tabular-nums; }

.hr { height: 2px; border: 0; margin: var(--space-4) 0; background: var(--color-divider); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 14px; line-height: 1.2; color: var(--color-text);
  background: transparent; border: 1px solid transparent;
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  border-radius: var(--radius-md);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover { background: var(--color-accent-600); }
.btn-primary:active { background: var(--color-accent-700); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-danger { border-color: var(--color-accent-700); color: var(--color-accent-700); }
.btn-danger:hover { background: var(--color-accent-100); }
.btn-ghost { color: var(--color-accent); padding-inline: var(--space-1); border: none; }
.btn-ghost:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-block { width: 100%; margin-top: var(--space-2); justify-content: center; }

/* RC-Kiosk: Bediener-Auswahl (Pilot/Kamera) wird auf dem RC-Touchscreen bedient, deshalb deutlich
   groessere Tipp-Flaeche als normale Buttons; Name links, Qualifikations-Tags rechtsbuendig. */
.rc-select-btn {
  min-height: 88px; padding: var(--space-4) var(--space-6);
  font-size: 24px; justify-content: space-between; text-align: left;
}
.rc-select-btn .rc-select-btn-tags { display: inline-flex; gap: 8px; flex: none; }
.rc-select-btn .tag { font-size: 15px; padding: 6px 14px; }

/* Formulare */
.field { margin-bottom: var(--space-3); }
.field > label { display: block; font-size: 12px; margin-bottom: 5px; color: color-mix(in srgb, var(--color-text) 70%, transparent); }
.input, select.input {
  width: 100%; min-height: 36px; padding: 6px 10px; font: inherit;
  font-size: 14px; color: var(--color-text); caret-color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.input:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
textarea.input { min-height: 90px; resize: vertical; }
.checkbox-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto;
  border: 1px solid var(--color-divider); padding: var(--space-2); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }

.radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.radio input, .seg-opt input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.radio .dot { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 1.5px solid var(--color-divider); }
.radio:hover .dot { border-color: var(--color-accent); }
.radio input:checked + .dot { border-color: var(--color-accent); background: var(--color-accent); box-shadow: inset 0 0 0 4px var(--color-bg); }
.seg { display: inline-flex; flex-wrap: wrap; overflow: hidden; border: 1px solid var(--color-divider); border-radius: var(--radius-md); }
.seg-opt { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; font-size: 13px; cursor: pointer; }
.seg-opt + .seg-opt { border-left: 1px solid var(--color-divider); }
.seg-opt:has(input:checked) { background: var(--color-accent); color: #fff; }
.seg-opt:not(:has(input:checked)):hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }

/* Karten */
.card { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); border-radius: var(--radius-md); background: var(--color-surface); }
.card-kicker { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-accent); }
.card-title { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 17px; line-height: 1.2; }
.card-body { margin: 0; font-size: 13px; opacity: 0.8; flex: 1; }
.card-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: color-mix(in srgb, var(--color-text) 50%, transparent); }
.elev-sm { box-shadow: var(--shadow-sm); }
.elev-md { box-shadow: var(--shadow-md); }
.elev-lg { box-shadow: var(--shadow-lg); }

/* RC-Kiosk: Flugdauer-Anzeige ab Freigabe bis "Flug beenden" */
.flight-timer {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 36px; text-align: center; margin: var(--space-2) 0;
}

/* Tags */
.tag { display: inline-flex; align-items: center; font-size: 11px; letter-spacing: 0.02em; padding: 3px 10px; border-radius: calc(var(--radius-md) * 0.75); }
.tag-accent { background: var(--color-accent-100); color: var(--color-accent-800); }
.tag-neutral { background: var(--color-neutral-100); color: var(--color-neutral-800); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent); }

/* Tabellen */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: color-mix(in srgb, var(--color-text) 60%, transparent); padding: var(--space-2); border-bottom: 2px solid var(--color-divider); }
.table td { padding: var(--space-2); border-bottom: 1px solid var(--color-divider); vertical-align: middle; }
.table tbody tr:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }

/* Flash-Meldungen */
.flash-list { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.flash { padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); font-size: 14px; border: 1px solid var(--color-divider); background: var(--color-surface); }
.flash-error { border-color: var(--color-accent-700); color: var(--color-accent-700); }

/* ---- App-Shell / Layout (nicht im Guide enthalten, ergänzt passend zu Navigation & Layout) ---- */

.logo-badge { width: 36px; height: 36px; background: #181514; display: flex; align-items: center; justify-content: center; flex: none; }

.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-4); }
.auth-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: var(--space-4); }
.auth-brand { display: flex; align-items: center; justify-content: center; }
.auth-logo { width: 160px; height: 160px; display: block; }
.auth-logo-dark { display: none; }
:root[data-theme="dark"] .auth-logo-light { display: none; }
:root[data-theme="dark"] .auth-logo-dark { display: block; }

/* Profilbild (app/profile/) -- quadratisch statt rund, konsistent mit dem scharfkantigen
   Design-System (--radius-* ist überall 0px, s. o.). */
.avatar { width: 96px; height: 96px; object-fit: cover; border: 1px solid var(--color-divider); background: var(--color-neutral-200); display: block; flex: none; }
.avatar-placeholder {
  width: 96px; height: 96px; display: flex; align-items: center; justify-content: center; flex: none;
  border: 1px solid var(--color-divider); background: var(--color-neutral-200); color: var(--color-neutral-700);
  font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 30px;
}
.profile-header { display: flex; align-items: center; gap: var(--space-4); }

/* height (nicht min-height) + overflow:hidden hält die Sidebar auf Viewport-Höhe fixiert -- sonst
   dehnt sie sich als Flex-Kind gleich hoch wie .app-main (Standard-Flexbox-Stretch) und scrollt beim
   Scrollen langer Dashboard-Inhalte mit der ganzen Seite mit, statt stehen zu bleiben. Nur .app-content
   scrollt intern (s. u.). Für Mobile wird das im Media-Query unten bewusst wieder aufgehoben, weil der
   dortige sticky-bottom-Tab-Balken (.sidebar) einen echten Dokument-Scroll braucht, um zu funktionieren. */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-width); flex: none; display: flex; flex-direction: column; gap: var(--space-4);
  padding: var(--space-4); border-right: 2px solid var(--color-divider); background: var(--color-surface);
  overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.sidebar-brand-text { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 18px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-link { display: block; padding: 8px var(--space-2); border-radius: var(--radius-md); color: var(--color-text); text-decoration: none; font-size: 14px; }
.sidebar-link:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.sidebar-link.is-active { background: var(--color-accent-100); color: var(--color-accent-800); }

/* min-height:0 ist hier nötig, nicht nur Deko: ohne das würde dieses Flex-Kind sich nie unter die
   Höhe seines Inhalts (.app-content) zusammendrücken lassen, wodurch dessen overflow-y:auto nie
   greifen und stattdessen wieder das ganze .app-shell aufblähen würde -- derselbe Grund, warum die
   Sidebar bisher mitgewachsen ist. */
.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-3) var(--space-6); border-bottom: 2px solid var(--color-divider); }
.topbar-title { margin: 0; font-size: 20px; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-3); }
.role-switch-form { margin: 0; }

.topbar-user { font-weight: 700; color: var(--color-text); text-decoration: none; white-space: nowrap; }
.topbar-user:hover { color: var(--color-accent); }

/* Topbar-Glocke: Verlauf-Sprechblase + Live-Badge (app/static/js/notifications.js: initNotificationBell) */
.notif-center { position: relative; }
.notif-bell {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; background: none; border: none; border-radius: var(--radius-md);
  color: var(--color-text); cursor: pointer;
}
.notif-bell:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.notif-badge {
  position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 50%; background: var(--color-accent); color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.notif-popover {
  position: absolute; top: calc(100% + var(--space-2)); right: 0; width: 320px;
  max-width: calc(100vw - var(--space-4)); background: var(--color-surface); border: 1px solid var(--color-divider);
  box-shadow: var(--shadow-lg); z-index: 20;
}
.notif-popover-header {
  padding: var(--space-3); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em;
  color: color-mix(in srgb, var(--color-text) 65%, transparent); border-bottom: 1px solid var(--color-divider);
}
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-list p.text-muted { padding: var(--space-3); margin: 0; }
.notif-item { display: block; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-divider); }
.notif-item:last-child { border-bottom: none; }
a.notif-item { color: inherit; text-decoration: none; cursor: pointer; }
a.notif-item:hover { background: color-mix(in srgb, var(--color-text) 6%, transparent); }
.notif-item-unread { background: var(--color-accent-100); }
.notif-item-title { font-size: 13px; font-weight: 700; }
.notif-item-body { font-size: 12px; color: color-mix(in srgb, var(--color-text) 70%, transparent); margin-top: 2px; }
.notif-popover-footer {
  display: block; padding: var(--space-2) var(--space-3); font-size: 12px; text-align: center;
  color: color-mix(in srgb, var(--color-text) 65%, transparent); text-decoration: none;
  border-top: 1px solid var(--color-divider);
}
.notif-popover-footer:hover { color: var(--color-accent); }

/* Live-Toast bei eingehendem Push, während die Seite offen ist (sw.js: postMessage) -- oben mittig
   statt in einer Ecke (Nutzervorgabe), damit er unabhängig von der Sprechblasen-Position auffällt. */
.toast-container {
  position: fixed; top: var(--space-4); left: 50%; transform: translateX(-50%); z-index: 50;
  display: flex; flex-direction: column; gap: var(--space-2);
  width: min(320px, calc(100vw - var(--space-4) * 2));
}
.toast {
  background: var(--color-surface); border: 1px solid var(--color-divider); border-left: 3px solid var(--color-accent);
  box-shadow: var(--shadow-lg); padding: var(--space-3);
}
.toast-title { font-size: 13px; font-weight: 700; }
.toast-body { font-size: 12px; color: color-mix(in srgb, var(--color-text) 70%, transparent); margin-top: 2px; }

/* OpenSky-Luftraum-Widget: Flugzeug-Icons statt Standard-Leaflet-Pins (opensky_widget_map.js:
   aircraftIcon). Selektor mit zwei Klassen nötig, um Leaflets eigene `.leaflet-div-icon`-Regel
   (weißer Kasten+Rand) zu schlagen, ohne auf !important angewiesen zu sein -- leaflet.css wird erst
   innerhalb des Widget-Partials geladen, also nach app.css im Dokument, und würde bei gleicher
   Spezifität sonst gewinnen. */
.leaflet-marker-icon.aircraft-marker { background: none; border: none; color: var(--color-accent-700); }

/* Flugbuch-Karte: pulsierendes "Blaulicht" für Einsätze, schlichter grüner Punkt für Übungen
   (incidents_map.js/incidents_widget_map.js: incidentMarker). Zwei-Klassen-Selektor aus demselben
   Grund wie .aircraft-marker oben (schlägt Leaflets `.leaflet-div-icon`-Box ohne !important). */
.leaflet-marker-icon.bluelight-marker-wrap { background: none; border: none; }
.bluelight-marker {
  display: block; width: 14px; height: 14px; margin: 1px; box-sizing: border-box;
  border-radius: 50%; background: #1a56db; border: 2px solid #fff;
  animation: bluelight-pulse 1.2s ease-out infinite;
}
@keyframes bluelight-pulse {
  0% { box-shadow: 0 0 0 0 rgba(26, 86, 219, 0.6); }
  70% { box-shadow: 0 0 0 10px rgba(26, 86, 219, 0); }
  100% { box-shadow: 0 0 0 0 rgba(26, 86, 219, 0); }
}

.app-content { padding: var(--space-6); flex: 1; overflow-y: auto; }

/* Unterseiten-Navigation für Bereiche mit eigenen Unterseiten (administration/_base.html,
   profile/_base.html) */
.subnav { display: flex; flex-wrap: wrap; column-gap: var(--space-4); row-gap: 4px; margin-bottom: var(--space-5); border-bottom: 2px solid var(--color-divider); }
.subnav-link { padding: var(--space-2) 0; font-size: 13px; color: color-mix(in srgb, var(--color-text) 65%, transparent); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.subnav-link:hover { color: var(--color-text); }
.subnav-link.is-active { color: var(--color-accent); border-bottom-color: var(--color-accent); }

/* Sidebar-Fußzeile (Mein Profil/Abmelden), unten fixiert wie zuvor der Administration-Block */
.sidebar-nav-footer { margin-top: auto; }
.sidebar-link-button {
  width: 100%; text-align: left; background: none; border: none; font: inherit; cursor: pointer;
}

.dashboard-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--space-4); }
.dashboard-widget { grid-column: span 12; }
.widget-actions { display: flex; gap: var(--space-2); margin-top: var(--space-2); }

.role-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); margin-top: var(--space-6); }
.role-card { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); text-align: left; cursor: pointer; border: 2px solid transparent; }
.role-card:hover { border-color: var(--color-accent); }
.role-card-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--color-accent-100); color: var(--color-accent-800); display: flex; align-items: center; justify-content: center; font-family: var(--font-heading); font-weight: 800; }

.page-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.form-actions { display: flex; gap: var(--space-2); margin-top: var(--space-4); }

@media (max-width: 760px) {
  /* Hebt den Desktop-Fixed-Viewport-Umbau oben bewusst wieder auf: die sticky-bottom-Tableiste
     unten (.sidebar) braucht echten Dokument-Scroll, um an der Stelle "stecken" zu bleiben --
     mit height:100vh+overflow:hidden auf .app-shell gäbe es keinen Scroll-Kontext dafür mehr. */
  .app-shell { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; overflow-y: visible; position: sticky; bottom: 0; order: 2;
    border-right: none; border-top: 2px solid var(--color-divider); }
  .sidebar-brand { display: none; }
  .sidebar-nav { flex-direction: row; }
  .app-content { padding: var(--space-4); overflow-y: visible; }
  .dashboard-widget { grid-column: span 12 !important; }
}
