/* =========================================
   Location Splash Overlay
   ========================================= */

.loc-splash {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.loc-splash.dismiss {
    opacity: 0;
    transform: scale(1.05);
    pointer-events: none;
}

.loc-splash-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 50%, rgba(59, 130, 246, 0.06) 0%, transparent 70%),
        linear-gradient(180deg, #080e1e 0%, #0f172a 40%, #111827 100%);
    z-index: 0;
}

/* Grid lines — fallback behind map */
.loc-splash-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(59, 130, 246, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.04) 1px, transparent 1px);
    background-size: 60px 60px;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
}

/* Live Leaflet map fills the splash background */
.loc-splash-map {
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* Dark vignette over the map so radar/text are readable */
.loc-splash-vignette {
    position: absolute;
    inset: 0;
    z-index: 2;
    background:
        radial-gradient(ellipse at center, rgba(255, 255, 255, 0.1) 0%, rgba(240, 244, 255, 0.4) 60%, rgba(248, 250, 252, 0.7) 100%);
    pointer-events: none;
}

/* Splash detected marker on map */
.splash-detected-marker {
    position: relative;
}

.sdm-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background: #3b82f6;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.8);
    z-index: 3;
}

.sdm-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 2px solid rgba(59, 130, 246, 0.5);
    border-radius: 50%;
    animation: sdmPulse 2s ease-out infinite;
    z-index: 1;
}

.sdm-ring-2 {
    animation-delay: 1s;
}

@keyframes sdmPulse {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(3); opacity: 0; }
}

/* Radar — sits above vignette */
.loc-radar {
    position: relative;
    width: 240px;
    height: 240px;
    z-index: 3;
    margin-bottom: 40px;
}

.loc-radar-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    border-radius: 50%;
    border: 1.5px solid rgba(59, 130, 246, 0.35);
    opacity: 0;
    animation: radarExpand 3s ease-out infinite;
}

.loc-radar-ring-1 {
    width: 100px;
    height: 100px;
    animation-delay: 0s;
}

.loc-radar-ring-2 {
    width: 170px;
    height: 170px;
    animation-delay: 1s;
}

.loc-radar-ring-3 {
    width: 240px;
    height: 240px;
    animation-delay: 2s;
}

@keyframes radarExpand {
    0% {
        transform: translate(-50%, -50%) scale(0.3);
        opacity: 0.8;
        border-color: rgba(59, 130, 246, 0.5);
    }
    60% {
        opacity: 0.3;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.6);
        opacity: 0;
        border-color: rgba(99, 102, 241, 0);
    }
}

/* Center dot */
.loc-radar-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background: #3b82f6;
    border-radius: 50%;
    box-shadow:
        0 0 20px rgba(59, 130, 246, 0.7),
        0 0 60px rgba(59, 130, 246, 0.3);
    animation: dotPulse 1.5s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); box-shadow: 0 0 20px rgba(59, 130, 246, 0.7), 0 0 60px rgba(59, 130, 246, 0.3); }
    50% { transform: translate(-50%, -50%) scale(1.3); box-shadow: 0 0 30px rgba(59, 130, 246, 0.9), 0 0 80px rgba(59, 130, 246, 0.4); }
}

/* Status text */
.loc-splash-status {
    z-index: 4;
    font-size: 15px;
    font-weight: 600;
    color: #334155;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-shadow: 0 1px 4px rgba(255, 255, 255, 0.8);
    transition: all 0.4s ease;
}

.loc-splash.found .loc-splash-status {
    color: #059669;
    font-weight: 700;
}

/* District name — big reveal */
.loc-splash-name {
    z-index: 4;
    font-size: 48px;
    font-weight: 800;
    color: transparent;
    background: linear-gradient(135deg, #1e293b, #1d4ed8, #4338ca);
    -webkit-background-clip: text;
    background-clip: text;
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.6);
    margin-top: 12px;
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.loc-splash.found .loc-splash-name {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* When found — stop radar, turn dot green */
.loc-splash.found .loc-radar-ring {
    animation-play-state: paused;
    opacity: 0 !important;
}

.loc-splash.found .loc-radar-dot {
    background: #10b981;
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.8), 0 0 60px rgba(16, 185, 129, 0.3);
    animation: none;
    transform: translate(-50%, -50%) scale(1.2);
    transition: all 0.5s ease;
}

/* =========================================
   Map Panel
   ========================================= */

.map-panel {
    width: 0;
    overflow: hidden;
    background-color: #0f172a;
    border-right: 1px solid rgba(59, 130, 246, 0.2);
    display: flex;
    flex-direction: column;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 15;
}

.map-panel.open {
    width: 420px;
}

.map-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(59, 130, 246, 0.15);
    flex-shrink: 0;
}

.map-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.map-panel-title h3 {
    font-size: 15px;
    font-weight: 500;
    color: #e2e8f0;
    white-space: nowrap;
}

.close-map-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-map-btn:hover {
    background: rgba(148, 163, 184, 0.15);
    color: #e2e8f0;
}

.map-body {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.map-container {
    width: 100%;
    height: 100%;
    background: #0f172a;
}

/* District Info Card — Glassmorphism */
.district-info-card {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 24px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 60px rgba(59, 130, 246, 0.08);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 20;
    white-space: nowrap;
    pointer-events: none;
}

.district-info-card.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.district-info-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.district-info-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.district-info-status {
    font-size: 11px;
    font-weight: 500;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.district-info-name {
    font-size: 20px;
    font-weight: 600;
    color: #f1f5f9;
    background: linear-gradient(90deg, #e2e8f0, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Leaflet Tooltip Overrides */
.district-tooltip {
    background: rgba(15, 23, 42, 0.92) !important;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(59, 130, 246, 0.3) !important;
    border-radius: 8px !important;
    color: #e2e8f0 !important;
    font-family: 'Outfit', sans-serif !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    padding: 6px 12px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) !important;
}

.district-tooltip::before {
    border-top-color: rgba(15, 23, 42, 0.92) !important;
}

.highlight-tooltip {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(99, 102, 241, 0.9)) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    padding: 8px 16px !important;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4) !important;
}

.highlight-tooltip::before {
    border-top-color: rgba(59, 130, 246, 0.9) !important;
}

.user-tooltip {
    background: rgba(16, 185, 129, 0.9) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.user-tooltip::before {
    border-top-color: rgba(16, 185, 129, 0.9) !important;
}

/* Pulsing User Location Marker */
.user-pulse-marker {
    position: relative;
}

.pulse-core {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
    z-index: 2;
}

.pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    background: rgba(16, 185, 129, 0.25);
    border-radius: 50%;
    animation: pulseRing 2s ease-out infinite;
    z-index: 1;
}

@keyframes pulseRing {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0;
    }
}

/* Glowing District Highlight Marker */
.district-glow-marker {
    position: relative;
}

.glow-core {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.7);
    z-index: 3;
}

.glow-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 2px solid rgba(59, 130, 246, 0.4);
    border-radius: 50%;
    animation: glowPulse 2.5s ease-out infinite;
    z-index: 1;
}

.glow-ring-2 {
    animation-delay: 1.25s;
}

@keyframes glowPulse {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
        border-color: rgba(59, 130, 246, 0.6);
    }
    100% {
        transform: translate(-50%, -50%) scale(3);
        opacity: 0;
        border-color: rgba(99, 102, 241, 0);
    }
}
