/* Rad-Routen.de — Routing-spezifisches CSS */

/* ===================================================
   Routing-Layout: 3-Bereiche-Grid
   Desktop: Sidebar (links) + Karte (rechts, sticky), Settings unter Sidebar
   Mobile:  Header+Formular → Karte → Settings (gestapelt)

   Die Karte bleibt auf Desktop sichtbar, solange man durch Sidebar und
   Gewichtungseinstellungen scrollt. Erst wenn das Grid-Ende (nach der
   Kartenlegende) erreicht wird, scrollt die Karte mit der Seite hoch.
   =================================================== */

/* Desktop (≥993px): CSS Grid, Karte sticky */
@media (min-width: 993px) {
    .routing-layout {
        display: grid;
        grid-template-columns: 25% 75%;
        grid-template-rows: auto 1fr;
    }
    .routing-col-sidebar {
        grid-column: 1;
        grid-row: 1;
    }
    .routing-col-map {
        grid-column: 2;
        grid-row: 1 / 3;
    }
    .map-sticky-wrapper {
        position: sticky;
        top: 0;
        height: 100vh;
        overflow: hidden; /* Skalierte/gedrehte Karte nicht aus dem Wrapper herausragen lassen */
    }
    .map-sticky-wrapper #map {
        height: 100% !important;
        min-height: 500px !important;
    }
    .routing-col-settings {
        grid-column: 1;
        grid-row: 2;
    }
}

/* Tablet (601–992px): CSS Grid, breitere Sidebar */
@media (min-width: 601px) and (max-width: 992px) {
    .routing-layout {
        display: grid;
        grid-template-columns: 33.33% 66.67%;
        grid-template-rows: auto 1fr;
    }
    .routing-col-sidebar {
        grid-column: 1;
        grid-row: 1;
    }
    .routing-col-map {
        grid-column: 2;
        grid-row: 1 / 3;
    }
    .map-sticky-wrapper {
        position: sticky;
        top: 0;
        height: 100vh;
        overflow: hidden;
    }
    .map-sticky-wrapper #map {
        height: 100% !important;
        min-height: 400px !important;
    }
    .routing-col-settings {
        grid-column: 1;
        grid-row: 2;
    }
}

/* Mobile (≤600px): gestapelt in natürlicher Reihenfolge */
@media (max-width: 600px) {
    .routing-layout {
        display: flex;
        flex-direction: column;
    }
    .routing-col-sidebar  { order: 1; }
    .routing-col-map      { order: 2; }
    .routing-col-settings { order: 3; }
    #map {
        height: 100vh !important;
        height: 100dvh !important;
        min-height: 300px !important;
    }
}

/* Sticky-Wrapper für die Karte: position:relative nur auf Mobile,
   damit es auf Desktop/Tablet nicht position:sticky überschreibt.
   sticky erzeugt ebenfalls einen Positionierungskontext für die Buttons. */
@media (max-width: 600px) {
    .map-sticky-wrapper {
        position: relative;
        overflow: hidden; /* Gedrehte Karte nicht aus dem Wrapper herausragen lassen */
    }
}

/* Aktive Karten-Buttons (GPS an, Heading-Up an) */
.map-buttons button.active {
    background: #1a73e8 !important;
    color: #fff !important;
    border-color: #1565c0 !important;
}
.map-buttons button.active:hover {
    background: #1565c0 !important;
}

/* Formular-Eingaben */
#routing-form input[type="text"] {
    padding-right: 110px;
}

/* Suchergebnisse */
#from-results li, #to-results li {
    cursor: pointer;
}
#from-results li:hover, #to-results li:hover {
    background: #f0f0f0;
}

/* Routing-Typ Buttons */
.routing-type-btn {
    font-size: 1.6em;
    min-width: 54px;
    line-height: 1.2;
    background: #fff;
    color: #111;
    border-color: #999;
}
.routing-type-btn.active {
    background: #111 !important;
    color: #fff !important;
    border-color: #111 !important;
}
.routing-type-btn:hover:not(.active) {
    background: #f0f0f0 !important;
}

/* Karten-Typ-Buttons */
.map-type-btn {
    font-size: 1.5em;
    width: 50px;
    height: 50px;
    padding: 4px !important;
    line-height: 1;
    background: #fff;
    color: #111;
}
.map-type-btn.active {
    background: #111 !important;
    color: #fff !important;
    border-color: #111 !important;
}
.map-type-btn:hover:not(.active) {
    background: #f0f0f0 !important;
}
.map-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: absolute;
    right: 10px;
    top: 10px;
    z-index: 1000;
}

/* Geschwindigkeitsanzeige unten in der Karte */
#map-speed-display {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 1.1rem;
    font-weight: bold;
    padding: 4px 14px;
    border-radius: 20px;
    pointer-events: none;
    white-space: nowrap;
    letter-spacing: 0.03em;
}
.map-buttons br { display: none; }

/* Alle Buttons im Karten-Overlay (inkl. Geolocation-Button) */
.map-buttons button {
    font-size: 1.5em;
    width: 50px;
    height: 50px;
    padding: 4px !important;
    line-height: 1;
    background: #fff;
    color: #111;
    border-color: #bbb;
}
.map-buttons button:hover {
    background: #f0f0f0 !important;
}

/* Button-Gruppe im Eingabefeld (volle Höhe) */
.input-btn-group {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: stretch;
    gap: 0;
    z-index: 2;
}

/* Kleine Aktions-Buttons (Basis) */
.input-action-btn {
    font-size: 1.6em;
    line-height: 1;
    padding: 4px 8px !important;
    vertical-align: middle;
    background: #111 !important;
    color: #fff !important;
    border-color: #111 !important;
}
/* Buttons innerhalb der Eingabefeld-Gruppe: volle Höhe, kein Radius */
.input-btn-group .input-action-btn {
    padding: 0 10px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-left: 1px solid #ccc;
    border-radius: 0 !important;
}
/* Letzter Button: rechte Ecke abrunden passend zum Input */
.input-btn-group .input-action-btn:last-child {
    border-radius: 0 4px 4px 0 !important;
}
.input-action-btn:hover {
    background: #333 !important;
}
/* Standort-Button (hell) abweichend vom Such-Button */
.input-action-btn.btn-light {
    background: #e0e0e0 !important;
    color: #111 !important;
}
.input-action-btn.btn-light:hover {
    background: #ccc !important;
}

/* Sidebar-Header: Home-Icon + Rad-Routen.de Markenzeile */
.sidebar-header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff !important;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.1em;
    letter-spacing: 0.02em;
}
.sidebar-header-brand:hover {
    text-decoration: underline;
}
.sidebar-header-brand .btn-icon {
    background-color: #fff;
    flex-shrink: 0;
}

/* Ergebnis */
#routing-result dl {
    margin: 0;
}
#routing-result dt {
    float: left;
    clear: left;
    width: 120px;
    font-weight: bold;
    color: #555;
}
#routing-result dd {
    margin-left: 130px;
    margin-bottom: 4px;
}

/* ===================================================
   SVG-Icon-System (CSS mask-image = einfarbig)
   Farbe folgt dem CSS `color`-Property des Buttons
   =================================================== */
.btn-icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    background-color: currentColor;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    vertical-align: middle;
    pointer-events: none;
}

.btn-icon.icon-home    { -webkit-mask-image: url('icons/icon-home.svg');    mask-image: url('icons/icon-home.svg');    }
.btn-icon.icon-locate  { -webkit-mask-image: url('icons/icon-locate.svg');  mask-image: url('icons/icon-locate.svg');  }
.btn-icon.icon-bicycle { -webkit-mask-image: url('icons/icon-bicycle.svg'); mask-image: url('icons/icon-bicycle.svg'); }
.btn-icon.icon-map     { -webkit-mask-image: url('icons/icon-map.svg');     mask-image: url('icons/icon-map.svg');     }
.btn-icon.icon-hiking  { -webkit-mask-image: url('icons/icon-hiking.svg');  mask-image: url('icons/icon-hiking.svg');  }
.btn-icon.icon-hiker   { -webkit-mask-image: url('icons/icon-hiker.svg');   mask-image: url('icons/icon-hiker.svg');   }
.btn-icon.icon-car     { -webkit-mask-image: url('icons/icon-car.svg');     mask-image: url('icons/icon-car.svg');     }
.btn-icon.icon-search  { -webkit-mask-image: url('icons/icon-search.svg');  mask-image: url('icons/icon-search.svg');  }
.btn-icon.icon-edit    { -webkit-mask-image: url('icons/icon-edit.svg');    mask-image: url('icons/icon-edit.svg');    }
.btn-icon.icon-swap    { -webkit-mask-image: url('icons/icon-swap.svg');    mask-image: url('icons/icon-swap.svg');    }

/* ===================================================
   Gewichtungs-Panel (Routing-Einstellungen)
   =================================================== */
.weights-panel {
    border-top: 2px solid #ddd;
}

/* ── Gesperrte Straßen ── */
.forbidden-panel {
    border-top: 2px solid #e53935;
}
.forbidden-heading {
    padding: 8px 16px;
    font-weight: bold;
    font-size: 0.9em;
    color: #b71c1c;
    background: #ffebee;
    border-bottom: 1px solid #ffcdd2;
}
.forbidden-item {
    display: flex;
    align-items: center;
    padding: 6px 16px;
    border-bottom: 1px solid #ffcdd2;
    background: #fff8f8;
    gap: 6px;
}
.forbidden-item:last-child { border-bottom: none; }
.forbidden-name {
    flex: 1;
    font-size: 0.85em;
    cursor: pointer;
    color: #c62828;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.forbidden-name:hover { text-decoration: underline; }
.forbidden-remove {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    font-size: 1em;
    padding: 2px 5px;
    border-radius: 3px;
    line-height: 1;
}
.forbidden-remove:hover { background: #ffcdd2; color: #b71c1c; }

/* Zahnrad-Link im Popup → springt zum Schieberegler */
.popup-gear {
    cursor: pointer;
    font-style: normal;
    opacity: 0.5;
    font-size: 0.95em;
    margin-left: 3px;
    transition: opacity 0.15s;
}
.popup-gear:hover { opacity: 1; }

/* Aufleuchten eines Sliders wenn aus dem Popup angesprungen */
@keyframes slider-highlight {
    0%   { background: #fff3cd; }
    100% { background: transparent; }
}
.weight-row--highlight {
    animation: slider-highlight 1.6s ease-out forwards;
}

/* Karten-Pin für gesperrte Straßen */
.forbidden-pin {
    font-size: 1.3em;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.5));
    cursor: pointer;
}
.weights-heading {
    padding: 8px 16px;
    font-weight: bold;
    font-size: 0.9em;
    color: #333;
    background: #f0f0f0;
    border-bottom: 1px solid #ddd;
}
.weights-arrow { font-size: 0.8em; color: #888; }

.weight-group {
    border-bottom: 1px solid #eee;
}
.weight-group summary {
    padding: 6px 14px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.82em;
    color: #444;
    background: #fafafa;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.weight-group summary::before { content: '▶'; font-size: 0.7em; color: #aaa; }
.weight-group[open] summary::before { content: '▼'; }
.weight-group summary:hover { background: #f0f0f0; }
.weight-group-modified {
    display: none;
    font-size: 0.85em;
    margin-left: auto;
    color: #e08600;
    flex-shrink: 0;
}
.weight-group--has-changes .weight-group-modified { display: inline; }

.weight-row {
    padding: 5px 14px 7px 24px;
    border-bottom: 1px solid #f8f8f8;
}
.weight-row-header {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 3px;
}
.weight-label {
    flex: 1;
    font-size: 0.78em;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.weight-val {
    font-size: 0.8em;
    color: #222;
    font-weight: bold;
    min-width: 32px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    background: rgba(0,0,0,0.07);
    padding: 1px 5px;
    border-radius: 3px;
}
.weight-reset {
    background: none;
    border: none;
    color: #bbb;
    cursor: pointer;
    font-size: 1em;
    padding: 0 2px;
    line-height: 1;
    display: none;
    flex-shrink: 0;
}
.weight-row--changed .weight-reset { display: inline; color: #999; }
.weight-reset:hover { color: #333; }

.weight-neutral {
    background: none;
    border: 1px solid #ccc;
    border-radius: 3px;
    color: #999;
    cursor: pointer;
    font-size: 0.65em;
    padding: 1px 5px;
    line-height: 1.3;
    flex-shrink: 0;
    user-select: none;
}
.weight-neutral:hover { background: #f0f0f0; color: #555; border-color: #999; }

.weight-row-slider {
    display: flex;
    align-items: center;
    gap: 5px;
}
.weight-end {
    font-size: 0.68em;
    color: #888;
    white-space: nowrap;
    flex-shrink: 0;
    user-select: none;
}
.wl-m { display: none; }
@media (max-width: 600px) {
    .wl-d { display: none; }
    .wl-m { display: inline; }
}

/* Slider: Farbverlauf grün → gelb → rot */
input[type=range].weight-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #4caf50 0%, #ffeb3b 50%, #f44336 100%);
    outline: none;
    cursor: pointer;
    margin: 0;
}
input[type=range].weight-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #222;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
input[type=range].weight-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #222;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
input[type=range].weight-slider::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #4caf50 0%, #ffeb3b 50%, #f44336 100%);
}

/* Route-Layer-Stil überschrieben in JS */

/* ===================================================
   Karten-Vorschau während Routenberechnung
   =================================================== */

/* Spinner-Overlay zentriert über der Karte */
.map-spinner-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: rgba(255,255,255,0.92);
    border-radius: 50%;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.28);
    pointer-events: none;
}
.map-spinner-inner {
    width: 2em !important;
    height: 2em !important;
    border-width: 3px !important;
    border-color: rgba(0,0,0,0.18) !important;
    border-top-color: #111 !important;
}

/* Start- und Ziel-Marker (Leaflet divIcon) */
.route-marker {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid #111;
    box-shadow: 0 2px 6px rgba(0,0,0,0.45);
    box-sizing: border-box;
}
.route-marker-start {
    background: #fff;
    color: #111;
}
.route-marker-end {
    background: #111;
    color: #fff;
}

/* ===================================================
   Warte-Spinner (drehendes Symbol, pure CSS)
   =================================================== */
@keyframes rr-spin {
    to { transform: rotate(360deg); }
}

/* Freistehender Spinner (z.B. in Suchergebnissen, Fortschrittsanzeige) */
.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 0.15em solid #ccc;
    border-top-color: #333;
    border-radius: 50%;
    animation: rr-spin 0.7s linear infinite;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Button-Ladezustand: Icon ausblenden, Spinner als ::after einblenden */
.is-loading .btn-icon {
    display: none;
}
.is-loading::after {
    content: '';
    display: inline-block;
    width: 0.85em;
    height: 0.85em;
    border: 0.15em solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: rr-spin 0.7s linear infinite;
    vertical-align: middle;
}
/* Helle Buttons (btn-light): dunkler Spinner */
.btn-light.is-loading::after {
    border-color: rgba(0,0,0,0.15);
    border-top-color: #333;
}

/* ===================================================
   Karten-Klick-Popup (Start / Ziel wählen)
   =================================================== */
.map-click-popup {
    min-width: 160px;
    text-align: center;
}
.map-click-popup-coords {
    font-size: 0.78em;
    color: #666;
    margin-bottom: 8px;
    word-break: break-all;
}
.map-click-popup-btns {
    display: flex;
    gap: 6px;
    justify-content: center;
}
.map-click-popup-btns button {
    flex: 1;
    font-size: 0.82em;
    padding: 5px 8px !important;
    cursor: pointer;
}

/* ===================================================
   Routen-Listen mit Vorschaubildern
   =================================================== */
.route-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
/* Thumbnail-Container: feste Größe, Platzhalter-Gradient als Hintergrund.
   Wenn das <img> lädt, überdeckt es den Gradienten vollständig.
   Falls das Bild fehlt oder noch lädt, ist der Platzhalter sichtbar. */
.route-thumb {
    flex-shrink: 0;
    width: 140px;
    height: 73px;
    border-radius: 4px;
    display: block;
    background: linear-gradient(135deg, #e8e8e8 0%, #d5d5d5 100%);
    text-decoration: none;
    overflow: hidden;
    line-height: 0;
}
.route-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.route-info {
    flex: 1;
    min-width: 0;
}
@media (max-width: 600px) {
    .route-thumb {
        width: 100px;
        height: 53px;
    }
}

/* ===================================================
   Straßenliste nach Routenberechnung (rss = route-street)
   =================================================== */

.rss-list {
    padding: 2px 0 4px;
}

.rss-item {
    padding: 5px 14px 6px;
    border-bottom: 1px solid #f0f0f0;
}
.rss-item:last-child {
    border-bottom: none;
}

.rss-header {
    display: flex;
    align-items: center;
    gap: 4px;
}

.rss-name {
    flex: 1;
    font-size: 0.80em;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rss-name:hover {
    color: #0066cc;
    text-decoration: underline;
}

.rss-km {
    display: block;
    font-size: 0.72em;
    color: #999;
    margin-top: 1px;
    margin-bottom: 3px;
}

/* Bewertungsbalken */
.rss-bar {
    position: relative;
    height: 18px;
    margin-top: 3px;
}
.rss-bar-track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 5px;
    transform: translateY(-50%);
    border-radius: 3px;
    background: linear-gradient(to right,
        hsl(120,80%,36%) 0%,
        hsl(80,80%,36%)  35%,
        hsl(60,85%,40%)  50%,
        hsl(30,80%,38%)  65%,
        hsl(0,80%,38%)   100%);
    box-shadow: inset 0 1px 2px rgba(0,0,0,.18);
}
.rss-bar-thumb {
    position: absolute;
    top: 50%;
    font-size: 0.85em;
    line-height: 1;
    transform: translate(-50%, -50%);
    cursor: default;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.25));
}

.rss-ban {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.78em;
    padding: 0 2px;
    color: #bbb;
    flex-shrink: 0;
    line-height: 1;
    font-weight: bold;
}
.rss-ban:hover { color: #c00; }

.rss-banned {
    font-size: 0.88em;
    flex-shrink: 0;
    opacity: 0.65;
}
