/* Map Container Styles */
.map-container {
    position: relative;
    height: calc(100vh - 56px);
    width: 100%;
    overflow: hidden;
}

#map {
    height: 100%;
    width: 100%;
    z-index: 1;
}

/* Map Legend */
.map-legend {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    min-width: 180px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.map-legend h6 {
    margin: 0 0 10px 0;
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.8rem;
    color: #555;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    margin-right: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

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

.leaflet-popup-content {
    margin: 15px 20px;
    line-height: 1.5;
    font-size: 0.9rem;
}

.leaflet-popup-tip {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Custom Popup Content */
.popup-header {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.popup-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    padding: 3px 0;
}

.popup-metric-label {
    color: #666;
    font-size: 0.85rem;
}

.popup-metric-value {
    font-weight: 600;
    color: #333;
}

.popup-chart-button {
    background: #0d6efd;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    margin-top: 8px;
    width: 100%;
    transition: background-color 0.2s;
}

.popup-chart-button:hover {
    background: #0b5ed7;
}

/* Traffic Intensity Colors */
.traffic-marker {
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.traffic-heavy {
    background-color: #d73027;
}

.traffic-moderate {
    background-color: #fc8d59;
}

.traffic-light {
    background-color: #fee08b;
}

.traffic-minimal {
    background-color: #d9ef8b;
}

.traffic-very-light {
    background-color: #91bfdb;
}

/* Leaflet Control Customization */
.leaflet-control-zoom {
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.leaflet-control-zoom a {
    background-color: white;
    color: #333;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    transition: all 0.2s;
}

.leaflet-control-zoom a:hover {
    background-color: #f8f9fa;
    color: #0d6efd;
}

.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
    border-radius: 4px;
    font-size: 0.75rem;
}

/* Custom Map Controls */
.map-controls {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.map-control-button {
    background: white;
    border: none;
    padding: 10px;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    color: #333;
    min-width: 120px;
}

.map-control-button:hover {
    background: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.map-control-button.active {
    background: #0d6efd;
    color: white;
}

/* Heatmap Layer Styles */
.leaflet-heatmap-layer {
    opacity: 0.7;
}

/* Cluster Marker Styles */
.marker-cluster {
    background-color: rgba(13, 110, 253, 0.8);
    border: 3px solid rgba(13, 110, 253, 0.3);
    border-radius: 50%;
    color: white;
    font-weight: 600;
    text-align: center;
    font-size: 12px;
}

.marker-cluster-small {
    width: 30px;
    height: 30px;
    line-height: 24px;
}

.marker-cluster-medium {
    width: 40px;
    height: 40px;
    line-height: 34px;
}

.marker-cluster-large {
    width: 50px;
    height: 50px;
    line-height: 44px;
}

/* Loading States */
.map-loading {
    position: relative;
}

.map-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    z-index: 999;
    pointer-events: none;
}

/* Responsive Map Styles */
@media (max-width: 768px) {
    .map-legend {
        bottom: 10px;
        right: 10px;
        left: 10px;
        padding: 10px;
        min-width: auto;
    }
    
    .map-legend h6 {
        font-size: 0.8rem;
    }
    
    .legend-item {
        font-size: 0.75rem;
    }
    
    .legend-color {
        width: 12px;
        height: 12px;
    }
    
    .map-controls {
        top: 10px;
        left: 10px;
        right: 10px;
    }
    
    .map-control-button {
        padding: 8px;
        font-size: 0.8rem;
        min-width: auto;
    }
    
    .leaflet-popup-content {
        margin: 10px 15px;
        font-size: 0.8rem;
    }
}

@media (max-width: 576px) {
    .map-legend {
        position: relative;
        bottom: auto;
        right: auto;
        left: auto;
        margin: 10px;
        border-radius: 6px;
    }
    
    .leaflet-control-zoom {
        margin-right: 10px !important;
        margin-bottom: 60px !important;
    }
    
    .leaflet-popup-content-wrapper {
        max-width: 250px;
    }
}

/* Animation for Map Elements */
.map-marker-animate {
    animation: markerPulse 2s infinite;
}

@keyframes markerPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.fade-in-map {
    animation: fadeInMap 0.5s ease-in;
}

@keyframes fadeInMap {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .map-legend {
        background: rgba(33, 37, 41, 0.95);
        color: #f8f9fa;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .map-legend h6 {
        color: #f8f9fa;
        border-bottom-color: #495057;
    }
    
    .legend-item {
        color: #ced4da;
    }
    
    .map-control-button {
        background: #495057;
        color: #f8f9fa;
    }
    
    .map-control-button:hover {
        background: #6c757d;
    }
    
    .popup-header {
        color: #f8f9fa;
    }
    
    .popup-metric-label {
        color: #ced4da;
    }
    
    .popup-metric-value {
        color: #f8f9fa;
    }
}

/* County Polygon Styles */
.leaflet-interactive {
    cursor: pointer;
    transition: all 0.2s ease;
}

.leaflet-interactive:hover {
    filter: brightness(1.1);
}

/* County polygon popup styling */
.traffic-popup .leaflet-popup-content {
    margin: 12px 16px;
    line-height: 1.4;
}

.traffic-popup .popup-header {
    font-weight: 600;
    font-size: 16px;
    color: var(--primary-color);
    margin-bottom: 8px;
    border-bottom: 1px solid #eee;
    padding-bottom: 4px;
}

.traffic-popup .popup-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 8px 0;
}

.traffic-popup .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px;
    background: #f8f9fa;
    border-radius: 4px;
}

.traffic-popup .stat-value {
    font-weight: 600;
    font-size: 18px;
    color: var(--primary-color);
}

.traffic-popup .stat-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Print Styles for Maps */
@media print {
    .map-legend,
    .map-controls,
    .leaflet-control-zoom,
    .leaflet-control-attribution {
        display: none !important;
    }
    
    #map {
        height: 600px !important;
    }
}
