/* ==========================================================================
   0. 기본 화면 초기화 (전체 화면 구성)
   ========================================================================== */
html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#main-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

#map-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* ==========================================================================
   1. 최외곽 사이드바 레이어 (자체 배경 없음, 마우스 통과)
   ========================================================================== */
#map-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 390px;
    height: 100%;
    z-index: 2;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    pointer-events: none; /* 빈 공간은 지도가 클릭되도록 관통 */
    padding: 12px;        /* 외곽 마진 */
    transition: width 0.3s ease;
}

.sidebar-minimized { width: 60px !important; }
.sidebar-default { width: 390px !important; }
.sidebar-maximized { width: 500px !important; }

/* 내부 실제 카드들은 마우스 이벤트를 받도록 복구 */
.sidebar-header-ui, 
.sidebar-content-viewport > section {
    pointer-events: auto;
}

/* ==========================================================================
   2. 1층 레벨: 맨 위 상단 컨트롤 버튼 카드 (Rounded Rect)
   ========================================================================== */
.sidebar-header-ui {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px; /* 아래 목록 카드와의 확실한 이격 */
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    display: flex;
    justify-content: flex-end;
}

.window-action-buttons button {
    background: none;
    border: 1px solid #ced4da;
    border-radius: 4px;
    margin-left: 5px;
    cursor: pointer;
    padding: 3px 8px;
    font-size: 0.75rem;
    transition: background 0.1s;
}
.window-action-buttons button:hover { background: #f1f3f4; }

/* ==========================================================================
   3. 2층 레벨: 아래 목록 카드 컨테이너 (★배경 투명화)
   ========================================================================== */
.sidebar-content-viewport {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* 팝업창 내부의 메인 섹션 판넬 자체를 투명하게 만들어 뒤쪽 지도가 보이게 처리 */
.sidebar-content-viewport > section {
    background: transparent !important; /* 배경 투명화 */
    box-shadow: none !important;        /* 외곽 그림자 제거 */
    padding: 0;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 80px);
}

/* 목록 내부에서 요소를 수직 배치하는 스택 공간 (카드 사이 틈새 정의) */
.data-stack {
    display: flex;
    flex-direction: column;
    gap: 10px; /* 개별 미술관 카드 사이의 틈새 공간 -> 이 사이로 지도가 비침 */
    overflow-y: auto;
    padding: 2px;
}

/* 투명한 목록 카드 내부의 상단 메타 정보 박스 (가독성을 위해 살짝 띄움) */
.view-meta { 
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.view-meta h2 { font-size: 1.15rem; margin: 0 0 4px 0; color: #212529; font-weight: 600; }
.view-meta p { font-size: 0.8rem; margin: 0; color: #6c757d; }

/* 뒤로가기 버튼도 독자적인 둥근 버튼 형태로 플로팅 */
.nav-back-btn {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid #dadce0;
    padding: 6px 14px;
    border-radius: 100px;
    cursor: pointer;
    font-size: 0.8rem;
    margin-bottom: 10px;
    color: #3c4043;
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* ==========================================================================
   4. 3층 레벨: 실제 내부의 구글 맵스 스타일 미술관 카드 (Rounded Rect)
   ========================================================================== */
.ui-card, .ui-row-card, .artwork-card {
    padding: 14px;
    background: rgba(255, 255, 255, 0.98); /* 불투명한 흰색으로 카드가 명확히 인지되도록 처리 */
    border: 1px solid #dadce0;
    border-radius: 8px; /* 둥근 사각형 사양 */
    cursor: pointer;
    box-sizing: border-box;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08); /* 개별 카드가 공중에 뜬 느낌 부여 */
    transition: background-color 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.ui-card:hover, .ui-row-card:hover, .artwork-card:hover {
    background-color: #f8f9fa;
    border-color: #1a73e8;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.ui-card strong, .ui-row-card h4, .artwork-card strong {
    display: block;
    font-size: 0.95rem;
    color: #212529;
    margin-bottom: 4px;
    font-weight: 500;
}
.ui-card small, .ui-row-card p, .artwork-card small {
    display: block;
    font-size: 0.8rem;
    color: #5f6368;
    line-height: 1.3;
}
.ui-card span {
    display: inline-block;
    font-size: 0.75rem;
    color: #1a73e8;
    margin-top: 4px;
    font-weight: 500;
}

/* ==========================================================================
   5. 기타 서브 컴포넌트 레이아웃 정돈
   ========================================================================== */
#museum-profile-summary {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    padding: 14px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.native-link { display: inline-block; font-size: 0.8rem; color: #1a73e8; text-decoration: none; margin-top: 6px; font-weight: 500; }
.section-divider { height: 1px; background: #dadce0; margin: 12px 0; }

.data-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    overflow-y: auto;
}

.status-loader { 
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    text-align: center; 
    padding: 30px 0; 
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.status-loader h3 { color: #1a73e8; margin: 0 0 8px 0; font-size: 1.1rem; }
.status-loader p { font-size: 0.8rem; margin: 0; color: #6c757d; }

/* Screen 4 상세 페이지용 컨테이너 박스 격리 */
.artwork-hero-card, .data-ledger-table, .financial-card-box, .docent-essay-block {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    box-sizing: border-box;
}
.artwork-hero-card { text-align: center; }
.artwork-hero-card img { width: 100%; max-height: 180px; object-fit: cover; border-radius: 6px; margin-bottom: 8px; }
.ui-badge-gold { display: inline-block; font-size: 0.7rem; background: #fef7e0; color: #b06000; padding: 2px 8px; border-radius: 4px; margin-bottom: 6px; font-weight: 500; }

.data-ledger-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.data-ledger-table th { text-align: left; color: #5f6368; padding: 6px 0; border-bottom: 1px solid #f1f3f4; font-weight: 400; }
.data-ledger-table td { text-align: right; color: #202124; padding: 6px 0; border-bottom: 1px solid #f1f3f4; }

.financial-header { display: flex; justify-content: space-between; margin-bottom: 6px; font-weight: 600; color: #202124; }
.financial-body .data-field { display: flex; justify-content: space-between; margin-bottom: 4px; }
.financial-body .emphasis { color: #d93025; font-weight: 600; }

.docent-essay-block { overflow-y: auto; max-height: 200px; }
.docent-essay-block h3 { font-size: 0.85rem; color: #202124; margin: 10px 0 4px 0; font-weight: 600; }
.prose-text { font-size: 0.8rem; line-height: 1.4; color: #3c4043; text-align: justify; margin: 0; }

/* 카드 레이아웃 정돈 스타일 */
.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}
.card-title {
    font-size: 0.95rem;
    font-weight: 600;
}
.card-distance {
    font-size: 0.8rem;
    color: #1a73e8;
    font-weight: 500;
    flex-shrink: 0;
    margin-left: 8px;
}
.card-address {
    display: block;
    color: #5f6368;
    margin-bottom: 6px;
}
.card-footer-row {
    margin-top: 4px;
    font-size: 0.8rem;
}
.card-hp-link {
    color: #1a73e8;
    text-decoration: none;
    font-weight: 500;
}
.card-hp-link:hover {
    text-decoration: underline;
}
.card-hp-empty {
    color: #9aa0a6;
}

/* 로딩 오버레이 레이아웃 */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(255, 255, 255, 0.7); /* 반투명 배경 */
    z-index: 9999; /* 최상단 배치 */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* 로딩 오버레이 활성화 상태 */
#loading-overlay.active {
    opacity: 1;
    pointer-events: auto; /* 로딩 중 백그라운드 클릭 방지 (더블탭 버그 차단) */
}

/* 아워글래스/스피너 스타일 애니메이션 */
.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #e0e0e0;
    border-top: 5px solid #3498db; /* 메인 포인트 컬러 */
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: 15px;
    font-size: 14px;
    color: #555;
    font-weight: 500;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 탭 UI */
.tabs-container {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    border-bottom: 2px solid #eee;
}
.tab {
    padding: 8px 16px;
    cursor: pointer;
    font-weight: bold;
    color: #888;
}
.tab.active {
    color: #333;
    border-bottom: 2px solid #3498db;
}

/* 전시 배지 */
.exh-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}
.badge-perm { background: #e8f5e9; color: #2e7d32; }
.badge-temp { background: #fff3e0; color: #ef6c00; }

/* 리스트 간격 */
.ui-row-card {
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
}
.exh-period { font-size: 12px; color: #666; margin-top: 5px; }

/* 리스트 카드 내 미니 링크 버튼 */
.btn-mini-link {
    display: inline-block;
    padding: 4px 8px;
    background-color: #f1f3f5;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    color: #495057;
    font-size: 11px;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-mini-link:hover {
    background-color: #e9ecef;
}

.btn-mini-disabled {
    font-size: 11px;
    color: #ced4da;
}

.card-footer-row {
    display: flex;
    justify-content: flex-end;
}