/**
 * PDF FlipBook Styles v3
 * Giao diện đơn giản, responsive, hỗ trợ zoom scroll
 */

/* Overlay fullscreen */
.flipbook-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    z-index: 99999;
    display: none;
    flex-direction: column;
}

/* Wrapper */
.flipbook-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

/* Header */
.flipbook-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    height: 52px;
    box-sizing: border-box;
}

.flipbook-title {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.flipbook-title i {
    color: #667eea;
}

.flipbook-controls-top {
    display: flex;
    align-items: center;
    gap: 6px;
}

.flipbook-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.flipbook-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.flipbook-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.flipbook-close {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
}

.flipbook-close:hover {
    background: rgba(239, 68, 68, 0.4);
}

.flipbook-zoom-level {
    color: #fff;
    font-size: 13px;
    min-width: 50px;
    text-align: center;
    font-weight: 500;
}

/* Main Book Area */
.flipbook-main {
    flex: 1;
    display: flex;
    align-items: stretch;
    justify-content: center;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

/* Navigation Buttons */
.flipbook-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 40px;
    height: 70px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
    z-index: 100;
}

.flipbook-nav:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

.flipbook-nav-prev {
    left: 8px;
}

.flipbook-nav-next {
    right: 8px;
}

/* Book Container - Full width with scroll */
.flipbook-book-container {
    flex: 1;
    display: block;
    padding: 20px 60px;
    overflow: auto;
    min-height: 0;
    text-align: center;
    cursor: grab;
}

.flipbook-book-container:active {
    cursor: grabbing;
}

.flipbook-book-container.dragging {
    cursor: grabbing;
    user-select: none;
}

/* Custom Scrollbar */
.flipbook-book-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.flipbook-book-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.flipbook-book-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.flipbook-book-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}

.flipbook-book-container::-webkit-scrollbar-corner {
    background: transparent;
}

/* Firefox scrollbar */
.flipbook-book-container {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) rgba(255, 255, 255, 0.05);
}

/* Book wrapper for zoom scrolling */
.flipbook-book {
    background: #fff;
    border-radius: 2px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(0, 0, 0, 0.1);
    display: inline-flex;
    flex-shrink: 0;
    min-width: 300px;
    min-height: 400px;
    margin: auto;
    vertical-align: top;
    /* Size will be set by JS based on viewport and zoom */
}

.flipbook-pages {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
    min-height: 100%;
}

/* Pages */
.flipbook-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    min-height: 100%;
}

.flipbook-page-left {
    border-right: 1px solid #ddd;
    background: linear-gradient(to right, #f5f5f5 0%, #fff 3%, #fff 100%);
}

.flipbook-page-right {
    background: linear-gradient(to left, #f5f5f5 0%, #fff 3%, #fff 100%);
}

/* Canvas - full size */
.flipbook-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Book spine removed - using border on page-left instead */

/* Loading */
.flipbook-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #666;
    width: 100%;
    height: 100%;
    font-size: 14px;
}

.flipbook-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #666;
    text-align: center;
}

.flipbook-page-error {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
    width: 100%;
    height: 100%;
}

/* Footer */
.flipbook-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    min-height: 52px;
    box-sizing: border-box;
    gap: 10px;
}

.flipbook-page-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    font-size: 13px;
    flex-shrink: 0;
    white-space: nowrap;
}

.flipbook-page-nav .flipbook-btn {
    width: 28px;
    height: 28px;
    font-size: 11px;
}

.flipbook-page-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 45px;
    height: 28px;
    border-radius: 4px;
    text-align: center;
    font-size: 13px;
}

.flipbook-page-input:focus {
    outline: none;
    border-color: #667eea;
    background: rgba(255, 255, 255, 0.15);
}

/* Progress bar */
.flipbook-progress {
    flex: 1;
    min-width: 80px;
    max-width: 400px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.flipbook-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s ease;
}

/* CTA Button */
.flipbook-cta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.flipbook-cta-text {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    white-space: nowrap;
}

.flipbook-buy-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: #fff;
    padding: 6px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.flipbook-buy-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* ============ RESPONSIVE ============ */

/* Tablet */
@media (max-width: 1024px) {
    .flipbook-book-container {
        padding: 10px 50px;
    }
}

/* Mobile - Scroll mode (hiển thị tất cả trang, scroll dọc) */
@media (max-width: 768px) {
    .flipbook-header {
        padding: 6px 10px;
    }
    
    .flipbook-title span {
        display: none;
    }
    
    .flipbook-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    .flipbook-zoom-level {
        font-size: 11px;
        min-width: 40px;
    }
    
    /* Ẩn navigation arrows trên mobile */
    .flipbook-nav {
        display: none !important;
    }
    
    /* Full width book container cho mobile scroll */
    .flipbook-book-container {
        padding: 10px 8px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Mobile scroll mode - book container */
    .flipbook-book {
        width: 100% !important;
        height: auto !important;
        display: flex;
        flex-direction: column;
        gap: 12px;
        background: transparent;
        box-shadow: none;
        min-height: auto;
    }
    
    /* Mobile scroll - pages container */
    .flipbook-pages {
        display: flex;
        flex-direction: column;
        gap: 12px;
        width: 100%;
        height: auto;
    }
    
    /* Each page in scroll mode */
    .flipbook-page {
        flex: none !important;
        width: 100% !important;
        height: auto !important;
        display: block;
        min-height: auto;
        background: #fff;
        border-radius: 4px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.3);
        overflow: hidden;
    }
    
    .flipbook-page-left,
    .flipbook-page-right {
        display: block !important;
        border: none;
        background: #fff;
    }
    
    .flipbook-book.spread-view::before {
        display: none;
    }
    
    /* Canvas trong scroll mode - responsive */
    .flipbook-canvas {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        max-width: 100%;
    }
    
    .flipbook-footer {
        padding: 6px 10px;
        flex-wrap: wrap;
        height: auto;
        gap: 8px;
    }
    
    .flipbook-page-nav {
        font-size: 12px;
    }
    
    .flipbook-progress {
        order: 3;
        width: 100%;
        max-width: none;
        margin: 0;
    }
    
    .flipbook-cta-text {
        display: none;
    }
    
    .flipbook-buy-btn {
        padding: 6px 14px;
        font-size: 12px;
    }
    
    /* Hide page nav buttons on mobile scroll mode */
    .flipbook-page-nav .flipbook-btn {
        display: none;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .flipbook-book-container {
        padding: 8px 5px;
    }
    
    .flipbook-btn {
        width: 28px;
        height: 28px;
    }
    
    .flipbook-scroll-page {
        border-radius: 2px;
    }
}

/* Scroll page indicator badge - hiển thị số trang góc phải */
.flipbook-scroll-page {
    position: relative;
}

.flipbook-scroll-page::after {
    content: attr(data-page);
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
    pointer-events: none;
}

/* Loading state cho scroll page */
.flipbook-scroll-page .flipbook-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 250px;
    background: rgba(255,255,255,0.05);
}
