:root {
    --primary: #4F46E5;
    --primary-light: #EEF2F6;
    --primary-hover: #4338CA;
    --safe-color: #10B981;
    --caution-color: #FBBF24;
    --danger-color: #EF4444;
    --bg-color: #FAF9F6; /* 파스텔 웜톤 베이지 */
    --panel-bg: rgba(255, 255, 255, 0.95);
    --text-main: #2D3748;
    --text-muted: #718096;
    --font-jua: 'Jua', sans-serif;
    --font-noto: 'Noto Sans KR', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-noto);
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
}

/* 메인 레이아웃: 50대 50 분할 */
#main-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    position: relative;
}

/* 왼쪽 지도 영역 */
#map-area {
    width: 50%;
    height: 100%;
    position: relative;
    border-right: 4px solid #E2E8F0;
    background-color: #E2E8F0;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

#map2d, #map3d, #vmap {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

#map3d, #vmap {
    background-color: #1a1a1a;
}

/* 오른쪽 로드뷰 영역 */
#roadview-area {
    width: 50%;
    height: 100%;
    position: relative;
    background-color: #1A202C;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

#roadview {
    width: 100%;
    height: 100%;
}

/* 가상 전체화면 줌 토글 클래스 */
.expanded-view {
    width: 100% !important;
    z-index: 10;
}
.hidden-view {
    width: 0% !important;
    display: none !important;
}

/* ------------------ UI 구성 요소들 ------------------ */

/* 상단 타이틀 배너 */
#header-banner {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 100;
    background: var(--panel-bg);
    padding: 12px 20px;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 12px;
    border: 2px solid #E2E8F0;
    pointer-events: auto;
}

#header-banner h1 {
    font-family: var(--font-jua);
    font-size: 20px;
    color: var(--primary);
    letter-spacing: 0.5px;
}

#header-banner .badge {
    background-color: var(--primary);
    color: white;
    font-family: var(--font-jua);
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 20px;
    text-transform: uppercase;
}

/* 2D/3D/위성 컨트롤 패널 */
#map-switch-panel {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 100;
    background: var(--panel-bg);
    padding: 6px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    display: flex;
    gap: 4px;
    border: 1px solid #E2E8F0;
}

.map-switch-btn {
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: var(--font-jua);
    font-size: 13px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.map-switch-btn.active {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.4);
}

/* 레이어 켜기/끄기 체크박스 패널 */
#layer-control-panel {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 100;
    background: var(--panel-bg);
    padding: 16px;
    border-radius: 16px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.06);
    border: 1px solid #E2E8F0;
    width: 250px;
}

#layer-control-panel h3 {
    font-family: var(--font-jua);
    font-size: 15px;
    margin-bottom: 12px;
    color: var(--text-main);
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 6px;
    display: flex;
    justify-content: space-between;
}

.layer-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #4A5568;
    cursor: pointer;
    user-select: none;
}

.layer-item input {
    margin-right: 10px;
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* 우측 상단 안전 판정 도장 배지 (HUD) */
#safety-stamp-hud {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 110;
    padding: 15px 30px;
    border-radius: 50px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    font-family: var(--font-jua);
    font-size: 28px;
    letter-spacing: 1.5px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 4px solid transparent;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    background-color: rgba(255, 255, 255, 0.95);
}

#safety-stamp-hud.stamp-safe {
    border-color: var(--safe-color);
    color: var(--safe-color);
    transform: rotate(-3deg) scale(1.05);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

#safety-stamp-hud.stamp-caution {
    border-color: var(--caution-color);
    color: var(--caution-color);
    transform: rotate(2deg) scale(1.05);
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.3);
}

#safety-stamp-hud.stamp-danger {
    border-color: var(--danger-color);
    color: var(--danger-color);
    transform: rotate(-5deg) scale(1.1);
    animation: pulse-border 1.5s infinite alternate;
}

@keyframes pulse-border {
    from {
        box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
    }
    to {
        box-shadow: 0 0 25px rgba(239, 68, 68, 0.7);
    }
}

/* 하단 안전 정보 대시보드 */
#dashboard-panel {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    background: var(--panel-bg);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    border: 1px solid #E2E8F0;
    width: 380px;
    transition: transform 0.3s ease;
}

#dashboard-panel h2 {
    font-family: var(--font-jua);
    font-size: 18px;
    margin-bottom: 12px;
    color: var(--primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.score-bar-wrapper {
    background-color: #E2E8F0;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 15px;
}

#score-bar {
    height: 100%;
    width: 0%;
    border-radius: 6px;
    background-color: var(--safe-color);
    transition: width 0.5s ease, background-color 0.3s ease;
}

.info-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 8px;
    font-weight: 500;
}

.info-row .label {
    color: var(--text-muted);
}

.info-row .value {
    color: var(--text-main);
    font-weight: 700;
}

/* 수색 아이템 리포트 내역 */
#radar-report {
    margin-top: 15px;
    border-top: 2px dashed #E2E8F0;
    padding-top: 12px;
    max-height: 120px;
    overflow-y: auto;
}

.report-item {
    font-size: 12px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.report-item.plus { color: var(--safe-color); }
.report-item.minus { color: var(--danger-color); }

/* 🕹️ 태블릿용 가상 D-Pad 오버레이 */
#dpad-controller {
    position: absolute;
    bottom: 40px;
    left: 40px;
    z-index: 120;
    width: 140px;
    height: 140px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    backdrop-filter: blur(5px);
    display: grid;
    grid-template-areas: 
        ". up ."
        "left . right"
        ". down .";
    grid-template-columns: 45px 50px 45px;
    grid-template-rows: 45px 50px 45px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    touch-action: none;
    user-select: none;
}

.dpad-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    cursor: pointer;
    transition: background 0.1s ease, transform 0.1s ease;
    user-select: none;
    -webkit-user-select: none;
}

.dpad-btn:active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0.9);
}

#dpad-up { grid-area: up; border-radius: 12px 12px 0 0; }
#dpad-down { grid-area: down; border-radius: 0 0 12px 12px; }
#dpad-left { grid-area: left; border-radius: 12px 0 0 12px; }
#dpad-right { grid-area: right; border-radius: 0 12px 12px 0; }
#dpad-center {
    grid-area: 2/2;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 12px;
    font-weight: bold;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
    cursor: pointer;
}

/* ↩️ 스마트 갈림길 가이드 HUD (Smart Turn Assist) */
#fork-assist-hud {
    position: absolute;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 120;
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.fork-btn {
    background: rgba(30, 41, 59, 0.85);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 10px 18px;
    border-radius: 30px;
    font-family: var(--font-jua);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.fork-btn:hover {
    background: var(--primary);
    border-color: white;
    transform: translateY(-2px);
}

.fork-btn:active {
    transform: translateY(0);
}

/* 📸 스냅 플래시 애니메이션 레이어 */
#flash-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: white;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
}

.flash-active {
    animation: flash-animation 0.3s ease-out;
}

@keyframes flash-animation {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* 수동 캡처(Clean View) 시 숨길 UI 요소들을 처리할 클래스 */
.clean-mode .hide-on-capture {
    display: none !important;
}

/* 핫키 단축키 도움말 배너 */
#hotkey-tip {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    background: rgba(15, 23, 42, 0.8);
    color: rgba(255,255,255,0.9);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 12px;
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    display: flex;
    gap: 12px;
    font-weight: 500;
}

#hotkey-tip kbd {
    background: #E2E8F0;
    color: #1A202C;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 11px;
    box-shadow: 0 2px 0 #CBD5E0;
}

/* 화면 캡처 가이드 크롭 박스 (HUD 뷰파인더) */
#viewfinder-overlay {
    position: absolute;
    top: 50px;
    left: 50px;
    right: 50px;
    bottom: 50px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    pointer-events: none;
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.clean-mode #viewfinder-overlay {
    opacity: 1;
}

.viewfinder-corner {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 4px solid white;
    pointer-events: none;
}
#vf-tl { top: -4px; left: -4px; border-right: none; border-bottom: none; }
#vf-tr { top: -4px; right: -4px; border-left: none; border-bottom: none; }
#vf-bl { bottom: -4px; left: -4px; border-right: none; border-top: none; }
#vf-br { bottom: -4px; right: -4px; border-left: none; border-top: none; }

#vf-center-cross {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255,255,255,0.4);
    font-size: 24px;
    font-weight: 300;
}

/* 스캔 상태 안내판 */
#radar-scanning-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 101;
    font-family: var(--font-jua);
    font-size: 32px;
    color: var(--primary);
    text-shadow: 0 0 15px rgba(255,255,255,0.8);
    background: rgba(255,255,255,0.9);
    padding: 15px 30px;
    border-radius: 20px;
    border: 3px solid var(--primary);
    display: none;
    animation: bounce 0.6s infinite alternate;
}

@keyframes bounce {
    from { transform: translate(-50%, -50%) scale(0.95); }
    to { transform: translate(-50%, -50%) scale(1.05); }
}

/* ====================================================
   신규 프리미엄 UI 패널 스타일 (장소 검색, 경로, 안전구역)
   ==================================================== */
.control-card {
    position: absolute;
    z-index: 100;
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
    padding: 12px 14px;
    transition: all 0.3s ease;
    width: 280px;
}

.control-card h3 {
    font-family: var(--font-jua);
    font-size: 14px;
    color: var(--primary);
    margin-bottom: 8px;
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 1. 장소 검색 */
#search-panel {
    top: 85px;
    left: 15px;
}

.search-box {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.search-box input {
    flex: 1;
    border: 1px solid #CBD5E0;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus {
    border-color: var(--primary);
}

.search-box button {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    font-family: var(--font-jua);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.search-box button:hover {
    background: var(--primary-hover);
}

.scroll-list {
    max-height: 100px;
    overflow-y: auto;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    background: #FFF;
}

.scroll-list::-webkit-scrollbar {
    width: 6px;
}

.scroll-list::-webkit-scrollbar-thumb {
    background: #CBD5E0;
    border-radius: 3px;
}

.search-item {
    padding: 6px 8px;
    font-size: 11px;
    border-bottom: 1px solid #F7FAFC;
    cursor: pointer;
    transition: background 0.15s;
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover {
    background: var(--primary-light);
}

.search-item .title {
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 2px;
}

.search-item .address {
    color: var(--text-muted);
}

/* 2. 경로 탐색 */
#route-panel {
    top: 265px;
    left: 15px;
}

.route-point-selectors {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.route-point-btn {
    border: 1px dashed var(--primary);
    background: rgba(255, 255, 255, 0.8);
    color: var(--primary);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.route-point-btn.active-set {
    background: var(--primary);
    color: white;
    border-style: solid;
}

.route-mode-selectors {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.route-mode-btn {
    flex: 1;
    border: 1px solid #CBD5E0;
    background: #FFF;
    color: var(--text-muted);
    border-radius: 8px;
    padding: 6px;
    font-size: 11px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.route-mode-btn.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: bold;
}

.route-action-buttons {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.route-action-btn {
    flex: 1;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px;
    font-family: var(--font-jua);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.route-action-btn:hover {
    background: var(--primary-hover);
}

.route-action-btn.secondary {
    background: #E2E8F0;
    color: var(--text-main);
}

.route-action-btn.secondary:hover {
    background: #CBD5E0;
}

.route-summary-info {
    font-size: 11px;
    color: var(--text-muted);
    padding: 6px;
    background: #F7FAFC;
    border-radius: 6px;
    line-height: 1.4;
    max-height: 50px;
    overflow-y: auto;
}

/* 3. 안전구역 설정 */
#safezone-panel {
    top: 500px;
    left: 15px;
}

.safezone-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.safezone-controls .input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
}

.safezone-controls input[type="number"] {
    width: 60px;
    border: 1px solid #CBD5E0;
    border-radius: 6px;
    padding: 4px 6px;
    outline: none;
    font-size: 11px;
}

.safezone-controls .button-row {
    display: flex;
    gap: 6px;
}

.safezone-controls button {
    flex: 1;
    border: 1px solid var(--primary);
    background: #FFF;
    color: var(--primary);
    border-radius: 8px;
    padding: 6px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.safezone-controls button:hover {
    background: var(--primary-light);
}

.safezone-controls button.active-set {
    background: var(--primary);
    color: white;
}

.safezone-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 6px;
    font-size: 11px;
    border-bottom: 1px solid #F7FAFC;
}

.safezone-item:last-child {
    border-bottom: none;
}

.safezone-item .info {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.safezone-item .delete-btn {
    border: none;
    background: transparent;
    color: var(--danger-color);
    font-weight: bold;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
}

.safezone-item .delete-btn:hover {
    background: #FEE2E2;
}

/* 레이어 조작 패널 위치 조정 */
#layer-control-panel {
    top: auto;
    bottom: 20px;
    left: 15px;
    margin-bottom: 0;
}

/* 4. 우측 위험 경고 HUD */
.danger-hud {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 110;
    width: 320px;
    background: rgba(15, 23, 42, 0.85); /* 다크 모드 블러 */
    border: 2px solid var(--danger-color);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.25);
    padding: 12px 16px;
    color: white;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    font-family: var(--font-noto);
    animation: slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none; /* 클릭 방해 금지 */
}

@keyframes slide-in {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.danger-header {
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(239, 68, 68, 0.4);
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.danger-header .warning-icon {
    font-size: 18px;
    animation: flash-warning 1s infinite alternate;
}

@keyframes flash-warning {
    from { opacity: 0.3; }
    to { opacity: 1; }
}

.danger-title {
    font-family: var(--font-jua);
    font-size: 15px;
    color: #FFA5A5;
    letter-spacing: 0.5px;
}

.danger-body {
    max-height: 150px;
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.5;
}

.danger-item {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 6px;
    color: #FFEAE8;
}

.danger-item:last-child {
    margin-bottom: 0;
}

.danger-item::before {
    content: "•";
    color: var(--danger-color);
    font-weight: bold;
}

/* 5. 3D 시뮬레이터 전용 공간 로더 오버레이 */
.loader-spinner {
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: #3B82F6;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    animation: sim-spin 1s linear infinite;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.35);
}

@keyframes sim-spin {
    to { transform: rotate(360deg); }
}
