/* 페이지 뷰어 공통 스타일 */
.page-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(12,12,12,0.93);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    cursor: pointer;
}

.viewer-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 반투명 스크롤바 */
.viewer-content::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.viewer-content::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.viewer-content::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
}

.viewer-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.5);
}

/* 메인 뷰어 영역 */
.viewer-main {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.viewer-image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    height: 100%;
    position: relative;
}

.viewer-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    cursor: default;
    transition: transform 0.3s ease;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
    will-change: transform; /* 성능 최적화 */
}

/* 미니맵 (구글 포토 스타일) */
.viewer-minimap {
    position: absolute;
    top: 80px;
    right: 20px;
    width: 200px;
    height: 200px;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    overflow: hidden;
    cursor: default; /* 배경 클릭 시 점프 */
    z-index: 1002;
    display: none; /* JS로 제어 */
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.minimap-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* 중앙 정렬 */
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    opacity: 0.8;
    pointer-events: none;
}

.minimap-viewport {
    position: absolute;
    border: 2px solid rgba(66, 133, 244, 0.8); /* 구글 블루 */
    background: rgba(66, 133, 244, 0.1);
    cursor: grab;
    box-sizing: border-box; /* 테두리 포함 크기 계산 */
    z-index: 10;
}

.minimap-viewport:active {
    cursor: grabbing;
}

/* 드래그 중일 때는 애니메이션 제거 */
.viewer-image.no-transition,
.minimap-viewport.no-transition {
    transition: none !important;
}

.viewer-key-hint {
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%) translateY(6px);
    padding: 8px 14px;
    border-radius: 14px;
    background: rgba(22, 20, 18, 0.75);
    color: #f2eee6;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;
    opacity: 0;
    pointer-events: none;
    backdrop-filter: blur(6px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.3);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1002;
}

.viewer-key-hint.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 네비게이션 버튼 */
.viewer-nav {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    cursor: pointer;
    transition: background-color 0.2s ease;
    z-index: 1001;
}

.viewer-nav:hover {
    background: rgba(255,255,255,0.1);
}

.viewer-nav.prev {
    left: 0;
}

.viewer-nav.next {
    right: 0;
}

.viewer-nav.disabled {
    cursor: not-allowed;
    opacity: 0.3;
}

.viewer-nav.disabled:hover {
    background: transparent;
}

.nav-arrow {
    font-size: 3rem;
    color: white;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.viewer-nav:hover .nav-arrow {
    opacity: 1;
}

.viewer-nav.disabled .nav-arrow {
    opacity: 0.2;
}

/* 통합 상단 영역 - 전체 상단을 덮도록 확장 */
.viewer-top-area {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 120px;
    display: flex;
    align-items: flex-start;
    padding: 20px;
    z-index: 1002;
    pointer-events: auto;
}

.viewer-top-area:hover .viewer-info-top,
.viewer-top-area:hover .viewer-zoom-controls,
.viewer-top-area:hover .viewer-close {
    opacity: 1;
}

/* 왼쪽: 페이지 정보 */
.viewer-info-top {
    background: rgba(24,24,24,0.82);
    color: #f5f5f0;
    padding: 8px 16px;
    border-radius: 14px;
    font-size: 14px;
    backdrop-filter: blur(6px);
    transition: opacity 0.3s ease;
    opacity: 0;
    animation: fadeInOut 4s ease-in-out;
    pointer-events: none;
}

/* 중간: 줌 컨트롤 (절대 위치로 정확한 가운데) */
.viewer-zoom-controls {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: min(calc(100vw - 180px), 720px);
    background: rgba(24,24,24,0.82);
    padding: 8px;
    border-radius: 18px;
    backdrop-filter: blur(6px);
    transition: opacity 0.3s ease;
    opacity: 0;
    animation: fadeInOut 4s ease-in-out;
    pointer-events: auto;
    z-index: 1006;
}

/* 오른쪽: 닫기 버튼 (절대 위치) */
.viewer-close {
    position: absolute;
    right: 20px;
    background: rgba(24,24,24,0.82);
    color: #f5f5f0;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(6px);
    opacity: 0;
    animation: fadeInOut 4s ease-in-out;
    pointer-events: auto;
}

.viewer-close:hover {
    background: rgba(0,0,0,0.8);
    opacity: 1 !important;
}

.viewer-help-panel {
    position: absolute;
    top: 20px;
    right: 72px;
    min-width: 240px;
    max-width: 320px;
    background: rgba(20,18,16,0.9);
    color: #f5f1e8;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 12px 12px 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 1003;
}

.viewer-help-panel.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.viewer-help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.viewer-help-title {
    font-weight: 700;
    font-size: 14px;
}

.viewer-help-close {
    background: transparent;
    border: none;
    color: #f5f1e8;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.viewer-help-close:hover {
    background: rgba(255,255,255,0.08);
}

.viewer-help-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.viewer-help-list li {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #e9e4d9;
    gap: 12px;
}

.viewer-help-list li span:first-child {
    font-weight: 700;
    color: #f7f2e8;
}

.viewer-detail-panel {
    position: absolute;
    right: 72px;
    bottom: 220px;
    min-width: 240px;
    max-width: 320px;
    background: rgba(20,18,16,0.9);
    color: #f5f1e8;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 12px 12px 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 1003;
}

.viewer-detail-panel.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.viewer-detail-footer {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

.viewer-auto-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #e9e4d9;
    cursor: pointer;
}

.viewer-auto-toggle input {
    width: 14px;
    height: 14px;
    accent-color: #f0e6d8;
}

/* 줌 버튼 */
.viewer-zoom-btn {
    background: rgba(255,255,255,0.14);
    color: #f5f5f0;
    border: 1px solid rgba(255,255,255,0.12);
    width: 30px;
    height: 30px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.viewer-zoom-btn:hover {
    background: rgba(255,255,255,0.22);
    border-color: rgba(255,255,255,0.18);
}

.viewer-zoom-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.viewer-help-btn,
.viewer-info-btn {
    background: rgba(255,255,255,0.1);
    color: #f5f5f0;
    border: 1px solid rgba(255,255,255,0.12);
    width: 30px;
    height: 30px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.viewer-help-btn:hover,
.viewer-info-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.18);
}

.viewer-help-btn:active,
.viewer-info-btn:active {
    transform: translateY(1px);
}

.viewer-help-btn:focus,
.viewer-info-btn:focus {
    outline: 2px solid rgba(255,255,255,0.25);
    outline-offset: 2px;
}

.viewer-help-btn {
    background: rgba(255,255,255,0.1);
    color: #f5f5f0;
    border: 1px solid rgba(255,255,255,0.12);
    width: 30px;
    height: 30px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.viewer-help-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.18);
}

.viewer-help-btn:active {
    transform: translateY(1px);
}

.viewer-help-btn:focus {
    outline: 2px solid rgba(255,255,255,0.25);
    outline-offset: 2px;
}


/* 애니메이션 */
@keyframes fadeInOut {
    0% { opacity: 1; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* 댓글 아이콘 (상단 툴바 통합) */
.viewer-comments-btn {
    position: relative; /* 배지 위치 기준 */
}

/* 댓글 개수 배지 */
.comments-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e67e22; /* 차분한 캐롯 오렌지 */
    color: white;
    border-radius: 10px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    border: 1px solid rgba(255,255,255,0.8);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* 댓글 모달 */
.comments-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.comments-modal.active {
    opacity: 1;
    visibility: visible;
}

.comments-modal-content {
    background: #faf9f6;
    border: 1px solid #e4e3dc;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0,0,0,0.25);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.comments-modal.active .comments-modal-content {
    transform: scale(1);
}

/* 댓글 모달 헤더 */
.comments-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.comments-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin: 0;
}

.comments-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.comments-close:hover {
    background: #efeee8;
}

/* 댓글 목록 */
.comments-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    max-height: 400px;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.comment-item {
    padding: 15px;
    background: #f4f3ef;
    border-radius: 8px;
    border-left: 3px solid #c5c0b4;
}

.comment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.comment-author-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.comment-profile-image {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #ddd;
}

.comment-profile-default {
    width: 24px;
    height: 24px;
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border: 1px solid #ddd;
}

.comment-author {
    font-weight: bold;
    color: #1f2933;
}

.comment-date {
    font-size: 12px;
    color: #4a5562;
}

.comment-text {
    color: #1f2933;
    line-height: 1.5;
    white-space: pre-wrap;
}

.comment-text-container {
    position: relative;
}

.comment-edit-textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    border: 2px solid #d0ccc2;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    margin-top: 5px;
    box-sizing: border-box;
    background: #f4f3ef;
    color: #1f2933;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.comment-edit-textarea:focus {
    outline: none;
    border-color: #c5c0b4;
    background: #f9f8f4;
}

.comment-actions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.comment-edit-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.comment-edit-btn, .comment-delete-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.comment-edit-btn:hover {
    background: #e3f2fd;
    color: #1976d2;
}

.comment-delete-btn:hover {
    background: #ffebee;
    color: #d32f2f;
}

.comment-save-btn, .comment-cancel-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.comment-save-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.comment-save-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.comment-cancel-btn {
    background: #f5f5f5;
    color: #666;
}

.comment-cancel-btn:hover {
    background: #e0e0e0;
}

.char-counter {
    font-size: 11px;
    color: #4a5562;
    margin-left: auto;
}

.char-counter .current {
    font-weight: 600;
    color: #1f2933;
}

/* 댓글 작성 폼 */
.comments-form {
    padding: 20px;
    border-top: 1px solid #e4e3dc;
    background: #f4f3ef;
    border-radius: 0 0 12px 12px;
}

.comment-textarea {
    width: 100%;
    min-height: 80px;
    max-height: 150px;
    padding: 12px;
    border: 1px solid #d0ccc2;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    box-sizing: border-box;
    background: #f4f3ef;
    color: #1f2933;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.comment-textarea:focus {
    outline: none;
    border-color: #c5c0b4;
    background: #f9f8f4;
}

.comments-form-actions {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.comment-submit {
    background: #e0ded6;
    color: #1f2933;
    border: 1px solid #d0ccc2;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.comment-submit:hover {
    background: #d6d3c9;
    border-color: #c5c0b4;
}

.comment-submit:disabled {
    background: #d8d8d0;
    border-color: #ccccc4;
    cursor: not-allowed;
}

.comment-char-count {
    font-size: 12px;
    color: #666;
}

/* 빈 상태 */
.comments-empty {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 40px;
}

/* 더 보기 버튼 */
.comments-load-more {
    display: block;
    width: 100%;
    padding: 12px;
    margin-top: 16px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 8px;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.comments-load-more:hover {
    background: #e8e8e8;
}

/* 로그인 필요 메시지 */
.comments-login-required {
    text-align: center;
    padding: 20px;
    color: #666;
}

.comments-login-required a {
    color: #007bff;
    text-decoration: none;
}

.comments-login-required a:hover {
    text-decoration: underline;
}



/* 썸네일 네비게이션 - 하단 호버 시 올라옴 */
.thumbnail-navigation {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 160px;
    background: rgba(0,0,0,0.9);
    border-top: 1px solid rgba(255,255,255,0.1);
    overflow: hidden;
    z-index: 1001;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.thumbnail-navigation.visible {
    transform: translateY(0);
}

.thumbnail-strip {
    display: flex;
    gap: 12px;
    padding: 20px 25px;
    overflow-x: auto;
    overflow-y: hidden;
    height: 100%;
    align-items: center;
    scroll-behavior: smooth;
    cursor: grab;
    user-select: none;
}

.thumbnail-strip:active {
    cursor: grabbing;
}

/* 스크롤바 숨기기 */
.thumbnail-strip::-webkit-scrollbar {
    display: none;
}

.thumbnail-strip {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.thumbnail-item {
    position: relative;
    flex-shrink: 0;
    width: 75px;
    height: 120px;
    cursor: pointer;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    background: rgba(255,255,255,0.1);
}

.thumbnail-item:hover {
    border-color: rgba(255,255,255,0.5);
    transform: scale(1.05);
}

.thumbnail-item.active {
    border-color: #007bff;
    box-shadow: 0 0 8px rgba(0,123,255,0.5);
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 2px;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.thumbnail-number {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0,0,0,0.8);
    color: white;
    font-size: 9px;
    padding: 1px 3px;
    border-radius: 2px;
    line-height: 1;
}

/* 모바일 최적화 */
@media (max-width: 768px) {
    .viewer-main {
        bottom: 92px;
    }

    .viewer-nav {
        width: 48px;
        top: 56px;
        bottom: 92px;
    }
    
    .viewer-image {
        max-width: calc(100% - 96px);
    }
    
    .nav-arrow {
        font-size: 1.7rem;
    }
    
    .viewer-top-area {
        left: 0;
        right: 0;
        height: 0;
        padding: 0;
        pointer-events: none;
    }
    
    .viewer-close {
        top: 10px;
        right: 12px;
        width: 35px;
        height: 35px;
        font-size: 20px;
        opacity: 1;
        animation: none;
        z-index: 3004;
    }
    
    .viewer-info-top {
        position: fixed;
        top: 10px;
        left: 12px;
        max-width: calc(100% - 72px);
        font-size: 11px;
        line-height: 1.35;
        padding: 6px 10px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        opacity: 1;
        animation: none;
    }

    .viewer-zoom-controls {
        position: fixed;
        left: 50%;
        bottom: 94px;
        transform: translateX(-50%);
        gap: 6px;
        padding: 6px 8px;
        max-width: calc(100% - 24px);
        overflow-x: auto;
        opacity: 1;
        animation: none;
        z-index: 3004;
        scrollbar-width: none;
    }

    .viewer-zoom-controls::-webkit-scrollbar {
        display: none;
    }
    
    .viewer-zoom-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .viewer-info-btn,
    .viewer-help-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .viewer-help-panel,
    .viewer-detail-panel {
        position: fixed;
        left: 12px;
        right: 12px;
        top: auto;
        bottom: 146px;
        min-width: 0;
        max-width: none;
        max-height: min(44vh, 360px);
        overflow: auto;
        z-index: 3005;
    }
    
    /* 댓글 버튼을 확대/축소 컨트롤 라인 오른쪽에 인라인 배치 */
    .viewer-comments-btn {
        margin-left: 6px;
    }
    
    .viewer-comments-btn:hover {
        transform: scale(1.05);
    }
    
    .comments-modal-content {
        width: 95%;
        max-height: 90%;
    }
    
    .comments-header {
        padding: 15px;
    }
    
    .comments-body {
        padding: 15px;
    }
    
    .comments-form {
        padding: 15px;
    }
    
    /* 모바일 썸네일 네비게이션 */
    .thumbnail-navigation {
        height: 92px;
        transform: translateY(0);
    }

    .thumbnail-strip {
        padding: 10px 12px 12px;
        gap: 8px;
    }

    .thumbnail-item {
        width: 52px;
        height: 72px;
    }
    
    .thumbnail-number {
        font-size: 8px;
        padding: 1px 2px;
    }

    .viewer-detail-footer {
        display: none;
    }
    
    /* 모바일 미니맵 */
    .viewer-minimap {
        display: none !important;
    }
}
