/* NJZ Simple PDF Viewer - 완전 수정 버전 7.2.2 */
/* 화이트 모노크롬 디자인 + 모바일 컨트롤 침범 완전 해결 */

.njz-pdf-container {
    position: relative !important;
    
    /* 완전 화이트 모노크롬 디자인 */
    background: #ffffff;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    
    /* 1340px 너비 제한 강제 적용 */
    max-width: 1340px !important;
    width: 100%;
    margin: 30px auto;
    
    /* 컨트롤 침범 해결: 충분한 하단 패딩 확보 */
    padding: 20px 20px 200px 20px; /* 하단 200px로 대폭 증가 */
    
    /* 기본 스타일 */
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    min-height: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* 컨테이너 내 모든 요소 너비 제한 강화 */
.njz-pdf-container * {
    max-width: 100% !important;
    box-sizing: border-box;
}

/* 데스크탑/태블릿 최적화 (769px 이상) */
@media (min-width: 769px) {
    .njz-pdf-container {
        overflow: hidden !important;
        max-height: 1080px;
        min-height: 1080px;
        padding: 30px 40px 200px 40px; /* 데스크탑도 200px 하단 패딩 */
    }
    
    .njz-pdf-canvas {
        max-height: 860px !important; /* 컨트롤 공간 220px 확보 */
        max-width: 1260px !important;
    }
}

/* PDF Canvas - 우측 잘림 방지 강화 */
.njz-pdf-canvas {
    display: block;
    background: #ffffff;
    cursor: grab;
    border: 1px solid #e5e5e5;
    
    /* 모바일 우측 잘림 완전 방지 */
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    
    margin: 0 auto;
    object-fit: contain;
    box-sizing: border-box;
}

.njz-pdf-canvas:active {
    cursor: grabbing;
}

/* 로딩 상태 - 완전 화이트 디자인 */
.njz-pdf-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 2;
    color: #666666;
}

.njz-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f5f5f5;
    border-top: 3px solid #000000; /* 블랙 포인트 */
    border-radius: 50%;
    animation: njz-spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

.njz-pdf-loading p {
    margin: 0;
    font-size: 14px;
    color: #666666;
    font-weight: 500;
}

/* 완전 화이트 모노크롬 컨트롤 바 - 침범 완전 해결 */
.njz-pdf-controls {
    position: absolute !important;
    bottom: 60px !important; /* 기본 60px로 증가 */
    left: 50% !important;
    transform: translateX(-50%) !important;
    
    /* 완전 화이트 디자인 */
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 24px;
    
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 24px;
    
    /* 미니멀 그림자 */
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    
    width: fit-content;
    z-index: 10 !important;
    pointer-events: auto;
    max-width: calc(100% - 40px);
    
    /* Safe Area 지원 추가 */
    margin-bottom: env(safe-area-inset-bottom, 0px);
}

/* 완전 화이트 모노크롬 버튼 */
.njz-pdf-btn {
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 18px;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 44px; /* 터치 접근성 */
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.njz-pdf-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.njz-pdf-btn:active {
    background: #f3f4f6;
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.njz-pdf-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #ffffff;
    transform: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.njz-pdf-btn:disabled:hover {
    transform: none;
    background: #ffffff;
    border-color: #d1d5db;
}

.njz-pdf-page-info {
    font-size: 14px;
    color: #6b7280;
    min-width: 70px;
    text-align: center;
    user-select: none;
    font-weight: 500;
    white-space: nowrap;
}

/* ★ 모바일 최적화 - 컨트롤 침범 완전 해결 + 우측 잘림 방지 */
@media (max-width: 768px) {
    .njz-pdf-container {
        margin: 20px auto;
        border-radius: 6px;
        
        /* ★ 수정: 하단 패딩 최적화 (160px → 110px) */
        padding: 15px 15px 110px 15px !important;
        
        min-height: 400px;
        max-height: none !important;
        
        /* 모바일 너비 최적화 */
        max-width: calc(100vw - 20px) !important;
        width: calc(100vw - 20px);
    }
    
    .njz-pdf-canvas {
        /* ★ 수정: 모바일 우측 잘림 완전 방지 (50px → 80px) */
        max-width: calc(100vw - 80px) !important;
        width: calc(100vw - 80px) !important;
        max-height: none !important;
        height: auto !important;
    }
    
    .njz-pdf-controls {
        /* 모바일 Safe Area 완전 지원 */
        bottom: calc(25px + env(safe-area-inset-bottom, 0px)) !important;
        padding: 14px 20px;
        gap: 20px;
        border-radius: 20px;
    }
    
    .njz-pdf-btn {
        min-width: 44px;
        height: 44px;
        padding: 8px 12px;
        font-size: 16px;
    }
    
    .njz-pdf-page-info {
        font-size: 13px;
        min-width: 60px;
    }
}

/* ★ 초소형 모바일 (480px 이하) - 하단 여백 최적화 */
@media (max-width: 480px) {
    .njz-pdf-container {
        margin: 15px auto;
        border-radius: 4px;
        /* ★ 수정: 하단 패딩 최적화 (150px → 100px) */
        padding: 10px 10px 100px 10px !important;
        min-height: 350px;
        width: calc(100vw - 10px);
        max-width: calc(100vw - 10px) !important;
    }
    
    .njz-pdf-canvas {
        /* ★ 수정: 여백 통일 (30px → 80px) */
        max-width: calc(100vw - 80px) !important;
        width: calc(100vw - 80px) !important;
    }
    
    .njz-pdf-controls {
        bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
        padding: 12px 16px;
        gap: 16px;
        border-radius: 18px;
    }
    
    .njz-pdf-btn {
        min-width: 40px;
        height: 40px;
        padding: 6px 10px;
        font-size: 14px;
    }
    
    .njz-pdf-page-info {
        font-size: 12px;
        min-width: 50px;
    }
}

/* 데스크탑 최적화 (1025px 이상) - 변경 없음 */
@media (min-width: 1025px) {
    .njz-pdf-container {
        padding: 40px 50px 220px 50px; /* 데스크탑 하단 패딩 220px로 대폭 증가 */
    }
    
    .njz-pdf-controls {
        bottom: 70px !important; /* 데스크탑 적절한 여백 */
        padding: 16px 32px;
        gap: 24px;
        border-radius: 28px;
    }
    
    .njz-pdf-btn {
        min-width: 48px;
        height: 48px;
        padding: 12px 16px;
        font-size: 20px;
    }
    
    .njz-pdf-page-info {
        font-size: 15px;
        min-width: 80px;
    }
}

/* 고해상도 디스플레이 대응 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .njz-pdf-canvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* 접근성 개선 */
.njz-pdf-btn:focus {
    outline: 2px solid #000000;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.1);
}

.njz-pdf-btn:focus:not(:focus-visible) {
    outline: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* 로딩 완료 후 애니메이션 */
.njz-pdf-container.loaded .njz-pdf-loading {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    display: none;
}

.njz-pdf-container.loaded .njz-pdf-canvas {
    opacity: 1;
    transition: opacity 0.3s ease;
    visibility: visible !important;
}

/* 페이지 전환 애니메이션 */
.njz-pdf-canvas.transitioning {
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

/* 디버깅용 (필요시 주석 해제) */
/*
.njz-pdf-container::before {
    content: "Container: " attr(data-max-width) "px max / Canvas visible";
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 10px;
    color: #999;
    background: rgba(255,255,255,0.9);
    padding: 2px 4px;
    border-radius: 2px;
    z-index: 1000;
}
*/