/**
 * Interactive Park Maps Styles
 * 
 * @package StateParksCPT
 * @version 1.0.0
 */

/* ==========================================================================
   Map Container
   ========================================================================== */

.asp-park-map {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    position: relative;
    background: #e5e7eb;
}

.asp-park-map[data-loading="true"]::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid #2d5016;
    border-top-color: transparent;
    border-radius: 50%;
    animation: asp-spin 0.8s linear infinite;
    z-index: 1000;
}

@keyframes asp-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ==========================================================================
   Custom Marker
   ========================================================================== */

.asp-map-marker {
    background: transparent !important;
    border: none !important;
}

.asp-map-marker svg {
    width: 32px;
    height: 40px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transition: transform 0.2s ease;
}

.asp-map-marker:hover svg {
    transform: scale(1.1);
}

/* ==========================================================================
   Marker Clusters (Dynamic Colors)
   Background colors are set inline via JavaScript based on activity category
   ========================================================================== */

.asp-marker-cluster {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    border: 3px solid #fff;
}

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

.asp-marker-cluster span {
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.asp-marker-cluster-small {
    width: 36px !important;
    height: 36px !important;
}

.asp-marker-cluster-medium {
    width: 44px !important;
    height: 44px !important;
}

.asp-marker-cluster-medium span {
    font-size: 15px;
}

.asp-marker-cluster-large {
    width: 52px !important;
    height: 52px !important;
}

.asp-marker-cluster-large span {
    font-size: 16px;
}

/* ==========================================================================
   Popups
   ========================================================================== */

.leaflet-popup-content-wrapper {
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
}

.leaflet-popup-content {
    margin: 0;
    min-width: 200px;
}

.asp-map-popup {
    display: flex;
    flex-direction: column;
}

.asp-popup-thumb {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.asp-popup-content {
    padding: 12px 16px;
}

.asp-popup-title {
    display: block;
    font-weight: 600;
    font-size: 15px;
    color: #1a1a1a;
    text-decoration: none;
    line-height: 1.3;
    margin-bottom: 4px;
}

.asp-popup-title:hover {
    color: #2d5016;
}

.asp-popup-state {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
}

/* Activity Tags in Popup */
.asp-popup-activities {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.asp-popup-activity {
    display: inline-block;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    white-space: nowrap;
    border: 1px solid;
    /* Colors are set inline via JavaScript */
}

.asp-popup-link {
    text-decoration: none;
    color: inherit;
}

.leaflet-popup-tip {
    background: #fff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Map Count
   ========================================================================== */

.asp-map-count {
    text-align: center;
    padding: 12px 0;
    font-size: 14px;
    color: #666;
}

.asp-map-count-number {
    font-weight: 700;
    color: #2d5016;
    font-size: 18px;
}

/* ==========================================================================
   Map Wrapper & Legend
   ========================================================================== */

.asp-map-wrapper {
    position: relative;
}

/* Legend Base */
.asp-map-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
}

/* Single Legend (Activity Archives) */
.asp-map-legend-single {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
}

/* Multi Legend (State Archives) */
.asp-map-legend-multi {
    max-width: 200px;
}

.asp-legend-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    text-align: left;
    border-radius: 10px 10px 0 0;
    transition: background 0.2s;
}

.asp-legend-toggle:hover {
    background: rgba(0, 0, 0, 0.03);
}

.asp-legend-toggle svg {
    flex-shrink: 0;
    color: #666;
}

.asp-legend-toggle[aria-expanded="false"]+.asp-legend-items {
    display: none;
}

.asp-legend-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 8px 8px;
    max-height: 250px;
    overflow-y: auto;
}

.asp-legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.2s;
    cursor: default;
}

.asp-legend-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

.asp-legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.asp-legend-label {
    color: #444;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Legend Items Scrollbar */
.asp-legend-items::-webkit-scrollbar {
    width: 4px;
}

.asp-legend-items::-webkit-scrollbar-track {
    background: transparent;
}

.asp-legend-items::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}


/* ==========================================================================
   Leaflet Overrides
   ========================================================================== */

.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
    border-radius: 8px !important;
    overflow: hidden;
}

.leaflet-control-zoom a {
    width: 32px !important;
    height: 32px !important;
    line-height: 32px !important;
    font-size: 16px !important;
    color: #333 !important;
    background: #fff !important;
    border: none !important;
}

.leaflet-control-zoom a:hover {
    background: #f5f5f5 !important;
}

.leaflet-control-attribution {
    font-size: 10px;
    background: rgba(255, 255, 255, 0.8) !important;
    padding: 2px 6px !important;
    border-radius: 4px 0 0 0;
}

/* ==========================================================================
   Map in Single Park Template
   ========================================================================== */

.sp-single-map-section {
    max-width: 100%;
    padding: 40px clamp(20px, 5vw, 80px);
}

.sp-single-map-header {
    margin-bottom: 24px;
}

.sp-single-map-header h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a5a1a;
    margin: 0;
}

.sp-single-map-header svg {
    width: 28px;
    height: 28px;
    color: #4CAF50;
}

.sp-single-map-container {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.sp-single-map-container .asp-park-map {
    width: 100% !important;
    min-height: 450px;
}

.sp-single-map-address {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 12px 16px;
    background: #f8faf8;
    border-radius: 8px;
    font-size: 0.95rem;
    color: #333;
}

.sp-map-address-icon {
    color: #1a5a1a;
}

.sp-map-address-icon svg {
    width: 18px;
    height: 18px;
}

/* ==========================================================================
   Map in State Archive Template
   ========================================================================== */

.sp-map-section {
    padding: 60px 0;
    background: linear-gradient(to bottom, #f8faf8, #fff);
}

.sp-map-section .sp-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.sp-map-container {
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.sp-map-container .asp-park-map {
    border-radius: 0;
}

/* ==========================================================================
   Map in Activity Archive Template
   ========================================================================== */

.sp-activity-map-section {
    padding: 40px 20px;
    background: linear-gradient(135deg, #f0f7f0 0%, #e8f5e9 100%);
    margin-bottom: 40px;
}

.sp-activity-map-header {
    max-width: 1200px;
    margin: 0 auto 24px;
    text-align: center;
}

.sp-activity-map-header h2 {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 1.75rem;
    font-weight: 700;
    color: #1a5a1a;
    margin: 0 0 12px;
}

.sp-activity-map-header h2 svg {
    width: 32px;
    height: 32px;
    color: #4CAF50;
}

.sp-activity-map-header p {
    font-size: 1.1rem;
    color: #666;
    margin: 0;
}

.sp-activity-map-container {
    max-width: 1200px;
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 992px) {
    .sp-single-map-section {
        padding: 24px;
    }

    .sp-map-section {
        padding: 40px 0;
    }

    .sp-activity-map-section {
        padding: 32px 16px;
    }

    .sp-activity-map-header h2 {
        font-size: 1.5rem;
    }
}

@media (max-width: 768px) {
    .asp-park-map-multi {
        height: 350px !important;
    }

    .asp-popup-thumb {
        height: 100px;
    }

    .leaflet-popup-content {
        min-width: 180px;
    }

    .sp-single-map-section {
        padding: 16px;
    }

    .sp-single-map-header h2 {
        font-size: 1.25rem;
    }

    .sp-activity-map-header h2 {
        font-size: 1.25rem;
        flex-direction: column;
        gap: 8px;
    }

    .sp-activity-map-header p {
        font-size: 1rem;
    }
}

/* ==========================================================================
   Mobile Legend - Better touch experience
   ========================================================================== */

@media (max-width: 640px) {
    .asp-map-legend {
        /* Position below map instead of overlaying */
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        margin: 12px !important;
        width: calc(100% - 24px) !important;
        max-width: none !important;
    }

    .asp-map-legend-multi {
        max-width: none !important;
    }

    .asp-legend-items {
        max-height: 150px;
        /* Reduced height for mobile */
    }

    .asp-legend-toggle {
        padding: 12px 16px;
        /* Larger touch target */
    }
}