/* 지도 플랫폼 메인 스타일 */

/* CSS 변수 정의 */
:root {
    --panel-width-desktop: 350px;
    --panel-width-tablet: 300px;
    --panel-width-mobile: 280px;
    --panel-min-width: 250px;
    --panel-max-width: 450px;
    --header-height: 48px;
    --footer-height: 32px;
    --transition-speed: 0.3s;
    --border-color: #e9ecef;
    --panel-bg: #f8f9fa;
    --shadow-light: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-medium: 0 4px 8px rgba(0,0,0,0.15);
    --z-panel: 20;
    --z-toggle: 25;
    --z-controls: 30;
}

/* 기본 레이아웃 - 전체 화면을 flex 컨테이너로 구성 */
.map-platform {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Noto Sans KR', 'Malgun Gothic', '맑은 고딕', Arial, sans-serif;
}

/* 메인 컨테이너 - 헤더와 푸터 사이의 flex 영역 */
.main-container {
    display: flex;
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

/* 패널 영역들 - 반응형 기본 설정 */
.left-panel-area,
.right-panel-area {
    flex: 0 0 var(--panel-width-desktop);
    min-width: var(--panel-min-width);
    max-width: var(--panel-max-width);
    background: var(--panel-bg);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    transition: all var(--transition-speed) ease;
    position: relative;
}

.left-panel-area {
    border-right: 1px solid var(--border-color);
    z-index: var(--z-panel);
}

.right-panel-area {
    border-left: 1px solid var(--border-color);
    z-index: calc(var(--z-panel) - 10);
}

/* 패널 숨김/표시 상태 */
.left-panel-area.collapsed {
    flex-basis: 0;
    min-width: 0;
    padding: 0;
    transform: translateX(-100%);
    border-right: none;
}

.right-panel-area.collapsed {
    flex-basis: 0;
    min-width: 0;
    padding: 0;
    transform: translateX(100%);
    border-left: none;
}

.panel-container {
    height: 100%;
    margin-bottom: 0;
}

/* 지도 영역 - 남은 공간을 모두 차지 */
.map-area {
    flex: 1;
    min-width: 0;
    position: relative;
    background: #e9ecef;
    overflow: hidden;
}

#map, #mapCanvas {
    width: 100%;
    height: 100%;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 18px;
    position: relative;
}

/* 지도 컨트롤 */
.map-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: var(--z-controls);
}

.map-control-btn {
    width: 40px;
    height: 40px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: var(--shadow-light);
    transition: all 0.2s ease;
}

.map-control-btn:hover {
    background: #f8f9fa;
    border-color: #007bff;
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

/* 패널 토글 버튼 */
.panel-toggle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 60px;
    background: #007bff;
    border: 1px solid #007bff;
    border-radius: 0 12px 12px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: var(--z-toggle);
    transition: all 0.2s ease;
    box-shadow: 2px 0 4px rgba(0,0,0,0.1);
    font-size: 12px;
    color: white;
    gap: 2px;
}

.panel-toggle:hover {
    background: #0056b3;
    border-color: #0056b3;
    color: white;
    transform: translateY(-50%) scale(1.05);
}

.panel-toggle:active {
    transform: translateY(-50%) scale(0.95);
}

.panel-toggle.left {
    left: 0;
    border-radius: 0 12px 12px 0;
}

.panel-toggle.right {
    right: 0;
    border-radius: 12px 0 0 12px;
    box-shadow: -2px 0 4px rgba(0,0,0,0.1);
}

.panel-toggle.collapsed.left {
    left: 0;
}

.panel-toggle.collapsed.right {
    right: 0;
}

.panel-toggle.collapsed:hover {
    background: #0056b3;
    border-color: #0056b3;
    color: white;
}

/* 토글 버튼 라벨 */
.panel-toggle .toggle-label {
    font-size: 9px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    line-height: 1;
    opacity: 0.9;
}

/* 패널 토글 아이콘 애니메이션 */
.panel-toggle i {
    transition: transform 0.2s ease;
    font-size: 10px;
}

.panel-toggle:hover i {
    transform: scale(1.1);
}

.panel-toggle.collapsed i {
    transform: rotate(180deg);
}

/* 팝업 레이어 */
.popup-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: popupSlideIn var(--transition-speed) ease;
}

.popup-layer.hidden {
    display: none;
}

.popup-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    z-index: 1001;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.popup-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.popup-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.popup-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.popup-close-btn:hover {
    background: #e9ecef;
    color: #333;
}

.popup-body {
    padding: 20px;
}

.popup-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
}

/* 알림 영역 */
.notification-area {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1100;
    pointer-events: none;
}

.notification {
    background: white;
    border-radius: 6px;
    box-shadow: var(--shadow-medium);
    padding: 12px 16px;
    margin-bottom: 10px;
    animation: slideInRight var(--transition-speed) ease;
    pointer-events: auto;
}

.notification.success {
    border-left: 4px solid #28a745;
}

.notification.warning {
    border-left: 4px solid #ffc107;
}

.notification.error {
    border-left: 4px solid #dc3545;
}

.notification.info {
    border-left: 4px solid #17a2b8;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 패널 내부 스타일 */
.panel-wrapper {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.panel {
    background: white;
    border-radius: 8px;
    margin: 12px;
    box-shadow: var(--shadow-light);
    overflow: hidden;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.panel:hover {
    box-shadow: var(--shadow-medium);
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: #f8f9fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.panel-controls {
    display: flex;
    gap: 8px;
}

.panel-controls button {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.panel-controls button:hover {
    background: #e9ecef;
    border-color: #007bff;
}

.panel-content {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

/* 탭 패널 스타일 */
.panel-tabs-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.panel-tabs-header {
    display: flex;
    background: white;
    border-bottom: 1px solid var(--border-color);
    margin: 12px 12px 0 12px;
    border-radius: 8px 8px 0 0;
    overflow-x: auto;
    flex-shrink: 0;
}

.panel-tab {
    background: none;
    border: none;
    padding: 12px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 80px;
}

.panel-tab:first-child {
    border-radius: 8px 0 0 0;
}

.panel-tab:last-child {
    border-radius: 0 8px 0 0;
}

.panel-tab:hover {
    background: #f8f9fa;
    color: #333;
}

.panel-tab.active {
    color: #007bff;
    border-bottom-color: #007bff;
    background: #f8f9fa;
    font-weight: 600;
}

.panel-tabs-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    margin: 0 12px 12px 12px;
    border-radius: 0 0 8px 8px;
}

.panel-tab-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-speed) ease;
    background: white;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.panel-tab-content.active {
    opacity: 1;
    visibility: visible;
}

.panel-tab-content .panel-wrapper {
    margin: 0;
}

.panel-tab-content .panel {
    margin: 0;
    border-radius: 0 0 8px 8px;
    box-shadow: none;
    height: 100%;
}

.panel-tab-content .panel-content {
    height: calc(100% - 60px);
    overflow-y: auto;
}

/* ===== 반응형 미디어 쿼리 ===== */

/* 대형 데스크톱 (1400px 이상) */
@media (min-width: 1400px) {
    .left-panel-area,
    .right-panel-area {
        flex-basis: 400px;
        max-width: 500px;
    }
}

/* 중형 데스크톱 (1200px - 1399px) */
@media (max-width: 1399px) and (min-width: 1200px) {
    .left-panel-area,
    .right-panel-area {
        flex-basis: var(--panel-width-desktop);
        max-width: 400px;
    }
}

/* 소형 데스크톱 (992px - 1199px) */
@media (max-width: 1199px) and (min-width: 992px) {
    .left-panel-area,
    .right-panel-area {
        flex-basis: var(--panel-width-tablet);
        max-width: 350px;
    }
    
    .panel-tab {
        padding: 10px 12px;
        font-size: 13px;
    }
}

/* 태블릿 (768px - 991px) */
@media (max-width: 991px) and (min-width: 768px) {
    .left-panel-area,
    .right-panel-area {
        flex-basis: var(--panel-width-tablet);
        max-width: 350px;
    }
    
    .panel-tab {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .map-controls {
        top: 15px;
        right: 15px;
        gap: 6px;
    }
    
    .map-control-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}

/* 모바일 (767px 이하) - 단일 패널 활성화 방식 */
@media (max-width: 767px) {
    /* 기본 레이아웃 유지 (좌우 배치) */
    .main-container {
        flex-direction: row; /* 상하 배치에서 좌우 배치로 변경 */
    }
    
    .left-panel-area,
    .right-panel-area {
        flex: 0 0 280px; /* 모바일 패널 너비 */
        width: 280px;
        max-width: 280px;
        min-width: 280px;
        height: 100%;
        position: relative;
        z-index: var(--z-panel);
    }
    
    .left-panel-area {
        border-right: 1px solid var(--border-color);
        border-bottom: none;
        order: 1;
    }
    
    .right-panel-area {
        border-left: 1px solid var(--border-color);
        border-top: none;
        order: 3;
    }
    
    .map-area {
        order: 2;
        flex: 1;
        min-width: 200px; /* 최소 지도 영역 확보 */
    }
    
    /* 패널 숨김 상태 - 좌우 슬라이딩 */
    .left-panel-area.collapsed {
        flex-basis: 0;
        width: 0;
        min-width: 0;
        transform: translateX(-100%);
        border-right: none;
    }
    
    .right-panel-area.collapsed {
        flex-basis: 0;
        width: 0;
        min-width: 0;
        transform: translateX(100%);
        border-left: none;
    }
    
    /* 토글 버튼 모바일 스타일 */
    .panel-toggle {
        width: 48px;
        height: 80px;
        font-size: 14px;
        border-radius: 8px;
        gap: 4px;
        background: #007bff;
        border-color: #007bff;
        color: white;
    }
    
    .panel-toggle:hover {
        background: #0056b3;
        border-color: #0056b3;
        color: white;
    }
    
    .panel-toggle.left {
        left: 0;
        border-radius: 0 8px 8px 0;
        box-shadow: 2px 0 6px rgba(0,0,0,0.15);
    }
    
    .panel-toggle.right {
        right: 0;
        border-radius: 8px 0 0 8px;
        box-shadow: -2px 0 6px rgba(0,0,0,0.15);
    }
    
    .panel-toggle.collapsed.left {
        left: 0;
    }
    
    .panel-toggle.collapsed.right {
        right: 0;
    }
    
    .panel-toggle.collapsed:hover {
        background: #0056b3;
        border-color: #0056b3;
        color: white;
    }
    
    /* 모바일에서 토글 버튼 라벨 */
    .panel-toggle .toggle-label {
        font-size: 10px;
        writing-mode: vertical-rl;
        text-orientation: mixed;
        opacity: 1;
        font-weight: 600;
    }
    
    .panel-toggle i {
        font-size: 12px;
    }
    
    /* 지도 컨트롤 */
    .map-controls {
        top: 10px;
        right: 10px;
        gap: 4px;
    }
    
    .map-control-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    /* 패널 내부 스타일 조정 */
    .panel {
        margin: 8px;
        border-radius: 6px;
    }
    
    .panel-header {
        padding: 12px 16px;
    }
    
    .panel-header h3 {
        font-size: 14px;
    }
    
    .panel-content {
        padding: 12px 16px;
    }
    
    /* 팝업 모바일 최적화 */
    .popup-content {
        max-width: 95vw;
        max-height: 95vh;
        margin: 10px;
    }
    
    .popup-header {
        padding: 12px 16px;
    }
    
    .popup-body {
        padding: 16px;
    }
    
    /* 알림 영역 */
    .notification-area {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    
    .notification {
        margin-bottom: 8px;
        padding: 10px 12px;
    }
    
    /* 탭 스타일 */
    .panel-tabs-header {
        margin: 8px 8px 0 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .panel-tab {
        padding: 8px 10px;
        font-size: 11px;
        min-width: 60px;
    }
    
    .panel-tabs-content {
        margin: 0 8px 8px 8px;
    }
}

/* 초소형 모바일 (480px 이하) */
@media (max-width: 480px) {
    .left-panel-area,
    .right-panel-area {
        flex-basis: 260px;
        width: 260px;
        max-width: 260px;
        min-width: 260px;
    }
    
    .map-area {
        min-width: 150px;
    }
    
    .panel-toggle {
        width: 40px;
        height: 60px;
        font-size: 12px;
    }
    
    .panel-toggle.left {
        left: 0;
    }
    
    .panel-toggle.right {
        right: 0;
    }
    
    .panel {
        margin: 6px;
    }
    
    .panel-header {
        padding: 10px 12px;
    }
    
    .panel-content {
        padding: 10px 12px;
    }
    
    .panel-tab {
        padding: 6px 8px;
        font-size: 10px;
        min-width: 50px;
    }
    
    .map-control-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

/* 가로 모드 최적화 (모바일) */
@media (max-width: 767px) and (orientation: landscape) {
    .left-panel-area,
    .right-panel-area {
        flex-basis: 240px;
        width: 240px;
        max-width: 240px;
        min-width: 240px;
    }
    
    .panel-toggle {
        height: 60px;
    }
    
    .panel-header {
        padding: 8px 12px;
        min-height: 40px;
    }
    
    .panel-header h3 {
        font-size: 13px;
    }
    
    .panel-content {
        padding: 8px 12px;
    }
}

/* 애니메이션 감소 설정 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* 고대비 모드 지원 */
@media (prefers-contrast: high) {
    .panel {
        border: 2px solid #000;
    }
    
    .map-control-btn,
    .panel-toggle {
        border: 2px solid #000;
    }
    
    .popup-content {
        border: 2px solid #000;
    }
}

/* 빈 패널 영역 숨기기 */
.left-panel-area:empty,
.right-panel-area:empty {
    display: none;
}

.left-panel-area:empty + .panel-toggle.left,
.right-panel-area:empty + .panel-toggle.right {
    display: none;
} 