/* ==========================================================
   PDF Flipbook Catalog — Frontend CSS v2.0
   ========================================================== */

/* ── Overlay ── */
#pdfflip-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body.pdfflip-open {
    overflow: hidden !important;
}

/* ============================================================
   TOP BAR
============================================================ */
#pdfflip-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 58px;
    background: rgba(0,0,0,0.50);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    flex-shrink: 0;
    gap: 12px;
    z-index: 10;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

/* Logo */
#pdfflip-logo-wrap { flex: 0 0 auto; display:flex; align-items:center; }
#pdfflip-logo-wrap a { display:flex; align-items:center; text-decoration:none; }
#pdfflip-logo {
    max-height: 36px;
    max-width: 160px;
    object-fit: contain;
    display: block;
}

/* Controls */
#pdfflip-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-size: 14px;
    flex: 1;
    justify-content: center;
}

#pdfflip-controls button {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
}
#pdfflip-controls button:hover { background: rgba(255,255,255,0.28); }

#pdfflip-zoom-level {
    min-width: 44px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
}

#pdfflip-page-info {
    background: rgba(255,255,255,0.1);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 13px;
    white-space: nowrap;
    border: 1px solid rgba(255,255,255,0.15);
}

/* Close button */
#pdfflip-close {
    background: #e53e3e;
    border: none;
    color: #fff;
    font-size: 26px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
    padding: 0;
}
#pdfflip-close:hover { background: #c53030; transform: scale(1.1); }

/* ============================================================
   STAGE (book area)
============================================================ */
#pdfflip-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px 8px;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

/* ── Nav Buttons ── */
.pdfflip-nav {
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.22);
    color: #fff;
    font-size: 44px;
    width: 50px;
    height: 80px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.12s;
    flex-shrink: 0;
    line-height: 1;
    user-select: none;
    padding: 0;
}
.pdfflip-nav:hover  { background: rgba(255,255,255,0.25); transform: scale(1.05); }
.pdfflip-nav:disabled { opacity: 0.2; cursor: not-allowed; transform: none; }

/* ── Book wrap ── */
#pdfflip-book-wrap {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 2000px;
    overflow: hidden;
    min-width: 0;
}

#pdfflip-book {
    display: flex;
    align-items: center;
    justify-content: center;
    transform-style: preserve-3d;
}

/* ── Spread ── */
.pdfflip-spread {
    display: flex;
    align-items: stretch;
    box-shadow: 0 20px 60px rgba(0,0,0,0.7), 0 4px 20px rgba(0,0,0,0.5);
    border-radius: 2px;
    overflow: hidden;
}

/* ── Page canvas ── */
.pdfflip-page-canvas {
    display: block;
    max-height: calc(100vh - 160px);
    max-width: 100%;
    background: #fff;
}

/* ── Page wrap ── */
.pdfflip-turn-wrap {
    position: relative;
    overflow: hidden;
    display: flex;
}

/* ── Shadows ── */
.pdfflip-shadow-l {
    position: absolute;
    top: 0; right: 0;
    width: 28px; height: 100%;
    background: linear-gradient(to right, transparent, rgba(0,0,0,0.15));
    pointer-events: none;
    z-index: 2;
}
.pdfflip-shadow-r {
    position: absolute;
    top: 0; left: 0;
    width: 28px; height: 100%;
    background: linear-gradient(to left, transparent, rgba(0,0,0,0.15));
    pointer-events: none;
    z-index: 2;
}

/* ── Spine ── */
.pdfflip-spine {
    width: 5px;
    flex-shrink: 0;
    background: linear-gradient(to right, #3a3a3a, #111, #3a3a3a);
    box-shadow: 0 0 8px rgba(0,0,0,0.5) inset;
}

/* ── Flip animations ──
   FORWARD (next): page curls from right → swings LEFT  (origin: left edge, rotateY 0 → -180)
   BACKWARD (prev): page curls from left → swings RIGHT (origin: right edge, rotateY 0 → 180)
*/
@keyframes pdfflip-forward {
    0%   { transform: rotateY(0deg);    }
    100% { transform: rotateY(-180deg); }
}
@keyframes pdfflip-backward {
    0%   { transform: rotateY(0deg);   }
    100% { transform: rotateY(180deg); }
}

.pdfflip-flip-forward {
    animation: pdfflip-forward 0.48s cubic-bezier(0.645, 0.045, 0.355, 1.000) forwards;
    transform-origin: left center;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    z-index: 10;
    position: relative;
}
.pdfflip-flip-backward {
    animation: pdfflip-backward 0.48s cubic-bezier(0.645, 0.045, 0.355, 1.000) forwards;
    transform-origin: right center;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    z-index: 10;
    position: relative;
}

/* ============================================================
   BOTTOM BAR — Download + Share
============================================================ */
#pdfflip-bottombar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 20px;
    background: rgba(0,0,0,0.50);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    flex-shrink: 0;
    border-top: 1px solid rgba(255,255,255,0.08);
    position: relative;
}

#pdfflip-bottombar button {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 20px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.12s;
    background: rgba(255,255,255,0.10);
    white-space: nowrap;
}

#pdfflip-download {
    background: rgba(66,153,225,0.25) !important;
    border-color: rgba(66,153,225,0.5) !important;
}
#pdfflip-download:hover { background: rgba(66,153,225,0.45) !important; transform: translateY(-1px); }

#pdfflip-share-btn {
    background: rgba(72,187,120,0.25) !important;
    border-color: rgba(72,187,120,0.5) !important;
}
#pdfflip-share-btn:hover { background: rgba(72,187,120,0.45) !important; transform: translateY(-1px); }

/* ── Share wrap (relative parent for menu) ── */
#pdfflip-share-wrap { position: relative; }

/* ── Share popup menu ── */
#pdfflip-share-menu {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 4px;
    min-width: 180px;
    z-index: 100;
    border: 1px solid rgba(0,0,0,0.08);
}

/* Arrow */
#pdfflip-share-menu::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #fff;
}

.pdfflip-share-item {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 9px 14px !important;
    border-radius: 8px !important;
    border: none !important;
    background: transparent !important;
    color: #333 !important;
    font-size: 14px !important;
    cursor: pointer !important;
    transition: background 0.15s !important;
    width: 100% !important;
    text-align: left !important;
    white-space: nowrap !important;
}
.pdfflip-share-item:hover { background: #f5f5f5 !important; transform: none !important; }
.pdfflip-share-item svg { flex-shrink: 0; }

/* ============================================================
   LOADING
============================================================ */
#pdfflip-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: rgba(255,255,255,0.85);
    font-size: 15px;
    z-index: 50;
    text-align: center;
    padding: 20px;
}
#pdfflip-load-msg { margin: 0; max-width: 480px; line-height: 1.6; white-space: pre-wrap; }

.pdfflip-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.18);
    border-top-color: #fff;
    border-radius: 50%;
    animation: pdfflip-spin 0.75s linear infinite;
    flex-shrink: 0;
}
@keyframes pdfflip-spin { to { transform: rotate(360deg); } }

/* ============================================================
   RESPONSIVE — TABLET (max 900px): side-by-side but smaller
============================================================ */
@media (max-width: 900px) {
    #pdfflip-topbar { height: 52px; padding: 0 14px; gap: 8px; }
    #pdfflip-logo   { max-height: 30px; max-width: 120px; }
    #pdfflip-controls { gap: 6px; font-size: 13px; }
    .pdfflip-nav    { width: 40px; height: 68px; font-size: 36px; }
    #pdfflip-book-wrap { max-width: calc(100vw - 100px); }
}

/* ============================================================
   RESPONSIVE — MOBILE (max 640px): SINGLE PAGE VIEW
   On mobile we show ONE page at a time, full width
============================================================ */
@media (max-width: 640px) {

    /* Top bar — compact */
    #pdfflip-topbar {
        height: 48px;
        padding: 0 10px;
        gap: 6px;
    }
    #pdfflip-logo       { max-height: 26px; max-width: 90px; }
    #pdfflip-controls   { gap: 5px; font-size: 11px; }
    #pdfflip-zoom-level { min-width: 32px; font-size: 11px; }
    #pdfflip-controls button { width: 26px; height: 26px; font-size: 16px; }
    #pdfflip-page-info  { padding: 3px 8px; font-size: 11px; }
    #pdfflip-close      { width: 32px; height: 32px; font-size: 20px; }

    /* Stage — full width, nav arrows at bottom corners */
    #pdfflip-stage {
        flex-direction: column;
        padding: 8px 0 0 0;
        gap: 0;
        position: relative;
    }

    /* Book wrap fills full screen width */
    #pdfflip-book-wrap {
        max-width: 100vw;
        width: 100vw;
        flex: 1;
        padding: 0;
    }

    /* Spread: single column, one page at a time */
    .pdfflip-spread {
        flex-direction: column;
        align-items: center;
        gap: 0;
        box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    }

    /* Hide right page on mobile — show single page full width */
    .pdfflip-spread .pdfflip-turn-wrap:nth-child(3),
    .pdfflip-spread .pdfflip-turn-wrap.pdfflip-wrap-right {
        display: none;
    }

    /* Hide spine on mobile */
    .pdfflip-spine { display: none; }

    /* Left page fills full width */
    .pdfflip-turn-wrap.pdfflip-wrap-left,
    .pdfflip-turn-wrap.pdfflip-wrap-cover {
        width: 100%;
    }

    /* Canvas fills screen */
    .pdfflip-page-canvas {
        width: 100% !important;
        height: auto !important;
        max-height: calc(100vh - 140px);
        object-fit: contain;
    }

    /* Nav arrows: fixed at sides, vertically centered in stage */
    .pdfflip-nav {
        position: fixed;
        top: 50%;
        transform: translateY(-50%);
        width: 38px;
        height: 70px;
        font-size: 30px;
        z-index: 100;
        border-radius: 6px;
        opacity: 0.85;
    }
    #pdfflip-prev { left: 0; border-radius: 0 6px 6px 0; }
    #pdfflip-next { right: 0; border-radius: 6px 0 0 6px; }

    /* Bottom bar */
    #pdfflip-bottombar {
        gap: 8px;
        padding: 8px 12px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
    #pdfflip-bottombar > button,
    #pdfflip-share-wrap > button {
        padding: 8px 16px;
        font-size: 13px;
    }

    /* Share menu opens upward, aligned right */
    #pdfflip-share-menu {
        left: auto;
        right: 0;
        transform: none;
        min-width: 160px;
    }
    #pdfflip-share-menu::after {
        left: auto;
        right: 20px;
        transform: none;
    }
}

/* ── Cover page (single, centered) ── */
.pdfflip-spread.pdfflip-cover {
    box-shadow: 4px 0 20px rgba(0,0,0,0.5), -4px 0 20px rgba(0,0,0,0.3);
}
.pdfflip-wrap-cover {
    position: relative;
}
