/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: #1e293b;
    background: #f8fafc;
}

/* ── App Layout ────────────────────────────────────────────────────────────── */
.layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
    width: 320px;
    min-width: 280px;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    box-shadow: 2px 0 8px rgba(0,0,0,.06);
}

.sidebar-header {
    padding: 16px 20px;
    background: #1e293b;
    color: #f8fafc;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: .3px;
}

.logo { display: flex; align-items: center; gap: 8px; }
.logo img { border-radius: 6px; display: block; flex-shrink: 0; }

.panel {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
}

.panel h2 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #64748b;
    margin-bottom: 12px;
}

.panel h3 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #64748b;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Sprachauswahl (unten links) ────────────────────────────────────────────── */
.language-bar {
    margin-top: auto;
    padding: 12px 20px;
    border-top: 1px solid #f1f5f9;
    background: #fff;
}

.lang-select {
    position: relative;
    width: 100%;
}

.lang-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
}

.lang-trigger:hover { background: #f1f5f9; }

.lang-select.open .lang-trigger {
    border-color: #34b6f0;
    box-shadow: 0 0 0 2px rgba(52,182,240,.2);
}

.lang-chevron {
    margin-left: auto;
    transition: transform .15s ease;
}

.lang-select.open .lang-chevron { transform: rotate(180deg); }

.lang-dropdown {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 0;
    right: 0;
    list-style: none;
    margin: 0;
    padding: 4px 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    z-index: 100;
}

.lang-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    color: #1e293b;
}

.lang-item:hover { background: #f1f5f9; }
.lang-item.selected { color: #0c4a6e; background: #e0f2fe; }

.lang-item .flag,
.lang-trigger .flag {
    width: 22px;
    height: 16px;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0,0,0,.08);
    flex-shrink: 0;
    display: block;
}

/* ── File Input ─────────────────────────────────────────────────────────────── */
.file-label {
    display: block;
    cursor: pointer;
    margin-bottom: 12px;
}

.file-label input[type=file] {
    /* Visually hide the native input but keep it accessible */
    position: absolute;
    width: 1px; height: 1px;
    opacity: 0;
    overflow: hidden;
}

.file-label span {
    display: block;
    padding: 8px 12px;
    border: 1.5px dashed #cbd5e1;
    border-radius: 6px;
    color: #64748b;
    font-size: 13px;
    transition: border-color .15s, background .15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-label:hover span {
    border-color: #2563eb;
    background: #eff6ff;
    color: #2563eb;
}

/* ── Form ───────────────────────────────────────────────────────────────────── */
.form-row {
    margin-bottom: 10px;
}

.form-row label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 4px;
}

.form-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    color: #1e293b;
    background: #fff;
    outline: none;
    color-scheme: light;
    transition: border-color .15s;
}

/* Make the native date/time picker indicator clearly clickable */
input[type="datetime-local"].form-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: .65;
    padding: 2px;
}
input[type="datetime-local"].form-input::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.form-input:focus { border-color: #2563eb; box-shadow: 0 0 0 2px #bfdbfe; }

.input-unit {
    display: flex;
    align-items: center;
    gap: 6px;
}

.input-unit .form-input { flex: 1; }

.input-unit span {
    font-size: 12px;
    color: #94a3b8;
    white-space: nowrap;
}

/* ── Button ─────────────────────────────────────────────────────────────────── */
.btn-primary {
    width: 100%;
    margin-top: 4px;
    padding: 9px 16px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background .15s;
}

.btn-primary:hover:not(:disabled) { background: #1d4ed8; }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; }

/* ── Error Banner ───────────────────────────────────────────────────────────── */
.error-banner {
    margin-top: 10px;
    padding: 8px 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #b91c1c;
    font-size: 12px;
    line-height: 1.5;
}

/* ── Route Meta ─────────────────────────────────────────────────────────────── */
.route-meta h2 {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.meta-label {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
}

.meta-value {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

/* ── Badge ───────────────────────────────────────────────────────────────────── */
.badge {
    background: #e2e8f0;
    color: #475569;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 999px;
    text-transform: none;
    letter-spacing: 0;
}

/* ── Marker List ────────────────────────────────────────────────────────────── */
.marker-list-panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.marker-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.marker-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .12s;
}

.marker-row:hover { background: #f1f5f9; }
.marker-row.selected { background: #dbeafe; border-left: 3px solid #3b82f6; padding-left: 13px; }

.marker-row.pending { opacity: .65; }

.marker-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.marker-km {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}

.marker-desc {
    font-size: 14px;
    font-weight: 500;
    color: #0f172a;
}

.marker-temp, .marker-wind, .marker-precip, .marker-eta, .marker-elev {
    font-size: 13px;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 4px;
}

.loading-text {
    font-size: 12px;
    color: #94a3b8;
    font-style: italic;
}

/* ── Map ────────────────────────────────────────────────────────────────────── */
.map-wrapper {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

.map-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(248,250,252,.75);
    backdrop-filter: blur(4px);
    gap: 12px;
    font-size: 14px;
    color: #475569;
    z-index: 9999;
}

/* ── Filter FABs (mirror MAUI right-edge filter buttons) ─────────────────────── */
.filter-fabs {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 800;
}

.filter-fabs .fab {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #94a3b8;
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
    transition: background .15s, transform .1s;
}

.filter-fabs .fab:hover {
    transform: scale(1.08);
}

.filter-fabs .fab.active {
    background: #2563eb;
}

.filter-fabs .fab:disabled {
    background: #cbd5e1;
    color: rgba(255,255,255,.85);
    opacity: .55;
    cursor: not-allowed;
}

.filter-fabs .fab:disabled:hover {
    transform: none;
}

/* ── Leaflet Popup (dark + semi-transparent, matches marker pills) ───────────── */
.leaflet-popup-content-wrapper {
    background: rgba(0,0,0,.59);
    color: #e8e8e8;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,.4);
    backdrop-filter: blur(2px);
}

.leaflet-popup-content-wrapper strong { color: #fff; }

.leaflet-popup-content { margin: 10px 12px; font-size: 13px; line-height: 1.6; }

.leaflet-popup-tip {
    background: rgba(0,0,0,.59);
    box-shadow: none;
}

.leaflet-popup-close-button { color: #cbd5e1 !important; }
.leaflet-popup-close-button:hover { color: #fff !important; }
.leaflet-popup-content a { color: #93c5fd; }

/* ── Marker declutter fade (mirrors MarkerVisibilityService opacity fade) ────── */
.leaflet-marker-icon { transition: opacity .2s ease; }
.leaflet-marker-icon.lm-hidden { opacity: 0; pointer-events: none; }

/* ── Spinner ────────────────────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex-shrink: 0;
}

.spinner.large {
    width: 36px;
    height: 36px;
    border-color: #e2e8f0;
    border-top-color: #2563eb;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Leaflet Marker Override ────────────────────────────────────────────────── */
.rp-marker {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2.5px solid rgba(255,255,255,.8);
    box-shadow: 0 2px 6px rgba(0,0,0,.35);
    font-size: 14px;
    line-height: 1.1;
    color: #fff;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: transform .12s;
}

.rp-marker:hover { transform: scale(1.15); }

.rp-marker span {
    font-size: 11px;
    line-height: 1;
    color: rgba(255,255,255,.95);
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .layout { flex-direction: column; position: relative; height: 100vh; height: 100dvh; }

    /* No route: sidebar full screen, map hidden */
    .layout:not(.has-route) .sidebar {
        width: 100%; max-width: 100%; max-height: none;
        flex: 1; overflow-y: auto;
        border-right: none;
    }
    .layout:not(.has-route) .map-wrapper { display: none; }
    .layout:not(.has-route) .bottom-sheet { display: none; }

    /* Has route: map full screen, sidebar hidden, bottom sheet overlay */
    .layout.has-route .sidebar { display: none; }
    .layout.has-route .map-wrapper {
        position: fixed; inset: 0; z-index: 1;
    }
    .layout.has-route .filter-fabs { bottom: 80px; top: auto; transform: none; }
    .layout.has-route .bottom-sheet { display: flex; }
}

/* ── Bottom Sheet (mobile only, mirrors MAUI BottomSheet.cs) ────────────────── */
.bottom-sheet {
    display: none;                        /* hidden on desktop */
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 1000;
    flex-direction: column;
    background: #1e1e1e;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -2px 16px rgba(0,0,0,.35);
    max-height: 85vh;
    max-height: 85dvh;
    touch-action: none;
    user-select: none;
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    will-change: transform;
}

.bottom-sheet .sheet-handle {
    width: 40px; height: 6px;
    background: #555;
    border-radius: 3px;
    margin: 10px auto 6px;
    flex-shrink: 0;
}

.bottom-sheet .sheet-stripe {
    padding: 8px 16px 10px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}

.bottom-sheet .sheet-stripe h2 {
    font-size: 15px; font-weight: 700; color: #f1f5f9;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin: 0 0 2px;
}

.bottom-sheet .sheet-stripe .stripe-meta {
    font-size: 12px; color: #94a3b8;
    display: flex; gap: 12px; flex-wrap: wrap;
}

.bottom-sheet .sheet-stripe .stripe-meta span {
    white-space: nowrap;
}

.bottom-sheet .sheet-body {
    flex: 1; min-height: 0;
    overflow-y: auto;
    display: flex; flex-direction: column;
    touch-action: pan-y;   /* allow scroll inside the sheet */
}

/* Marker list inside bottom sheet (light-on-dark) */
.bottom-sheet .marker-list-panel {
    flex: 1; min-height: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
    padding: 12px 16px;
}

.bottom-sheet .marker-list-panel h3 {
    font-size: 12px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .6px; color: #94a3b8; margin-bottom: 8px;
    display: flex; align-items: center; gap: 8px;
}

.bottom-sheet .marker-list {
    flex: 1; display: flex; flex-direction: column;
    gap: 3px; overflow-y: auto;
}

.bottom-sheet .marker-row {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px; border-radius: 8px;
    cursor: pointer;
    transition: background .12s;
}

.bottom-sheet .marker-row:hover { background: rgba(255,255,255,.06); }
.bottom-sheet .marker-row.selected { background: rgba(59,130,246,.18); border-left: 3px solid #3b82f6; padding-left: 7px; }
.bottom-sheet .marker-row.pending { opacity: .55; }

.bottom-sheet .marker-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bottom-sheet .marker-km { font-size: 14px; font-weight: 700; color: #e2e8f0; }
.bottom-sheet .marker-desc { font-size: 13px; font-weight: 500; color: #cbd5e1; }
.bottom-sheet .marker-temp,
.bottom-sheet .marker-wind,
.bottom-sheet .marker-precip,
.bottom-sheet .marker-eta,
.bottom-sheet .marker-elev {
    font-size: 12px; color: #94a3b8;
    display: flex; align-items: center; gap: 4px;
}
.bottom-sheet .loading-text { font-size: 11px; color: #64748b; font-style: italic; }

/* Language bar inside bottom sheet */
.bottom-sheet .sheet-footer {
    padding: 10px 16px 14px;
    border-top: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
    display: flex; flex-direction: column; gap: 4px;
}

.bottom-sheet .lang-trigger {
    width: 100%; display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    font-size: 13px; font-weight: 600; color: #e2e8f0;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 8px; cursor: pointer; text-align: left;
}

.bottom-sheet .lang-trigger:hover { background: rgba(255,255,255,.1); }

.bottom-sheet .lang-select.open .lang-trigger {
    border-color: #34b6f0;
    box-shadow: 0 0 0 2px rgba(52,182,240,.25);
}

.bottom-sheet .lang-select { position: relative; width: 100%; }

.bottom-sheet .lang-dropdown {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 0; right: 0;
    list-style: none; margin: 0; padding: 4px 0;
    background: #2a2a2a;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.4);
    z-index: 1100;
}

.bottom-sheet .lang-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; font-size: 13px;
    cursor: pointer; color: #e2e8f0;
}

.bottom-sheet .lang-item:hover { background: rgba(255,255,255,.08); }
.bottom-sheet .lang-item.selected { color: #7dd3fc; background: rgba(56,189,248,.12); }

.bottom-sheet .lang-item .flag,
.bottom-sheet .lang-trigger .flag {
    width: 22px; height: 16px;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(255,255,255,.15);
    flex-shrink: 0; display: block;
}

.bottom-sheet .lang-chevron { margin-left: auto; transition: transform .15s ease; }
.bottom-sheet .lang-select.open .lang-chevron { transform: rotate(180deg); }

.bottom-sheet .impressum-link {
    display: block; width: 100%; margin-top: 2px;
    padding: 4px 0;
    background: none; border: none;
    font-size: 11px; color: #64748b;
    text-align: center; cursor: pointer;
    text-decoration: none;
    transition: color .12s;
}

.bottom-sheet .impressum-link:hover { color: #94a3b8; }

/* Badge inside bottom sheet */
.bottom-sheet .badge {
    background: rgba(255,255,255,.12);
    color: #94a3b8;
    font-size: 10px; font-weight: 600;
    padding: 2px 7px; border-radius: 999px;
    text-transform: none; letter-spacing: 0;
}

/* ── Welcome Panel (shown before route is loaded) ────────────────────────────── */
.welcome-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px 16px;
    gap: 10px;
    text-align: center;
    overflow: hidden;
}

.welcome-tagline {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.3;
}

.welcome-desc {
    font-size: 12px;
    color: #64748b;
    line-height: 1.6;
    max-width: 240px;
}

.welcome-features {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-self: stretch;
    text-align: left;
    padding: 0 8px;
}

.welcome-features li {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: #475569;
}

.welcome-features li svg {
    flex-shrink: 0;
    color: #2563eb;
}

.welcome-attrib {
    margin-top: auto;
    padding-top: 12px;
    font-size: 10px;
    color: #94a3b8;
    line-height: 1.6;
    text-align: center;
}

.welcome-attrib a {
    color: #64748b;
    text-decoration: none;
}

.welcome-attrib a:hover { text-decoration: underline; }

/* ── Impressum-Link (unterhalb Sprachauswahl) ────────────────────────────────── */
.impressum-link {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 4px 0;
    background: none;
    border: none;
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
    cursor: pointer;
    text-decoration: none;
    transition: color .12s;
}

.impressum-link:hover { color: #475569; }

/* ── Impressum Modal ─────────────────────────────────────────────────────────── */
.impressum-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(3px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.impressum-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.impressum-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.impressum-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.impressum-close {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    border-radius: 6px;
    transition: background .12s, color .12s;
}

.impressum-close:hover { background: #f1f5f9; color: #1e293b; }

.impressum-body {
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    font-size: 13px;
    color: #334155;
    line-height: 1.6;
}

.impressum-body section h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #94a3b8;
    margin-bottom: 6px;
}

.impressum-body section p { margin: 0 0 4px; }

.impressum-body a { color: #2563eb; text-decoration: none; }
.impressum-body a:hover { text-decoration: underline; }
