/**
 * Geo-Fin Map Styles
 * Styles für OpenLayers-Karte, Popups und Controls
 */

/* Karten-Container */
#map {
    width: 100%;
    height: 600px;
    position: relative;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

@media (max-width: 768px) {
    #map {
        height: 400px;
    }
}

/* Popup-Container */
.ol-popup {
    position: absolute;
    background-color: white;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    padding: 1rem;
    border-radius: 0.5rem;
    bottom: 12px;
    left: -50px;
    min-width: 280px;
    max-width: 400px;
    z-index: 1000;
}

.ol-popup:after, .ol-popup:before {
    top: 100%;
    border: solid transparent;
    content: " ";
    height: 0;
    width: 0;
    position: absolute;
    pointer-events: none;
}

.ol-popup:after {
    border-top-color: white;
    border-width: 10px;
    left: 48px;
    margin-left: -10px;
}

.ol-popup:before {
    border-top-color: rgba(0, 0, 0, 0.1);
    border-width: 11px;
    left: 48px;
    margin-left: -11px;
}

.ol-popup-closer {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #9ca3af;
    transition: color 0.2s;
}

.ol-popup-closer:hover {
    color: #374151;
}

#popup-content {
    max-height: 450px;
    overflow-y: auto;
}

#popup-content img {
    max-height: 200px;
    object-fit: cover;
}

/* POI-Popup Content */
.poi-popup h3 {
    margin: 0 0 0.5rem 0;
    color: #111827;
}

.poi-popup p {
    margin: 0;
    color: #374151;
    line-height: 1.5;
}

/* Karten-Switcher */
.map-switcher {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.map-switcher-btn {
    background: white;
    border: 1px solid #d1d5db;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    text-align: left;
    white-space: nowrap;
}

.map-switcher-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.map-switcher-btn.active {
    background: var(--primary-600);
    color: white;
    border-color: var(--primary-600);
}

@media (max-width: 768px) {
    .map-switcher-btn {
        font-size: 0.7rem;
        padding: 0.15rem 0.3rem;
    }
}

/* Geolocation-Button */
.map-controls {
    position: absolute;
    bottom: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    gap: 0.5rem;
}

@media (max-width: 768px) {
    .map-controls {
        bottom: 0.25rem;
    }
}

#geolocation-btn {
    background: white;
    border: 2px solid #e5e7eb;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#geolocation-btn:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #d1d5db;
}

#geolocation-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    #geolocation-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
}

/* Zoom-Level Anzeige */
.zoom-level-display {
    position: absolute;
    bottom: 2.5rem;
    right: 0.5rem;
    z-index: 10;
    background: white;
    border: 1px solid #d1d5db;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #374151;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.dark .zoom-level-display {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

@media (max-width: 768px) {
    .zoom-level-display {
        bottom: 2rem;
        font-size: 0.625rem;
        padding: 0.15rem 0.35rem;
    }
}

/* OpenLayers Attribution (Info-Button) */
.ol-attribution {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    z-index: 10;
}

.ol-attribution button {
    background: white !important;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    width: 1.5rem;
    height: 1.5rem;
    font-size: 0.75rem;
    cursor: pointer;
}

.ol-attribution button:hover {
    background: #f3f4f6 !important;
}

.ol-attribution.ol-collapsed ul {
    display: none;
}

.ol-attribution ul {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.625rem;
    color: #6b7280;
    margin: 0;
    list-style: none;
    max-width: 300px;
}

.dark .ol-attribution button {
    background: #1e293b !important;
    border-color: #475569;
    color: #e2e8f0;
}

.dark .ol-attribution button:hover {
    background: #334155 !important;
}

.dark .ol-attribution ul {
    background: #1e293b;
    border-color: #475569;
    color: #94a3b8;
}

/* OpenLayers Controls Override */
.ol-control {
    background-color: rgba(255, 255, 255, 0.9) !important;
    border-radius: 0.375rem;
}

.ol-control button {
    background-color: white !important;
    color: #374151 !important;
    border-radius: 0.25rem;
    transition: background-color 0.2s;
}

.ol-control button:hover {
    background-color: #f3f4f6 !important;
}

/* Map-Container müssen position: relative haben für absolute Kinder */
#map,
#detail-map,
#picker-map,
#picker-map-inner {
    position: relative;
}

/* Zoom-Controls - größer und innerhalb der Karte */
#map .ol-zoom,
#detail-map .ol-zoom,
#picker-map-inner .ol-zoom {
    top: 1rem !important;
    left: 1rem !important;
    z-index: 100 !important;
    position: absolute !important;
}

#map .ol-zoom button,
#detail-map .ol-zoom button,
#picker-map-inner .ol-zoom button {
    width: 2.5rem !important;
    height: 2.5rem !important;
    font-size: 1.5rem !important;
    line-height: 2.5rem !important;
    margin: 2px !important;
    cursor: pointer;
}

/* Home-Button und andere unerwünschte Controls ausblenden */
#map .ol-zoom-extent,
#map .ol-rotate,
#map .ol-full-screen,
#map .ol-overviewmap,
#map .ol-control:not(.ol-zoom):not(.ol-scale-line):not(.ol-attribution),
#detail-map .ol-zoom-extent,
#detail-map .ol-rotate,
#detail-map .ol-full-screen,
#detail-map .ol-overviewmap,
#detail-map .ol-control:not(.ol-zoom):not(.ol-scale-line):not(.ol-attribution),
#picker-map-inner .ol-zoom-extent,
#picker-map-inner .ol-rotate,
#picker-map-inner .ol-full-screen,
#picker-map-inner .ol-overviewmap,
#picker-map-inner .ol-control:not(.ol-zoom):not(.ol-scale-line):not(.ol-attribution) {
    display: none !important;
}

@media (max-width: 768px) {
    #map .ol-zoom,
    #detail-map .ol-zoom,
    #picker-map-inner .ol-zoom {
        top: 0.75rem !important;
        left: 0.75rem !important;
    }

    #map .ol-zoom button,
    #detail-map .ol-zoom button,
    #picker-map-inner .ol-zoom button {
        width: 2rem !important;
        height: 2rem !important;
        font-size: 1.25rem !important;
    }
}

/* Maßstabsanzeige - unten links */
#map .ol-scale-line,
#detail-map .ol-scale-line,
#picker-map-inner .ol-scale-line {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 0.25rem;
    padding: 0.25rem 0.5rem;
    bottom: 1rem !important;
    left: 1rem !important;
    top: auto !important;
    position: absolute !important;
    max-width: 120px;
    z-index: 100;
}

#map .ol-scale-line-inner,
#detail-map .ol-scale-line-inner,
#picker-map-inner .ol-scale-line-inner {
    font-size: 0.75rem;
    border-width: 1px;
    color: #333;
}

@media (max-width: 768px) {
    #map .ol-scale-line,
    #detail-map .ol-scale-line,
    #picker-map-inner .ol-scale-line {
        bottom: 0.5rem !important;
        left: 0.5rem !important;
        max-width: 100px;
    }
}

/* Loading-Indicator */
.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

.map-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Filter-Panel */
.map-filters {
    background: white;
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    margin-bottom: 1rem;
}

.map-filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

@media (max-width: 768px) {
    .map-filters-grid {
        grid-template-columns: 1fr;
    }
}

/* Cluster-Popup-Liste */
.cluster-popup {
    position: absolute;
    background-color: white;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    border-radius: 0.5rem;
    min-width: 200px;
    max-width: 280px;
    z-index: 1000;
    overflow: hidden;
}

.cluster-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
}

.cluster-popup-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: #374151;
}

.cluster-popup-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    margin: 0;
}

.cluster-popup-close:hover {
    color: #374151;
}

.cluster-popup-list {
    max-height: 250px;
    overflow-y: auto;
}

.cluster-poi-item {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background-color 0.15s;
}

.cluster-poi-item:last-child {
    border-bottom: none;
}

.cluster-poi-item:hover {
    background-color: #eff6ff;
}

.cluster-poi-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: #111827;
    margin-bottom: 0.125rem;
}

.cluster-poi-category {
    font-size: 0.65rem;
    color: #6b7280;
    background: #f3f4f6;
    padding: 0.1rem 0.35rem;
    border-radius: 0.25rem;
}

/* Responsive Adjustments */
@media (max-width: 640px) {
    #map {
        height: 350px;
        border-radius: 0;
    }

    .ol-popup {
        min-width: 240px;
        padding: 0.75rem;
    }

    .map-switcher {
        max-width: 160px;
    }

    .map-switcher-btn {
        font-size: 0.625rem;
        padding: 0.25rem 0.5rem;
    }

    .cluster-popup {
        min-width: 180px;
        max-width: 220px;
    }
}

/* POI-Tooltip (Hover) */
.poi-tooltip {
    display: none;
    position: fixed;
    background-color: #1f2937;
    color: white;
    padding: 0.4rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 99999;
    pointer-events: none;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
    transform: translateX(-50%);
}

.poi-tooltip:after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: #1f2937 transparent transparent transparent;
}

/* ===========================================
   DARK MODE STYLES
   =========================================== */

/* Karten-Container Dark Mode */
.dark #map {
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
}

/* Popup Dark Mode */
.dark .ol-popup {
    background-color: #1e293b;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

.dark .ol-popup:after {
    border-top-color: #1e293b;
}

.dark .ol-popup:before {
    border-top-color: rgba(0, 0, 0, 0.3);
}

.dark .ol-popup-closer {
    color: #64748b;
}

.dark .ol-popup-closer:hover {
    color: #f1f5f9;
}

/* POI-Popup Content Dark Mode */
.dark .poi-popup h3 {
    color: #f1f5f9;
}

.dark .poi-popup p {
    color: #cbd5e1;
}

/* Map-Switcher Dark Mode */
.dark .map-switcher-btn {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

.dark .map-switcher-btn:hover {
    background: #334155;
    border-color: #64748b;
}

.dark .map-switcher-btn.active {
    background: var(--primary-600);
    color: white;
    border-color: var(--primary-600);
}

/* Geolocation-Button Dark Mode */
.dark #geolocation-btn {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

.dark #geolocation-btn:hover:not(:disabled) {
    background: #334155;
    border-color: #64748b;
}

/* OpenLayers Controls Dark Mode */
.dark .ol-control {
    background-color: rgba(30, 41, 59, 0.9) !important;
}

.dark .ol-control button {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
}

.dark .ol-control button:hover {
    background-color: #334155 !important;
}

.dark #map .ol-scale-line {
    background: rgba(30, 41, 59, 0.9);
    color: #e2e8f0;
}

.dark #map .ol-scale-line-inner {
    border-color: #64748b;
    color: #cbd5e1;
}

/* Loading-Indicator Dark Mode */
.dark .map-loading {
    background: #1e293b;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

.dark .map-loading-spinner {
    border-color: #475569;
    border-top-color: #3b82f6;
}

/* Filter-Panel Dark Mode */
.dark .map-filters {
    background: #1e293b;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3);
}

/* Cluster-Popup Dark Mode */
.dark .cluster-popup {
    background-color: #1e293b;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

.dark .cluster-popup-header {
    background: #334155;
    border-bottom-color: #475569;
}

.dark .cluster-popup-count {
    color: #e2e8f0;
}

.dark .cluster-popup-close {
    color: #64748b;
}

.dark .cluster-popup-close:hover {
    color: #f1f5f9;
}

.dark .cluster-poi-item {
    border-bottom-color: #334155;
}

.dark .cluster-poi-item:hover {
    background-color: #334155;
}

.dark .cluster-poi-name {
    color: #f1f5f9;
}

.dark .cluster-poi-category {
    color: #94a3b8;
    background: #334155;
}
