/**
 * Program Sites Interactive Map Styles
 * Custom CSS for Leaflet.js map integration
 */

/* Map Container */
#program-sites-map {
    position: relative;
    background: #f8fafc;
}

/* Custom Marker Icons */
.custom-marker-icon {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #184B77;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.custom-marker-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Marker Clusters */
.marker-cluster {
    background-clip: padding-box;
    border-radius: 50%;
    font-weight: bold;
    text-align: center;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-cluster div {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-cluster-small {
    background-color: rgba(24, 75, 119, 0.8); /* anambas-oceanblue */
}

.marker-cluster-small div {
    background-color: rgba(24, 75, 119, 0.9);
}

.marker-cluster-medium {
    background-color: rgba(41, 131, 185, 0.8); /* anambas-seablue */
}

.marker-cluster-medium div {
    background-color: rgba(41, 131, 185, 0.9);
}

.marker-cluster-large {
    background-color: rgba(43, 126, 72, 0.8); /* anambas-green */
}

.marker-cluster-large div {
    background-color: rgba(43, 126, 72, 0.9);
}

/* Custom Popup Styles */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: none;
}

.leaflet-popup-content {
    margin: 0;
    padding: 0;
    font-family: 'Open Sans', sans-serif;
}

.custom-popup .popup-content {
    max-width: 300px;
}

.leaflet-popup-tip {
    background: white;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Map Controls Styling */
.leaflet-control-zoom {
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.leaflet-control-zoom a {
    background-color: white;
    border: 1px solid #ddd;
    color: #184B77;
    font-weight: bold;
    transition: all 0.2s ease;
}

.leaflet-control-zoom a:hover {
    background-color: #184B77;
    color: white;
    border-color: #184B77;
}

/* Map Stats and Legend Boxes */
.absolute.bg-white\/90 {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Mobile Bottom Sheet */
#mobile-bottom-sheet {
    max-height: 70vh;
    overflow-y: auto;
    z-index: 2000;
}

#mobile-bottom-sheet .p-4 {
    padding-bottom: env(safe-area-inset-bottom, 1rem);
}

/* Filter Controls */
.filter-controls select {
    transition: all 0.2s ease;
}

.filter-controls select:focus {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(24, 75, 119, 0.15);
}

/* Search Input */
#map-search {
    transition: all 0.2s ease;
}

#map-search:focus {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(24, 75, 119, 0.15);
}

/* Active Filter Tags */
#filter-tags span {
    animation: fadeInScale 0.3s ease;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Loading Animation */
#map-loading {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.animate-spin {
    animation: spin 1s linear infinite;
}

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

/* Sites List Cards */
#sites-list .bg-white {
    transition: all 0.3s ease;
}

#sites-list .bg-white:hover {
    transform: translateY(-2px);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .absolute.top-4.left-4,
    .absolute.bottom-4.left-4 {
        position: relative;
        top: auto;
        left: auto;
        bottom: auto;
        margin: 1rem;
        width: calc(100% - 2rem);
    }
    
    #program-sites-map {
        height: 400px !important;
    }
    
    .marker-cluster,
    .custom-marker-icon {
        transform: scale(0.9);
    }
    
    .leaflet-popup-content-wrapper {
        max-width: 250px;
    }
}

@media (max-width: 640px) {
    .container.mx-auto.px-4 {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .flex.flex-col.lg\\:flex-row.gap-4 {
        gap: 1rem;
    }
    
    .flex.flex-wrap.gap-2 {
        gap: 0.5rem;
    }
    
    select {
        font-size: 0.875rem;
        padding: 0.5rem;
    }
}

/* Print Styles */
@media print {
    #program-sites-map {
        height: 400px !important;
        background: white;
    }
    
    .absolute {
        display: none;
    }
    
    #mobile-bottom-sheet {
        display: none;
    }
    
    .filter-controls {
        display: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .custom-marker-icon {
        border-width: 3px;
        box-shadow: 0 0 0 2px white, 0 2px 8px rgba(0, 0, 0, 0.4);
    }
    
    .marker-cluster {
        border: 2px solid white;
    }
    
    .leaflet-popup-content-wrapper {
        border: 2px solid #184B77;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .custom-marker-icon,
    .filter-controls select,
    #map-search,
    #sites-list .bg-white {
        transition: none;
    }
    
    .animate-spin {
        animation: none;
    }
    
    #filter-tags span {
        animation: none;
    }
}

/* Focus Styles for Accessibility */
.leaflet-control-zoom a:focus,
#map-search:focus,
select:focus,
button:focus {
    outline: 2px solid #184B77;
    outline-offset: 2px;
}

/* Custom Scrollbar for Mobile Bottom Sheet */
#mobile-bottom-sheet::-webkit-scrollbar {
    width: 4px;
}

#mobile-bottom-sheet::-webkit-scrollbar-track {
    background: #f1f5f9;
}

#mobile-bottom-sheet::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

#mobile-bottom-sheet::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
