/* ================================================
   Flipbook PDF Viewer — Realistic Book Style
   Uses StPageFlip + PDF.js for real page-turn effect
   ================================================ */

.pdf-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 15, 25, 0.96);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    -webkit-user-select: none;
    user-select: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* ========== Header ========== */
.pdf-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    color: #fff;
    z-index: 10;
    flex-shrink: 0;
}

.pdf-viewer-title {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.pdf-viewer-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.pdf-viewer-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ========== Book Container ========== */
.pdf-viewer-book-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    padding: 10px;
}

/* The book wrapper with shadow and perspective */
.flipbook-container {
    position: relative;
    display: inline-block;
    /* Book shadow — gives depth */
    filter: drop-shadow(0 15px 40px rgba(0, 0, 0, 0.6));
}

/* Individual pages */
.flipbook-page {
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.flipbook-page canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

/* Page loading state */
.flipbook-page-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 0.9rem;
    gap: 8px;
    width: 100%;
    height: 100%;
    background: #fafafa;
}

.flipbook-page-loading .spinner-border {
    width: 1.5rem;
    height: 1.5rem;
    border-width: 2px;
}

/* Global loading overlay */
.pdf-viewer-loading {
    color: #fff;
    text-align: center;
    font-size: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.pdf-viewer-loading .spinner-border {
    width: 2.5rem;
    height: 2.5rem;
}

/* ========== Controls ========== */
.pdf-viewer-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    flex-shrink: 0;
    z-index: 10;
}

.pdf-viewer-controls button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-viewer-controls button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.08);
}

.pdf-viewer-controls button:active:not(:disabled) {
    transform: scale(0.95);
}

.pdf-viewer-controls button:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

.pdf-viewer-page-info {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95rem;
    font-weight: 500;
}

.pdf-viewer-page-info input {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    width: 40px;
    padding: 4px 2px;
    border-radius: 6px;
    outline: none;
    transition: all 0.2s;
    -moz-appearance: textfield;
}

.pdf-viewer-page-info input::-webkit-outer-spin-button,
.pdf-viewer-page-info input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.pdf-viewer-page-info input:focus {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.5);
}

.pdf-page-separator {
    opacity: 0.5;
}

#pdfPageTotal {
    font-weight: 600;
}

/* ========== Protection ========== */
.pdf-viewer-overlay * {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .pdf-viewer-header {
        padding: 8px 12px;
    }
    .pdf-viewer-title {
        font-size: 0.85rem;
    }
    .pdf-viewer-controls {
        padding: 8px 12px;
        gap: 10px;
    }
    .pdf-viewer-controls button {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }
    .pdf-viewer-page-info {
        font-size: 0.8rem;
        min-width: 60px;
    }
}
