/**
 * Styling for FlipBook — v1.6.0
 * Fix: Layout kontrol di bawah buku (bukan overlap), buku tidak terpotong di laptop
 * New: Zoom In buttons (1x, 1.5x, 2x, 2.5x, 3x)
 */

/* ── Wrapper Paling Luar (Full-screen overlay) ── */
.flipbook-outer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    /* % bukan vw agar tidak melebar akibat scrollbar */
    height: 100vh;
    z-index: 90000;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    overflow: hidden;
    box-sizing: border-box;
}

/* ── Area buku (flex: 1 → mengisi sisa ruang) ── */
.flipbook-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #f8f9fa 0%, #e9ecef 100%);
    overflow: hidden;
    /* JS sudah ukur konservatif, tidak perlu scroll */
    min-height: 0;
    box-sizing: border-box;
    /* Cegah text-selection saat drag pan */
    user-select: none;
    -webkit-user-select: none;
}

/* ── Kontainer buku ── */
#book-container {
    display: block;
    position: relative;
    flex-shrink: 0;
    background-color: transparent;
}

#book-container canvas {
    display: block;
}

/* ================================================================
   PANEL NAVIGASI — Sekarang bagian dari flex column, bukan absolute
   ================================================================ */
.flipbook-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-shrink: 0;
    /* jangan menyusut */
    height: 60px;
    /* tinggi tetap agar bisa diperhitungkan JS */
    padding: 5px 12px;
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(8px);
    color: #fff;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    z-index: 100;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-sizing: border-box;
    /* Hapus absolute positioning */
    position: static;
    left: auto;
    bottom: auto;
    transform: none;
    width: 100% !important;
}

/* ── Tombol TOC ── */
.flipbook-btn-toc {
    background: #6366f1;
    color: white;
    min-width: auto;
}

.flipbook-btn-toc:hover {
    background: #4f46e5;
}

/* ── Panel TOC (Slide-out dari kiri) ── */
.fb-toc-panel {
    position: fixed;
    top: 40px;
    left: 20px;
    width: 280px;
    max-height: calc(100vh - 140px);
    background: #1a1a2e;
    z-index: 99999;
    border-radius: 12px;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    transform: translateX(-120%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.fb-toc-panel.active {
    transform: translateX(0);
}

.fb-toc-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fb-toc-header h3 {
    margin: 0;
    font-size: 16px;
    color: #fff;
}

#fb-toc-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.fb-toc-list {
    list-style: none;
    margin: 0;
    padding: 10px 0;
    overflow-y: auto;
    flex: 1;
}

.fb-toc-list li a {
    display: flex;
    justify-content: space-between;
    padding: 12px 20px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s, color 0.2s;
}

.fb-toc-list li a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.fb-toc-list li a .toc-page {
    color: #3b82f6;
    font-weight: bold;
}

/* ── Bagian Tengah (Page Input) ── */
.flipbook-nav-center {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    padding: 3px 10px;
    border-radius: 20px;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#flipbook-page-go {
    width: 35px;
    background: transparent;
    border: none;
    border-bottom: 1px solid #3b82f6;
    color: #fff;
    text-align: center;
    font-size: 13px;
    font-weight: bold;
    padding: 0;
    outline: none;
}

.fb-label {
    font-size: 14px;
    color: #94a3b8;
    font-weight: 500;
}

/* ── Tombol ── */
.flipbook-btn {
    border: none;
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: auto;
    justify-content: center;
    white-space: nowrap;
}

.flipbook-btn-nav {
    background: #3b82f6;
    color: white;
}

.flipbook-btn-nav:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.flipbook-btn-go {
    background: #10b981;
    color: white;
    min-width: auto;
    padding: 3px 8px;
    border-radius: 15px;
    font-size: 9px;
}

.flipbook-btn-go:hover {
    background: #059669;
}

/* ── Tombol Home ── */
.flipbook-btn-home {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    min-width: auto;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.flipbook-btn-home:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ── Responsive Mobile ── */
@media (max-width: 768px) {
    .flipbook-controls {
        height: auto;
        flex-wrap: wrap;
        padding: 10px;
        gap: 10px;
    }

    .flipbook-btn {
        font-size: 11px;
    }

    .flipbook-nav-center {
        order: -1;
    }
}

/* Override parent WP — cegah parent menyembunyikan konten */
.entry-content,
.post-content,
main,
article,
.elementor-section {
    overflow: visible !important;
}

/* ── Halaman FlipBook ── */
.my-page {
    overflow: hidden;
    background: #fff;
    box-sizing: border-box;
}

.my-page img {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    object-fit: fill !important;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
}

/* ══════════════════════════════════════════
   ZOOM BUTTON & DROPDOWN
   ══════════════════════════════════════════ */

/* ── Wrapper tombol zoom (relative untuk dropdown) ── */
.flipbook-zoom-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* ── Tombol utama zoom ── */
.flipbook-btn-zoom {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    border: none;
    min-width: auto;
    gap: 5px;
    font-size: 10px;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
    transition: all 0.2s ease;
}

.flipbook-btn-zoom:hover {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.5);
}

.flipbook-btn-zoom.is-zoomed {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    animation: zoom-pulse 1.8s ease-in-out infinite;
}

@keyframes zoom-pulse {
    0%, 100% { box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4); }
    50%       { box-shadow: 0 4px 16px rgba(239, 68, 68, 0.7); }
}

/* ── Dropdown menu (muncul ke atas) ── */
.flipbook-zoom-menu {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    background: rgba(18, 18, 35, 0.97);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0,0,0,0.3);
    overflow: hidden;
    min-width: 130px;
    display: none;           /* hidden by default */
    flex-direction: column;
    padding: 6px 0;
    z-index: 999999;
    transform-origin: bottom right;
    animation: zoom-menu-in 0.18s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.flipbook-zoom-menu.open {
    display: flex;
}

@keyframes zoom-menu-in {
    from { opacity: 0; transform: scale(0.85) translateY(6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Setiap opsi ── */
.zoom-option {
    background: transparent;
    border: none;
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 500;
    padding: 9px 18px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.zoom-option::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: transparent;
    transition: background 0.15s;
    flex-shrink: 0;
}

.zoom-option:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
}

.zoom-option.active {
    color: #fbbf24;
    font-weight: 700;
}

.zoom-option.active::before {
    background: #fbbf24;
}

/* ── Responsive mobile: dropdown tetap terlihat ── */
@media (max-width: 768px) {
    .flipbook-zoom-menu {
        right: 0;
        min-width: 115px;
    }

    .zoom-option {
        font-size: 12px;
        padding: 8px 14px;
    }
}