/**
 * Karten-Styles für das zentrale Kartensystem (Leaflet-basiert).
 *
 * Enthält: Container, Satelliten-Toggle, Consent-Overlay, Cluster-Styles,
 * Popup-Styles, Fullscreen-Sidebar, responsive Anpassungen.
 */

/* === Karten-Container === */

.cms-karte {
    position: relative;
    width: 100%;
    background: #e8e8e8;
    border: 1px solid #ccc;
    border-radius: 4px;
    overflow: hidden;
    z-index: 0; /* Leaflet-Kontext isolieren */
}

.cms-karte .leaflet-container {
    width: 100%;
    height: 100%;
    font-family: inherit;
}

/* Noscript-Fallback */
.cms-karte noscript {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2em;
    color: #666;
    font-style: italic;
}

/* === Fullscreen-Control === */

.leaflet-control-fullscreen a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    font-size: 14px;
    color: #333;
    background: #fff;
    text-decoration: none;
}

.leaflet-control-fullscreen a:hover {
    background: #f0f0f0;
}

/* CSS-Fullscreen-Overlay (kein Browser-Fullscreen) */
.cms-karte-fs {
    position: fixed !important;
    inset: 0 !important;
    z-index: 9999 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    margin: 0 !important;
}

/* === Satelliten-Toggle (Custom Leaflet Control) === */

.leaflet-control-satellite {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    overflow: hidden;
    display: flex;
}

.leaflet-control-satellite button {
    padding: 6px 12px;
    border: none;
    background: #fff;
    color: #333;
    font-size: 13px;
    cursor: pointer;
    line-height: 1.4;
    transition: background-color 0.15s, color 0.15s;
}

.leaflet-control-satellite button:first-child {
    border-right: 1px solid #ddd;
}

.leaflet-control-satellite button:hover {
    background: #f0f0f0;
}

.leaflet-control-satellite button.active {
    background: #2563eb;
    color: #fff;
}

/* === Consent-Overlay (für Satelliten-Layer) === */

.karte-consent-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1em;
}

.karte-consent-box {
    background: #fff;
    border-radius: 8px;
    padding: 1.5em 2em;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.karte-consent-box h3 {
    margin: 0 0 0.5em;
    font-size: 1.1em;
}

.karte-consent-box p {
    margin: 0 0 1em;
    color: #555;
    font-size: 0.9em;
    line-height: 1.5;
}

.karte-consent-box .consent-actions {
    display: flex;
    gap: 0.5em;
    justify-content: center;
    flex-wrap: wrap;
}

.karte-consent-box button {
    padding: 8px 20px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

.karte-consent-box .consent-accept {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.karte-consent-box .consent-accept:hover {
    background: #1d4ed8;
}

.karte-consent-box .consent-decline {
    background: #f3f4f6;
    color: #333;
}

.karte-consent-box .consent-decline:hover {
    background: #e5e7eb;
}

.karte-consent-box .consent-remember {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4em;
    margin-top: 0.75em;
    font-size: 0.85em;
    color: #666;
}

/* === Marker-Popups === */

.cms-karte-popup {
    min-width: 180px;
    max-width: 300px;
}

.cms-karte-popup h4 {
    margin: 0 0 0.3em;
    font-size: 1em;
    font-weight: 600;
}

.cms-karte-popup p {
    margin: 0 0 0.5em;
    font-size: 0.9em;
    color: #444;
    line-height: 1.4;
}

.cms-karte-popup a {
    color: #2563eb;
    text-decoration: none;
}

.cms-karte-popup a:hover {
    text-decoration: underline;
}

.cms-karte-popup .popup-address {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 0.5em;
}

.cms-karte-popup .popup-icon {
    margin-right: 0.3em;
    width: 1em;
    text-align: center;
}

/* === Marker-Cluster (MarkerCluster-Plugin-Overrides) === */

.marker-cluster-small {
    background-color: rgba(37, 99, 235, 0.3);
}
.marker-cluster-small div {
    background-color: rgba(37, 99, 235, 0.6);
}

.marker-cluster-medium {
    background-color: rgba(234, 179, 8, 0.3);
}
.marker-cluster-medium div {
    background-color: rgba(234, 179, 8, 0.6);
}

.marker-cluster-large {
    background-color: rgba(239, 68, 68, 0.3);
}
.marker-cluster-large div {
    background-color: rgba(239, 68, 68, 0.6);
}

.marker-cluster div {
    color: #fff;
    font-weight: 600;
    font-size: 12px;
}

/* === Fullscreen-Karte === */

.cms-karte-fullscreen {
    display: flex;
    height: calc(100vh - 120px);
    min-height: 500px;
}

.cms-karte-fullscreen .karte-sidebar {
    width: 280px;
    min-width: 280px;
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    overflow-y: auto;
    padding: 1em;
}

.cms-karte-fullscreen .karte-map-container {
    flex: 1;
    position: relative;
}

.karte-sidebar h3 {
    font-size: 1em;
    margin: 0 0 0.75em;
    padding-bottom: 0.5em;
    border-bottom: 1px solid #e5e7eb;
}

.karte-sidebar .layer-group {
    margin-bottom: 1em;
}

.karte-sidebar .layer-item {
    display: flex;
    align-items: center;
    gap: 0.5em;
    padding: 4px 0;
    font-size: 0.9em;
    cursor: pointer;
}

.karte-sidebar .layer-item input[type="checkbox"] {
    margin: 0;
}

.karte-sidebar .layer-icon {
    width: 1.2em;
    text-align: center;
    color: #666;
}

.karte-sidebar .layer-count {
    margin-left: auto;
    font-size: 0.8em;
    color: #999;
    background: #e5e7eb;
    padding: 1px 6px;
    border-radius: 10px;
}

/* === Suchfeld in Sidebar === */

.karte-search {
    margin-bottom: 1em;
}

.karte-search input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.9em;
}

.karte-search input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* === Font Awesome Marker === */

.fa-marker-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #fff;
    font-size: 14px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    border: 2px solid #fff;
}

/* === Straßenverzeichnis (Accordion + Einträge) === */

.karte-strassen-accordion {
    margin-top: 1em;
    border-top: 1px solid #e5e7eb;
    padding-top: 0.75em;
}

.karte-accordion-toggle {
    font-size: 1em;
    margin: 0 0 0.5em;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.4em;
}

.karte-accordion-toggle:hover {
    color: #2563eb;
}

.karte-accordion-arrow {
    font-size: 0.75em;
    display: inline-block;
    transition: transform 0.15s;
}

.strassen-item {
    display: flex;
    align-items: center;
    gap: 0.5em;
    padding: 3px 0;
    font-size: 0.9em;
}

.strassen-name {
    cursor: pointer;
    color: #333;
    flex: 1;
}

.strassen-name:hover {
    color: #2563eb;
    text-decoration: underline;
}

/* === Straßen-Legende === */

.karte-legende {
    margin-bottom: 0.75em;
    padding: 0.5em 0;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}

.karte-legende-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78em;
    color: #555;
    white-space: nowrap;
}

/* === Eingebettete Karte mit Breite/Align (Wrapper) === */

.cms-karte-embed {
    position: relative;
}

.cms-karte-embed .cms-karte {
    width: 100%; /* füllt den Wrapper */
}

/* Kompakter OSM-Hinweis-Bar (unter eingebetteter Karte) */
.karte-osm-bar {
    display: flex;
    align-items: center;
    gap: 0.3em;
    padding: 2px 6px;
    background: #f8f9fa;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 4px 4px;
    font-size: 0.7em;
    color: #999;
    line-height: 1.4;
    position: relative;
}

.karte-osm-bar a {
    color: #888;
    text-decoration: none;
}

.karte-osm-bar a:hover {
    text-decoration: underline;
    color: #555;
}

.karte-osm-info-btn {
    background: none;
    border: none;
    color: #bbb;
    cursor: pointer;
    padding: 0 2px;
    font-size: 1em;
    line-height: 1;
    margin-left: auto;
}

.karte-osm-info-btn:hover {
    color: #2563eb;
}

/* Info-Popup (standardmäßig versteckt, sichtbar via .is-open) */
.karte-osm-popup {
    display: none;
    position: absolute;
    bottom: calc(100% + 4px);
    right: 0;
    width: 280px;
    max-width: 90vw;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0.75em 1em;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: 1.3em; /* relativ zum .karte-osm-bar (0.7em) → effektiv ~0.9em */
    color: #444;
    line-height: 1.5;
    z-index: 1000;
}

.karte-osm-popup.is-open {
    display: block;
}

.karte-osm-popup a {
    color: #2563eb;
}

/* === Einzelkategorie ohne Sidebar === */

.cms-karte-no-sidebar .karte-map-container {
    width: 100%;
}

/* === Responsive === */

@media (max-width: 768px) {
    .cms-karte-fullscreen {
        flex-direction: column;
        height: auto;
    }

    .cms-karte-fullscreen .karte-sidebar {
        width: 100%;
        min-width: unset;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }

    .cms-karte-fullscreen .karte-map-container {
        height: calc(100vh - 320px);
        min-height: 400px;
    }

    /* Eingebettete Karten: Float aufheben auf Mobil */
    .cms-karte-embed {
        float: none !important;
        width: 100% !important;
        margin: 0 0 1em 0 !important;
    }
}
