/* ==========================================================================
   3D FLIPBOOK & CONTROLS STYLESHEET
   Supports single/double page spread, 3D paper curl, realistic drop shadows
   ========================================================================== */

.flipbook-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    perspective: 2500px; /* Enhanced 3D effect from snapon_flipfile */
    user-select: none;
}

/* Book Frame & Stage */
.book-viewport {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: center center;
    border-radius: 4px;
}

/* Cursor states for Zoom & Drag */
.flipbook-wrapper.is-zoomed {
    cursor: grab;
}

.flipbook-wrapper.is-dragging {
    cursor: grabbing !important;
}

/* StPageFlip Canvas / DOM container */
.st-page-flip {
    box-shadow: 0 25px 65px rgba(0, 0, 0, 0.65), 0 8px 24px rgba(0, 0, 0, 0.4);
    background-color: #ffffff;
    border-radius: 4px;
    margin: 0 auto;
    transition: box-shadow 0.3s ease;
}

/* Each Page */
.page-item,
.page {
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    position: relative;
}

.page-item img,
.page img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    display: block;
    pointer-events: none;
}

/* Spine Shadow for double page spreads (center crease) */
.page-item.--left::after,
.page.--left::after,
.st__page.--left::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 34px;
    height: 100%;
    background: linear-gradient(to right, rgba(0,0,0,0) 0%, rgba(0,0,0,0.18) 100%);
    pointer-events: none;
    z-index: 10;
}

.page-item.--right::before,
.page.--right::before,
.st__page.--right::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 34px;
    height: 100%;
    background: linear-gradient(to left, rgba(0,0,0,0) 0%, rgba(0,0,0,0.18) 100%);
    pointer-events: none;
    z-index: 10;
}

/* Single page subtle border */
.page-item.--single,
.page.--single {
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   FLIPBOOK FLOATING TOOLBAR
   ========================================================================== */
.flipbook-toolbar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    background: rgba(18, 22, 28, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 30px;
    padding: 6px 14px;
    gap: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    z-index: 50;
    user-select: none;
}

.tool-btn {
    background: transparent;
    border: none;
    outline: none;
    color: #f1f5f9;
    font-size: 18px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.18s ease;
}

.tool-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    transform: scale(1.06);
}

.tool-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.tool-separator {
    width: 1px;
    height: 18px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 2px;
}

/* Page Indicator */
.page-indicator {
    color: #ffffff;
    font-size: 13.5px;
    font-weight: 500;
    padding: 0 8px;
    letter-spacing: 0.5px;
    min-width: 58px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Zoom display */
.zoom-display {
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 600;
    min-width: 44px;
    text-align: center;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
}

.zoom-display:hover {
    color: #ffffff;
}

/* Download button */
.download-tool-btn {
    color: #ffffff;
    text-decoration: none;
}

/* ==========================================================================
   THUMBNAILS DRAWER
   ========================================================================== */
.thumbnails-drawer {
    position: fixed;
    bottom: -150px;
    left: 0;
    width: 100%;
    height: 130px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(14px);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    gap: 16px;
    overflow-x: auto;
    transition: bottom 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
}

.thumbnails-drawer.open {
    bottom: 0;
}

.thumb-item {
    height: 100px;
    border-radius: 4px;
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.thumb-item:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.8);
}

.thumb-item.active {
    border-color: var(--brand-green);
}

.thumb-item img {
    height: 100%;
    width: auto;
    object-fit: contain;
}

.thumb-close-btn {
    position: absolute;
    top: 6px;
    right: 12px;
    background: none;
    border: none;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
}

/* Fullscreen Mode Adjustments */
body:fullscreen .main-canvas,
body:-webkit-full-screen .main-canvas {
    min-height: 100vh;
}
