:root { 
    --accent: #ff9800; 
    --panel-bg: #262c35; 
    --input-bg: #1e232a;
    --text-main: #e0e0e0;
    --border: #3d4450;
}
body { border: 5px solid red !important; }
body, html { margin: 0; padding: 0; height: 100%; font-family: 'Segoe UI', sans-serif; background: #1a1e23; overflow: hidden; }
#map { position: absolute; top: 0; bottom: 0; left: 0; right: 0; z-index: 1; }

/* POI Button mittig */
.top-bar-center { 
    position: absolute; 
    top: 20px; 
    left: 50%; 
    transform: translateX(-50%); 
    z-index: 2000;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}
.top-bar-center > * {
    pointer-events: auto;
}

.tool-item {
    background: var(--panel-bg); border: 1px solid var(--border); color: #ccc;
    padding: 10px 18px; border-radius: 10px; cursor: pointer; font-size: 0.85em;
    font-weight: 600; transition: 0.2s; white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.tool-item:hover { border-color: var(--accent); color: #fff; }

/* POI-Menü Grid */
.poi-menu {
    position: absolute; top: 70px; left: 50%; transform: translateX(-50%);
    background: var(--panel-bg); border: 1px solid var(--border);
    border-radius: 12px; padding: 15px; z-index: 4000;
   display: block;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6); width: 320px;
}

.poi-item {
    background: var(--input-bg); border: 1px solid var(--border);
    border-radius: 8px; padding: 12px; display: flex; flex-direction: column;
    align-items: center; gap: 5px; cursor: pointer; font-size: 0.8em; color: #eee;
    transition: 0.2s;
}
.poi-item:hover { border-color: var(--accent); }

/* Sidebar */
.sidebar {
    position: absolute; top: 20px; left: 20px; width: 340px;
    background: var(--panel-bg); z-index: 1000; border-radius: 12px; 
    border: 1px solid var(--border); box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    transition: left 0.3s ease;
    display: flex; flex-direction: column; 
    max-height: calc(100vh - 40px);
    overflow: hidden;
}
.sidebar.collapsed { left: -340px; }

.sidebar-header {
    padding: 15px 20px; border-bottom: 1px solid var(--border);
    background: rgba(0,0,0,0.2); display: flex; align-items: center;
    gap: 12px; border-radius: 12px 12px 0 0;
    flex-shrink: 0;
    min-height: 56px;
    box-sizing: border-box;
}

.sidebar-header h1 { margin: 0; font-size: 1.1em; color: #ffffff; letter-spacing: 0.5px; }
.sidebar-header h1 span { color: var(--accent); font-weight: 800; }

.back-link {
    text-decoration: none; color: var(--accent); font-size: 1.5em;
    font-weight: bold; line-height: 1; transition: transform 0.2s;
}

.routing-content { 
    padding: 15px;
    overflow-y: auto;
    /* Explizite Höhe: Viewport minus Sidebar-Abstand (40px) minus Header (56px) */
    max-height: calc(100vh - 40px - 56px);
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.routing-content::-webkit-scrollbar { width: 4px; }
.routing-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.admin-list { display: flex; flex-direction: column; gap: 4px; }
.admin-link {
    display: block; padding: 10px; color: #ccc; text-decoration: none;
    border-radius: 6px; transition: 0.2s; font-size: 0.85em;
}
.admin-link:hover { background: var(--input-bg); color: var(--accent); }

/* Form Elemente */
.route-input {
    width: 100%; background: var(--input-bg); border: 1px solid var(--border); 
    color: #fff; padding: 10px; border-radius: 6px; box-sizing: border-box;
    margin-bottom: 8px; font-size: 0.9em; outline: none;
}
::placeholder { color: #bbbbbb !important; opacity: 1; }

.btn-calc {
    width: 100%; background: var(--accent); color: #000; border: none;
    padding: 14px; border-radius: 8px; font-weight: 800; margin-top: 10px; cursor: pointer;
}

/* Accordion & Items */
.accordion-header {
    color: #ffffff !important; background: rgba(0,0,0,0.3);
    padding: 10px; border-radius: 6px; margin-top: 10px;
    cursor: pointer; font-weight: bold; display: flex;
    justify-content: space-between; align-items: center;
}
.accordion-content, .avoid-item, .admin-link { 
    color: var(--text-main) !important; 
}

.accordion-content,
.wp-container {
    position: relative;
}

.avoid-item { 
    font-size: 0.9em; display: flex; align-items: center; gap: 10px; cursor: pointer; 
}

/* Modal & Abo */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); z-index: 9999; display: flex;
    justify-content: center; align-items: center; backdrop-filter: blur(3px);
}
.modal-content {
    background: var(--panel-bg); border: 2px solid var(--accent);
    padding: 30px; border-radius: 15px; max-width: 400px; text-align: center;
    color: var(--text-main); box-shadow: 0 10px 50px rgba(0,0,0,0.5);
}
.btn-premium {
    display: inline-block; background: var(--accent); color: #000;
    padding: 12px 20px; border-radius: 8px; text-decoration: none;
    font-weight: bold; margin-top: 20px; transition: 0.2s;
}
.abo-container { display: flex; gap: 10px; margin-top: 15px; justify-content: center; }
.btn-abo {
    flex: 1; padding: 10px; border-radius: 8px; text-decoration: none;
    font-weight: bold; font-size: 0.85em; color: #fff; border: 1px solid var(--accent);
    transition: 0.2s;
}
.btn-abo:hover { background: var(--accent); color: #000; }
.price-tag { display: block; font-size: 0.8em; font-weight: normal; opacity: 0.8; }

/* Sonstiges */
.wp-container { position: relative; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.remove-wp { color: #ff5252; cursor: pointer; font-weight: bold; font-size: 1.2em; padding: 5px; }
.toggle-tab {
    position: absolute; right: -35px; top: 20px; width: 35px; height: 50px;
    background: var(--panel-bg); border: 1px solid var(--border);
    border-left: none; border-radius: 0 8px 8px 0; cursor: pointer;
    display: flex; align-items: center; justify-content: center; color: var(--accent);
}
.hidden { display: none; }
/* --- Autocomplete & Suchvorschläge --- */
.autocomplete-results {
    background: var(--panel-bg);
    border: 1px solid var(--accent);
    border-radius: 0 0 10px 10px;
    max-height: 250px;
    overflow-y: auto;
    position: fixed; /* fixed statt absolute: nicht vom sidebar-overflow abgeschnitten */
    z-index: 9000 !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}

.suggestion-item {
    padding: 12px 15px;
    cursor: pointer !important; /* Erzwingt das Händchen-Symbol */
    border-bottom: 1px solid var(--border);
    font-size: 0.85em;
    color: var(--text-main);
    display: block;
    text-align: left;
    transition: background 0.2s;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: var(--input-bg);
    color: var(--accent);
}

/* Scrollbar für die Vorschläge verschönern */
.autocomplete-results::-webkit-scrollbar {
    width: 6px;
}
.autocomplete-results::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}
/* ============================================================
   RESPONSIVE DESIGN
   Desktop (>900px): unverändertes Layout
   Tablet  (600-900px): schmalere Sidebar
   Mobile  (<600px): Bottom-Sheet Sidebar (wie Google Maps)
   ============================================================ */

/* --- Tablet --- */
@media (max-width: 1200px) {
    .sidebar {
        width: 300px;
        top: 15px;
        left: 15px;
        max-height: calc(100% - 30px);
    }
    .sidebar.collapsed { left: -300px; }

    .poi-menu {
        width: 280px;
        gap: 8px;
        padding: 12px;
    }

    .poi-item {
        padding: 10px 8px;
        font-size: 0.75em;
    }

    .route-info-box-responsive {
        font-size: 0.85em;
        gap: 12px;
        padding: 10px 16px;
    }
}

/* --- Mobile: Bottom Sheet --- */
@media (max-width: 1024px) {

    /* Sidebar wird zur Bottom Sheet */
    .sidebar {
        width: 100% !important;
        left: 0 !important;
        right: 0;
        top: auto !important;
        bottom: 0;
        border-radius: 18px 18px 0 0;
        max-height: 75vh;
        min-height: 60px;
        transform: translateY(0);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        overflow: hidden;
        box-shadow: 0 -8px 40px rgba(0,0,0,0.5);
    }

    /* Collapsed = nur Header sichtbar (60px) */
    .sidebar.collapsed {
        left: 0 !important;
        transform: translateY(calc(100% - 60px));
    }

    /* Drag-Handle oben in der Sidebar auf Mobile */
    .sidebar::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
        margin: 8px auto 0 auto;
    }

    /* Der seitliche Toggle-Tab wird auf Mobile ausgeblendet */
    .toggle-tab {
        display: none;
    }

    /* Header wird zum Tap-Ziel für auf/zu */
    .sidebar-header {
        cursor: pointer;
        padding: 10px 15px;
        min-height: 44px; /* Touch-freundlich */
        border-radius: 18px 18px 0 0;
    }

    /* Scrollbarer Inhaltsbereich */
    .routing-content {
        overflow-y: auto;
        max-height: calc(75vh - 130px);
        padding: 12px;
    }

    /* POI-Button: auf Mobile links neben dem Karten-Layer-Switcher */
    .top-bar-center {
        top: auto;
        bottom: 70px; /* Über der Sidebar */
        left: 50%;
        transform: translateX(-50%);
    }

    /* POI-Menü: volle Breite auf Mobile */
    .poi-menu {
        width: calc(100vw - 30px);
        max-width: 400px;
        top: auto;
        bottom: 130px;
        left: 50%;
        transform: translateX(-50%);
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    /* Route-Info Box: kompakter auf Mobile */
    #route-info-box {
        bottom: 75px !important; /* Über der Sidebar */
        padding: 8px 14px !important;
        gap: 10px !important;
        font-size: 0.8em !important;
        border-radius: 20px !important;
        flex-wrap: wrap;
        justify-content: center;
        max-width: calc(100vw - 40px);
    }

    /* Abbiegehinweise: volle Breite auf Mobile */
    #instructions-modal {
        width: calc(100vw - 30px) !important;
        bottom: 140px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    /* Modal auf Mobile: volle Breite */
    .modal-content {
        max-width: calc(100vw - 40px);
        padding: 20px;
        margin: 0 20px;
    }

    /* QR-Modal auf Mobile */
    #qr-modal .modal-content {
        padding: 20px;
    }

    /* Autocomplete auf Mobile: volle Breite */
    .autocomplete-results {
        max-height: 180px;
    }

    /* Vermeidungen: 2-spaltig bleiben aber kompakter */
    .avoid-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .avoid-item {
        font-size: 0.8em;
    }

    /* Leaflet Zoom-Buttons: nicht von Sidebar verdeckt */
    .leaflet-bottom.leaflet-right {
        bottom: 70px;
    }

    /* Layer-Switcher: oben rechts, nicht von Bottom-Sheet verdeckt */
    .leaflet-control-layers {
        margin-top: 15px !important;
        margin-right: 15px !important;
    }

    /* Sidebar-Footer kompakter */
    .sidebar-footer {
        padding: 10px 12px;
    }

    .admin-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px;
    }

    .admin-link {
        font-size: 0.78em;
        padding: 8px 6px;
        text-align: center;
    }
}

/* --- Sehr kleine Geräte (iPhone SE etc.) --- */
@media (max-width: 380px) {
    .sidebar {
        max-height: 70vh;
    }

    .routing-content {
        max-height: calc(70vh - 130px);
    }

    .poi-menu {
        grid-template-columns: 1fr 1fr;
        font-size: 0.7em;
    }

    #route-info-box {
        font-size: 0.72em !important;
        gap: 7px !important;
    }
}

/* --- Save Toast Animation --- */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateX(-50%) translateY(-15px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ═══ Mixed Routing — Segment Divider ══════════════════ */
.wp-wrapper { margin-bottom: 4px; }
.wp-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0;
}
.wp-row .route-input { margin-bottom: 0; flex: 1; }

/* Der Trennstrich zwischen zwei Punkten */
.seg-divider {
    margin: 4px 0;
    border-left: 2px solid rgba(255,107,0,0.3);
    padding-left: 8px;
}
.seg-div-label-row {
    padding: 2px 0 2px 0;
}
.seg-div-label {
    font-size: 0.72em;
    color: #666;
    font-style: italic;
    letter-spacing: 0.2px;
}
.seg-divider-inner {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 0 4px 0;
}

/* Profil-Dropdown im Divider */
.seg-div-profile {
    background: var(--input-bg);
    color: #aaa;
    border: 1px solid #333;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 0.8em;
    cursor: pointer;
    flex: 1;
    min-width: 0;
    transition: border-color 0.15s, color 0.15s;
}
.seg-div-profile:hover,
.seg-div-profile:focus { border-color: var(--accent); color: #fff; outline: none; }
.seg-div-profile option { background: #1e232a; }

/* Vermeidungen-Button */
.seg-div-avoid-btn {
    background: var(--input-bg);
    color: #aaa;
    border: 1px solid #333;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 0.8em;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s;
}
.seg-div-avoid-btn:hover { border-color: var(--accent); color: #fff; }

/* Dropdown-Menü */
.seg-div-avoid-menu {
    display: none;
    position: fixed;
    background: #1a1e25;
    border: 1px solid var(--accent);
    border-radius: 10px;
    z-index: 9999;
    padding: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    min-width: 170px;
}
.seg-div-avoid-menu.open { display: block; }
.seg-av-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.88em;
    color: #bbb;
    user-select: none;
    transition: background 0.1s;
}
.seg-av-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.seg-av-item:has(input:checked) { color: #fff; background: rgba(255,107,0,0.12); }
.seg-av-item input[type="checkbox"] {
    appearance: none; -webkit-appearance: none;
    width: 15px; height: 15px;
    border: 1px solid #555; border-radius: 4px;
    background: var(--input-bg);
    cursor: pointer; flex-shrink: 0; position: relative;
    transition: background 0.15s, border-color 0.15s;
}
.seg-av-item input:checked { background: var(--accent); border-color: var(--accent); }
.seg-av-item input:checked::after {
    content: '✓'; position: absolute;
    top: -1px; left: 2px; font-size: 10px; color: #000; font-weight: bold;
}

/* Mixed-Profil Anzeige in Info-Box */
.route-info-mixed {
    color: var(--accent);
    font-size: 0.8em;
    background: rgba(255,107,0,0.15);
    padding: 2px 8px;
    border-radius: 10px;
}

/* ═══ Rechte Panel-Buttons ════════════════════════════════ */
#right-panel-btns {
    position: fixed;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}
.rpanel-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background: rgba(20,20,20,0.92);
    color: white;
    font-size: 1.3em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    transition: background 0.15s, transform 0.15s;
    backdrop-filter: blur(6px);
}
.rpanel-btn:hover {
    background: rgba(255,107,0,0.25);
    transform: scale(1.08);
}

/* ═══ Rechte Slide-Panels ══════════════════════════════════ */
.right-panel {
    position: fixed;
    right: -360px;
    top: 0;
    width: 340px;
    height: 100%;
    background: rgba(18,20,26,0.97);
    border-left: 2px solid var(--accent);
    z-index: 999;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
    backdrop-filter: blur(12px);
}
.right-panel.open { right: 0; }

.rp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    font-weight: bold;
    font-size: 1em;
    color: var(--accent);
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}
.rp-close {
    cursor: pointer;
    color: #888;
    font-size: 1.1em;
    transition: color 0.15s;
}
.rp-close:hover { color: #fff; }

.rp-body {
    overflow-y: auto;
    flex: 1;
    padding: 8px 0;
}

/* Etappen */
.rp-etappe {
    padding: 14px 20px;
    border-bottom: 1px solid #1e2230;
    transition: background 0.1s;
}
.rp-etappe:hover { background: rgba(255,255,255,0.03); }
.rp-etappe-title {
    font-size: 0.85em;
    font-weight: bold;
    color: #ddd;
    margin-bottom: 8px;
}
.rp-etappe-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    font-size: 0.82em;
    color: #aaa;
}
.rp-etappe-stats span { white-space: nowrap; }

/* Abbiegehinweise */
.rp-turn {
    display: flex;
    gap: 14px;
    padding: 12px 20px;
    border-bottom: 1px solid #1e2230;
    align-items: flex-start;
    transition: background 0.1s;
}
.rp-turn:hover { background: rgba(255,255,255,0.03); }
.rp-turn-icon {
    font-size: 1.4em;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
    margin-top: 2px;
}
.rp-turn-text {
    color: #e0e0e0;
    font-size: 0.88em;
    line-height: 1.4;
}
.rp-turn-dist {
    color: #666;
    font-size: 0.76em;
    margin-top: 3px;
}

/* ═══ Karten-Kontext-Menü ══════════════════════════════════ */
.ctx-popup .leaflet-popup-content-wrapper {
    background: #161b22;
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}
.ctx-popup .leaflet-popup-tip { background: #161b22; }
.ctx-popup .leaflet-popup-content { margin: 8px 0; width: auto !important; }
.map-ctx-menu { display: flex; flex-direction: column; min-width: 210px; }
.ctx-btn {
    background: none;
    border: none;
    color: #ddd;
    padding: 11px 18px;
    text-align: left;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}
.ctx-btn:hover { background: rgba(255,255,255,0.06); color: #fff; }
.ctx-start:hover  { color: #4caf50; }
.ctx-wp:hover     { color: var(--accent); }
.ctx-ziel:hover   { color: #e53935; }
.ctx-clear:hover  { color: #ef5350; }
.ctx-divider {
    height: 1px;
    background: #2a2f3a;
    margin: 4px 0;
}

/* Etappen-Vermeidungen */
.rp-etappe-avoid {
    font-size: 0.76em;
    color: #666;
    margin-top: 5px;
}
