:root {
    --color-primary: #c62828;
    --color-primary-dark: #8e0000;
    --color-bg: #0d1626;
    --color-card: #16223a;
    --color-text: #f2f4f7;
    --color-text-muted: #8b93a3;
    --color-border: rgba(255,255,255,0.10);
    --color-success: #43a047;
    --color-danger: #ff5252;
    --radius: 12px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
    /* Fest auf dunkel, unabhängig vom Farbschema: für Elemente, die immer
       eine helle Fläche haben (Eingabefelder, Homescreen-Icon-Kacheln). */
    --color-input-text: #1c1c1e;
}

/* Roboto Bold, komplett lokal eingebunden (kein Zugriff auf Google Fonts zur
   Laufzeit). Datei muss unter frontend/fonts/ abgelegt werden:
   Roboto-Bold.woff2 (bevorzugt) und/oder Roboto-Bold.ttf (Fallback). Fehlt
   eine der beiden Dateien, wird einfach die jeweils andere bzw. am Ende die
   normale System-Schrift verwendet - nichts bricht dadurch. */
@font-face {
    font-family: 'Roboto Bold';
    src: url('../fonts/Roboto-Bold.woff2') format('woff2'),
         url('../fonts/Roboto-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

/* Als installierte "Web-App" (Homebildschirm, standalone) lässt iOS die
   Seite sonst wie ein natives Scrollview seitlich wegziehen/wippen - im
   normalen Browser-Tab passiert das nicht. Fix: body wird komplett fixiert
   (scrollt selbst gar nicht mehr), stattdessen scrollt ausschließlich #app
   intern nach oben/unten. Damit gibt es nichts mehr, das sich seitlich
   wegschieben lässt. */
html, body {
    position: fixed;
    inset: 0;
    overscroll-behavior: none;
    touch-action: pan-y;
}
body {
    display: flex;
    flex-direction: column;
}

/* Hintergrundfoto am Seitenfuß (wie im Mockup): fest im Viewport verankert,
   blendet oben in die dunkle Seitenfarbe über. Liegt per z-index hinter dem
   normalen Seiteninhalt (Karten etc. decken es dort ab, wo Inhalt steht),
   die Fußzeile (#nav) deckt es unten mit ihrer eigenen Fläche ab - genau wie
   im Mockup. Auf der Login-Seite (eigenes Hintergrundfoto) ausgeblendet. */
#bg-photo {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    pointer-events: none;
    line-height: 0;
}
/* Echtes <img> statt CSS-Hintergrundbild: füllt garantiert die komplette
   Breite aus, die Höhe ergibt sich proportional aus dem Seitenverhältnis
   des Fotos - dadurch wird nie etwas beschnitten und es bleibt auch nie
   Leerraum an den Seiten. */
#bg-photo img {
    display: block;
    width: 100%;
    height: auto;
}
/* Verlauf oben über dem Foto, damit es weich in die dunkle Seitenfarbe
   übergeht (per Gradient-Ebene statt Bildbeschnitt). */
#bg-photo::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, var(--color-bg) 0%, rgba(13,22,38,0.55) 22%, rgba(13,22,38,0.15) 45%, rgba(13,22,38,0) 65%);
}
#bg-photo.hidden { display: none; }

/* Sicherheitsnetz gegen seitliches Verschieben/Abschneiden auf dem iPhone,
   falls ein einzelnes Element (z.B. ein zu breites Logo) über den
   Viewport hinausragt. */
#topbar, #app, #nav {
    max-width: 100%;
    overflow-x: hidden;
}

#topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(14px + var(--safe-top)) 16px 14px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    color: #fff;
    font-weight: 600;
    font-size: 1.1rem;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.topbar-brand {
    font-family: 'Roboto Bold', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Seitenname steht jetzt am Anfang jeder Seite statt in der Kopfleiste. */
.page-title {
    margin: 0 0 18px;
    font-size: 1.3rem;
}

#app {
    padding: 16px 16px calc(90px + var(--safe-bottom));
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    /* Einziger scrollbarer Bereich der App (siehe html/body oben) - dadurch
       lässt sich nichts mehr seitlich wegziehen, nur noch #app scrollt. */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
/* Ohne feste Fußzeile (Startseite, Login) braucht #app kein großes Bottom-Padding */
#app.no-bottom-nav {
    padding-bottom: calc(24px + var(--safe-bottom));
}

/* Login-Seite: volles Vollbild ohne Kopfleiste, ohne Innenabstand/Breitenbegrenzung,
   damit das Hintergrundfoto randlos über den ganzen Bildschirm geht. */
#app.login-page {
    padding: 0;
    max-width: none;
    margin: 0;
}

#nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--color-card);
    border-top: 1px solid var(--color-border);
    padding-bottom: var(--safe-bottom);
    z-index: 10;
}

.nav-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 2px 6px;
    text-decoration: none;
    color: var(--color-text-muted);
    font-size: 0.68rem;
}
/* "Mehr" ist ein <button>, browsereigenes Aussehen zurücksetzen, damit es
   wie die übrigen (Link-)Einträge in der Fußzeile aussieht. */
button.nav-link {
    border: none;
    background: none;
    font-family: inherit;
    cursor: pointer;
}

.nav-link.active { color: var(--color-primary); font-weight: 600; }

/* Fußzeilen-Icons: eigene Bilddateien aus icons/icn_*.png statt Emojis.
   Größe/Deckkraft hier zentral anpassbar; aktiver Eintrag wird voll
   deckend dargestellt, inaktive etwas gedimmt. */
.nav-icon {
    display: block;
    width: 24px;
    height: 24px;
    opacity: 0.7;
}
.nav-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.nav-icon svg { width: 100%; height: 100%; display: block; }
.nav-link.active .nav-icon { opacity: 1; }

/* "Mehr"-Menü: Bottom-Sheet mit den restlichen Seiten-Links (Umfragen,
   Bestellungen, Getränke), analog zum bestehenden Modal-Muster. */
.more-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 25;
    align-items: flex-end;
    justify-content: center;
}
.more-backdrop.open { display: flex; }
.more-sheet {
    background: var(--color-card);
    width: 100%;
    max-width: 720px;
    border-radius: 16px 16px 0 0;
    padding: 8px 16px calc(16px + var(--safe-bottom));
}
.more-sheet-handle {
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: var(--color-border);
    margin: 6px auto 12px;
}
.more-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 4px;
    text-decoration: none;
    color: var(--color-text);
    font-size: 0.95rem;
    font-weight: 600;
    border-bottom: 1px solid var(--color-border);
}
.more-link:last-child { border-bottom: none; }
.more-link .nav-icon { width: 26px; height: 26px; opacity: 1; }

/* Abmelden-Button in der Kopfleiste, neben dem Benutzernamen: kräftiger
   roter Button mit Icon + Text, wie im Mockup. */
#logout-btn {
    border: none;
    background: var(--color-primary);
    border-radius: 50%;
    width: 34px;
    height: 34px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
#logout-btn:active { background: var(--color-primary-dark); }
#logout-btn .nav-icon { width: 17px; height: 17px; opacity: 1; }

.loading, .empty-hint { color: var(--color-text-muted); text-align: center; padding: 24px 0; }

.card {
    background: var(--color-card);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.card h3 { margin: 0 0 6px; font-size: 1rem; }
.card p { margin: 4px 0; font-size: 0.9rem; color: var(--color-text-muted); }

.section-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin: 22px 0 10px;
}
.section-title:first-child { margin-top: 0; }

/* Überschriften durchgängig in Roboto Bold (lokal eingebunden, siehe
   @font-face oben). Gilt für aktuelle und künftige Überschriften. */
h1, h2, h3,
.section-title,
.page-title,
.card h3 {
    font-family: 'Roboto Bold', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-weight: 700;
}

/* Icon-Raster auf der Startseite (Homescreen-Optik, 4 Icons pro Reihe) */
.app-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px 6px;
    margin-bottom: 26px;
}
.app-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--color-text);
    font-size: 0.72rem;
    text-align: center;
}
.app-icon-tile {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.app-icon-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.app-icon:active .app-icon-tile { transform: scale(0.94); }
.app-icon-disabled { opacity: 0.55; cursor: default; }
.app-icon-disabled:active .app-icon-tile { transform: none; }

/* "Aktuelle Informationen des Tages"-Kopfzeile: fette Überschrift mit rotem
   Balken links, Datum rechts (siehe Homescreen-Mockup). */
.today-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 22px 0 12px;
    padding-left: 12px;
    border-left: 4px solid var(--color-primary);
}
.today-title h2 { margin: 0; font-size: 1.08rem; }
.today-date {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.76rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Kleines Icon inline im Text (ersetzt Emojis, lokale Datei aus icons/). */
.inline-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    vertical-align: -3px;
    margin-right: 2px;
}

/* Einzelne Hinweiszeile im Zwei-Spalten-Layout wie im Mockup: links Icon +
   Uhrzeit übereinander, rechts (mit Trennlinie) Titel/Untertitel. */
.hint-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}
.hint-row:last-child { border-bottom: none; }
.hint-col {
    flex: 0 0 auto;
    width: 163px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}
.hint-icon-img { width: 26px; height: 26px; object-fit: contain; flex-shrink: 0; }
.hint-time {
    font-size: 0.95rem;
    color: #fff;
    line-height: 1.2;
}
.hint-text {
    min-width: 0;
    flex: 1;
    padding-left: 14px;
    border-left: 1px solid var(--color-border);
}
.hint-title { font-weight: 700; font-size: 0.94rem; }
.hint-subtitle { font-size: 0.82rem; color: var(--color-text-muted); margin-top: 2px; }

/* Hervorgehobener Hinweis (z.B. neue Umfrage): rot umrandete Karte, wie
   "Hinweis der Lehrgangsleitung" im Mockup. */
.alert-card {
    border: 1.5px solid var(--color-primary);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 12px;
    background: rgba(198,40,40,0.08);
}
.alert-card .hint-row { padding: 0; border-bottom: none; }

/* A-Z-Index (Kontakte, Getränke-Übersicht, ...): echte zwei-Spalten-Aufteilung.
   Links (.az-content) läuft ganz normal mit der Seite mit, rechts steht der
   Buchstaben-Index per position:fixed WIRKLICH fest auf dem Bildschirm -
   unabhängig von jeglichem Scroll-Container, bleibt also garantiert stehen,
   während links alles vorbeiscrollt (wie bei Kontakten auf dem Handy). */
.az-content {
    padding-right: 30px;
}
.az-index {
    position: fixed;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    /* Feste Höhe (ca. zwei Infofelder), trotzdem passen alle 26 Buchstaben
       ohne Scrollen hinein (overflow:hidden als Absicherung). */
    height: 480px;
    max-height: 480px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    overflow: hidden;
    padding: 2px 0;
    z-index: 9;
}
.az-letter {
    font-size: 0.56rem;
    line-height: 1;
    font-weight: 700;
    color: var(--color-primary);
    cursor: pointer;
}
.az-letter.az-disabled {
    color: #c7c7cc;
    cursor: default;
}

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    background: #eef1ff;
    color: #3949ab;
}
.badge.today { background: #fff3e0; color: #ef6c00; }
.badge.birthday { background: #fce4ec; color: #ad1457; }
.badge.new { background: #e8f5e9; color: #2e7d32; }

input[type=text], input[type=search], input[type=password], input[type=date],
input[type=time], input[type=email], input[type=tel], textarea, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
    color: var(--color-input-text);
    font-family: inherit;
}
textarea { resize: vertical; min-height: 70px; }

label { display: block; font-size: 0.82rem; color: var(--color-text-muted); margin: 10px 0 4px; }
label:first-child { margin-top: 0; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    background: var(--color-primary);
    color: #fff;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
}
.btn:active { background: var(--color-primary-dark); }
.btn.secondary { background: rgba(255,255,255,0.08); color: var(--color-text); }
.btn.small { padding: 6px 10px; font-size: 0.8rem; }
.btn.danger { background: #fdecea; color: #c62828; }
.btn:disabled { opacity: 0.5; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* Detailansicht (z.B. Kontakt-Details): ausgeschriebene Label ohne Icon,
   Wert darunter. */
.detail-field { margin-bottom: 16px; }
.detail-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin-bottom: 3px;
}
.detail-value { font-size: 1rem; }
.detail-value a { color: var(--color-text); text-decoration: none; }

.fab {
    position: fixed;
    right: 18px;
    bottom: calc(78px + var(--safe-bottom));
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: 1.6rem;
    border: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    cursor: pointer;
    z-index: 9;
}

.search-bar { margin-bottom: 16px; }

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border);
}
.list-item:last-child { border-bottom: none; }

.error-box {
    background: #fdecea;
    color: #c62828;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 20;
}
.modal {
    background: var(--color-card);
    border-radius: 16px 16px 0 0;
    padding: 20px;
    width: 100%;
    max-width: 720px;
    max-height: 88vh;
    overflow-y: auto;
    padding-bottom: calc(20px + var(--safe-bottom));
}
.modal h2 { margin-top: 0; font-size: 1.05rem; }
.modal-close {
    position: absolute;
    top: 14px;
    right: 18px;
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--color-text-muted);
}

.progress-bar-track {
    background: #eef0f2;
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
    margin-top: 4px;
}
.progress-bar-fill { background: var(--color-primary); height: 100%; }

.option-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0; }
.option-row label { margin: 0; flex: 1; color: var(--color-text); font-size: 0.92rem; }
.option-percent { font-size: 0.78rem; color: var(--color-text-muted); min-width: 34px; text-align: right; }
.drink-price { font-size: inherit; color: var(--color-text); }

/* Login-Bildschirm: dunkler Hero-Hintergrund mit Flammen-Logo, angelehnt an
   das BIV-Feuerwehr-Lehrgang-Mockup. Eigenes Hintergrundfoto kann optional
   per background-image auf .login-wrap ergänzt werden (z.B. über eine Klasse
   mit url(../images/login-bg.jpg) vor dem Gradient). */
.login-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: calc(56px + var(--safe-top)) 26px calc(36px + var(--safe-bottom));
    background: url('../images/login-bg.jpg');
    background-size: cover;
    background-position: top center;
    background-repeat: no-repeat;
    color: #fff;
    text-align: center;
}

.login-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 44px;
    /* Verschiebt nur das Logo selbst nach unten (ca. eine Textzeilenhöhe),
       ohne die Position der übrigen, unten ausgerichteten Elemente
       (Formular etc.) zu beeinflussen. margin-bottom etwas erhöht, damit
       trotz der Verschiebung genug Abstand zum Formular bleibt. */
    transform: translateY(32px);
}
.login-logo {
    max-width: 330px;
    max-height: 210px;
    width: auto;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 14px rgba(0,0,0,0.35));
}

.login-form {
    width: 100%;
    max-width: 360px;
}

.input-icon-field {
    position: relative;
    margin-bottom: 14px;
}
.input-icon-field .field-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--color-primary);
    pointer-events: none;
}
.input-icon-field input {
    height: 50px;
    padding-left: 44px;
    padding-right: 44px;
    border-radius: 14px;
    border: none;
    font-size: 0.95rem;
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}
.pw-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #9aa0a8;
    cursor: pointer;
}
.pw-toggle svg { width: 18px; height: 18px; }
.pw-toggle.active { color: var(--color-primary); }

.forgot-link {
    display: block;
    text-align: left;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.75);
    text-decoration: underline;
    margin: 2px 0 22px;
}

.btn-login {
    width: 100%;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, #e53935, #b71c1c);
    box-shadow: 0 10px 22px rgba(198,40,40,0.4);
    font-size: 0.98rem;
}
.btn-login svg { width: 18px; height: 18px; }

.login-wrap .error-box { max-width: 360px; margin: 0 auto 16px; text-align: left; }
