/* ─── 한의원 탐색 — 풀스크린 통합 사이드바 ──────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

.cf-body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

/* ── 전체화면 지도 — 사이드바 영역 제외 ─────────────────────────────────── */
.cf-map {
    position: fixed;
    top: 0;
    left: 320px; /* 사이드바 폭만큼 오프셋 — 지도 중심이 보이는 영역 기준으로 계산됨 */
    right: 0;
    bottom: 0;
    z-index: 0;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cf-map.detail-open { left: 620px; }

/* ── 통합 사이드바 ────────────────────────────────────────────────────────── */
.cf-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 320px;
    background: #fff;
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.10);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── 검색 영역 ────────────────────────────────────────────────────────────── */
.cf-sidebar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 12px 12px 12px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.cf-back-btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f5f5f5;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 0.8rem;
    transition: background 0.2s, color 0.2s;
}

.cf-back-btn:hover {
    background: #e8f5ee;
    color: #2e7d52;
}

.cf-input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.cf-input-icon {
    position: absolute;
    left: 10px;
    color: #aaa;
    font-size: 0.82rem;
    pointer-events: none;
}

.cf-address-input {
    width: 100%;
    height: 34px;
    padding: 0 30px 0 30px;
    border: 1.5px solid #e8e8e8;
    border-radius: 8px;
    background: #fafafa;
    color: #222;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.cf-address-input:focus {
    border-color: #2e7d52;
    background: #fff;
}

.cf-address-input::placeholder {
    color: #bbb;
}

.cf-clear-btn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: #bbb;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 0.78rem;
    line-height: 1;
    transition: color 0.15s;
}

.cf-clear-btn:hover { color: #666; }

.cf-locate-btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f5f5f5;
    color: #555;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
}

.cf-locate-btn:hover {
    background: #e8f5ee;
    color: #2e7d52;
}

/* ── 반경 선택 바 ─────────────────────────────────────────────────────────── */
.cf-radius-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.cf-radius-label {
    font-size: 0.75rem;
    color: #aaa;
    white-space: nowrap;
}

.cf-radius-group {
    display: flex;
    gap: 4px;
}

.cf-radius-btn {
    padding: 3px 10px;
    border: 1.5px solid #e0e0e0;
    border-radius: 12px;
    background: none;
    color: #777;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.cf-radius-btn:hover {
    border-color: #2e7d52;
    color: #2e7d52;
}

.cf-radius-btn.active {
    border-color: #2e7d52;
    background: #2e7d52;
    color: #fff;
}

/* ── 결과 영역 ────────────────────────────────────────────────────────────── */
.cf-results {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.cf-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px 8px;
    flex-shrink: 0;
    border-bottom: 1px solid #f5f5f5;
}

.cf-result-count {
    font-size: 0.82rem;
    font-weight: 700;
    color: #222;
}

.cf-data-note {
    font-size: 0.7rem;
    color: #ccc;
}

/* 스크롤 가능 목록 래퍼 */
.cf-clinic-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
}

.cf-clinic-item {
    padding: 11px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.13s;
    border-left: 3px solid transparent;
}

.cf-clinic-item:hover { background: #f9f9f9; }

.cf-clinic-item.active {
    background: #f0faf5;
    border-left-color: #2e7d52;
}

.cf-clinic-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 3px;
}

.cf-clinic-meta {
    font-size: 0.73rem;
    color: #999;
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.4;
}

.cf-clinic-distance {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #2e7d52;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 4px;
}

/* ── 페이지네이션 ─────────────────────────────────────────────────────────── */
.cf-pagination {
    padding: 8px 14px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-shrink: 0;
}

.cf-page-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #e0e0e0;
    background: #fff;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all 0.15s;
}

.cf-page-btn:hover:not(:disabled) { border-color: #2e7d52; color: #2e7d52; }
.cf-page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.cf-page-info { font-size: 0.8rem; color: #888; }

/* ── 로딩 / 빈 결과 ──────────────────────────────────────────────────────── */
.cf-loading,
.cf-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 36px 20px;
    color: #bbb;
    gap: 8px;
    text-align: center;
    flex-shrink: 0;
}

.cf-loading i { font-size: 1.3rem; color: #2e7d52; }
.cf-empty i   { font-size: 1.3rem; }
.cf-empty p   { margin: 0; font-size: 0.8rem; line-height: 1.6; }

/* ── 초기 안내 오버레이 ──────────────────────────────────────────────────── */
.cf-map-hint {
    position: fixed;
    bottom: 36px;
    left: 50%;
    transform: translateX(calc(-50% + 160px)); /* 사이드바 폭의 절반만큼 오른쪽으로 */
    z-index: 80;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 14px 20px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    pointer-events: none;
    transition: opacity 0.3s;
}

.cf-map-hint.hidden { opacity: 0; }

.cf-map-hint i {
    font-size: 1.3rem;
    color: #2e7d52;
    display: block;
    margin-bottom: 6px;
}

.cf-map-hint p {
    margin: 0;
    font-size: 0.8rem;
    color: #666;
    line-height: 1.5;
}

/* ── 모바일 토글 버튼 ────────────────────────────────────────────────────── */
.cf-mob-toggle {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 95;
    padding: 10px 20px;
    border-radius: 24px;
    background: #fff;
    border: none;
    color: #444;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.cf-mob-toggle:hover { background: #f5f5f5; }

/* ── 모바일 ──────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .cf-sidebar {
        top: auto;
        left: 0;
        right: 0;
        width: 100%;
        height: 60vh;
        bottom: 0;
        border-radius: 16px 16px 0 0;
        transform: translateY(calc(100% - 58px)); /* 검색창만 보이게 */
        box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
    }

    .cf-sidebar.expanded {
        transform: translateY(0);
    }

    .cf-sidebar-search {
        border-radius: 16px 16px 0 0;
        /* 드래그 핸들 표시 */
        padding-top: 16px;
    }

    .cf-sidebar-search::before {
        content: '';
        position: absolute;
        top: 7px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        border-radius: 2px;
        background: #ddd;
    }

    .cf-map-hint {
        transform: translateX(-50%);
        bottom: calc(60vh + 12px);
    }

    .cf-mob-toggle { display: none !important; }
}

/* ── 상세 패널 ───────────────────────────────────────────────────────────── */
.cf-detail-panel {
    position: fixed;
    top: 0;
    left: 320px;
    bottom: 0;
    width: 300px;
    background: #fff;
    z-index: 98;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.10);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cf-detail-panel.open { transform: translateX(0); }

.cf-detail-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 14px 12px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.cf-detail-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f5f5f5;
    border: none;
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    margin-top: 2px;
    transition: background 0.15s, color 0.15s;
}

.cf-detail-close:hover { background: #ffe5e5; color: #c00; }

.cf-detail-title { flex: 1; min-width: 0; }

.cf-detail-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 3px;
    line-height: 1.3;
    word-break: keep-all;
}

.cf-detail-category {
    font-size: 0.72rem;
    color: #2e7d52;
    font-weight: 600;
}

.cf-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cf-detail-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.82rem;
    color: #555;
    line-height: 1.5;
}

.cf-detail-row i {
    flex-shrink: 0;
    width: 14px;
    color: #aaa;
    margin-top: 2px;
    font-size: 0.78rem;
}

.cf-detail-row a { color: #555; text-decoration: none; }
.cf-detail-row a:hover { color: #2e7d52; }

.cf-detail-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.cf-detail-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    border: 1.5px solid #e0e0e0;
    color: #555;
    background: #fafafa;
    transition: all 0.15s;
    white-space: nowrap;
}

.cf-detail-btn:hover { border-color: #2e7d52; color: #2e7d52; background: #f0faf5; }

.cf-detail-btn-primary { background: #2e7d52; border-color: #2e7d52; color: #fff; }
.cf-detail-btn-primary:hover { background: #256644; border-color: #256644; color: #fff; }

/* 다크모드 — 상세 패널 */
body[data-theme="dark"] .cf-detail-panel { background: #1e1e1e; }
body[data-theme="dark"] .cf-detail-header { border-color: #2e2e2e; }
body[data-theme="dark"] .cf-detail-close { background: #2a2a2a; color: #888; }
body[data-theme="dark"] .cf-detail-name { color: #eee; }
body[data-theme="dark"] .cf-detail-row { color: #999; }
body[data-theme="dark"] .cf-detail-row i { color: #555; }
body[data-theme="dark"] .cf-detail-btn { background: #252525; border-color: #383838; color: #888; }
body[data-theme="dark"] .cf-detail-btn:hover { border-color: #2e7d52; color: #5abf82; background: #1a2e22; }

/* ── 다크모드 (data-theme="dark") ───────────────────────────────────────── */
body[data-theme="dark"] .cf-sidebar {
    background: #1e1e1e;
    box-shadow: 2px 0 16px rgba(0,0,0,0.4);
}

body[data-theme="dark"] .cf-sidebar-search,
body[data-theme="dark"] .cf-radius-bar,
body[data-theme="dark"] .cf-results-header { border-color: #2e2e2e; }

body[data-theme="dark"] .cf-back-btn,
body[data-theme="dark"] .cf-locate-btn { background: #2a2a2a; color: #ccc; }
body[data-theme="dark"] .cf-back-btn:hover,
body[data-theme="dark"] .cf-locate-btn:hover { background: #1a2e22; color: #5abf82; }

body[data-theme="dark"] .cf-address-input {
    background: #252525;
    border-color: #383838;
    color: #ddd;
}
body[data-theme="dark"] .cf-address-input::placeholder { color: #555; }
body[data-theme="dark"] .cf-address-input:focus { border-color: #2e7d52; background: #2a2a2a; }

body[data-theme="dark"] .cf-radius-btn { border-color: #383838; color: #888; }
body[data-theme="dark"] .cf-radius-btn.active { background: #2e7d52; border-color: #2e7d52; color: #fff; }

body[data-theme="dark"] .cf-result-count { color: #ddd; }
body[data-theme="dark"] .cf-clinic-item { border-bottom-color: #2a2a2a; border-left-color: transparent; }
body[data-theme="dark"] .cf-clinic-item:hover { background: #252525; }
body[data-theme="dark"] .cf-clinic-item.active { background: #1a2e22; border-left-color: #2e7d52; }
body[data-theme="dark"] .cf-clinic-name { color: #eee; }
body[data-theme="dark"] .cf-clinic-meta { color: #666; }

body[data-theme="dark"] .cf-pagination { border-top-color: #2e2e2e; }
body[data-theme="dark"] .cf-page-btn { background: #2a2a2a; border-color: #383838; color: #888; }

body[data-theme="dark"] .cf-map-hint { background: rgba(28,28,28,0.94); }
body[data-theme="dark"] .cf-map-hint p { color: #999; }

/* ── 입지 데이터 카드 ─────────────────────────────────────────────────────── */
.cf-analysis-card {
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
    background: #fafffe;
}

.cf-analysis-label {
    font-size: 0.68rem;
    color: #aaa;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.cf-analysis-src {
    font-size: 0.63rem;
    color: #ccc;
}

.cf-analysis-stats {
    display: flex;
    align-items: center;
    gap: 0;
}

.cf-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.cf-stat-val {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: -0.02em;
    line-height: 1;
}

.cf-stat-label {
    font-size: 0.65rem;
    color: #bbb;
}

.cf-stat-divider {
    width: 1px;
    height: 28px;
    background: #ebebeb;
    flex-shrink: 0;
}

.cf-analysis-stats-2 {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
}

/* ── 연령대 분포 바 ───────────────────────────────────────────────────────── */
.cf-age-bar-wrap {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
}

.cf-age-bar-track {
    display: flex;
    height: 7px;
    border-radius: 4px;
    overflow: hidden;
    background: #eee;
    margin-bottom: 6px;
}

.cf-age-seg {
    height: 100%;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.cf-age-youth  { background: #90caf9; }
.cf-age-young  { background: #2e7d52; }
.cf-age-middle { background: #ff9800; }
.cf-age-senior { background: #7b1fa2; }

.cf-age-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
}

.cf-age-legend span {
    font-size: 0.62rem;
    color: #aaa;
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.cf-age-legend b { color: #777; font-weight: 600; }

.cf-age-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* 다크모드 — 연령 바 */
body[data-theme="dark"] .cf-age-bar-wrap  { border-top-color: #2a2a2a; }
body[data-theme="dark"] .cf-age-bar-track { background: #2a2a2a; }
body[data-theme="dark"] .cf-age-legend span { color: #555; }
body[data-theme="dark"] .cf-age-legend b  { color: #777; }

/* 스켈레톤 */
@keyframes cf-shimmer {
    0%   { background-position: -200px 0; }
    100% { background-position: 200px 0; }
}

.cf-analysis-card.skeleton .cf-stat-val,
.cf-analysis-card.skeleton .cf-stat-label,
.cf-analysis-card.skeleton .cf-analysis-label {
    color: transparent;
    border-radius: 4px;
    background: linear-gradient(90deg, #ebebeb 25%, #f5f5f5 50%, #ebebeb 75%);
    background-size: 400px 100%;
    animation: cf-shimmer 1.2s infinite linear;
}

.cf-analysis-card.skeleton .cf-stat-val  { min-width: 48px; min-height: 18px; display: inline-block; }
.cf-analysis-card.skeleton .cf-stat-label{ min-width: 32px; min-height: 11px; display: inline-block; }
.cf-analysis-card.skeleton .cf-analysis-label { min-width: 80px; min-height: 11px; display: inline-block; }

/* 다크모드 — 데이터 카드 */
body[data-theme="dark"] .cf-analysis-card    { background: #192820; border-color: #2a2a2a; }
body[data-theme="dark"] .cf-analysis-label   { color: #555; }
body[data-theme="dark"] .cf-analysis-src     { color: #444; }
body[data-theme="dark"] .cf-stat-val         { color: #ddd; }
body[data-theme="dark"] .cf-stat-label       { color: #555; }
body[data-theme="dark"] .cf-stat-divider     { background: #2e2e2e; }
body[data-theme="dark"] .cf-analysis-stats-2 { border-top-color: #2a2a2a; }

body[data-theme="dark"] .cf-analysis-card.skeleton .cf-stat-val,
body[data-theme="dark"] .cf-analysis-card.skeleton .cf-stat-label,
body[data-theme="dark"] .cf-analysis-card.skeleton .cf-analysis-label {
    background: linear-gradient(90deg, #2a2a2a 25%, #333 50%, #2a2a2a 75%);
    background-size: 400px 100%;
}
