/**
 * Custom Mapbox Styles for MatchaNear.Me
 */

/* Map Container */
#map {
    width: 100%;
    height: 600px;
    border-radius: 8px;
    border: 1px solid var(--border-color, #e0e0e0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* View Toggle Container */
.view-toggle-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    gap: 8px;
}

.view-toggle-btn {
    padding: 10px 24px;
    background-color: white;
    border: 2px solid var(--border-color, #e0e0e0);
    color: var(--secondary-color, #666);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.view-toggle-btn:hover {
    border-color: var(--primary-color, #6B9F78);
    color: var(--primary-color, #6B9F78);
    transform: translateY(-2px);
}

.view-toggle-btn.active {
    background-color: var(--primary-color, #6B9F78);
    color: white;
    border-color: var(--primary-color, #6B9F78);
}

.view-toggle-btn i {
    font-size: 16px;
}

/* Map View Container */
#mapView {
    display: none;
}

#mapView.active {
    display: block;
}

/* List View Container */
#listView.hidden {
    display: none;
}

/* Custom Map Popup Styles */
.mapboxgl-popup-content {
    padding: 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 280px;
}

/* Close Button Styling */
.mapboxgl-popup-close-button {
    font-size: 24px;
    padding: 8px 12px;
    color: #666;
    background: white;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    right: 8px;
    top: 8px;
    transition: all 0.2s ease;
}

.mapboxgl-popup-close-button:hover {
    background: #f0f0f0;
    color: #333;
    transform: scale(1.1);
}

.mapboxgl-popup-close-button:focus {
    outline: 2px solid var(--primary-color, #6B9F78);
    outline-offset: 2px;
}

.map-popup {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.popup-image {
    width: 100%;
    height: 140px;
    background-size: cover;
    background-position: center;
    background-color: #f5f5f5;
}

.popup-content {
    padding: 16px;
}

.popup-title {
    font-size: 18px;
    font-weight: 300;
    color: #2c3e50;
    margin: 0 0 8px 0;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.popup-location {
    font-size: 13px;
    color: #666;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.popup-rating {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 13px;
}

.rating-stars {
    background-color: #FFF8E1;
    color: #F57C00;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 500;
}

.purity-score {
    background-color: #E8F5E9;
    color: #2E7D32;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 500;
}

.popup-signature {
    font-size: 13px;
    color: #555;
    margin-bottom: 12px;
    padding: 8px;
    background-color: #f9f9f9;
    border-radius: 6px;
    border-left: 3px solid var(--primary-color, #6B9F78);
}

.popup-features {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.feature-tag {
    font-size: 11px;
    padding: 4px 8px;
    background-color: #f0f0f0;
    color: #555;
    border-radius: 4px;
}

.popup-link {
    display: inline-block;
    width: 100%;
    text-align: center;
    padding: 10px;
    background-color: var(--primary-color, #6B9F78);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.popup-link:hover {
    background-color: #5a8a67;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(107, 159, 120, 0.3);
}

/* Custom Marker Styles */
.custom-marker {
    position: relative;
}

/* Individual marker styling (for clustered view) */
.mapboxgl-canvas-container canvas {
    /* Ensure canvas is properly rendered */
}

/* Add background to emoji markers */
.mapboxgl-marker.mapboxgl-marker-anchor-center {
    /* For symbol layer markers */
}

/* Mapbox Control Styles */
.mapboxgl-ctrl-group {
    border-radius: 6px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

.mapboxgl-ctrl-group button {
    width: 36px !important;
    height: 36px !important;
}

.mapboxgl-ctrl-geolocate {
    background-color: white !important;
}

/* Map Loading Indicator */
.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

.map-loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color, #6B9F78);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
}

/* Highlighted Card from Map Click */
.listing-card.map-highlighted {
    outline: 3px solid var(--primary-color, #6B9F78);
    outline-offset: 2px;
    animation: pulse-highlight 1s ease-in-out;
}

@keyframes pulse-highlight {
    0%, 100% {
        outline-color: var(--primary-color, #6B9F78);
    }
    50% {
        outline-color: rgba(107, 159, 120, 0.5);
    }
}

/* Responsive Map Styles */
@media (max-width: 768px) {
    #map {
        height: 500px;
        border-radius: 0;
    }

    .mapboxgl-popup-content {
        min-width: 260px;
    }

    .popup-title {
        font-size: 16px;
    }

    .view-toggle-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
}

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

    .popup-image {
        height: 120px;
    }

    .popup-content {
        padding: 12px;
    }

    .mapboxgl-popup-content {
        min-width: 240px;
    }
}

/* Map Stats Overlay */
.map-stats-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1;
    font-size: 13px;
    color: #666;
}

.map-stats-overlay strong {
    color: var(--primary-color, #6B9F78);
    font-weight: 600;
}

/* Cluster Marker Styles (if clustering is implemented) */
.marker-cluster {
    background-color: var(--primary-color, #6B9F78);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.marker-cluster:hover {
    transform: scale(1.1);
}

/* Premium Marker Pulse Effect */
@keyframes marker-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(212, 175, 55, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(212, 175, 55, 0);
    }
}

.custom-marker.premium {
    animation: marker-pulse 2s infinite;
}

