/* PDF 뷰어 스타일 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#pdf-viewer {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

/* PDF 툴바 스타일 */
#pdf-toolbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
    border-bottom: 1px solid #dee2e6;
    padding: 12px 20px;
    display: none;
    z-index: 15;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

#pdf-toolbar > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 100%;
}

#pdf-toolbar .toolbar-left,
#pdf-toolbar .toolbar-center,
#pdf-toolbar .toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

#pdf-toolbar .toolbar-center {
    gap: 12px;
}

#pdf-toolbar button {
    transition: all 0.2s ease;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

#pdf-toolbar button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#pdf-toolbar button:disabled {
    background: #6c757d !important;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

/* 네비게이션 버튼 */
#prev-page, #next-page {
    background: #6c757d;
    color: white;
    padding: 8px 12px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
}

#prev-page:hover, #next-page:hover {
    background: #5a6268 !important;
}

/* 페이지 정보 */
#page-info {
    font-size: 14px;
    color: #495057;
    font-weight: 500;
    background: white;
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    min-width: 100px;
    text-align: center;
}

/* 줌 컨트롤 */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

#zoom-out, #zoom-in {
    background: #fff;
    color: #495057;
    border: 1px solid #dee2e6;
    padding: 6px 8px;
    font-size: 16px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#zoom-level {
    font-size: 12px;
    color: #6c757d;
    min-width: 35px;
    text-align: center;
}

#zoom-out:hover, #zoom-in:hover, #fit-width:hover {
    background: #f8f9fa !important;
    border-color: #adb5bd !important;
}

/* 기능 버튼 */
#fit-width {
    background: #fff;
    color: #495057;
    border: 1px solid #dee2e6;
    padding: 6px 10px;
    font-size: 12px;
}

#fullscreen-toggle {
    background: #17a2b8;
    color: white;
    padding: 8px 12px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
}

#fullscreen-toggle:hover {
    background: #138496 !important;
}

#fullscreen-toggle.exit-fullscreen {
    background: #dc3545;
}

#fullscreen-toggle.exit-fullscreen:hover {
    background: #c82333 !important;
}

#download-pdf {
    background: #28a745;
    color: white;
    padding: 8px 12px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
}

#download-pdf:hover {
    background: #218838 !important;
}

/* 전체화면 모드 스타일 */
.pdf-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    background: #000 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.pdf-fullscreen .container {
    max-width: 100% !important;
    padding: 0 !important;
    height: 100vh !important;
}

.pdf-fullscreen .pdf-viewer-container {
    width: 100% !important;
    height: 100vh !important;
    padding: 0 !important;
    margin: 0 !important;
}

.pdf-fullscreen #pdf-viewer {
    width: 100% !important;
    height: 100vh !important;
    min-height: 100vh !important;
    border: none !important;
    border-radius: 0 !important;
    background: #000 !important;
}

.pdf-fullscreen #pdf-container {
    width: 100% !important;
    height: auto !important;
    min-height: 100vh !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding-top: 60px !important; /* 툴바 공간 확보 */
}

.pdf-fullscreen #pdf-canvas {
    margin: 0 auto !important;
}

.pdf-fullscreen #pdf-toolbar {
    background: rgba(0, 0, 0, 0.8) !important;
    border-bottom: 1px solid #333 !important;
    backdrop-filter: blur(10px) !important;
}

.pdf-fullscreen #pdf-toolbar button {
    background: #333 !important;
    color: white !important;
    border: 1px solid #555 !important;
}

.pdf-fullscreen #pdf-toolbar button:hover {
    background: #555 !important;
    border-color: #777 !important;
}

.pdf-fullscreen #prev-page,
.pdf-fullscreen #next-page {
    background: #444 !important;
}

.pdf-fullscreen #prev-page:hover,
.pdf-fullscreen #next-page:hover {
    background: #666 !important;
}

.pdf-fullscreen #page-info {
    background: rgba(255, 255, 255, 0.1) !important;
    color: white !important;
    border: 1px solid #555 !important;
}

.pdf-fullscreen #zoom-out,
.pdf-fullscreen #zoom-in,
.pdf-fullscreen #fit-width {
    background: #333 !important;
    color: white !important;
    border: 1px solid #555 !important;
}

.pdf-fullscreen #zoom-level {
    color: #ccc !important;
}

/* 전체화면에서 ESC 키 안내 */
.fullscreen-hint {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 10000;
    animation: fadeInOut 3s ease-in-out;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 1; }
}

/* PDF 뷰어 컨테이너 */
.pdf-viewer-container {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    min-height: auto;
}

/* PDF 캔버스 중앙정렬 */
#pdf-canvas {
    display: block;
    margin: 0 auto;
    touch-action: none; /* 터치 스크롤 방지하여 드래그 개선 */
    user-select: none; /* 텍스트 선택 방지 */
}

/* 드래그 가능한 상태에서 커서 변경 */
#pdf-canvas.draggable {
    cursor: grab;
}

#pdf-canvas.dragging {
    cursor: grabbing;
}

#pdf-container {
    padding-top: 60px; /* 툴바 공간 확보 */
}

/* 상단 네비게이션 호버 효과 */
.back a:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

/* 태블릿 대응 */
@media (max-width: 1000px) {
    .container {
        max-width: 100% !important;
        padding: 0 15px !important;
    }

    #pdf-viewer {
        min-height: 400px;
    }
}

/* 모바일 대응 - 한페이지씩 보기 */
@media (max-width: 768px) {
    .container {
        padding: 0 10px !important;
    }

    #detail {
        padding: 20px 0 !important;
    }

    #pdf-viewer {
        min-height: 350px;
        border-radius: 6px;
    }

    #pdf-toolbar {
        padding: 8px 12px;
    }

    #pdf-toolbar > div {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }

    #pdf-toolbar .toolbar-left,
    #pdf-toolbar .toolbar-center,
    #pdf-toolbar .toolbar-right {
        flex-direction: row;
        gap: 6px;
        width: 100%;
        justify-content: center;
    }

    #pdf-toolbar button {
        padding: 6px 10px;
        font-size: 12px;
    }

    #page-info {
        font-size: 12px;
        min-width: 80px;
    }

    #zoom-level {
        font-size: 10px;
        min-width: 30px;
    }

    /* 모바일에서 PDF 캔버스 최적화 - max-width 제거로 비율 유지 */
    #pdf-canvas {
        /* max-width: 100% !important; ← 비율 깨뜨리는 원인, 제거 */
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 5px !important;
    }

    #pdf-viewer {
        min-height: 280px;
        border-radius: 4px;
    }

    #pdf-toolbar {
        padding: 6px 8px;
    }

    #pdf-toolbar button {
        padding: 4px 8px;
        font-size: 11px;
    }

    #page-info {
        font-size: 11px;
        min-width: 70px;
    }

    #zoom-level {
        font-size: 9px;
        min-width: 25px;
    }

    #pdf-toolbar svg {
        width: 12px;
        height: 12px;
    }

    #prev-page, #next-page {
        gap: 2px;
    }

    #download-pdf {
        gap: 2px;
    }
}
