:root {
    /* Zentrale Steuerung der Farben nach CI */
    --btn-bg: #053873;       /* Dunkelblau als Standard */
    --btn-border: #053873;
    --btn-hover: #5FBEE6;    /* Hellblau für Mouseover */
    --btn-text: #ffffff;
    --accent-orange: #fd7e14; /* Dein bevorzugtes Orange */
    --neutral-anthrazit: #2D373C;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body { 
    margin: 0; 
    padding: 0; 
    display: flex; 
    flex-direction: column; 
    height: 100vh; 
    overflow: hidden; 
}

#app-container { 
    display: flex; 
    flex: 1; 
    position: relative; 
}

/* --- MAIN NAVBAR --- */
.navbar {
    border-bottom: 3px solid var(--accent-orange) !important;
}

/* Karte & Sidebar */
#map { 
    flex: 1; 
    height: 100%; 
    z-index: 1; 
}

/* --- Z-ACHSEN HIERARCHIE --- */

/* EBENE 1: Buttons auf der Karte */
#btn-filter-toggle {
    position: absolute;   
    top: 20px;            
    left: 20px;           
    z-index: 1000;
    background-color: var(--btn-bg);
    color: var(--btn-text);
    border: 1px solid var(--btn-border);
    box-shadow: var(--shadow);
    height: 40px;         
    padding: 0 20px;
    border-radius: 20px;  
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
}

#btn-report-new {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--btn-bg);
    color: var(--btn-text);
    border: 1px solid var(--btn-border);
    box-shadow: var(--shadow);
    width: auto;
    height: 48px;
    padding: 0 25px;
    z-index: 1000; 
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 24px;
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: all 0.2s ease-in-out;
}

#btn-legal {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    z-index: 1000; 
    background-color: var(--btn-bg);
    color: var(--btn-text);
    border: 2px solid rgba(255,255,255,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    border-radius: 50%;
}

#btn-locate-me {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 1000;
    background-color: var(--btn-bg);
    color: var(--btn-text);
    border: 1px solid var(--btn-border);
    box-shadow: var(--shadow);
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.4rem;
    transition: transform 0.2s;
}

/* Hover-Logik (Dunkelblau -> Hellblau umgedreht) - HIER ergänzt */
#btn-filter-toggle:hover, #btn-report-new:hover, #btn-legal:hover, #btn-locate-me:hover {
    background-color: var(--btn-hover);
    border-color: var(--btn-hover);
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

#btn-report-new:hover { 
    transform: translateX(-50%) scale(1.05); 
}

/* EBENE 2: Sidebar & Panels - Padding auf 0 für Header-Look */
#sidebar {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 350px;          
    background: white;
    z-index: 1010;
    padding: 0; /* Padding entfernt für bündigen Header */
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: none;          
    max-height: 90vh;       
    overflow: hidden; /* Wichtig für abgerundete Ecken am Header */
}

#filter-panel {
    position: absolute;
    top: 70px;
    left: 20px;
    z-index: 1020; 
    background: rgba(255, 255, 255, 0.98);
    padding: 0; /* Padding entfernt für bündigen Header */
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    width: 320px;
    max-height: 80vh; 
    overflow: hidden;
    animation: fadeIn 0.2s ease-out;
}

/* EBENE 3: Fullscreen Sidebar */
#sidebar.sidebar-fullscreen {
    position: fixed !important; 
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    max-height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    z-index: 1100 !important; 
    overflow: hidden !important; 
    padding-bottom: 0 !important;
}

#sidebar.sidebar-fullscreen .panel-body {
    max-height: calc(100vh - 55px) !important;
    overflow-y: auto !important;
}

/* EBENE 4: Modals */
.modal-backdrop { 
    z-index: 1150 !important; 
}
.modal { 
    z-index: 1500 !important; 
}
.modal-header { 
    background-color: #053873 !important; /* Dunkelblau fixiert */
    color: white !important; 
    border-bottom: 3px solid var(--accent-orange) !important; 
}

/* Verhindert, dass das eckige iframe die runden Ecken des Modals überschreibt */
#legalModal .modal-content {
    overflow: hidden !important;
}

/* --- FIX: FULLSCREEN LOGIK FÜR MODALE (Legal & Report) --- */
.modal-fullscreen-custom {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
}
.modal-fullscreen-custom .modal-content {
    height: 100vh !important;
    border-radius: 0 !important;
}

/* --- DER NEUE EINHEITLICHE HEADER-LOOK FÜR SIDEBAR & FILTER --- */
.panel-header {
    background-color: #053873 !important;
    color: white !important;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid var(--accent-orange) !important;
}

.panel-body {
    padding: 15px;
    overflow-y: auto;
    max-height: calc(80vh - 50px); /* Platz für Header lassen */
}

/* --- Restliche Styles --- */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}


.badge-cpo { 
    background-color: #053873; 
    color: white; 
    padding: 3px 8px; 
    border-radius: 4px; 
}

.leaflet-div-icon.custom-pin { 
    background: transparent; 
    border: none; 
}

.img-preview {
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid #ddd;
    display: block;
    cursor: pointer; 
    transition: transform 0.2s;
}

.img-preview:hover { 
    opacity: 0.9; 
    transform: scale(1.02); 
}

.custom-map-icon { 
    background: none; 
    border: none; 
}

.checked-badge { 
    letter-spacing: 0.5px; 
    font-weight: 700; 
    padding: 3px 6px; 
    text-transform: uppercase; 
    color: var(--accent-orange); 
}

.icon-pin svg { 
    display: block; 
    width: 90%; 
    height: 90%; 
}

.pin-green  { background-color: #198754 !important; border-color: #ffffff !important; }
.pin-orange { background-color: #fd7e14 !important; border-color: #ffffff !important; }
.pin-red    { background-color: #dc3545 !important; border-color: #ffffff !important; }
.pin-gray   { background-color: #6c757d !important; border-color: #ffffff !important; }


/** Schwarzer Rand um Pins
.pin-green  { background-color: #198754 !important; border-color: #000000 !important; }
.pin-orange { background-color: #fd7e14 !important; border-color: #000000 !important; }
.pin-red    { background-color: #dc3545 !important; border-color: #000000 !important; }
.pin-gray   { background-color: #6c757d !important; border-color: #000000 !important; }
**/

#detail-price, #sidebar .bi-lightning-charge, #sidebar .bi-plug { 
    transition: color 0.8s ease-in-out !important; 
}

@keyframes markerSpawn {
    0% { opacity: 0; transform: scale(0.5); }
    100% { opacity: 1; transform: scale(1); }
}

/* --- Schwarzer Rand um Pins (Auskommentiert) ---
.icon-pin {
    width: 56px; 
    height: 28px; 
    border-radius: 6px; 
    border: 2px solid #000000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5); 
    overflow: hidden; 
    color: white; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    animation: markerSpawn 0.4s ease-out forwards;
    transition: background-color 0.4s ease-in-out, border-color 0.4s ease-in-out !important;
}
*/

/* --- Weißer Rand um Pins (Aktiv) --- */
.icon-pin {
    width: 56px; 
    height: 28px; 
    border-radius: 6px; 
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5); 
    overflow: hidden; 
    color: white;
    display: flex; 
    align-items: center; 
    justify-content: center;
    animation: markerSpawn 0.4s ease-out forwards;
    transition: background-color 0.4s ease-in-out, border-color 0.4s ease-in-out !important;
}

.marker-tooltip {
    font-size: 0.8rem;
    padding: 3px 8px;
    background: rgba(5, 56, 115, 0.85);
    color: white;
    border: none;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.marker-tooltip::before {
    border-top-color: rgba(5, 56, 115, 0.85) !important;
}

#enlarged-image { 
    max-height: 90vh; 
    object-fit: contain; 
    border: 3px solid white; 
}

#btn-maximize-sidebar, #btn-maximize-report, #btn-maximize-legal { 
    opacity: 0.5; 
    transition: opacity 0.15s ease-in-out; 
    background: none !important; 
    border: none !important; 
    padding: 0; 
    line-height: 1; 
}

#btn-maximize-sidebar:hover, #btn-maximize-report:hover, #btn-maximize-legal:hover { 
    opacity: 1; 
    cursor: pointer; 
}

#btn-maximize-sidebar:active, #btn-maximize-report:active, #btn-maximize-legal:active { 
    transform: scale(0.9); 
}

/* --- CI-FINISH FÜR FORMULARELEMENTE --- */

.form-check-input:checked {
    background-color: var(--accent-orange) !important;
    border-color: var(--accent-orange) !important;
}

.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: #5FBEE6 !important; 
    box-shadow: 0 0 0 0.25rem rgba(95, 190, 230, 0.25) !important;
    outline: 0;
}

/* --- GLOBALE & EINHEITLICHE SCROLLBARS FÜR DIE GESAMTE APP --- */
/* Gilt automatisch für alle Modals, Panels, Listen und Textfelder */
::-webkit-scrollbar {
    width: 6px;
    height: 8px; /* Wichtig für horizontales Scrollen im Summary */
}

::-webkit-scrollbar-thumb {
    background-color: #5FBEE6; /* CI Hellblau */
    border-radius: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

#sidebar .panel-body::-webkit-scrollbar-thumb, 
#filter-cards-container::-webkit-scrollbar-thumb,
#legalModal .modal-body::-webkit-scrollbar-thumb {
    background-color: #5FBEE6; /* CI Hellblau */
    border-radius: 10px;
}

#sidebar .panel-body::-webkit-scrollbar-track, 
#filter-cards-container::-webkit-scrollbar-track,
#legalModal .modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}
/* --- SIDEBAR KOMPAKT --- */
#sidebar .panel-body {
    padding: 10px;
}

/* Legal Modal Tabs */
#legalModal .nav-pills .nav-link {
    color: #ffffff !important;
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    margin-right: 8px;
    transition: background-color 0.2s ease;
}

#legalModal .nav-pills .nav-link.active {
    background-color: #5FBEE6 !important;
    color: #ffffff !important;
    border-color: #5FBEE6 !important;
}

#legalModal .nav-pills .nav-link:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
    border-color: #ffffff !important;
}

/* Trefferanzeige im Filter-Panel */
#filter-results-status.alert-info {
    background-color: #5FBEE6 !important; 
    color: white !important;
    border: none;
    font-weight: 600;
}

#filter-results-status.alert-warning {
    background-color: #fd7e14 !important; 
    color: white !important;
    border: none;
    font-weight: 700;
}

/* --- BUTTON STYLES (Universal Fix) --- */

/* 1. RESET & FILTER BUTTONS (btn-outline-secondary) */
/* Basis: Grau & Transparent */
.btn-outline-secondary {
    border-color: #6c757d !important;
    color: #6c757d !important;
    background-color: transparent !important;
}

/* Hover, Active, Checked: DUNKELBLAU */
.btn-outline-secondary:hover,
.btn-outline-secondary:active,
.btn-outline-secondary.active,
.btn-check:checked + .btn-outline-secondary {
    background-color: #053873 !important;
    border-color: #053873 !important;
    color: white !important;
}

/* 2. POWER BUTTONS (btn-outline-primary) */
/* Basis: Hellblau & Transparent */
.btn-outline-primary {
    color: #5FBEE6 !important;
    border-color: #5FBEE6 !important;
    background-color: transparent !important;
}

/* Hover, Active, Checked: DUNKELBLAU */
.btn-outline-primary:hover,
.btn-outline-primary:active,
.btn-outline-primary.active,
.btn-check:checked + .btn-outline-primary {
    background-color: #053873 !important;
    border-color: #053873 !important;
    color: white !important;
}

/* 3. FOCUS RINGS ENTFERNEN (Verhindert grauen Schatten beim Klicken) */
.btn:focus, .btn-check:focus + .btn {
    box-shadow: none !important;
}

/* --- FEHLER-ANZEIGE  --- */

.form-control.is-invalid, 
.form-select.is-invalid, 
.form-check-input.is-invalid {
    border-width: 3px !important;       /* Viel dickerer Rahmen */
    border-color: #ff0000 !important;   /* Knallrot */
    border-style: solid !important;     /* Erzwingt durchgehende Linie (gegen das "Dashed"-Problem) */
    box-shadow: 0 0 8px rgba(255, 0, 0, 0.4) !important; /* Roter Schein */
}

/* Speziell für die Privacy-Checkbox: Den Text daneben auch rot und fett machen */
.form-check-input.is-invalid ~ .form-check-label {
    color: #ff0000 !important;
    font-weight: bold !important;
    text-decoration: underline; /* Unterstreichen zur Sicherheit */
}

/* --- SIDEBAR BOXEN (EINHEITLICHES DESIGN) --- */
.sb-box {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 8px;
}
.sb-head {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    font-size: 11px;
    font-weight: 500;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.sb-head i {
    font-size: 14px;
    color: #053873;
}
.sb-body {
    padding: 8px 10px;
    font-size: 13px;
}

/* ==========================================================================
   MOBILE MEDIA QUERY (MUSS IMMER GANZ UNTEN STEHEN)
   ========================================================================== */
@media (max-width: 768px) {
    #btn-legal { bottom: 90px; right: 15px; }
    #btn-locate-me { bottom: 90px; left: 15px; }
    
    /* SIDEBAR MOBILE */
    #sidebar { 
        top: auto !important; bottom: 0; left: 0; right: 0; width: 100%; 
        max-height: 70vh; 
        border-radius: 20px 20px 0 0; 
        box-shadow: 0 -4px 20px rgba(0,0,0,0.2); margin: 0; z-index: 1040; 
    }
    
    /* FIX: overflow-y erzwingt die Scrollbar! */
    #sidebar .panel-body {
        max-height: calc(70vh - 60px) !important; 
        overflow-y: auto !important; 
        padding-bottom: 40px !important; 
    }

    /* FILTER MOBILE */
    #filter-panel { 
        width: 95%; left: 2.5%; top: 70px; z-index: 1100; 
        max-height: 75vh;
    }
    
    /* FIX: overflow-y erzwingt die Scrollbar! */
    #filter-panel .panel-body {
        max-height: calc(75vh - 60px) !important;
        overflow-y: auto !important;
        padding-bottom: 40px !important;
    }

    /* LEGAL MODAL MOBILE: iframe muss kleiner werden */
    #legalModal .modal-content {
        height: 75vh !important;
    }
}