/* ============================================
   Map Container
   ============================================ */
#map {
    width: 100%;
    height: calc(100vh - 80px);
    position: relative;
    z-index: 1;
}

/* ============================================
   Video Panel (Slide-in from right) — Modern
   ============================================ */
.video-panel {
    position: fixed;
    top: 92px;
    right: 12px;
    width: 40%;
    max-width: 560px;
    min-width: 320px;
    height: calc(100vh - 104px);
    background: linear-gradient(180deg, #0f1320 0%, #151923 100%);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: var(--radius-lg);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.6), 0 8px 32px rgba(0, 0, 0, 0.4), -2px 0 8px rgba(99, 102, 241, 0.08);
    z-index: 1000;
    transform: translateX(calc(100% + 24px));
    transition: transform var(--transition-slow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.video-panel.active {
    transform: translateX(0);
}

/* Panel Header */
.panel-header {
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(99, 102, 241, 0.12);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 48px;
    flex-shrink: 0;
}

.panel-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.panel-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-accent-success);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
    animation: livePulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes livePulse {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
    }

    50% {
        opacity: 0.5;
        box-shadow: 0 0 16px rgba(16, 185, 129, 0.3);
    }
}

.panel-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.02em;
}

.panel-close {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--color-text-muted);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.panel-close:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--color-accent-danger);
}

/* Panel Video Area */
.panel-video {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    background: #000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.panel-video video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: #000;
}

/* Live Badge Overlay */
.panel-video-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(239, 68, 68, 0.85);
    backdrop-filter: blur(4px);
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 700;
    color: white;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    z-index: 5;
    pointer-events: none;
}

.badge-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: white;
    animation: livePulse 1.5s ease-in-out infinite;
}

/* Camera Selector (for multi-camera locations) */
.camera-selector {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.camera-selector-label {
    font-size: 0.625rem;
    color: var(--color-text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.camera-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.camera-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--color-text-secondary);
    font-size: 0.75rem;
}

.camera-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--color-text-primary);
}

.camera-item.active {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.35);
    color: var(--color-accent-primary);
    font-weight: 500;
}

.camera-item-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--color-accent-success);
    flex-shrink: 0;
    box-shadow: 0 0 4px rgba(16, 185, 129, 0.4);
}

.camera-item-dot.inactive {
    background: var(--color-accent-danger);
    box-shadow: 0 0 4px rgba(239, 68, 68, 0.4);
}

/* Weather Footer */
.panel-weather {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 10px 14px;
    margin-top: auto;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.25);
}

.weather-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 0;
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

.weather-loading .hls-loading {
    width: 16px;
    height: 16px;
}

/* Weather Main — icon + temp + description */
.weather-main {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.weather-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 6px rgba(255, 255, 255, 0.15));
}

.weather-temp-block {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.weather-temp {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-primary);
    line-height: 1;
    letter-spacing: -0.02em;
}

.weather-desc {
    font-size: 0.6875rem;
    color: var(--color-text-secondary);
    text-transform: capitalize;
    font-weight: 500;
}

/* Weather Details — 3 items in a row */
.weather-details {
    display: flex;
    gap: 4px;
}

.weather-detail-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
}

.weather-detail-item:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(99, 102, 241, 0.2);
}

.weather-detail-icon {
    font-size: 0.875rem;
    line-height: 1;
}

.weather-detail-label {
    font-size: 0.5rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    white-space: nowrap;
}

.weather-detail-value {
    font-size: 0.6875rem;
    color: var(--color-text-primary);
    font-weight: 600;
    white-space: nowrap;
}

/* Weather Error */
.weather-error {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

/* ============================================
   Custom Map Markers
   ============================================ */
.cctv-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--gradient-primary);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 3px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.5);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.cctv-marker:hover {
    transform: rotate(-45deg) scale(1.2);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.7);
}

.cctv-marker.active {
    background: var(--gradient-accent);
    box-shadow: 0 4px 20px rgba(236, 72, 153, 0.6);
    transform: rotate(-45deg) scale(1.2);
    z-index: 100;
}

.cctv-marker.inactive {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.5);
    border-color: rgba(255, 255, 255, 0.8);
}

.cctv-marker-inner {
    transform: rotate(45deg);
    font-size: 14px;
    line-height: 1;
}

/* Leaflet popup override */
.leaflet-popup-content-wrapper {
    background: var(--color-bg-secondary) !important;
    color: var(--color-text-primary) !important;
    border-radius: var(--radius-md) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: var(--shadow-lg) !important;
}

.leaflet-popup-tip {
    background: var(--color-bg-secondary) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.leaflet-popup-content {
    margin: 10px 14px !important;
    font-family: var(--font-family) !important;
    font-size: 0.8125rem !important;
}

.popup-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 4px;
    color: var(--color-text-primary);
}

.popup-subtitle {
    color: var(--color-text-muted);
    font-size: 0.75rem;
    margin-bottom: 8px;
}

.popup-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-family);
    transition: all var(--transition-fast);
    width: 100%;
    justify-content: center;
}

.popup-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

/* Leaflet close button override */
.leaflet-popup-close-button {
    color: var(--color-text-muted) !important;
}

.leaflet-popup-close-button:hover {
    color: var(--color-text-primary) !important;
}

/* ============================================
   Responsive — Video Panel
   ============================================ */
@media (max-width: 768px) {
    .video-panel {
        width: 100%;
        max-width: 100%;
        min-width: unset;
        height: 60vh;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        transform: translateY(100%);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .video-panel.active {
        transform: translateY(0);
    }

    #map {
        height: calc(100vh - 80px);
    }

    .video-panel.active~#map,
    body.panel-open #map {
        height: calc(40vh - 80px);
    }
}

@media (max-width: 480px) {
    .video-panel {
        height: 55vh;
    }

    .panel-header {
        padding: var(--spacing-xs) var(--spacing-sm);
        min-height: 44px;
    }

    .panel-title {
        font-size: 0.8125rem;
    }
}