/* Fahrer-App – mobile-first Styles (Phase 7.2/7.3). Baut auf app.css-Tokens auf.
   Ziel: großflächige Touch-Bedienung am Umzugstag, ein Daumen, Sonnenlicht. */

:root {
    /* MARKE – folgt der Vereinsfarbe. Die var()-Indirektion löst sich erst bei der Benutzung auf,
       funktioniert also unabhängig davon, ob branding_head_style() vor oder nach dieser Datei steht.
       Hieß früher --fahrer-red/-dark und war fest #c62828: die Fahrer-App blieb rot, egal was der
       Verein eingestellt hatte (das Layout band branding_head_style() gar nicht erst ein). */
    --fahrer-brand: var(--primary);
    --fahrer-on-brand: var(--on-primary);

    /* SEMANTIK – hängt bewusst NICHT am Branding und wird nie mitgefärbt:
       Grün heißt Ankunft, Blau heißt Abfahrt. Diese Bedeutung muss in jeder Installation
       dieselbe bleiben, sonst liest ein Fahrer am Umzugstag die Farbe falsch. */
    --fahrer-arrive: #2e7d32;
    --fahrer-depart: #1565c0;
}
:root[data-theme="dark"] {
    --fahrer-arrive: #3ea864;
    --fahrer-depart: #4a86d0;
}

.fahrer-body {
    margin: 0;
    background: var(--bg-soft);
    -webkit-text-size-adjust: 100%;
    overscroll-behavior-y: none;
}

/* ---------- Flash ---------- */
.fahrer-flash {
    padding: .8rem 1rem;
    font-weight: 600;
    text-align: center;
}
.fahrer-flash.flash-error { background: var(--danger-soft); color: var(--danger); }
.fahrer-flash.flash-success { background: var(--success-soft); color: var(--success); }

/* ---------- Zentrierte Karten (Login / Consent) ---------- */
.fahrer-center {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.2rem;
}
.fahrer-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.6rem 1.4rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .06);
}
.fahrer-card h1 { margin: 0 0 .2rem; font-size: 1.5rem; }
.fahrer-sub { margin: 0 0 1.2rem; color: var(--muted); }
.fahrer-card label { display: block; margin: .9rem 0 .3rem; font-weight: 600; font-size: .95rem; }
.fahrer-card input[type="text"],
.fahrer-card input[type="password"] {
    width: 100%;
    font-size: 1.1rem;
    padding: .75rem .8rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    color: var(--ink);
}
.fahrer-consent-text {
    max-height: 42vh;
    overflow-y: auto;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: .8rem;
    font-size: .92rem;
    line-height: 1.55;
    color: var(--ink);
}
.fahrer-check {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    margin-top: 1rem;
    font-weight: 600;
    cursor: pointer;
}
.fahrer-check input { width: 1.4rem; height: 1.4rem; margin-top: .1rem; flex: none; }

/* ---------- Buttons ---------- */
.fahrer-btn {
    display: block;
    width: 100%;
    border: none;
    border-radius: 10px;
    font: inherit;
    font-weight: 700;
    font-size: 1.15rem;
    padding: .95rem 1rem;
    color: var(--fahrer-on-brand);
    background: var(--fahrer-brand);
    cursor: pointer;
    text-align: center;
}
.fahrer-btn:disabled { opacity: .5; cursor: not-allowed; }
.fahrer-btn-primary { background: var(--fahrer-brand); color: var(--fahrer-on-brand); }
.fahrer-btn-ghost {
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    font-size: 1rem;
    padding: .6rem;
}
.fahrer-link,
.fahrer-link-light {
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}
.fahrer-link { color: var(--primary-ink); }
.fahrer-link-light { color: color-mix(in srgb, var(--fahrer-on-brand) 92%, transparent); }
.fahrer-link-muted { color: var(--muted); font-size: .85rem; }
.fahrer-footer { padding: 1.4rem 1rem 2.5rem; margin-top: 1rem; text-align: center; border-top: 1px solid var(--line); }
.fahrer-footer p { color: var(--muted); font-size: .78rem; margin: .55rem 0 0; }

/* ---------- Touren-Liste ---------- */
.fahrer-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .8rem 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    font-weight: 600;
}
.fahrer-list { padding-bottom: 2rem; }
.fahrer-list h1 { font-size: 1.4rem; margin: 1rem 0 .5rem; }
.fahrer-empty { color: var(--muted); padding: 1.5rem 1rem; text-align: center; }
.fahrer-tour-item {
    display: block;
    margin: .6rem 1rem;
    padding: 1rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--ink);
}
.fahrer-tour-item:active { background: var(--bg-soft); }
.fahrer-tour-name { font-weight: 700; font-size: 1.1rem; }
.fahrer-tour-meta { color: var(--muted); font-size: .9rem; margin-top: .25rem; }

/* ---------- Tour-Ansicht (Timeline + Riesen-Buttons) ---------- */
.fahrer-app {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}
.fahrer-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--fahrer-brand);
    color: var(--fahrer-on-brand);
    padding: .7rem 1rem .8rem;
}
.fahrer-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
}
.fahrer-header-row strong { font-size: 1.1rem; text-align: center; flex: 1; }
.fahrer-header-sub { margin-top: .3rem; font-size: .85rem; opacity: .9; text-align: center; }

.fahrer-banner {
    background: var(--warning-soft);
    color: var(--warning);
    padding: .7rem 1rem;
    font-size: .9rem;
    font-weight: 600;
    text-align: center;
}

.fahrer-timeline {
    flex: 1;
    padding: .5rem .8rem 1rem;
}
/* Übergang zwischen zwei Stopps: Fahrt/Lauf + Reserve/Wartezeit (aus dem übernommenen Plan). */
.fahrer-leg {
    font-size: .82rem;
    color: var(--muted);
    padding: .1rem 0 .1rem .3rem;
    line-height: 1.3;
}
.fahrer-leg-wait { opacity: .9; }

.fahrer-stop {
    display: flex;
    gap: .7rem;
    padding: .8rem .3rem;
    border-bottom: 1px solid var(--line);
}
.fahrer-stop.is-active {
    background: var(--bg);
    border-left: 4px solid var(--primary-ink);
    border-radius: 8px;
    padding-left: .6rem;
    box-shadow: 0 1px 6px rgba(0, 0, 0, .08);
}
.fahrer-stop.status-done { opacity: .62; }
.fahrer-stop.status-skipped { opacity: .55; }
.fahrer-stop-time {
    flex: none;
    width: 3.2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 1.05rem;
    color: var(--ink);
}
.fahrer-stop-body { flex: 1; min-width: 0; }
.fahrer-stop-label { font-weight: 600; font-size: 1.02rem; }
.fahrer-tag {
    display: inline-block;
    margin-left: .4rem;
    padding: .05rem .45rem;
    font-size: .72rem;
    font-weight: 700;
    border-radius: 999px;
    background: var(--bg-soft);
    color: var(--muted);
    vertical-align: middle;
}
.fahrer-stop-addr { color: var(--muted); font-size: .9rem; margin-top: .15rem; }
.fahrer-stop-state { margin-top: .35rem; }
.fahrer-badge {
    display: inline-block;
    padding: .12rem .5rem;
    border-radius: 6px;
    font-size: .82rem;
    font-weight: 700;
}
.badge-done { background: var(--success-soft); color: var(--success); }
.badge-arrived { background: var(--warning-soft); color: var(--warning); }
.badge-skip { background: var(--bg-soft); color: var(--muted); }
.fahrer-stop-note { margin-top: .3rem; font-size: .88rem; color: var(--ink); }

.fahrer-stop-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-top: .5rem;
}
.fahrer-mini {
    font: inherit;
    font-size: .85rem;
    font-weight: 600;
    padding: .35rem .7rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg);
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
}
.fahrer-mini:active { background: var(--bg-soft); }

/* Bodennaher Aktions-Balken mit Riesen-Button */
.fahrer-actions {
    position: sticky;
    bottom: 0;
    z-index: 10;
    padding: .8rem;
    padding-bottom: calc(.8rem + env(safe-area-inset-bottom, 0));
    background: var(--bg);
    border-top: 1px solid var(--line);
}
.fahrer-actions .fahrer-btn {
    min-height: 22vh;
    font-size: 1.7rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .3rem;
}
/* Schriftfarbe hier explizit, NICHT von .fahrer-btn geerbt: die erbte Farbe gehört zur Marke.
   Bei einer hellen Vereinsfarbe (Gelb) wäre sie dunkel — auf dem grünen Ankunft-Button also
   unlesbar. Diese vier Flächen sind Semantik bzw. neutral und für weiße Schrift ausgelegt. */
.fahrer-btn-arrive { background: var(--fahrer-arrive); color: #fff; }
.fahrer-btn-depart { background: var(--fahrer-depart); color: #fff; }
.fahrer-btn-done { background: var(--muted); color: #fff; }
.fahrer-btn-disabled { background: var(--muted); color: #fff; }
.fahrer-btn-sub { font-size: .95rem; font-weight: 600; opacity: .9; }

/* ---------- P4: JETZT-Marker (pulsierend) + Peek-Schutz ---------- */
.fahrer-jetzt-badge {
    display: inline-block;
    background: var(--fahrer-brand);
    color: var(--fahrer-on-brand);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .05em;
    padding: .1rem .5rem;
    border-radius: 999px;
    vertical-align: middle;
    animation: fahrer-pulse 1.6s ease-in-out infinite;
}
.fahrer-stop.is-jetzt { animation: fahrer-jetzt-glow 1.9s ease-in-out infinite; }
@keyframes fahrer-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}
@keyframes fahrer-jetzt-glow {
    0%, 100% { box-shadow: 0 1px 6px rgba(0, 0, 0, .08); }
    /* Leuchtring in der Vereinsfarbe – war fest das alte Rot (198,40,40). */
    50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--fahrer-brand) 20%, transparent), 0 1px 6px rgba(0, 0, 0, .08); }
}
@media (prefers-reduced-motion: reduce) {
    .fahrer-jetzt-badge, .fahrer-stop.is-jetzt { animation: none; }
}

/* Peek: der aktuelle Stopp ist aus dem Blick gescrollt -> Erfassung sperren,
   stattdessen "Zurueck zum aktuellen Stopp" zeigen (verhindert Fehl-Erfassung). */
.fahrer-peek-return {
    display: none;
    width: 100%;
    border: none;
    border-radius: 10px;
    font: inherit;
    font-weight: 700;
    font-size: 1.15rem;
    padding: 1.1rem 1rem;
    color: #fff;
    background: #37474f;
    cursor: pointer;
}
.fahrer-app.is-peeking .fahrer-peek-return { display: block; }
.fahrer-app.is-peeking .fahrer-actions .fahrer-btn { display: none; }

/* ---------- P5: GPS-Geofencing – Umschalter + Ampel-Distanz ---------- */
.fahrer-gps {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    padding: .35rem .2rem .75rem;
}
.fahrer-gps-toggle {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 600;
    cursor: pointer;
}
.fahrer-gps-toggle input { width: 1.3rem; height: 1.3rem; flex: none; }
.fahrer-gps-toggle input:disabled { opacity: .5; }
.fahrer-gps-status {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: .9rem;
    padding: .18rem .55rem;
    border-radius: 6px;
    color: var(--muted);
    white-space: nowrap;
}
.fahrer-gps-status.gps-green { background: var(--success-soft); color: var(--success); }
.fahrer-gps-status.gps-yellow { background: var(--warning-soft); color: var(--warning); }
.fahrer-gps-status.gps-red { background: var(--danger-soft); color: var(--danger); }

/* ---------- Fahrer-Einteilung: eigener Abschnitt / fremde Stopps / Übergabe ---------- */
:root { --fahrer-mine: #1a6d88; }
:root[data-theme="dark"] { --fahrer-mine: #4fb6d6; }
.fahrer-stop.is-mine {
    border-left: 4px solid var(--fahrer-mine);
    border-radius: 8px;
    padding-left: .6rem;
}
/* Der aktuelle (JETZT-)Stopp bleibt rot markiert, auch wenn er „meiner" ist. */
.fahrer-stop.is-active.is-mine { border-left-color: var(--primary-ink); }
.fahrer-stop.is-other { opacity: .5; }
.fahrer-tag-driver {
    background: color-mix(in srgb, var(--fahrer-mine) 16%, var(--bg-soft));
    color: var(--fahrer-mine);
}
.fahrer-handover {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin: .7rem .1rem;
    font-size: .8rem;
    font-weight: 700;
    color: var(--muted);
}
.fahrer-handover::before, .fahrer-handover::after { content: ""; height: 1px; flex: 1; background: currentColor; opacity: .35; }
.fahrer-handover.is-mine { color: var(--fahrer-mine); }
