/* Frontend Styles for Fiji Villages Map */

#fvm-map-container {
    position: relative;
    width: 100%;
    margin: 0;
    padding: 0;
    isolation: isolate; /* Create new stacking context */
}

#fvm-map {
    position: relative;
    z-index: 1;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Search Control - Fixed within map container */
.fvm-search-control {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 999; /* Below global header but above map */
    background: white;
    padding: 10px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    max-width: 280px;
}

.fvm-search-control input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 250px;
    font-size: 14px;
}

.fvm-search-control input:focus {
    outline: none;
    border-color: #4CAF50;
}

.fvm-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: none;
}

.fvm-search-results.active {
    display: block;
}

.fvm-search-result-item {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s;
}

.fvm-search-result-item:hover {
    background-color: #f5f5f5;
}

.fvm-search-result-item:last-child {
    border-bottom: none;
}

.fvm-search-result-name {
    font-weight: 600;
    color: #333;
}

.fvm-search-result-island {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

/* Legend Control */
.fvm-legend-control {
    position: absolute;
    bottom: 30px;
    right: 10px;
    z-index: 999; /* Same as search control */
    background: white;
    padding: 15px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    min-width: 150px;
}

.fvm-legend-control h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.fvm-legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
}

.fvm-legend-item:last-child {
    margin-bottom: 0;
}

.fvm-legend-marker {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 8px;
    border: 2px solid rgba(0,0,0,0.3);
}

.fvm-legend-marker.blue-marker {
    background-color: #2196F3;
}

/* Popup Styling - Scrollable Content */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 3px 14px rgba(0,0,0,0.3);
    max-height: 70vh; /* Maximum 70% of viewport height */
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0;
    padding: 15px;
    min-width: 300px;
    max-width: 500px;
    max-height: 60vh; /* Scrollable if content exceeds 60% of viewport */
    overflow-y: auto; /* Enable vertical scrolling */
    overflow-x: hidden; /* Prevent horizontal scroll */
    scroll-behavior: smooth; /* Smooth scrolling */
}

/* Custom scrollbar styling for webkit browsers (Chrome, Safari, Edge) */
.leaflet-popup-content::-webkit-scrollbar {
    width: 10px;
}

.leaflet-popup-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
    margin: 5px 0;
}

.leaflet-popup-content::-webkit-scrollbar-thumb {
    background: #0468b1;
    border-radius: 5px;
    border: 2px solid #f1f1f1;
}

.leaflet-popup-content::-webkit-scrollbar-thumb:hover {
    background: #0468b1;
}

/* Firefox scrollbar styling */
.leaflet-popup-content {
    scrollbar-width: thin;
    scrollbar-color: #0468b1#f1f1f1;
}

/* Visual indicator for scrollable content */
.leaflet-popup-content::after {
    content: '';
    position: sticky;
    bottom: -15px;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.9));
    pointer-events: none;
    margin-left: -15px;
    margin-right: -15px;
    margin-bottom: -15px;
}

.fvm-popup-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0 0 15px 0;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 8px;
    position: sticky;
    top: -15px; /* Account for parent padding */
    background: white;
    z-index: 10;
    margin-left: -15px;
    margin-right: -15px;
    margin-top: -15px;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 15px;
}

.fvm-popup-details {
    margin: 15px 0;
}

.fvm-popup-detail-item {
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.5;
}

.fvm-popup-detail-label {
    font-weight: 600;
    color: #555;
    display: inline-block;
    min-width: 100px;
}

.fvm-popup-detail-value {
    color: #333;
}

.fvm-popup-card-content {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.fvm-popup-card-content h3 {
    font-size: 16px;
    margin: 0 0 10px 0;
    color: #333;
}

.fvm-popup-card-content img {
    max-width: 100%;
    height: auto;
    margin: 10px 0;
    border-radius: 4px;
}

.fvm-popup-card-content p {
    margin: 8px 0;
    line-height: 1.6;
}

/* Marker Clusters (if needed later) */
.marker-cluster-small {
    background-color: rgba(76, 175, 80, 0.6);
}

.marker-cluster-small div {
    background-color: rgba(76, 175, 80, 0.8);
}

.marker-cluster-medium {
    background-color: rgba(33, 150, 243, 0.6);
}

.marker-cluster-medium div {
    background-color: rgba(33, 150, 243, 0.8);
}

/* Responsive Design */
@media (max-width: 768px) {
    .fvm-search-control {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .fvm-search-control input {
        width: 100%;
    }
    
    .fvm-legend-control {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
    
    .leaflet-popup-content-wrapper {
        max-height: 80vh; /* More space on mobile */
    }
    
    .leaflet-popup-content {
        min-width: 250px;
        max-width: 90vw;
        max-height: 70vh; /* More scrollable space on mobile */
    }
}

/* Loading State */
#fvm-map.loading::after {
    content: "Loading map data...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px 30px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 2000;
    font-weight: 600;
    color: #333;
}
