/* ============================================================
   Route Tracker im Design der Reise-Tools (wie SD Migrator)
   Wird NACH styles.css geladen. Die gemeinsamen Tokens kommen
   aus sd-migrator static/tokens.css; bei Änderungen beide anpassen.
   Kopfzeile oben, Bereiche als untere Menüleiste, Kompaktmodus
   im Querformat mit wenig Höhe als linke Leiste.
   ============================================================ */

/* ── Gemeinsame Tokens (dunkel ist Standard) ─────────────── */
:root { color-scheme: dark; --bg: #0d1218; --surface: #151d27; --text: #eff4f8; --muted: #aab9c9; --line: #364657; --accent: #b8ed78; --ink: #17210c; --warn: #ffbf7b; --highlight: #203125; --alert: #432c1d; --state-warn: #ffd703; --state-crit: #ff3232; }
:root[data-theme=light] { color-scheme: light; --bg: #edf1f4; --surface: #ffffff; --text: #17232c; --muted: #485c6a; --line: #a0afba; --accent: #32621b; --ink: #ffffff; --warn: #8a3a00; --highlight: #e6f1df; --alert: #fff0df; --state-warn: #ffd703; --state-crit: #e00000; }

/* ── Alte Variablen auf die Tokens umbiegen ──────────────── */
:root, :root[data-theme] {
    --primary-color: var(--text);
    --secondary-color: var(--accent);
    --success-color: var(--accent);
    --warning-color: var(--warn);
    --error-color: var(--state-crit);
    --border-radius: 10px;
    --transition: border-color .15s ease, background-color .15s ease, color .15s ease;
    --global-bg: var(--bg);
    --boxes-bg: var(--surface);
    --boxes-bg-secondary: var(--bg);
    --button-bg: var(--accent);
    --text-primary: var(--text);
    --text-secondary: var(--muted);
    --text-color: var(--text);
    --border-color: var(--line);
    --shadow: none;
    --shadow-hover: 0 6px 18px #0006;
    --nav-h: 66px;
}

html, body { background: var(--bg); color: var(--text); }
body { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
    outline: 3px solid var(--accent); outline-offset: 2px;
}

/* ── Kopfzeile mit Wortmarke ─────────────────────────────── */
.header {
    margin: 0; border-radius: 0; box-shadow: none;
    padding: 10px 3vw; min-height: 0;
    background: var(--bg); color: var(--text);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 1100;
}
.header--dev { border-bottom: 3px solid var(--state-crit); }
.header-brand { align-items: center; gap: 12px; }
.header .app-icon { display: none; }
.header .logo { display: block; width: 44px; height: 44px; flex: 0 0 auto; }
.logo-card { fill: #2a3320; }
:root[data-theme=light] .logo-card { fill: #17210c; }
.logo-road { fill: none; stroke: #b8ed78; stroke-width: 5; stroke-linecap: round; }
.logo-pin { fill: #b8ed78; }
.logo-pin-hole { fill: #2a3320; }
:root[data-theme=light] .logo-pin-hole { fill: #17210c; }
.brand-name.wordmark {
    font: 700 26px/1.05 "Avenir Next", "Helvetica Neue", Arial, sans-serif;
    letter-spacing: -0.3px; color: var(--text); white-space: nowrap;
}
.wm-accent { color: #b8ed78; }
:root[data-theme=light] .wm-accent { color: #32621b; }
.brand-version { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.dev-badge { background: var(--state-crit); color: #fff; border-radius: 6px; }
.user-greeting { color: var(--text); font-weight: 650; }

/* Kopfzeilen-Knöpfe: Fläche + Linie wie im SD Migrator */
.theme-toggle, .logout-btn, .btn-switch-account, .btn-help, #promoteBtn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 40px; padding: 6px 14px;
    border: 1px solid var(--line) !important; border-radius: 10px !important;
    background: var(--surface) !important; color: var(--text) !important;
    font: inherit; font-size: 15px; font-weight: 650; text-decoration: none; cursor: pointer;
    box-shadow: none;
}
.btn-help { width: 40px; padding: 0; }
.theme-toggle:hover, .logout-btn:hover, .btn-switch-account:hover, .btn-help:hover, #promoteBtn:hover {
    border-color: var(--accent) !important; background: var(--surface) !important;
}
.logout-btn { border-color: var(--state-crit) !important; }
#promoteBtn { border-color: var(--warn) !important; color: var(--warn) !important; margin-right: 0 !important; }
.language-switch { gap: 6px; }
.lang-option {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 40px; min-height: 40px; padding: 6px;
    border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.lang-option img { width: 24px; height: 16px; border-radius: 2px; }
.lang-option.active { border: 2px solid var(--accent); background: var(--highlight); }

/* ── Arbeitsfläche ───────────────────────────────────────── */
.main-content {
    margin: 0 auto; width: 100%; max-width: 1560px;
    padding: 14px 3vw 14px;
}
/* Platz für die feste Menüleiste unter dem letzten Inhalt (Fußzeile) */
body[data-can-manage="true"] { padding-bottom: var(--nav-h); }
.app-footer { margin: 0 auto 10px; width: 100%; max-width: 1560px; padding: 10px 3vw; border-top-color: var(--line); }
.footer-link, .footer-copy { color: var(--muted); }
.card, .modal-content {
    background: var(--surface); color: var(--text);
    border: 1px solid var(--line); border-radius: 14px; box-shadow: none;
}
.card:hover { box-shadow: none; transform: none; }
.card .card, .card-inner { background: var(--bg); }
.section-header { border-bottom-color: var(--line); }
.section-header h2, .card-header h2, .card-header h3 { color: var(--text); }
.section-header p, .card-header p { color: var(--muted); }

/* Buttons: neutral mit Linie, Akzent nur für Hauptaktionen */
.btn {
    background: var(--surface); color: var(--text);
    border: 1px solid var(--line); border-radius: 10px;
    font-weight: 650; box-shadow: none; transform: none;
}
.btn:hover { background: var(--surface); color: var(--text); border-color: var(--accent); transform: none; box-shadow: none; }
.btn-primary, .btn-success, .btn-primary:hover, .btn-success:hover {
    background: var(--accent); color: var(--ink); border-color: var(--accent);
}
.btn-primary:hover, .btn-success:hover { filter: brightness(1.08); }
.btn-warning, .btn-warning:hover { background: var(--surface); color: var(--warn); border-color: var(--warn); }
.btn-danger, .btn-danger:hover { background: var(--surface); color: var(--state-crit); border-color: var(--state-crit); }

/* Formulare */
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date],
input[type=time], input[type=search], input[type=url], select, textarea,
.form-input, .form-select, .form-textarea {
    background: var(--bg); color: var(--text);
    border: 1px solid var(--line); border-radius: 10px;
}
input:focus, select:focus, textarea:focus,
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); box-shadow: none; }
input[type=checkbox], input[type=radio], input[type=range] { accent-color: var(--accent); }
label, .form-label { color: var(--text); }

/* Tabellen und Listen */
table { color: var(--text); }
th { color: var(--muted); border-bottom-color: var(--line); }
td { border-bottom-color: var(--line); }
tr:hover td { background: var(--highlight); }

/* Karte */
.leaflet-container { background: var(--bg); }
.leaflet-bar a { background: var(--surface); color: var(--text); border-bottom-color: var(--line); }
.leaflet-bar a:hover { background: var(--highlight); color: var(--text); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); }
#mapLoadingBar { background: var(--accent); animation: none; }

/* Dialoge */
.modal { background: #000a; backdrop-filter: none; }
.modal-header, .modal-footer { border-color: var(--line); }

/* ── Untere Menüleiste (die Bereiche) ────────────────────── */
.sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100;
    margin: 0; border-radius: 0; box-shadow: none;
    display: flex; flex-wrap: nowrap; justify-content: center; gap: 10px;
    padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
}
.nav-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-width: 150px; min-height: 48px; padding: 8px 16px;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--surface); color: var(--text);
    font: inherit; font-size: 16px; font-weight: 650;
}
.nav-btn:hover { background: var(--surface); color: var(--text); border-color: var(--accent); }
.nav-btn.active { background: var(--surface); color: var(--accent); border-color: var(--accent); }
.nav-icon { display: inline; font-size: 18px; }

/* ── Tablet / schmal ─────────────────────────────────────── */
@media (max-width: 1100px) {
    .nav-btn { min-width: 0; flex: 1; padding: 8px; }
}
@media (max-width: 768px) {
    .header { margin: 0; padding: 8px 12px; }
    .header .logo { width: 36px; height: 36px; }
    .brand-name.wordmark { font-size: 21px; }
    .sidebar { margin: 0; padding: 6px; gap: 6px; }
    .nav-btn { font-size: 20px; padding: 6px; min-height: 48px; }
    .nav-label { display: none; }
    .main-content { margin: 0; padding: 10px 10px; }
    .card { border-radius: 12px; }
    /* Kopfzeile: Zeile 1 Marke + Hell/Dunkel + Sprache, Zeile 2 Name + Konto */
    .brand-name.wordmark { font-size: 19px; }
    .header .logo { width: 30px; height: 30px; }
    .brand-version, button.dev-badge { display: none; }
    .header-brand { gap: 8px; align-items: center; }
    .header-controls { gap: 4px; }
    .theme-toggle, .logout-btn, .btn-switch-account { min-height: 36px; padding: 4px 10px; font-size: 14px; }
    .lang-option { min-width: 36px; min-height: 36px; width: 36px; height: 36px; padding: 4px; }
    .lang-option img { width: 22px; height: 15px; }
}

/* ── Kompaktmodus: Querformat mit wenig Höhe (wie SD Migrator) ──
   Bereiche als linke Leiste, die Arbeitsfläche bekommt die volle Höhe. */
@media (orientation: landscape) and (max-height: 700px) {
    :root, :root[data-theme] { --rail-w: 104px; }
    .header { padding: 4px 10px; }
    .header .logo { width: 30px; height: 30px; }
    .brand-name.wordmark { font-size: 18px; }
    .theme-toggle, .logout-btn, .btn-switch-account, .btn-help, #promoteBtn, .lang-option { min-height: 34px; padding-top: 2px; padding-bottom: 2px; }
    .btn-help, .lang-option { min-width: 34px; }
    .sidebar {
        top: var(--header-h, 44px); bottom: 0; right: auto; width: var(--rail-w);
        flex-direction: column; justify-content: flex-start; gap: 6px;
        padding: 6px; border-top: 0; border-right: 1px solid var(--line); overflow-y: auto;
    }
    .nav-btn { min-width: 0; width: 100%; flex: 0 0 auto; min-height: 52px; flex-direction: column; gap: 2px; font-size: 12px; line-height: 1.2; padding: 4px; }
    .nav-label { display: block; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
    body[data-can-manage="true"] { padding-bottom: 0; }
    .main-content { max-width: none; padding: 6px 10px; }
    body[data-can-manage="true"] .main-content { margin-left: var(--rail-w); width: auto; }
    .app-footer { display: none; }
}

/* Vollbildkarte: Leisten ausblenden (styles.css blendet Kopf + Menü schon aus) */
body.map-only-mode { display: block; }
body.map-only-mode .main-content { padding: 0; max-width: none; }
