/* ==============================================
   style.css — 광주 버스 노선 개편 웹페이지 스타일
   ============================================== */

/* 1. CSS 변수 */
:root {
    --primary: #2c3e50;
    --accent:  #e67e22;
    --success: #27ae60;
    --danger:  #c0392b;
    --bg:      #f8f9fa;
    --walk:    #8e44ad;
}

/* 2. 기본 레이아웃 */
* { box-sizing: border-box; }

body {
    margin: 0;
    display: flex;
    height: 100vh;
    font-family: 'Noto Sans KR', sans-serif;
}

#sidebar {
    width: 400px;
    background: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #ddd;
    z-index: 2000;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

#sidebar-content {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    background: var(--bg);
}

#map { flex-grow: 1; }

/* 3. 사이드바 헤더 */
.sidebar-header {
    padding: 20px;
    background: var(--primary);
    color: white;
    font-weight: bold;
    text-align: center;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* 모바일 햄버거 버튼 (기본 숨김) */
#btn-sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 3000;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* 4. 섹션 타이틀 */
.section-title {
    font-size: 14px;
    color: #7f8c8d;
    font-weight: bold;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 5. 검색 탭 */
.search-tab-container {
    display: flex;
    border-bottom: 2px solid #ddd;
    margin-bottom: 10px;
}

.search-tab {
    flex: 1;
    text-align: center;
    padding: 10px 0;
    cursor: pointer;
    font-size: 13px;
    color: #777;
    font-weight: 500;
    background: #f1f3f5;
    border-radius: 6px 6px 0 0;
    margin-right: 2px;
    transition: 0.2s;
}

.search-tab:hover { background: #e9ecef; color: #333; }

.search-tab.active {
    background: white;
    color: var(--primary);
    font-weight: bold;
    border-top: 2px solid var(--primary);
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    border-bottom: 2px solid white;
    margin-bottom: -2px;
}

.search-tab:last-child { margin-right: 0; }

/* 6. 검색창 */
.search-box { position: relative; margin-bottom: 10px; }

.search-input {
    width: 100%;
    padding: 12px 75px 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.search-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: none;
    cursor: pointer;
    color: #555;
    transition: 0.2s;
}

.search-btn:hover { color: var(--primary); transform: translateY(-50%) scale(1.1); }

.reset-btn {
    position: absolute;
    right: 45px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: none;
    cursor: pointer;
    color: #95a5a6;
    transition: 0.2s;
}

.reset-btn:hover { color: var(--danger); transform: translateY(-50%) rotate(180deg); }

/* 7. 검색 결과 드롭다운 */
.search-results {
    background: white;
    border: 1px solid #ddd;
    margin-top: 5px;
    max-height: 250px;
    overflow-y: auto;
    display: none;
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.search-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    transition: 0.2s;
}

.search-item:hover { background: #f8f9fa; }

.stop-info { cursor: pointer; flex-grow: 1; }
.stop-info b { color: #2c3e50; }
.stop-info small { color: #95a5a6; margin-left: 5px; }

.btn-view-routes {
    background: #fff;
    border: 1px solid #ddd;
    color: #555;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    margin-left: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: 0.2s;
}

.btn-view-routes:hover { background: var(--primary); color: white; border-color: var(--primary); }

/* 8. 정류장 경유 노선 영역 */
#stop-routes-area {
    margin-bottom: 25px;
    display: none;
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #eee;
}

.route-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }

.bus-tag {
    padding: 4px 10px;
    border-radius: 15px;
    color: white;
    font-weight: bold;
    font-size: 12px;
    cursor: pointer;
    transition: 0.2s;
}

.bus-tag:hover { transform: scale(1.1); box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.bus-tag.active { border: 2px solid #2c3e50; transform: scale(1.1); box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.bus-normal { background: #3498db; }
.bus-direct { background: #e67e22; }

/* 9. 분석 버튼 그리드 */
.btn-analysis {
    width: 100%;
    margin: 0;
    padding: 8px 5px;
    font-size: 13px;
    background-color: #34495e;
    color: white;
    border: none;
    border-radius: 4px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
}

.btn-analysis:hover { background-color: #2c3e50; }
.btn-analysis.active { background-color: #2980b9; font-weight: bold; }

/* 10. 경로 탐색 패널 */
.route-planner {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    border: 1px solid #eee;
}

.loc-input-wrapper { position: relative; flex-grow: 1; }

.loc-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}

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

.suggestion-box {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.suggestion-item {
    padding: 8px 10px;
    font-size: 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
}

.suggestion-item:hover { background-color: #f1f1f1; }
.suggestion-item:last-child { border-bottom: none; }

.location-row { display: flex; align-items: center; margin-bottom: 15px; }

.loc-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-right: 10px;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.loc-icon:hover { transform: scale(1.1); }
.icon-start { background: var(--success); }
.icon-end   { background: var(--danger); }

.loc-value {
    flex-grow: 1;
    padding: 10px;
    background: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 6px;
    font-size: 13px;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

/* 11. 공통 버튼 */
.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    margin-bottom: 5px;
    font-size: 14px;
    transition: 0.2s;
}

.btn:hover { opacity: 0.9; }
.btn-green { background: var(--success); }
.btn-gray  { background: #95a5a6; }

/* 12. 경로 결과 카드 */
.result-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 5px solid #ddd;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

.result-card:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.08); }
.result-card.direct   { border-left-color: #e67e22; }
.result-card.transfer { border-left-color: #2980b9; }

.result-header {
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.route-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 13px;
    margin-top: 5px;
}

.total-dist { font-size: 11px; color: #7f8c8d; font-weight: normal; }

/* 13. 지도 상태바 */
#status-bar {
    padding: 10px;
    text-align: center;
    font-size: 12px;
    background: white;
    border-top: 1px solid #ddd;
    color: #555;
}

/* 14. 지도 관련 */
.map-picking { cursor: crosshair !important; }

.custom-pin { pointer-events: auto !important; cursor: context-menu !important; }

.stop-tooltip {
    background: rgba(0,0,0,0.8);
    border: none;
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
}

.leaflet-tile-pane { filter: grayscale(80%); }

/* 15. 범례 */
.info.legend {
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
    font-size: 12px;
    line-height: 18px;
    color: #555;
}

.info.legend i {
    width: 14px; height: 14px;
    float: left; margin-right: 8px;
    opacity: 0.7; border-radius: 50%;
}

.legend-item {
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 4px;
    transition: 0.2s;
    margin-bottom: 2px;
}

.legend-item:hover { background-color: #f1f1f1; }
.legend-item.active { background-color: #ddd; font-weight: bold; border: 1px solid #bbb; }
.legend-item.inactive { opacity: 0.4; }

/* 16. 토스트 메시지 */
.map-toast {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(44,62,80,0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: bold;
    z-index: 3000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
}

.map-toast.show { opacity: 1; bottom: 110px; }

/* 17. 학교 라벨 툴팁 */
.school-label-tooltip {
    background: rgba(255,255,255,0.9);
    border: 1px solid #ccc;
    border-radius: 4px;
    font-weight: bold;
    color: #2c3e50;
    font-size: 12px;
    padding: 2px 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.school-label-tooltip::before { display: none; }

/* 18. 레이어 컨트롤 폰트 */
.leaflet-control-layers label { font-size: 12px; }

/* =============================================
   19. 반응형 디자인 (모바일 768px 이하)
   ============================================= */
@media (max-width: 768px) {

    body { display: block; }

    /* 사이드바: 오버레이로 변경 */
    #sidebar {
        position: fixed;
        top: 0; left: 0;
        height: 100vh;
        width: 85vw;
        max-width: 360px;
        z-index: 2500;
        transform: translateX(-100%);
    }

    /* 열린 상태 */
    #sidebar.open { transform: translateX(0); }

    /* 지도가 전체 화면 차지 */
    #map {
        position: fixed;
        top: 0; left: 0;
        width: 100vw;
        height: 100vh;
    }

    /* 햄버거 버튼 표시 */
    #btn-sidebar-toggle { display: flex; align-items: center; justify-content: center; }

    /* 사이드바 오픈 시 어두운 배경 오버레이 */
    #sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0;
        width: 100vw; height: 100vh;
        background: rgba(0,0,0,0.4);
        z-index: 2400;
    }

    #sidebar-overlay.show { display: block; }

    .sidebar-header { font-size: 15px; padding: 15px; }

    /* 분석 버튼 그리드: 모바일에서 1열 */
    .analysis-grid { grid-template-columns: 1fr !important; }
}
