/* =====================================================================
   Feuerwehr Prüfverwaltung - Stylesheet
   Design an elms.at (FF Neumarkt Einsatzleitung) angeglichen: gleiche
   Farbpalette, gleiche Schriftart (system-ui), gleiches Karten-/Button-
   System, Sidebar+Topbar-Layout, Light/Dark-Mode.
   Zusätzlich weiterhin: große Kacheln/Touch-Ziele für Handschuh-/
   Mobilbedienung (Kernanforderung der Prüfapp bleibt erhalten).
   ===================================================================== */

/* ---------- Farbsystem (identisch zu elms.at) ---------- */
:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --card: #ffffff;
  --border: #dde3ea;
  --text: #1f2937;
  --muted: #6b7280;
  --red: #cf2e2e;
  --redhov: #b02525;
  --green: #2f9e44;
  --amber: #ef8a17;
  --blue: #2f6fed;
  --soft: #f8fafc;
  --soft-line: #e8edf2;
  --label: #8a94a3;

  /* Kompatibilitäts-Aliase (von bestehenden Klassen unten verwendet) */
  --rot: var(--red);
  --rot-dunkel: var(--redhov);
  --orange: var(--amber);
  --blau: var(--blue);
  --gruen: var(--green);
  --gelb: var(--amber);
  --grau: var(--muted);
  --dunkel: var(--text);
  --hell: var(--bg);
  --karte-bg: var(--card);
  --rand: var(--border);
  --radius: 12px;
  --schatten: 0 1px 3px rgba(16,24,40,.06);
  --schatten-hover: 0 6px 18px rgba(16,24,40,.12);
}

[data-theme="dark"] {
  --bg: #111111;
  --panel: #161616;
  --card: #1c1c1c;
  --border: #2a2a2a;
  --text: #e8e8e8;
  --muted: #9aa5b1;
  --red: #c0392b;
  --redhov: #a93226;
  --green: #27ae60;
  --amber: #e67e22;
  --blue: #2980b9;
  --soft: #1a1a1a;
  --soft-line: #2a2a2a;
  --label: #9aa5b1;
  --schatten: 0 1px 3px rgba(0,0,0,.4);
  --schatten-hover: 0 6px 18px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
code { background: var(--soft); border: 1px solid var(--soft-line); border-radius: 4px; padding: 1px 6px; }

/* Sichtbarer, dezenter Fokus-Ring statt Browser-Standard - überall */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, .nav-item:focus-visible, .kachel:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(207,46,46,.13);
}
[data-theme="dark"] input:focus, [data-theme="dark"] select:focus, [data-theme="dark"] textarea:focus {
  box-shadow: 0 0 0 3px rgba(192,57,43,.25);
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Layout: Topbar + Sidebar (wie elms.at) ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

#topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 200;
}
#topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
#topbar .brand .flamme { color: var(--red); display: flex; }
#topbar-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--soft); border-color: var(--soft-line); color: var(--text); text-decoration: none; }
#nav-toggle { display: none; }
.user-badge { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-right: 4px; white-space: nowrap; }

.app-body { display: flex; flex: 1; min-height: 0; }

#sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  z-index: 150;
  transition: transform .18s ease;
}
.sidebar-label {
  padding: 14px 16px 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--label);
  font-weight: 700;
}
.nav-list { padding: 0 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: all .14s;
  border: 1px solid transparent;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: var(--soft); color: var(--text); text-decoration: none; }
.nav-item.active { color: var(--red); background: rgba(207,46,46,.12); border-color: rgba(207,46,46,.22); }
.sidebar-foot { margin-top: auto; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); line-height: 1.6; }

#nav-backdrop { display: none; }

.app-main { flex: 1; min-width: 0; padding: 20px; }

.app-footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 16px 20px; border-top: 1px solid var(--border); }

/* Admin-Einstellungsbutton bleibt als hervorgehobener Button erhalten, jetzt im Sidebar-Kontext */
.admin-settings-btn {
  background: var(--red) !important;
  color: #fff !important;
  border-radius: 8px !important;
}
.admin-settings-btn:hover { background: var(--redhov) !important; }
.admin-settings-btn.nav-item.active { color: #fff !important; }

/* ---------- Kacheln (Dashboard) - groß & touch-freundlich ---------- */
.kachel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  margin: 18px 0 32px;
}

.kachel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--schatten);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  color: var(--text);
  min-height: 170px;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.kachel:hover, .kachel:focus-visible {
  box-shadow: var(--schatten-hover);
  transform: translateY(-3px);
  text-decoration: none;
  border-color: var(--red);
}
.kachel .icon {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  font-size: 28px;
  color: #fff;
  background-image: linear-gradient(135deg, rgba(255,255,255,.22), rgba(255,255,255,0) 60%);
  box-shadow: 0 4px 10px rgba(0,0,0,.12);
}
.kachel .titel { font-size: 1.1rem; font-weight: 700; }
.kachel .unterinfo { font-size: 0.88rem; color: var(--muted); }

/* Ampel-/Statusfarben für Kacheln, Badges, Ränder */
.bg-gruen  { background: var(--green); }
.bg-gelb   { background: var(--amber); }
.bg-rot    { background: var(--red); }
.bg-grau   { background: var(--muted); }
.bg-blau   { background: var(--blue); }
.bg-orange { background: var(--amber); }

.status-punkt { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

.badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: #fff;
}

/* ---------- Karten / Boxen ---------- */
.box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--schatten);
  padding: 20px 22px;
  margin-bottom: 20px;
}
.box h2, .box h3 { margin-top: 0; }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 26px 0 14px;
}
.section-title h2 { margin: 0; }

/* ---------- Buttons (kompakt wie elms.at, mit großen Varianten für Touch-Bedienung) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 11px 18px;
  border-radius: 8px;
  border: none;
  background: var(--red);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  text-align: center;
  font-family: inherit;
  transition: background .14s, transform .1s ease, box-shadow .14s;
}
.btn:hover { background: var(--redhov); color: #fff; text-decoration: none; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(207,46,46,.25); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn.sekundaer { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn.sekundaer:hover { background: var(--soft); box-shadow: none; }
.btn.gruen { background: var(--green); }
.btn.gruen:hover { filter: brightness(0.92); box-shadow: 0 4px 12px rgba(47,158,68,.25); }
.btn.blau { background: var(--blue); }
.btn.blau:hover { filter: brightness(0.92); box-shadow: 0 4px 12px rgba(47,111,237,.25); }
.btn.gross { padding: 18px 26px; font-size: 1.15rem; width: 100%; border-radius: 10px; }
.btn.klein { padding: 7px 12px; font-size: 0.82rem; min-height: 36px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-leiste { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }

/* ---------- Formulare ---------- */
label { display: block; font-weight: 600; margin: 14px 0 6px; color: var(--text); }
input, select, textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--card);
  color: var(--text);
  min-height: 46px;
  font-family: inherit;
}
textarea { min-height: 100px; }
input[type=checkbox], input[type=radio] { width: auto; min-height: auto; margin-right: 8px; }
.form-hilfe { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }
.form-zeile { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .form-zeile { grid-template-columns: 1fr; } }

fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin: 16px 0; }
legend { font-weight: 700; padding: 0 8px; color: var(--text); }

/* Ergebnis-Auswahl als große Buttons (Touch-freundlich) */
.ergebnis-auswahl { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 12px; margin: 10px 0; }
.ergebnis-option {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  font-weight: 700;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
}
.ergebnis-option input { display: none; }
.ergebnis-option.ok { color: var(--green); }
.ergebnis-option.mangel { color: var(--amber); }
.ergebnis-option.mangel-schwer { color: var(--red); }
.ergebnis-option.ausgeschieden { color: var(--muted); }
.ergebnis-option:has(input:checked) { border-color: currentColor; background: var(--soft); }

/* ---------- Tabellen ---------- */
.tabelle-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--soft); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--label); font-weight: 700; }
tr:hover td { background: var(--soft); }

/* ---------- Listen als Kacheln (Geräte/Fahrzeuge) ---------- */
.item-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.item-karte {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--schatten);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 5px solid var(--muted);
}
.item-karte.status-gruen { border-left-color: var(--green); }
.item-karte.status-gelb  { border-left-color: var(--amber); }
.item-karte.status-rot   { border-left-color: var(--red); }
.item-karte .item-titel { font-weight: 700; font-size: 1.05rem; color: var(--text); }
.item-karte .item-meta { font-size: 0.86rem; color: var(--muted); }

/* ---------- Flash-Meldungen ---------- */
.flash { padding: 13px 18px; border-radius: 8px; margin-bottom: 16px; font-weight: 600; border: 1px solid transparent; }
.flash.erfolg { background: rgba(47,158,68,.12); color: var(--green); border-color: rgba(47,158,68,.25); }
.flash.fehler { background: rgba(207,46,46,.1); color: var(--red); border-color: rgba(207,46,46,.25); }
.flash.info   { background: rgba(47,111,237,.1); color: var(--blue); border-color: rgba(47,111,237,.25); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.login-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 30px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--schatten-hover);
}
.login-box .logo { text-align: center; margin-bottom: 6px; display: flex; justify-content: center; }
.login-box h1 { text-align: center; font-size: 1.3rem; margin-top: 0; color: var(--text); }

/* ---------- Auth-Split-Layout (Login, Setup, Passwort) - moderner Zweispalter ---------- */
.auth-shell { min-height: 100vh; display: flex; }

.auth-brand {
  flex: 1 1 42%;
  position: relative;
  overflow: hidden;
  background: linear-gradient(155deg, var(--red) 0%, #7a1f1f 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px 56px;
}
.auth-brand::before, .auth-brand::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.auth-brand::before { width: 420px; height: 420px; top: -160px; right: -140px; }
.auth-brand::after { width: 260px; height: 260px; bottom: -100px; left: -80px; background: rgba(0,0,0,.12); }
.auth-brand .logo-row { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; position: relative; z-index: 1; }
.auth-brand .logo-row .logo-icon {
  width: 46px; height: 46px; border-radius: 12px; background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.auth-brand .logo-row span.name { font-size: 1.1rem; font-weight: 700; }
.auth-brand h1 { font-size: 2.1rem; line-height: 1.18; margin: 0 0 16px; position: relative; z-index: 1; max-width: 420px; }
.auth-brand p.tagline { font-size: 1.05rem; line-height: 1.55; opacity: .92; max-width: 380px; margin: 0 0 40px; position: relative; z-index: 1; }
.auth-features { display: flex; flex-direction: column; gap: 16px; position: relative; z-index: 1; }
.auth-features .f { display: flex; align-items: center; gap: 12px; font-size: .95rem; opacity: .96; }
.auth-features .f .icon-circle {
  width: 36px; height: 36px; border-radius: 10px; background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.auth-form-wrap {
  flex: 1 1 58%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: var(--bg);
  overflow-y: auto;
}
.auth-form-card { width: 100%; max-width: 400px; }
.auth-form-card .eyebrow { display: none; } /* bewusst kein "ALL-CAPS"-Eyebrow-Label, s. Designrichtlinie */
.auth-form-card h2 { font-size: 1.5rem; margin: 0 0 6px; color: var(--text); }
.auth-form-card .sub { color: var(--muted); margin: 0 0 28px; font-size: .93rem; }
.auth-form-card .fuss-link { text-align: center; margin-top: 20px; font-size: .92rem; }

@media (max-width: 860px) {
  .auth-shell { flex-direction: column; min-height: auto; }
  .auth-brand { flex: none; padding: 28px 24px; }
  .auth-brand::before, .auth-brand::after { display: none; }
  .auth-brand .logo-row { margin-bottom: 4px; }
  .auth-brand h1 { font-size: 1.35rem; margin-bottom: 0; }
  .auth-brand p.tagline, .auth-features { display: none; }
  .auth-form-wrap { padding: 32px 20px; }
}

/* ---------- Foto-Galerie ---------- */
.foto-galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 10px; margin: 10px 0; }
.foto-galerie a { display: block; }
.foto-galerie img { width: 100%; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

/* ---------- Theme-Toggle-Icon ---------- */
#theme-toggle .icon-mond { display: none; }
[data-theme="dark"] #theme-toggle .icon-sonne { display: none; }
[data-theme="dark"] #theme-toggle .icon-mond { display: inline-flex; }

/* ---------- Responsive: Sidebar wird zur Drawer-Navigation ---------- */
@media (max-width: 860px) {
  body { font-size: 16px; }
  #nav-toggle { display: inline-flex; }
  #topbar { padding: 0 10px; height: 52px; }
  .app-main { padding: 14px; }

  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    padding-top: 52px;
    transform: translateX(-100%);
    box-shadow: 2px 0 16px rgba(15,23,42,.18);
  }
  .app-body.nav-offen #sidebar { transform: translateX(0); }
  .app-body.nav-offen #nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    top: 52px;
    background: rgba(0,0,0,.55);
    z-index: 140;
    border: none;
  }
  /* Auf Mobilgeräten größere Touch-Ziele in der Sidebar */
  .nav-item { padding: 14px 12px; font-size: 15px; }

  .kachel-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .kachel { min-height: 140px; padding: 18px 12px; }
  .kachel .icon { width: 52px; height: 52px; font-size: 24px; }
  th, td { padding: 10px 8px; font-size: 0.9rem; }
  .user-badge span.user-name { display: none; }
}

/* Große Touch-Ziele auch am PC beibehalten, damit Tablet/Smartphone gleich bedienbar bleiben */
button, .btn, a.btn, select, input[type=submit] { touch-action: manipulation; }

/* =====================================================================
   Druckkopf (Briefkopf) für alle Ausdrucke - siehe templates/druckkopf.php
   Logo oben links, daneben die Feuerwehr, rechts Dokumenttitel/Datum.
   ===================================================================== */
.druckkopf {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 10px;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--red);
}
.druckkopf-links { display: flex; align-items: center; gap: 14px; }
.druckkopf-logo { max-height: 22mm; max-width: 45mm; width: auto; height: auto; }
.druckkopf-logo-fallback { display: flex; align-items: center; }
.druckkopf-name { font-size: 1.15rem; font-weight: 700; line-height: 1.2; color: var(--text); }
.druckkopf-ort { font-size: 0.85rem; color: var(--muted); }
.druckkopf-rechts { text-align: right; }
.druckkopf-titel { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.druckkopf-untertitel { font-size: 0.9rem; color: var(--muted); }
.druckkopf-datum { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

@media print {
  .druckkopf {
    border-bottom: 2px solid #000;
    break-inside: avoid;
  }
  .druckkopf-name, .druckkopf-titel { color: #000; }
  .druckkopf-ort, .druckkopf-untertitel, .druckkopf-datum { color: #333; }
}

@media (max-width: 640px) {
  .druckkopf { flex-direction: column; gap: 10px; }
  .druckkopf-rechts { text-align: left; }
}

/* Blöcke, die nur im Ausdruck erscheinen sollen (z.B. Briefkopf auf
   normalen Bildschirmseiten wie den Berichten) */
.nur-druck { display: none; }
@media print {
  .nur-druck { display: block; }
}
