/* =========================================================================
   Tour-App – Stylesheet
   Farbschema bewusst auf echtes Schwarz (#000) als Hintergrund aufgebaut:
   Auf OLED-Bildschirmen (die meisten aktuellen Smartphones) bleiben
   schwarze Pixel physisch ausgeschaltet -> spürbar geringerer Stromverbrauch
   gegenüber hellen/weißen Oberflächen, gerade bei Dauerbetrieb im Freien.
   ========================================================================= */

:root {
    --bg: #000000;
    --surface: #131510;
    --surface-2: #1c1f18;
    --border: #2b2e24;

    --text: #ECEEE6;
    --text-muted: #9a9e91;
    --text-faint: #5a5e51;

    --accent: #3E9B6F;        /* "Los/Aktiv" – Tour starten, aktueller Stopp */
    --accent-strong: #57C68C;
    --accent-contrast: #04140C;

    --amber: #C98A3E;         /* Hinweis / Info */
    --amber-contrast: #1a1206;

    --danger: #b5544f;

    --pkg-klepa: #4A90D9;      /* Paket-Typ 1: KLEPA */
    --pkg-norna: #B87FE0;      /* Paket-Typ 2: NORNA/SELNA */

    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
}

h1, h2, h3, p { margin: 0; }

a { color: inherit; }

button, input {
    font-family: inherit;
    color: inherit;
}

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

/* ---------- Eyebrow-Labels (kleine Großbuchstaben-Labels wie im Entwurf) ---------- */
.eyebrow {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* ---------- Generisches Seiten-Grundgerüst ---------- */
.screen {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
}

.center-screen {
    justify-content: center;
}

/* ---------- Karten / Panels ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

/* ---------- Formulare ---------- */
.field { margin-bottom: 18px; }

.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="search"],
.field input[type="number"],
.field textarea,
.field select {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-size: 16px; /* verhindert Auto-Zoom auf iOS */
    color: var(--text);
}

.field input:focus,
.field textarea:focus,
.field select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.field textarea { resize: vertical; min-height: 120px; font-family: ui-monospace, monospace; font-size: 14px; }

.hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.4;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 52px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: var(--surface-2);
    color: var(--text);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    -webkit-user-select: none;
    user-select: none;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--accent);
    color: var(--accent-contrast);
}
.btn-primary:active { background: var(--accent-strong); }

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
}

.btn-danger-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--danger);
}

.btn-block { width: 100%; }

.error-box {
    background: rgba(181, 84, 79, 0.14);
    border: 1px solid var(--danger);
    color: #f3d3d1;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 14px;
    margin-bottom: 16px;
}

.info-box {
    background: rgba(62, 155, 111, 0.12);
    border: 1px solid var(--accent);
    color: #cdeedd;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 14px;
    margin-bottom: 16px;
}

/* ---------- Login / Setup ---------- */
.brand-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    background: rgba(62, 155, 111, 0.16);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}
.brand-icon svg { width: 26px; height: 26px; stroke: var(--accent); }

.site-name {
    font-size: 14px;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.lead {
    font-size: 16px;
    color: var(--text);
    margin-bottom: 26px;
    line-height: 1.4;
}

/* ---------- Dashboard: Rayon-Auswahl ---------- */
.rayon-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 20px;
}

.rayon-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 22px 10px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text);
    cursor: pointer;
}
.rayon-btn:active { border-color: var(--accent); color: var(--accent-strong); }

.empty-state {
    margin-top: 24px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
}

/* ---------- Main / Tour-Seite ---------- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 16px 8px;
}

.app-main {
    flex: 1;
    padding: 4px 16px 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-bottom: 110px; /* Platz für fixe Bottom-Nav */
}

.current-stop-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-lg);
    padding: 18px 18px 16px;
}

.current-stop-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.current-stop-street {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.25;
    margin-top: 4px;
}

.current-stop-meta {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.info-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.info-btn[aria-expanded="true"] {
    background: var(--amber);
    color: var(--amber-contrast);
    border-color: var(--amber);
}

.info-panel {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-line;
}
.info-panel[hidden] { display: none; }

/* Karte */
#map {
    height: 220px;
    width: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--surface-2);
}
.leaflet-container { background: var(--surface-2) !important; }

.gps-hint {
    font-size: 12px;
    color: var(--text-muted);
    padding: 2px 4px;
}

.stop-marker {
    width: 30px; height: 30px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    background: var(--accent);
    border: 2px solid var(--accent-contrast);
}
.gps-dot {
    width: 16px; height: 16px;
    border-radius: 50%;
    background: #4A90E2;
    border: 3px solid rgba(74, 144, 226, 0.35);
    box-shadow: 0 0 0 6px rgba(74, 144, 226, 0.18);
}

/* Stopp-Liste */
.stop-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stop-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.stop-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    scroll-margin-top: 8px;
}

/* Während der Tour ist jede Zeile ein anklickbarer <button> (Sprung zu diesem
   Stopp). Bewusst NICHT mit "all: unset" gearbeitet: das setzt ausnahmslos
   jede Eigenschaft zurück (Abstand, Zeilenhöhe, Trennlinie eingeschlossen) und
   gewinnt bei gleicher Spezifität gegen .stop-item je nach Reihenfolge im
   Stylesheet - genau das hatte das Layout zerschossen. Stattdessen werden nur
   die konkreten Browser-Vorgaben für <button> zurückgesetzt (Hintergrund,
   Rahmen, Schrift, Ausrichtung) und dieselben Maße wie .stop-item direkt
   übernommen, damit die Zeile unabhängig von der Regel-Reihenfolge exakt
   gleich aussieht. */
.stop-item-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    padding: 13px 16px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: none;
    margin: 0;
    text-align: left;
    font-family: inherit;
    font-size: 15px;
    color: inherit;
    cursor: pointer;
    scroll-margin-top: 8px;
}
.stop-item-btn:hover,
.stop-item-btn:active {
    background: rgba(255, 255, 255, 0.04);
}

/* Trennstrich am Zeilenende: einmal für die reine Text-Zeile (li.stop-item),
   einmal für die Button-Zeile (Button steckt in <li><form>, ist dort aber
   immer "einziges Kind" - :last-child auf .stop-item selbst würde daher bei
   JEDER Zeile fälschlich greifen). */
.stop-list > li.stop-item:last-child { border-bottom: none; }
.stop-list > li:last-child .stop-item-btn { border-bottom: none; }

.stop-index {
    font-size: 12px;
    color: var(--text-faint);
    width: 22px;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.stop-item.past { color: var(--text-faint); }
.stop-item.past .stop-index { color: var(--text-faint); }

.stop-item.future { color: var(--text); }

.stop-item.current {
    background: rgba(62, 155, 111, 0.14);
    color: var(--text);
    font-weight: 700;
    position: relative;
}
.stop-item.current .stop-index { color: var(--accent-strong); }
.stop-item.current::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent);
}

/* ---------- Bottom-Navigation ---------- */
.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    display: flex;
    justify-content: center;
    padding: 0 16px calc(14px + env(safe-area-inset-bottom));
    pointer-events: none;
}

.nav-capsule {
    pointer-events: auto;
    width: 100%;
    max-width: 448px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 8px 30px rgba(0,0,0,0.55);
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 10.5px;
    letter-spacing: 0.03em;
    padding: 6px 8px;
    cursor: pointer;
    text-decoration: none;
}
.nav-item svg { width: 20px; height: 20px; stroke: currentColor; fill: none; }
.nav-item:active { color: var(--text); }

.nav-item.danger { color: var(--danger); }

.nav-start-btn {
    background: var(--accent);
    color: var(--accent-contrast);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(62, 155, 111, 0.45);
    cursor: pointer;
    flex-shrink: 0;
    margin: -20px 6px 0;
}
.nav-start-btn svg { width: 26px; height: 26px; stroke: var(--accent-contrast); fill: none; }
.nav-start-btn:active { background: var(--accent-strong); }

.nav-back-btn {
    background: var(--surface-2);
    color: var(--text);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.nav-back-btn svg { width: 20px; height: 20px; }

.nav-next-btn {
    flex: 1;
    height: 60px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-contrast);
    border: none;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
}
.nav-next-btn:active { background: var(--accent-strong); }

.nav-logout-corner {
    position: absolute;
    top: 16px;
    right: 16px;
}

/* ---------- Lookup-Overlay ---------- */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.72);
    display: flex;
    align-items: flex-end;
    z-index: 40;
}
.overlay[hidden] { display: none; }

.overlay-sheet {
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 22px 22px 0 0;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.close-btn {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 34px; height: 34px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
}

.lookup-results {
    margin-top: 14px;
    overflow-y: auto;
    list-style: none;
    padding: 0;
}
.lookup-results li {
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
}
.lookup-results .company-name { font-weight: 600; }
.lookup-results .company-street { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.lookup-empty { color: var(--text-muted); font-size: 14px; padding: 10px 4px; }

/* ---------- Admin ---------- */
.admin-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.admin-nav a {
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    text-decoration: none;
    color: var(--text-muted);
}
.admin-nav a.active { color: var(--accent-strong); border-color: var(--accent); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }

.section-title { font-size: 18px; font-weight: 700; margin: 28px 0 4px; }
.section-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }

/* ---------- Pakete (nur während der Tour angezeigt) ---------- */

/* Farbiger Punkt: sowohl in der Stopp-Liste als auch in Formular/Übersicht */
.pkg-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.pkg-dot.pkg-klepa { background: var(--pkg-klepa); }
.pkg-dot.pkg-norna { background: var(--pkg-norna); }

/* Punkt(e) rechts in einer Stopp-Zeile - .stop-item/.stop-item-btn sind
   bereits display:flex, margin-left:auto schiebt sie an den rechten Rand. */
.pkg-dots {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
    flex-shrink: 0;
}

/* Typ-Auswahl im Erfassungsformular */
.package-type-choice {
    display: flex;
    gap: 10px;
}
.package-type-option {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    cursor: pointer;
    font-size: 14px;
}
.package-type-option input[type="radio"] {
    margin: 0;
    accent-color: var(--accent);
}

/* Liste der heute bereits erfassten Pakete (im Pakete-Overlay) */
.package-entry {
    display: flex;
    align-items: center;
    gap: 10px;
}
.package-entry-text { flex: 1; }
.package-delete {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}
