/* public/css/leaflet-custom.css */

/* Leaflet map container - ensure it has proper height */
#map {
    height: 600px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    position: relative;
    background: #f0f0f0;
}

/* Custom marker styles */
.custom-marker-icon {
    background: transparent;
    border: none;
}

.marker-pin {
    position: relative;
    width: 30px;
    height: 42px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.marker-pin.normal {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.marker-pin.emergency {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    animation: emergency-pulse 2s infinite;
}

.marker-pin.selected {
    transform: rotate(-45deg) scale(1.2);
    z-index: 1000 !important;
}

.marker-pin .marker-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    font-size: 16px;
    line-height: 1;
}

@keyframes emergency-pulse {
    0%, 100% { box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 4px 20px rgba(239, 68, 68, 0.6); }
}

/* User location marker */
.user-location-marker {
    background: transparent;
    border: none;
}

.pulse-marker {
    position: relative;
    width: 24px;
    height: 24px;
}

.pulse-marker .marker-center {
    position: absolute;
    width: 24px;
    height: 24px;
    background: #10b981;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 3;
}

.pulse-marker .pulse {
    position: absolute;
    width: 24px;
    height: 24px;
    background: rgba(16, 185, 129, 0.3);
    border-radius: 50%;
    animation: radar-pulse 2s infinite;
}

.pulse-marker .pulse:nth-child(2) {
    animation-delay: 1s;
}

@keyframes radar-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(3);
        opacity: 0;
    }
}

/* Marker cluster styles */
.marker-cluster {
    background-clip: padding-box;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.marker-cluster div {
    width: 40px;
    height: 40px;
    margin-left: 5px;
    margin-top: 5px;
    text-align: center;
    border-radius: 50%;
    font: 14px "Helvetica Neue", Arial, Helvetica, sans-serif;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-cluster span {
    line-height: 1;
}

.cluster-small {
    background-color: rgba(110, 204, 57, 0.6);
}

.cluster-small div {
    background-color: rgba(110, 204, 57, 0.9);
    color: white;
}

.cluster-medium {
    background-color: rgba(240, 194, 12, 0.6);
}

.cluster-medium div {
    background-color: rgba(240, 194, 12, 0.9);
    color: white;
}

.cluster-large {
    background-color: rgba(241, 128, 23, 0.6);
}

.cluster-large div {
    background-color: rgba(241, 128, 23, 0.9);
    color: white;
}

/* Custom popup styles */
.leaflet-popup {
    margin-bottom: 20px;
}

.leaflet-popup-content-wrapper {
    padding: 0;
    overflow: hidden;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.leaflet-popup-content {
    margin: 0;
    line-height: 1.4;
    min-width: 280px;
    max-width: 320px;
}

.leaflet-popup-content p {
    margin: 0;
}

.leaflet-popup-tip-container {
    width: 30px;
    height: 15px;
    position: absolute;
    left: 50%;
    margin-left: -15px;
    overflow: hidden;
    pointer-events: none;
}

.leaflet-popup-tip {
    background: white;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

/* Leaflet controls customization */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    border-radius: 12px !important;
    overflow: hidden;
}

.leaflet-control-zoom a {
    background-color: white !important;
    color: #333 !important;
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 18px !important;
    font-weight: normal !important;
    transition: all 0.3s ease;
}

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

.leaflet-control-zoom a:first-child {
    border-bottom: 1px solid #e5e7eb;
}

/* Leaflet attribution customization */
.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.8) !important;
    padding: 4px 8px !important;
    font-size: 11px !important;
    border-radius: 8px !important;
    margin: 10px !important;
}

/* Map loading indicator enhancement for Leaflet */
.map-loading-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 16px;
    border-radius: 20px;
    opacity: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.map-loading-indicator.active {
    opacity: 1;
}

/* Fix for Leaflet container in responsive layouts */
@media (max-width: 992px) {
    #map {
        height: 400px;
        margin-top: 20px;
    }
}

@media (max-width: 768px) {
    #map {
        height: 350px;
    }

    .leaflet-control-zoom {
        margin: 10px !important;
    }
}

/* Leaflet popup close button customization */
.leaflet-container a.leaflet-popup-close-button {
    color: #c3c3c3;
    text-decoration: none;
    font-size: 20px;
    font-weight: normal;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    padding: 0;
    background: transparent;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.leaflet-container a.leaflet-popup-close-button:hover {
    color: #999;
    background: #f3f4f6;
}

/* Fix z-index issues */
.leaflet-pane {
    z-index: 400;
}

.leaflet-popup-pane {
    z-index: 700;
}

.leaflet-control {
    z-index: 800;
}

/* Map stats overlay for Leaflet */
.map-stats {
    position: absolute;
    bottom: 60px;
    left: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 12px;
    color: #6b7280;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

/* Ensure proper stacking of map elements */
.leaflet-top, .leaflet-bottom {
    z-index: 1000;
}

/* Custom control button styling */
.map-control {
    background: white;
    border: none;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 10px;
}

.map-control:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

/* Marker animation on hover */
.leaflet-marker-icon:hover .marker-pin {
    transform: rotate(-45deg) scale(1.1);
}

/* Custom attribution below map */
.map-attribution-custom {
    background: white;
    border-radius: 0 0 20px 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-top: -1px;
    position: relative;
    z-index: 400;
}

.map-attribution-custom a {
    text-decoration: none;
    transition: color 0.2s ease;
}

.map-attribution-custom a:hover {
    text-decoration: underline;
}

/* Hide default Leaflet attribution if desired */
.leaflet-control-attribution {
    display: none;
}

/* Alternative: Style the default attribution */
.leaflet-control-attribution-alt {
    background: rgba(255, 255, 255, 0.9) !important;
    padding: 6px 12px !important;
    font-size: 12px !important;
    border-radius: 12px !important;
    margin: 10px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

.leaflet-control-attribution-alt a {
    color: #3b82f6 !important;
    font-weight: 500;
}
