/* 기본 스타일 - 전체 화면 및 어두운 무채색 */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: Arial, sans-serif;
    background-color: #1a1a1a;
    color: #e0e0e0;
}

.viewer-container {
    width: 100%;
    height: 100%;
    background-color: #1a1a1a; 
    display: flex;
    flex-direction: column;
}

/* 컨트롤 영역 (헤더) */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    padding: 8px 16px;
    background-color: #2a2a2a;
    border-bottom: 1px solid #444;
    flex-shrink: 0;
    font-size: 14px;
    z-index: 10;
}

/* --- 뷰 모드 아이콘 버튼 스타일 시작 --- */

/* 그룹 컨테이너 */
.view-mode-group {
    display: flex;
    gap: 8px;
    background: transparent;
    padding: 0;
    align-items: center;
}

/* 읽기 방향 & 클릭 방향 그룹 - 구분선 및 간격 처리 */
.reading-direction-group,
.click-direction-group {
    display: flex; 
    gap: 8px;
    align-items: center;
    padding-left: 20px;
    margin-left: 0;
    border-left: 1px solid #555; /* 구분선 */
}

.reading-direction-group {
    display: none; /* 기본 숨김 (JS로 제어) */
}

/* 개별 아이템 래퍼 */
.view-mode-item {
    position: relative;
    display: flex;
    align-items: center;
}

/* 실제 라디오 버튼 숨김 */
.view-mode-item input[type="radio"] {
    display: none;
}

/* 라디오 버튼 라벨 (아이콘 버튼 역할) */
.view-mode-item label {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 36px;
    background-color: #333;
    border: 1px solid #444;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 4px;
    box-sizing: border-box;
    margin: 0; 
}

/* SVG 아이콘 기본 스타일 */
.view-mode-item svg.icon,
.fullscreen-button svg.icon {
    width: 100%;
    height: 100%;
    color: #a0a0a0; /* 기본 회색 */
    pointer-events: none;
}

/* 마우스 오버 효과 */
.view-mode-item label:hover {
    background-color: #444;
    border-color: #555;
}
.view-mode-item label:hover svg.icon {
    color: #e0e0e0;
}

/* 선택된(Checked) 상태 효과 */
.view-mode-item input[type="radio"]:checked + label {
    background-color: #555;
    border-color: #777;
    box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

.view-mode-item input[type="radio"]:checked + label svg.icon {
    color: #fff; /* 흰색으로 강조 */
    filter: drop-shadow(0 0 2px rgba(255,255,255,0.3));
}

/* --- 뷰 모드 아이콘 버튼 스타일 끝 --- */

/* 페이지네이션 그룹 */
.pagination-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 기타 체크박스 라벨 공통 */
.controls > label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0;
}

select {
    padding: 5px 10px;
    background-color: #3a3a3a;
    color: #f0f0f0;
    border: 1px solid #555;
    border-radius: 4px;
    outline: none; 
}

/* 전체 화면 버튼 스타일 (아이콘형으로 변경) */
.fullscreen-button {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 40px; /* 다른 아이콘 버튼과 동일한 너비 */
    height: 36px; /* 다른 아이콘 버튼과 동일한 높이 */
    padding: 6px; /* 아이콘 크기 조절을 위한 패딩 */
    box-sizing: border-box;
    background-color: #333;
    color: #a0a0a0;
    border: 1px solid #444;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: auto; /* 우측 정렬 */
}

.fullscreen-button:hover {
    background-color: #444;
    border-color: #555;
}

.fullscreen-button:hover svg.icon {
    color: #e0e0e0;
}

/* 전체 화면 활성화 상태일 때 (선택사항) */
.fullscreen-button.active {
    background-color: #555;
    border-color: #777;
    color: #fff;
}
.fullscreen-button.active svg.icon {
    color: #fff;
}

/* 이미지 뷰어 영역 */
.image-viewer {
    position: relative;
    width: 100%;
    flex-grow: 1;
    background-color: #000;
    overflow: hidden; 
    user-select: none; 
    -webkit-overflow-scrolling: touch;
}

/* 세로 스크롤 모드에서는 터치 액션 허용 */
.image-viewer.mode-vertical {
    touch-action: pan-y;
    overflow-y: auto;
}

/* 전체 화면 모드일 때 헤더 숨기기 */
:fullscreen .controls { display: none; }
:-webkit-full-screen .controls { display: none; }
:-moz-full-screen .controls { display: none; }
:-ms-fullscreen .controls { display: none; }

/* 이미지 컨테이너 공통 */
.image-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transform: translateX(0); 
}

.image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none; 
}

/* --- 모드별 스타일 --- */

/* 1. 한 장 보기 (Single) */
.single-view {
    flex-direction: row;
    position: relative;
    width: 100%;
    height: 100%;
}

.single-view img {
    position: absolute; 
    left: 0;
    width: 100%;
    height: 100%;
}

/* 2. 두 장 보기 (Double) */
.double-view {
    flex-direction: row;
    gap: 0;
    justify-content: center; 
}

.double-view img {
    width: 50%;
    height: 100%;
    object-fit: contain;
}

/* 기본값: 왼쪽 정렬, 오른쪽 정렬 (LTR 기준) */
.double-view img:first-child {
    object-position: right center;
}

.double-view img:nth-child(2) {
    object-position: left center;
}

.double-view.single-item img {
    width: 50%;
    margin-right: 50%; 
}

/* 3. 세로 스크롤 (Vertical) */
.vertical-view {
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    height: auto;
    min-height: 100%;
}

.vertical-view img {
    width: 100%;
    max-width: 100%;
    height: auto; 
    margin-bottom: 0;
    display: block;
}

/* 클릭 영역 */
.click-area {
    position: absolute;
    top: 0;
    width: 50%; 
    height: 100%;
    cursor: pointer;
    z-index: 5;
}

.image-viewer.mode-vertical .click-area {
    display: none;
}

.left-area { left: 0; }
.right-area { right: 0; }

/* 모바일 최적화 */
@media (max-width: 768px) {
    .controls {
        font-size: 12px;
        padding: 4px 8px;
        gap: 10px;
    }
    
    .view-mode-group, 
    .reading-direction-group,
    .click-direction-group {
        gap: 4px;
    }

    .reading-direction-group,
    .click-direction-group {
        padding-left: 10px; /* 모바일에서 간격 축소 */
    }

    .view-mode-item label,
    .fullscreen-button { /* 전체 화면 버튼 크기 조정 */
        width: 36px;
        height: 32px;
        padding: 3px;
    }
    
    select {
        padding: 4px 8px;
        font-size: 12px;
    }
}