/* [v508] 맵 페이지 상단 검정색 바(여백) 제거 */
.main-content {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

#gis-map {
    height: 100vh;
    width: 100%;
    background: #000;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

.leaflet-container {
    background: #000 !important;
}

/* [v507] 팝업 다크 모드 스타일 강제 적용 */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: #111 !important;
    color: #ddd !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.leaflet-popup-content {
    margin: 12px 16px !important;
    line-height: 1.4;
}

/* X(닫기) 버튼 완전 숨김 - 맵 클릭으로 닫기 */
.leaflet-popup-close-button {
    display: none !important;
}

/* ══ 한국어 다크맵 필터 (가시성 보장) ══ */
.osm-dark-filter {
    filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(85%) grayscale(20%);
    -webkit-filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(85%) grayscale(20%);
}


/* ═══ CCTV 마커 스타일 ═══ */
.cctv-marker {
    width: 32px;
    height: 32px;
    background: rgba(239, 68, 68, 0.9);
    border: 2px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
    transition: all 0.2s ease;
    cursor: pointer;
}

.cctv-marker:hover {
    transform: scale(1.2);
    background: #f87171;
    z-index: 1000 !important;
}

/* ═══ 랜드마크 사진 마커 스타일 ═══ */
.landmark-photo-marker {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 3px solid #f59e0b;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.5), 0 4px 8px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: #1a1a1a;
}

.landmark-photo-marker:hover {
    transform: scale(1.3);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.8), 0 6px 16px rgba(0, 0, 0, 0.6);
    z-index: 9999 !important;
}

.landmark-photo-marker img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.landmark-photo-marker .lm-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
}

/* 랜드마크 팝업 스타일 (PC 데스크탑 1.5배율) */
.landmark-popup {
    text-align: center;
    min-width: 270px;
    /* 기존 180px -> 270px */
}

.landmark-popup img {
    width: 100%;
    max-width: 300px;
    /* 기존 200px -> 300px */
    height: 180px;
    /* 기존 120px -> 180px */
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 8px;
}

.landmark-popup .lm-title {
    font-size: 1.1rem;
    /* 확대 */
    font-weight: 700;
    color: #f5f5f5;
    margin: 6px 0;
}

.landmark-popup .lm-country {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 6px;
}

.landmark-popup .lm-link {
    display: inline-block;
    padding: 8px 22px;
    background: var(--accent, #ffb5a7);
    color: #111 !important;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 20px;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
    letter-spacing: 0.3px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.landmark-popup .lm-link:hover {
    background: var(--primary-brown-dark, #f2745f);
    transform: translateY(-2px) scale(1.05);
    color: #fff !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.landmark-popup .lm-link:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* 라이트 모드 지원 (data-theme="light") */
html[data-theme='light'] .landmark-popup .lm-link {
    color: #fff !important;
}

html[data-theme='light'] .landmark-popup .lm-link:hover {
    color: #fff !important;
}

/* ═══ CCTV Video Modal (Split-Screen with AI Panel) ═══ */
#cctv-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: calc(50% + 100px);
    transform: translate(-50%, -50%);
    width: calc(100% - 240px);
    max-width: 1200px;
    background: var(--bg-modal, #ffffff);
    color: var(--text-primary, #111111);
    z-index: 10000;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 0 40px var(--shadow-card, rgba(0, 0, 0, 0.3));
    border: 1px solid var(--border-light, #e2e8f0);
}

#cctv-modal-header {
    padding: 12px 20px;
    background: var(--bg-card, #f8fafc);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light, #e2e8f0);
}

#cctv-modal-title {
    color: var(--text-primary, #ffffff);
    font-weight: 700;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

#cctv-modal-close {
    position: absolute;
    top: 8px;
    right: 15px;
    width: 32px;
    height: 32px;
    background: var(--bg-card, rgba(255, 255, 255, 0.08));
    border: 1px solid var(--border-light, rgba(255, 255, 255, 0.15));
    color: var(--text-primary, #e2e8f0);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 1.2rem;
    z-index: 100;
}

#cctv-modal-close:hover {
    background: #ff4757;
    border-color: #ff4757;
    color: #fff;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 0 15px rgba(255, 71, 87, 0.3);
}

.cctv-modal-body {
    display: flex;
    height: 640px;
    /* [v550] 세로 크기 확장 (480px -> 640px) */
}

/* [v550] CCTV 비디오 컨트롤 버튼 스타일 */
.cctv-video-controls {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.4);
    padding: 5px 20px;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(4px);
    transition: opacity 0.3s;
}

.cctv-control-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0.8;
}

.cctv-control-btn:hover {
    opacity: 1;
    transform: scale(1.1);
    color: var(--accent, #ff4757);
}

/* [v1130] CCTV 로딩 오버레이 & 스피너 스타일 */
.cctv-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
    /* [UX] 최우선 순위로 상단 배치 */
    pointer-events: all;
    /* 클릭 방지 */
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: all 0.3s ease;
}

.cctv-loading-overlay.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.cctv-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--accent, #a29bfe);
    border-radius: 50%;
    animation: cctv-spin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    margin-bottom: 16px;
    box-shadow: 0 0 15px rgba(162, 155, 254, 0.2);
}

.cctv-loading-text {
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

@keyframes cctv-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* 라이트 모드에서의 로딩 텍스트/배경 미세 조정 */
html[data-theme='light'] .cctv-loading-overlay {
    background: rgba(255, 255, 255, 0.2);
}

html[data-theme='light'] .cctv-loading-text {
    color: #111;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

/* Left: Video + Canvas */
.cctv-video-section {
    flex: 7;
    position: relative;
    background: #000;
    overflow: hidden;
}

#cctv-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#cctv-canvas-overlay {
    z-index: 9999 !important;
    pointer-events: none !important;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.cctv-ai-status {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    z-index: 2;
    display: none;
}

.cctv-ai-status.active {
    display: block;
    background: rgba(46, 213, 115, 0.2);
    color: #2ed573;
    border: 1px solid rgba(46, 213, 115, 0.4);
    animation: pulse-ai 2s infinite;
}

@keyframes pulse-ai {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* Right: AI Panel */
.cctv-ai-panel {
    flex: 3;
    display: flex;
    flex-direction: column;
    background: var(--bg-body, rgba(15, 15, 25, 0.95));
    border-left: 1px solid var(--border-light, rgba(162, 155, 254, 0.1));
    min-width: 260px;
    max-width: 320px;
}

.ai-panel-section {
    padding: 14px;
    border-bottom: 1px solid var(--border-light, rgba(255, 255, 255, 0.06));
}

.ai-panel-section h6 {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--accent, #ff4757);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-toggle-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary, rgba(255, 255, 255, 0.8));
}

/* Switch from cctv/view.html */
.map-filters {
    position: relative;
    display: flex;
    gap: 50px;
    /* [v1185] 카테고리 간격 1cm(약 50px) 수준으로 확장 */
    z-index: 2000;
}

.cctv-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.cctv-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.cctv-switch .cctv-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: .3s;
    border-radius: 34px;
}

.cctv-switch .cctv-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

.cctv-switch input:checked+.cctv-slider {
    background-color: var(--accent, #ff4757);
}

.cctv-switch input:checked+.cctv-slider:before {
    transform: translateX(20px);
}

/* Class Button Grid */
.class-group {
    margin-bottom: 8px;
}

.class-group-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.35);
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.class-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.class-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 3px 8px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.3;
}

.class-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.class-btn.active {
    background: var(--cls-color, #a29bfe);
    color: #fff;
    border-color: var(--cls-color, #a29bfe);
    box-shadow: 0 0 8px color-mix(in srgb, var(--cls-color, #a29bfe) 50%, transparent);
}

.ai-current-target {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.ai-current-target span {
    color: #ff4757;
    font-weight: 700;
}

/* Detection Log */
.ai-log-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 14px;
}

.ai-log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.ai-log-header span {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--accent, #a29bfe);
}

.ai-log-header button {
    background: none;
    border: none;
    color: var(--text-muted, rgba(255, 255, 255, 0.4));
    font-size: 0.65rem;
    cursor: pointer;
}

.ai-btn-save {
    background: var(--accent) !important;
    color: #fff !important;
    border: none;
    padding: 5px 12px !important;
    border-radius: 6px;
    font-size: 0.75rem !important;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(var(--accent-rgb), 0.3);
    line-height: 1;
}

.ai-btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(var(--accent-rgb), 0.4);
    filter: brightness(1.15);
}

.ai-log-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.ai-log-entry {
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--bg-card, rgba(255, 255, 255, 0.04));
    border: 1px solid var(--border-light, rgba(255, 255, 255, 0.02));
    margin-bottom: 5px;
    border-left: 3px solid var(--sub1, #ff4757);
    font-size: 0.75rem;
    color: var(--text-primary, #e2e8f0);
    animation: aiSlideIn 0.3s ease-out;
}

@keyframes aiSlideIn {
    from {
        opacity: 0;
        transform: translateX(12px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.ai-log-empty {
    text-align: center;
    color: var(--text-muted, rgba(255, 255, 255, 0.3));
    font-size: 0.75rem;
    margin-top: 30px;
}

@media (max-width: 768px) {
    #cctv-modal {
        left: 50%;
        width: 95%;
    }

    .cctv-modal-body {
        flex-direction: column;
        height: auto;
    }

    .cctv-video-section {
        height: 260px;
    }

    .cctv-ai-panel {
        max-width: 100%;
        min-width: auto;
        max-height: 300px;
    }
}

/* CCTV 마커 스타일 */
.cctv-marker {
    background: #ef4444;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
    cursor: pointer;
    transition: transform 0.2s;
}

.cctv-marker:hover {
    transform: scale(1.2);
}

.cctv-marker i {
    color: #fff;
    font-size: 12px;
}


/* ═══ Marker Cluster Custom Styling ═══ */
.marker-cluster-small {
    background-color: rgba(239, 68, 68, 0.4);
}

.marker-cluster-small div {
    background-color: rgba(239, 68, 68, 0.8);
    color: #fff;
}

.marker-cluster-medium {
    background-color: rgba(239, 68, 68, 0.6);
}

.marker-cluster-medium div {
    background-color: rgba(239, 68, 68, 0.9);
    color: #fff;
}

.marker-cluster-large {
    background-color: rgba(239, 68, 68, 0.8);
}

.marker-cluster-large div {
    background-color: rgba(239, 68, 68, 1);
    color: #fff;
}

.marker-cluster {
    background-clip: padding-box;
    border-radius: 50%;
}

.marker-cluster div {
    width: 30px;
    height: 30px;
    margin-left: 5px;
    margin-top: 5px;
    text-align: center;
    border-radius: 50%;
    font-weight: 700;
    font-size: 12px;
    line-height: 30px;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
}

/* ═══ [v1300] 이벤트 타임라인 필터 UI ═══ */
.event-filter-group {
    display: none;
    /* 기본 숨김 */
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.08);
    /* 배경 약간 투명하게 */
    padding: 4px 12px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    margin-left: auto;
    /* 우측 끝으로 밀기 */
    margin-right: 15px;
}

.event-filter-btn {
    background: transparent;
    border: none;
    color: #aaa;
    font-family: 'Outfit', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s;
}

.event-filter-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.event-filter-btn.active {
    background: var(--accent, #ff4757);
    color: #fff;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
}

.calendar-pick-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Flatpickr 커스텀 도트 (Editorial 스타일 차용) */
.has-event {
    position: relative;
}

.has-event::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: #a47864;
    border-radius: 50%;
}

/* [v4000] 라이트 모드 시간 필터 대응 */
[data-theme="light"] .event-filter-group {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .event-filter-btn {
    color: #666;
}
[data-theme="light"] .event-filter-btn:hover {
    color: #333;
    background: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .event-filter-btn.active {
    background: #a47864;
    color: #fff;
    box-shadow: 0 2px 8px rgba(164, 120, 100, 0.3);
}
[data-theme="light"] .calendar-pick-btn {
    background: rgba(0, 0, 0, 0.08);
    color: #444;
}
[data-theme="light"] .calendar-pick-btn:hover {
    background: rgba(0, 0, 0, 0.15);
    color: #222;
}
