/**
 * Routenplaner – Formular und Lade-Einstellungen (4 Reiter wie in der App)
 * Pfad: /pages/route-planner/assets/route-settings.css
 * Eingebunden in: /pages/route-planner/route-planner.php
 * Markup: sections/route-form.php · Logik: route-settings.js
 *
 * Eigene Klassen (rs-*) statt Tailwind-Utilities: der lokale Tailwind-Build
 * enthält nur bereits verwendete Klassen.
 */

.rs-form {
    --rs-green: #16a34a;
    --rs-green-dark: #065f46;
    --rs-green-bg: #ecfdf3;
    --rs-green-border: #10b981;
    --rs-border: #e5e7eb;
    --rs-border-strong: #d1d5db;
    --rs-text: #111827;
    --rs-muted: #6b7280;
}

.rs-help-btn {
    font-size: 12px;
    padding: 4px 10px;
    border: 1px solid var(--rs-border-strong);
    border-radius: 6px;
    background: #fff;
    color: #374151;
    cursor: pointer;
}

.rs-help-btn:hover {
    background: var(--rs-green-bg);
}

/* ---------- Start / Ziel ---------- */

.rs-endpoints {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr);
    gap: 10px;
    align-items: end;
    margin-bottom: 14px;
}

.rs-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}

.rs-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--rs-border-strong);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: var(--rs-text);
}

.rs-input:focus {
    outline: none;
    border-color: var(--rs-green-border);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.rs-input-icon {
    padding-left: 30px;
    padding-right: 34px;
}

.rs-dot {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    pointer-events: none;
}

.rs-dot-start {
    background: #16a34a;
}

.rs-dot-dest {
    background: #dc2626;
}

.rs-input-action {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    color: #9ca3af;
    background: none;
    border: none;
    cursor: pointer;
}

.rs-input-action:hover {
    color: var(--rs-green);
}

.rs-swap {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--rs-border-strong);
    background: #fff;
    color: var(--rs-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.rs-swap svg {
    width: 18px;
    height: 18px;
    transform: rotate(90deg);
}

.rs-swap:hover {
    color: var(--rs-green);
    border-color: var(--rs-green-border);
}

/* ---------- Abfahrt / Fahrzeug ---------- */

.rs-trip-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.rs-pill-field {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 7px 12px;
    border: 1px solid var(--rs-border-strong);
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
    min-height: 42px;
}

.rs-pill-field > svg {
    width: 18px;
    height: 18px;
    color: var(--rs-muted);
    flex: none;
}

.rs-pill-label {
    color: var(--rs-muted);
    font-size: 13px;
}

.rs-pill-input {
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--rs-text);
    padding: 2px 0;
}

.rs-pill-input:focus {
    outline: none;
}

.rs-pill-select {
    flex: 1;
    min-width: 0;
}

/* Fahrzeug bestimmt die Planung: deutlich als aktiv erkennbar */
.rs-pill-field.rs-vehicle-active {
    border-color: var(--rs-green-border);
    background: var(--rs-green-bg);
    box-shadow: 0 0 0 1px var(--rs-green-border) inset;
}

.rs-pill-field.rs-vehicle-active > svg,
.rs-pill-field.rs-vehicle-active .rs-pill-label {
    color: var(--rs-green-dark);
}

.rs-pill-field.rs-vehicle-active .rs-vehicle-text {
    color: var(--rs-green-dark);
}

/* ---------- Fahrzeugauswahl mit Bildern ---------- */

/* Natives Feld bleibt im DOM (Datenquelle), ist aber unsichtbar */
.rs-vehicle-native {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

/* Liste hängt am ganzen Fahrzeugfeld, damit sie auch mobil volle Breite hat */
#rs-vehicle-field {
    position: relative;
}

.rs-vehicle-picker {
    flex: 1;
    min-width: 0;
}

.rs-vehicle-button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    border: none;
    background: transparent;
    padding: 0;
    font-size: 14px;
    color: var(--rs-text);
    cursor: pointer;
    text-align: left;
}

.rs-vehicle-button:focus-visible {
    outline: 2px solid var(--rs-green-border);
    outline-offset: 3px;
    border-radius: 6px;
}

.rs-vehicle-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rs-vehicle-range {
    color: var(--rs-muted);
    font-weight: 400;
}

.rs-vehicle-caret {
    width: 16px;
    height: 16px;
    flex: none;
    color: var(--rs-muted);
}

.rs-vehicle-thumb {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 30px;
    flex: none;
    border-radius: 6px;
    background: #fff;
    border: 1px solid var(--rs-border);
    overflow: hidden;
}

.rs-vehicle-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.rs-vehicle-thumb.hidden {
    display: none;
}

.rs-vehicle-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 40;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: #fff;
    border: 1px solid var(--rs-border-strong);
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
    max-height: 320px;
    overflow-y: auto;
}

.rs-vehicle-menu.hidden {
    display: none;
}

.rs-vehicle-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.rs-vehicle-option:hover,
.rs-vehicle-option:focus {
    background: #f3f4f6;
    outline: none;
}

.rs-vehicle-option[aria-selected="true"] {
    background: var(--rs-green-bg);
    box-shadow: 0 0 0 1px var(--rs-green-border) inset;
}

.rs-vehicle-option .rs-vehicle-thumb {
    width: 84px;
    height: 48px;
}

.rs-vehicle-option-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.rs-vehicle-option-text strong {
    font-size: 14px;
    color: var(--rs-text);
}

.rs-vehicle-option-text small {
    font-size: 12px;
    color: var(--rs-muted);
}

.rs-vehicle-primary {
    display: inline-block;
    margin-left: 6px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--rs-green-bg);
    color: var(--rs-green-dark);
    font-size: 11px;
    font-weight: 600;
    vertical-align: 1px;
}

.rs-vehicle-option-none {
    border-top: 1px solid var(--rs-border);
    border-radius: 0 0 8px 8px;
    margin-top: 4px;
}

.rs-vehicle-status {
    font-size: 12px;
    font-weight: 600;
    color: var(--rs-green-dark);
    background: #fff;
    border: 1px solid var(--rs-green-border);
    border-radius: 999px;
    padding: 2px 9px;
    white-space: nowrap;
}

.rs-vehicle-enable {
    font-size: 12px;
    color: var(--rs-green-dark);
    background: #fff;
    border: 1px dashed var(--rs-green-border);
    border-radius: 999px;
    padding: 2px 9px;
    cursor: pointer;
    white-space: nowrap;
}

.rs-vehicle-enable:hover {
    background: var(--rs-green-bg);
}

.rs-vehicle-status.hidden,
.rs-vehicle-enable.hidden {
    display: none;
}

.rs-link {
    font-size: 13px;
    color: var(--rs-green);
    text-decoration: none;
}

.rs-link:hover {
    text-decoration: underline;
}

/* ---------- Kurzübersicht ---------- */

.rs-summary {
    border: 1px solid var(--rs-border);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: #fff;
}

.rs-summary-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.rs-summary-head > svg {
    width: 18px;
    height: 18px;
    color: #374151;
}

.rs-summary-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--rs-text);
}

.rs-summary-meta {
    font-size: 12px;
    color: var(--rs-muted);
}

.rs-summary-toggle {
    margin-left: auto;
    font-size: 13px;
    font-weight: 500;
    color: var(--rs-green);
    background: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.rs-summary-toggle[aria-expanded="true"] .route-advanced-toggle-caret {
    transform: rotate(180deg);
}

.rs-summary-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.rs-summary-chip {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--rs-green-bg);
    color: var(--rs-green-dark);
    border: 1px solid #a7f3d0;
}

/* ---------- Panel mit Reitern ---------- */

.rs-panel {
    border: 1px solid var(--rs-border);
    border-radius: 12px;
    padding: 4px 18px 16px;
    margin-bottom: 14px;
    background: #fff;
}

.rs-tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    border-bottom: 1px solid var(--rs-border);
    margin-bottom: 14px;
}

.rs-tab {
    font-size: 14px;
    padding: 10px 12px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--rs-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: -1px;
}

.rs-tab.active {
    color: var(--rs-text);
    font-weight: 600;
    border-bottom-color: var(--rs-green-border);
}

.rs-tab-count:empty {
    display: none;
}

.rs-tab-count {
    font-size: 11px;
    min-width: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--rs-green-bg);
    color: var(--rs-green-dark);
}

.rs-reset {
    margin-left: auto;
    font-size: 12px;
    color: var(--rs-muted);
    background: none;
    border: none;
    cursor: pointer;
}

.rs-reset:hover {
    color: #b91c1c;
}

.rs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.rs-section + .rs-section {
    margin-top: 18px;
}

.rs-grid > .rs-section + .rs-section {
    margin-top: 0;
}

.rs-h {
    font-size: 14px;
    font-weight: 600;
    color: var(--rs-text);
    margin: 0 0 8px;
}

.rs-h-inline {
    margin: 0;
}

.rs-h-spaced {
    margin-top: 18px;
}

.rs-hint {
    font-size: 12px;
    color: var(--rs-muted);
    margin: 6px 0 0;
}

.rs-hint:empty {
    display: none;
}

.rs-slider-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 13px;
    color: #374151;
    margin: 8px 0 4px;
}

.rs-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(to right, var(--rs-green) 0, var(--rs-green) var(--rs-fill, 50%), #e5e7eb var(--rs-fill, 50%), #e5e7eb 100%);
    outline: none;
    margin: 6px 0;
}

.rs-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--rs-green);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    cursor: pointer;
}

.rs-range::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--rs-green);
    cursor: pointer;
}

.rs-range:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.25);
}

.rs-switch-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #374151;
    padding: 7px 0;
    cursor: pointer;
}

.rs-switch-row.rs-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rs-switch {
    appearance: none;
    -webkit-appearance: none;
    width: 36px;
    height: 20px;
    border-radius: 999px;
    background: #d1d5db;
    position: relative;
    flex: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.rs-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: left 0.15s ease;
}

.rs-switch:checked {
    background: var(--rs-green);
}

.rs-switch:checked::after {
    left: 18px;
}

.rs-switch:focus-visible {
    outline: 2px solid var(--rs-green-border);
    outline-offset: 2px;
}

.rs-details summary {
    font-size: 13px;
    color: var(--rs-green);
    cursor: pointer;
    margin-top: 8px;
}

.rs-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.rs-chip {
    font-size: 13px;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid var(--rs-border-strong);
    background: #fff;
    color: #374151;
    cursor: pointer;
}

.rs-chip:hover {
    border-color: var(--rs-green-border);
}

.rs-chip.active {
    background: var(--rs-green-bg);
    border-color: var(--rs-green-border);
    color: var(--rs-green-dark);
    font-weight: 600;
}

.rs-check-chip {
    position: relative;
    cursor: pointer;
}

.rs-check-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.rs-check-chip span {
    display: inline-block;
    font-size: 13px;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid var(--rs-border-strong);
    background: #fff;
    color: #374151;
}

.rs-check-chip input:checked + span {
    background: var(--rs-green-bg);
    border-color: var(--rs-green-border);
    color: var(--rs-green-dark);
    font-weight: 600;
}

.rs-check-chip input:checked + span::before {
    content: "✓ ";
}

.rs-check-chip input:focus-visible + span {
    outline: 2px solid var(--rs-green-border);
    outline-offset: 2px;
}

.rs-tiles {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.rs-tile {
    position: relative;
    border: 1px solid var(--rs-border-strong);
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
    color: var(--rs-muted);
}

.rs-tile input {
    position: absolute;
    opacity: 0;
}

.rs-tile strong {
    font-size: 14px;
    color: var(--rs-text);
}

.rs-tile:has(input:checked) {
    border: 2px solid var(--rs-green-border);
    background: var(--rs-green-bg);
    padding: 9px 11px;
}

.rs-off {
    opacity: 0.45;
    pointer-events: none;
}

.rs-operators-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.rs-operators-selected {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 38px;
    padding: 6px;
    border: 1px solid var(--rs-border);
    border-radius: 8px;
    margin-bottom: 10px;
}

.rs-operator-search {
    margin-bottom: 10px;
}

.rs-link-danger {
    font-size: 12px;
    color: #b91c1c;
    background: none;
    border: none;
    cursor: pointer;
}

.rp-operator-chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 4px 2px 10px;
    border-radius: 999px;
    font-size: 13px;
}

.rp-operator-chip.is-preferred {
    background: #dbeafe;
    color: #1e40af;
}

.rp-operator-chip.is-excluded {
    background: #fee2e2;
    color: #991b1b;
}

.rp-operator-chip .operator-chip-mode {
    background: none;
    border: none;
    color: inherit;
    font-weight: 500;
    cursor: pointer;
    padding: 2px 0;
}

.rp-operator-chip .operator-chip-remove {
    background: none;
    border: none;
    color: inherit;
    font-weight: 700;
    cursor: pointer;
    padding: 0 6px;
}

.rs-panel-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid var(--rs-border);
}

.rs-btn {
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--rs-border-strong);
    background: #fff;
    color: #374151;
    cursor: pointer;
}

.rs-btn:hover {
    background: #f9fafb;
}

.rs-btn-primary {
    background: var(--rs-green);
    border-color: var(--rs-green);
    color: #fff;
}

.rs-btn-primary:hover {
    background: #15803d;
}

/* ---------- Aktionen ---------- */

.rs-actions {
    display: flex;
    gap: 8px;
}

.rs-calc-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border: none;
    border-radius: 8px;
    background: var(--rs-green);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.rs-calc-btn svg {
    width: 18px;
    height: 18px;
}

.rs-calc-btn:hover {
    background: #15803d;
}

@media (max-width: 640px) {
    .rs-endpoints {
        grid-template-columns: minmax(0, 1fr);
    }

    .rs-swap {
        justify-self: end;
        margin: -6px 0;
    }

    .rs-tiles {
        grid-template-columns: minmax(0, 1fr);
    }

    .rs-tab {
        padding: 8px;
    }
}

.rs-form #estimated-cost,
.rs-form #price-range-display {
    font-size: inherit;
    color: inherit;
    font-weight: 600;
}

/* Ältere Reiter-Stile aus route-planner-custom.css (mobil grün gefüllt) neutralisieren */
.rs-tabs .rs-tab,
.rs-tabs .rs-tab.active,
.rs-tabs .rs-tab:hover,
.rs-tabs .rs-tab.active:hover {
    background: none;
    box-shadow: none;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    color: var(--rs-muted);
}

.rs-tabs .rs-tab:hover {
    color: #374151;
}

.rs-tabs .rs-tab.active,
.rs-tabs .rs-tab.active:hover {
    color: var(--rs-text);
    border-bottom-color: var(--rs-green-border);
}

.rs-input-action svg {
    width: 16px;
    height: 16px;
}

.rs-input-action {
    min-width: 0;
    min-height: 0;
    padding: 0;
}

@media (max-width: 640px) {
    .rs-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .rs-tabs::-webkit-scrollbar {
        display: none;
    }

    .rs-tab {
        white-space: nowrap;
        flex: none;
    }

    .rs-reset {
        flex: none;
        white-space: nowrap;
        padding-left: 8px;
    }

    .rs-panel {
        padding: 4px 12px 14px;
    }

    .rs-panel-foot .rs-btn {
        flex: 1;
    }
}

/* Zweite Überschrift innerhalb eines Abschnitts */
.rs-h.rs-h-spaced {
    margin-top: 18px;
}
