/**
 * @file 360 VR 파노라마 뷰어 UI 스타일시트
 * @version 2.9.2 (Minimap Aspect Ratio Fix)
 * @description
 * 뷰어의 모든 UI 요소에 대한 스타일을 정의합니다.
 * * ✨ [수정 v2.9.2] 500x500px 미니맵 비율 유지를 위해 background-size 및 icon-grid 조정
 * * ✨ [수정 v2.9.1] #pano-note의 max-width를 300px에서 400px로 확장
 * * ✨ [수정 v2.9.0] '옵션형 드레스룸' 씬 전용 안내 문구(#pano-note) 스타일 추가
 * * ✨ [수정 v2.8.2] 'display: block'이 'flex-direction'을 방해하는 CSS 특이성
 * * 문제를 최종 수정. display: flex를 공통 규칙에서 1줄/2줄 버튼의
 * * 개별 규칙으로 이동하여 flex-direction과 동일한 우선순위를 보장함.
 */

/*==========================================================================
  #1. GLOBAL (전역 및 기본 스타일)
==========================================================================*/
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    
    /* ▼▼▼ [수정] 한글 폰트 추가 및 우선순위 변경 ▼▼▼ */
    font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Nanum Gothic", sans-serif;
    /* ▲▲▲ 수정 완료 ▲▲▲ */

    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/*==========================================================================
  #2. LAYOUT (전체 UI 구조)
==========================================================================*/
#panorama {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* [v2.9.0] 옵션형 드레스룸 안내 문구 - 위치 및 정렬 수정 */
#pano-note {
    position: absolute;
    bottom: 20px;
    
    /* [수정] 우측 -> 좌측 배치 */
    left: 20px; 
    right: auto; 
    
    z-index: 10;
    display: none;
    
    color: white;
    font-size: 13px;
    font-weight: bold;
    
    /* [수정] 우측 정렬 -> 좌측 정렬 */
    text-align: left; 
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
    
    /* [수정] 너비 제한 해제 (한 줄 표시 허용) */
    max-width: none; 
    width: auto;
    
    padding: 5px;
    pointer-events: none;
    line-height: 1.4;
}

#UI_R,
#UI_T,
#UI_B {
    position: absolute;
    z-index: 2;
    display: none;
    background-color: rgba(0, 0, 0, 0.7);
}

/* --- 2.1 Landscape Layout (가로 모드) --- */
#UI_R {
    top: 0;
    right: 0;
    width: 15%;
    height: 100%;
    flex-direction: column;
}

/* [v2.9.0] 가로 모드일 때 노트 위치 수정 */
@media (orientation: landscape) {
    #pano-note {
        /* [수정] 우측 패널 피하기 로직 제거 -> 좌측 고정 */
        left: 20px; 
        right: auto;
        bottom: 20px; /* 바닥에서 약간 띄움 */
    }
}


#UI_R1 {
    flex: 0 0 5vw;
    height: 5vw;
}

#UI_R2 { flex: 4; } 
#UI_R3 { flex: 3; }
#UI_R4 {
    width: 100%;
    aspect-ratio: 1 / 1;
}

/* --- 2.2 Portrait Layout (세로 모드) --- */
#UI_T,
#UI_B {
    left: 0;
    width: 100%;
}

#UI_T {
    top: 0;
    height: 10%;
}

#UI_B {
    bottom: 0;
    height: 20svh;
}

/* [v2.9.0] 세로 모드일 때 노트 위치 수정 */
@media (orientation: portrait) {
    #pano-note {
        bottom: 21svh; /* 하단 패널 위로 배치 */
        /* [수정] 좌측 정렬 */
        left: 10px;
        right: auto; 
        font-size: 11px;
        /* 모바일 세로에서는 화면이 좁으므로 자동 줄바꿈 되도록 둠 */
    }
}

#UI_T1 {
    width: 100%;
    height: 100%;
    background: url('./Images/Logo_T.png') center/80% auto no-repeat;
}

.ui-b-second-row {
    display: flex;
    width: 100%;
    height: 100%;
}
/* [수정 v2.6] UI_B2(버튼) 1.5배 확장, UI_B3(공백) 축소 (3:2 비율) */
#UI_B2 { flex: 3; }
#UI_B3 { flex: 2; }
#UI_B4 {
    flex-shrink: 0;
    width: 20svh;
    height: 100%;
}

/*==========================================================================
  #3. COMPONENT (개별 UI 컴포넌트)
==========================================================================*/

/* --- 3.1 Minimap (미니맵) --- */
.minimap-container {
    position: relative;
    background-repeat: no-repeat;
    background-position: bottom center;
    /* [v2.9.2] 수정: 1:1 비율 유지를 위해 80% 80%로 설정 (기존 100% 80%) */
    background-size: 80% 80%;
}

.scene-name-display {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 20%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 18px;
    font-weight: bold;
    pointer-events: none;
    z-index: 22;

    /* ▼▼▼ [추가] 폰트 강제 적용 코드 추가 ▼▼▼ */
    font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Nanum Gothic", sans-serif !important;
    /* ▲▲▲ 추가 완료 ▲▲▲ */
}

.icon-grid {
    position: absolute;
    bottom: 0;
    /* [v2.9.2] 수정: 미니맵 이미지 영역(너비 80%)에 맞게 중앙 정렬 및 크기 조정 */
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 80%;
    z-index: 2;
}

.icon {
    position: absolute;
    width: 12px;
    height: 12px;
    background-color: #6C2B18;
    border-radius: 50%;
    cursor: pointer;
    transform: translate(-50%, -50%);
    transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.icon:hover {
    transform: translate(-50%, -50%) scale(1.5);
    z-index: 3; 
}

.icon.active {
    background-color: #F20017;
    box-shadow: 0 0 8px #F20017;
    transform: translate(-50%, -50%) scale(1.2);
}

.icon::before {
    content: attr(data-scene-name);
    position: absolute;
    bottom: 100%;
    left: 50%;
    z-index: 10;
    padding: 4px 8px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-5px);
    transition: opacity 0.2s, visibility 0.2s;
}
.icon:hover::before {
    opacity: 1;
    visibility: visible;
}

#radarCanvas {
    position: absolute;
    z-index: 1;
    display: none;
    cursor: pointer;
    transform-origin: center center;
}

/* --- 3.2 Type Selector (타입 선택기) --- */
.type-selector {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 10px;
    visibility: hidden;
}
.type-selector.visible {
    visibility: visible;
}

.type-selector p {
    margin: 0 0 2px 0;
    color: white;
    font-size: 12px;
    font-weight: bold;
    text-align: center;
}

.type-button {
    padding: 8px;
    border: 1px solid rgb(125, 125, 125); /* 비활성 버튼 회색 */
    border-radius: 5px;
    background-color: rgba(255, 255, 255, 0.2);
    color: rgb(125, 125, 125); /* 비활성 버튼 회색 */
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.type-button:hover {
    background-color: rgba(255, 255, 255, 0.4);
    color: white; /* 호버 시 흰색 하이라이트 */
    border-color: white; /* 호버 시 흰색 하이라이트 */
}
.type-button.active {
    background-color: #6C2B18;
    border: 2px solid white; /* 활성 버튼 흰색 테두리 */
    color: white; /* 활성 버튼 글자색 흰색 */
    cursor: default;
}
/* 활성 상태일 때 호버 효과가 적용되지 않도록 재정의 */
.type-button.active:hover {
    background-color: #6C2B18;
    color: white;
    border-color: white;
}

/* [v8.4] 버튼 래퍼 (기본 세로 정렬) */
.type-buttons-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 8px;
}
.type-buttons-wrapper .type-button {
    width: 80%;
}

/* * [v2.8.2] 74A 2x2 그리드 레이아웃 (세로 모드 #UI_B 전용) 
 * CSS 특이성 문제 해결을 위해 코드 순서 재배치 및 간소화
 */

/* 그리드 레이아웃 설정 */
#UI_B .type-buttons-wrapper.grid-layout-b {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    height: 100%;
    gap: 6px;
    padding: 0 5px;
    align-content: center;
}

/* [v2.8.2] 그리드 내 모든 버튼 (공통) - (display:flex 제외) */
#UI_B .type-buttons-wrapper.grid-layout-b .type-button {
    width: 100%;
    height: 100%;
    padding: 4px;
    margin: 0;
    line-height: 1.2;
}

/* [v2.8.2] 1줄 버튼 (기본형, 옵션형) - display: flex 명시 */
#UI_B .type-buttons-wrapper.grid-layout-b .type-button[data-view="Standard"],
#UI_B .type-buttons-wrapper.grid-layout-b .type-button[data-view="Option"] {
    display: flex; 
    align-items: center;
    justify-content: center;
    flex-direction: row; 
    font-size: 11px;
}

/* [v2.8.2] 2줄 버튼 (히든주방) - display: flex + flex-direction 명시 */
#UI_B .type-buttons-wrapper.grid-layout-b .type-button[data-view*="_Extend"] {
    display: flex; 
    align-items: center;
    justify-content: center;
    flex-direction: column; 
    font-size: 10px; 
}

/* [v2.8.2] 2줄 버튼의 <span> 텍스트 (순서 변경 없음) */
#UI_B .type-buttons-wrapper.grid-layout-b .type-button[data-view*="_Extend"] span {
    font-size: 9px; /* '(히든주방)' 텍스트 */
}

/* [v2.8] 그리드 순서 (기존과 동일) */
#UI_B .type-buttons-wrapper.grid-layout-b .type-button[data-view="Standard"] { grid-area: 1 / 1 / 2 / 2; }
#UI_B .type-buttons-wrapper.grid-layout-b .type-button[data-view="Standard_Extend"] { grid-area: 1 / 2 / 2 / 3; }
#UI_B .type-buttons-wrapper.grid-layout-b .type-button[data-view="Option"] { grid-area: 2 / 1 / 3 / 2; }
#UI_B .type-buttons-wrapper.grid-layout-b .type-button[data-view="Option_Extend"] { grid-area: 2 / 2 / 3 / 3; }


/* ✨ [수정 v2.5] 히든주방 버튼 2개(기본형, 옵션형)에 대해 글자 크기 축소 */
/* (v8.4 그리드 레이아웃이 아닐 경우, 예: 가로모드) */
.type-button[data-view="Option_Extend"],
.type-button[data-view="Standard_Extend"] {
    font-size: 9px; 
    /* 기존 11px에서 2px 축소 */
}


/* --- 3.3 Hotspot (핫스팟) --- */
.pnlm-hotspot.custom-hotspot {
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid rgba(255, 255, 255, 0.8);
    color: white;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 0 0 4px black;
    cursor: pointer;
    transition: none;
    will-change: transform;
}
.pnlm-hotspot.custom-hotspot:hover {
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
}

.pnlm-hotspot.custom-hotspot span {
    display: inline-block;
    padding: 5px 0;
}

.nav-hotspot {
    height: 30px;
    background-color: rgba(255, 255, 255, 0.3);
    white-space: nowrap;
    padding: 0px 20px;
    border-radius: 8px;
}

.popup-hotspot {
    width: 40px;
    height: 40px;
    background-color: rgba(200, 0, 0, 0.5);
    border-radius: 50%;
}
.popup-hotspot span {
    padding: 0;
}

/* --- 3.4 Popup (팝업) --- */
#popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.6);
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s, visibility 0.3s;
}
#popup-overlay.popup-hidden {
    opacity: 0;
    visibility: hidden;
}

#popup-container {
    position: relative;
    width: 80%;
    max-width: 960px;
    height: 80%;
    max-height: 720px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    transform: scale(1);
    transition: transform 0.3s;
}
#popup-overlay.popup-hidden #popup-container {
    transform: scale(0.9);
}

#popup-content {
    width: 100%;
    height: 100%;
    padding: 20px;
    overflow-y: auto;
    color: #333;
}

#popup-close {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 35px;
    height: 35px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid white;
    border-radius: 50%;
    background-color: #333;
    color: white;
    font-size: 20px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}
#popup-close:hover {
    background-color: #F20017;
    transform: scale(1.1);
}

/*==========================================================================
  #4. MEDIA QUERY (반응형 스타일)
==========================================================================*/

@media (orientation: landscape) {
    /* --- 가로 모드에서 UI_R2 타입 선택기 스타일 조정 --- */
    #UI_R2 .type-selector p {
        font-size: 16px;
        margin-bottom: 5px;
    }
    #UI_R2 .type-button {
        font-size: 15px;
        padding: 12px;
    }

    /* ✨ [수정 v2.5] 가로 모드에서 히든주방 버튼 2개 글자 크기 조정 */
    #UI_R2 .type-button[data-view="Option_Extend"],
    #UI_R2 .type-button[data-view="Standard_Extend"] {
        font-size: 12px;
        /* 기존 15px에서 3px 축소 */
    }

    /* --- 가로 모드에서 핫스팟 크기 확대 --- */
    .pnlm-hotspot.custom-hotspot {
        border-width: 4px;
    }
    .nav-hotspot {
        height: 60px;
        padding: 0px 40px;
        border-radius: 16px;
    }
    
    /* ✨ [수정] 가로 모드 nav 핫스팟 텍스트 크기 축소 (28px -> 22px) */
    .pnlm-hotspot.custom-hotspot.nav-hotspot span {
        font-size: 22px;
    }
    
    .popup-hotspot {
        width: 80px;
        height: 80px;
    }
    .popup-hotspot span {
        font-size: 28px;
    }
}


/*==========================================================================
  #5. LIBRARY OVERRIDE (라이브러리 스타일 재정의)
==========================================================================*/
.pnlm-orientation-button {
    display: none !important;
}

.pnlm-hotspot-base {
    background-image: none !important;
}

.pnlm-load-box {
    display: none !important;
}

/*==========================================================================
  #6. DEBUG (디버그 모드)
==========================================================================*/
#debug-coords {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 101;
    padding: 8px 12px;
    background-color: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-family: monospace;
    font-size: 14px;
    line-height: 1.4;
    text-align: left;
    border-radius: 5px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}
#debug-coords:hover {
    background-color: rgba(0, 0, 0, 0.9);
}
#debug-coords.copied {
    background-color: #28a745;
    color: white;
}
#debug-coords small {
    font-size: 11px;
    color: #ccc;
}

#debug-crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    z-index: 102;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

#debug-crosshair::before,
#debug-crosshair::after {
    content: '';
    position: absolute;
    background-color: rgba(255, 0, 0, 0.7);
    box-shadow: 0 0 3px black;
}
#debug-crosshair::before { /* 세로선 */
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    transform: translateX(-50%);
}
#debug-crosshair::after { /* 가로선 */
    top: 50%;
    left: 0;
    width: 100%;
    height: 2px;
    transform: translateY(-50%);
}