/**
 * NxtPaperLive 3D Flipbook Player Styling
 */

.nxtpaper-viewer-wrapper {
    position: relative;
    width: 100%;
    background: #090d16;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    margin: 24px 0;
    user-select: none;
    -webkit-user-select: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.nxtpaper-viewer-wrapper:fullscreen,
.nxtpaper-viewer-wrapper:-webkit-full-screen,
.nxtpaper-viewer-wrapper:-moz-full-screen,
.nxtpaper-viewer-wrapper:-ms-fullscreen {
    border-radius: 0 !important;
    margin: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    z-index: 999999 !important;
}

.nxtpaper-viewer-wrapper:fullscreen .nxtpaper-stage,
.nxtpaper-viewer-wrapper:-webkit-full-screen .nxtpaper-stage,
.nxtpaper-viewer-wrapper:-moz-full-screen .nxtpaper-stage,
.nxtpaper-viewer-wrapper:-ms-fullscreen .nxtpaper-stage {
    min-height: calc(100vh - 56px);
    height: calc(100vh - 56px);
}

/* Stage & Flipbook Canvas */
.nxtpaper-stage {
    position: relative;
    flex: 1;
    width: 100%;
    min-height: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 30px;
    overflow: hidden;
    background: radial-gradient(ellipse 65% 55% at 50% 45%, #2a374a 0%, #151d2a 45%, #080d16 100%);
}

.nxtpaper-flip-container {
    position: relative;
    margin: auto;
    display: block;
    border-radius: 4px;
    transition: transform 0.25s ease;
    max-width: 100%;
    max-height: 100%;

    /* Realistic Page Edges Stack & Ground Ambient Drop Shadow */
    box-shadow: 
        /* Left page edges stack (striations of stacked paper sheets) */
        -3px 0 0 -1px #f8fafc,
        -4px 0 0 -1px #cbd5e1,
        -6px 0 0 -2px #94a3b8,
        -8px 0 1px -3px #64748b,
        /* Right page edges stack (striations of stacked paper sheets) */
        3px 0 0 -1px #f8fafc,
        4px 0 0 -1px #cbd5e1,
        6px 0 0 -2px #94a3b8,
        8px 0 1px -3px #64748b,
        /* Ground Ambient Multi-stage Shadow (Alas Meja) */
        0 4px 6px -2px rgba(0, 0, 0, 0.35),
        0 14px 28px -6px rgba(0, 0, 0, 0.55),
        0 35px 70px -15px rgba(0, 0, 0, 0.85);
}

.nxtpaper-flip-container .stf__parent {
    position: relative;
    display: block;
    box-sizing: border-box;
    width: 100% !important;
    height: 100% !important;
}

.nxtpaper-flip-container .stf__wrapper {
    position: relative;
    width: 100% !important;
    height: 100% !important;
    box-sizing: border-box;
}

.nxtpaper-flip-container .stf__block {
    position: absolute;
    width: 100% !important;
    height: 100% !important;
    left: 0;
    top: 0;
    box-sizing: border-box;
    perspective: 2000px;
}

.nxtpaper-page-canvas {
    background: #ffffff;
    box-sizing: border-box;
    overflow: hidden;
    border-radius: 2px;
}

.nxtpaper-page-canvas canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    display: block;
    object-fit: contain;
}

/* Lekukan Jilidan Tengah (Spine Gutter Crease) & Real 3D Book Spine */
.nxtpaper-page-canvas.even {
    /* Left page: spine is at right edge */
    border-right: 1px solid rgba(0, 0, 0, 0.18);
    box-shadow: 
        inset -28px 0 35px -12px rgba(0, 0, 0, 0.28),
        inset -3px 0 4px rgba(0, 0, 0, 0.25),
        inset 1px 0 0 rgba(255, 255, 255, 0.6);
}

.nxtpaper-page-canvas.odd {
    /* Right page: spine is at left edge */
    border-left: 1px solid rgba(0, 0, 0, 0.18);
    box-shadow: 
        inset 28px 0 35px -12px rgba(0, 0, 0, 0.28),
        inset 3px 0 4px rgba(0, 0, 0, 0.25),
        inset -1px 0 0 rgba(255, 255, 255, 0.6);
}

/* Dog-Ear Curl Hint on Page 1 (Affordance) */
.nxtpaper-dog-ear-hint {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 56px;
    height: 56px;
    cursor: pointer;
    z-index: 30;
    pointer-events: auto;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nxtpaper-dog-ear-curl {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 42px 42px;
    border-color: transparent transparent #e2e8f0 transparent;
    filter: drop-shadow(-4px -4px 6px rgba(0, 0, 0, 0.32));
    animation: nxtpaperDogEarPulse 2.6s ease-in-out infinite;
    transform-origin: bottom right;
}

.nxtpaper-dog-ear-curl::after {
    content: '';
    position: absolute;
    bottom: -42px;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 42px 42px;
    border-color: transparent transparent rgba(2, 132, 199, 0.28) transparent;
}

.nxtpaper-dog-ear-hint:hover .nxtpaper-dog-ear-curl {
    animation: none;
    transform: scale(1.25);
}

@keyframes nxtpaperDogEarPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2) translate(-2px, -2px);
    }
}

/* Stage Reading Themes */
.nxtpaper-viewer-wrapper.theme-dark .nxtpaper-stage {
    background: radial-gradient(ellipse 65% 55% at 50% 45%, #2a374a 0%, #151d2a 45%, #080d16 100%);
}
.nxtpaper-viewer-wrapper.theme-light .nxtpaper-stage {
    background: radial-gradient(ellipse 65% 55% at 50% 45%, #ffffff 0%, #e2e8f0 55%, #94a3b8 100%);
}
.nxtpaper-viewer-wrapper.theme-light .nxtpaper-flip-container {
    box-shadow: 
        -3px 0 0 -1px #f1f5f9,
        -5px 0 0 -2px #cbd5e1,
        -7px 0 1px -3px #94a3b8,
        3px 0 0 -1px #f1f5f9,
        5px 0 0 -2px #cbd5e1,
        7px 0 1px -3px #94a3b8,
        0 4px 6px -2px rgba(0, 0, 0, 0.12),
        0 14px 28px -6px rgba(0, 0, 0, 0.18),
        0 30px 60px -15px rgba(0, 0, 0, 0.25);
}
.nxtpaper-viewer-wrapper.theme-light .nxtpaper-toolbar {
    background: rgba(248, 250, 252, 0.94);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    color: #1e293b;
}
.nxtpaper-viewer-wrapper.theme-light .nxtpaper-btn {
    color: #64748b;
}
.nxtpaper-viewer-wrapper.theme-light .nxtpaper-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #0284c7;
}
.nxtpaper-viewer-wrapper.theme-light .nxtpaper-page-badge {
    background: rgba(0, 0, 0, 0.05);
    color: #1e293b;
    border-color: rgba(0, 0, 0, 0.12);
}
.nxtpaper-viewer-wrapper.theme-sepia .nxtpaper-stage {
    background: radial-gradient(ellipse 65% 55% at 50% 45%, #4a382c 0%, #2a1c13 55%, #140d09 100%);
}
.nxtpaper-viewer-wrapper.theme-sepia .nxtpaper-flip-container {
    box-shadow: 
        -3px 0 0 -1px #e6d7c3,
        -5px 0 0 -2px #cca885,
        -7px 0 1px -3px #8b6b4d,
        3px 0 0 -1px #e6d7c3,
        5px 0 0 -2px #cca885,
        7px 0 1px -3px #8b6b4d,
        0 4px 6px -2px rgba(0, 0, 0, 0.4),
        0 14px 28px -6px rgba(0, 0, 0, 0.65),
        0 35px 70px -15px rgba(0, 0, 0, 0.9);
}

/* Reading Progress Scrubber Bar */
.nxtpaper-progress-track {
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.12);
    cursor: pointer;
    position: relative;
    z-index: 22;
    transition: height 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.nxtpaper-progress-track:hover {
    height: 8px;
}
.nxtpaper-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #0284c7 0%, #38bdf8 60%, #7dd3fc 100%);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.8), 0 0 4px rgba(56, 189, 248, 1);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}
.nxtpaper-progress-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 8px #38bdf8;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.nxtpaper-progress-track:hover .nxtpaper-progress-fill::after {
    opacity: 1;
}

/* Floating Toolbar */
.nxtpaper-toolbar {
    height: 52px;
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 20;
    color: #f8fafc;
}

.nxtpaper-tool-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nxtpaper-btn {
    background: transparent;
    border: none;
    outline: none;
    color: #94a3b8;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.nxtpaper-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #38bdf8;
}

.nxtpaper-btn.active {
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.15);
}

.nxtpaper-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.nxtpaper-page-badge {
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    min-width: 75px;
    text-align: center;
}

/* Loading Overlay */
.nxtpaper-loader-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 50;
    color: #f8fafc;
    transition: opacity 0.3s ease;
}

.nxtpaper-spinner {
    width: 44px;
    height: 44px;
    border: 3.5px solid rgba(56, 189, 248, 0.2);
    border-top-color: #38bdf8;
    border-radius: 50%;
    animation: nxtpaper-spin 0.8s linear infinite;
}

@keyframes nxtpaper-spin {
    to { transform: rotate(360deg); }
}

.nxtpaper-loader-text {
    font-size: 14px;
    font-weight: 600;
    color: #94a3b8;
}

/* Thumbnail Drawer */
.nxtpaper-thumb-drawer {
    position: absolute;
    bottom: 52px;
    left: 0;
    right: 0;
    height: 120px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: none;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    overflow-x: auto;
    z-index: 25;
}

.nxtpaper-thumb-drawer.open {
    display: flex;
}

.nxtpaper-thumb-item {
    flex-shrink: 0;
    width: 65px;
    height: 90px;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    background: #1e293b;
    position: relative;
    transition: transform 0.2s, border-color 0.2s;
}

.nxtpaper-thumb-item:hover {
    transform: translateY(-2px);
    border-color: #38bdf8;
}

.nxtpaper-thumb-item.active {
    border-color: #0284c7;
    box-shadow: 0 0 10px rgba(2, 132, 199, 0.5);
}

.nxtpaper-thumb-item canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.nxtpaper-thumb-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    font-size: 10px;
    text-align: center;
    padding: 2px 0;
}

/* Lightbox Modal */
.nxtpaper-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(4, 7, 13, 0.92) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    z-index: 9999999 !important;
    display: none !important;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.nxtpaper-modal-overlay.open {
    display: flex !important;
}

body.nxtpaper-modal-active {
    overflow: hidden !important;
}

.nxtpaper-modal-card {
    position: relative;
    width: 96vw;
    max-width: 1320px;
    height: 92vh;
    border-radius: 14px;
    overflow: hidden;
    background: #090d16;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.12);
    display: flex;
    flex-direction: column;
    animation: nxtpaperModalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes nxtpaperModalIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.nxtpaper-modal-card .nxtpaper-viewer-wrapper {
    margin: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 14px !important;
    box-shadow: none !important;
    flex: 1 1 auto;
}

.nxtpaper-modal-card .nxtpaper-stage {
    min-height: 0 !important;
    flex: 1 1 auto;
}

.nxtpaper-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 99999;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: all 0.2s ease;
}

.nxtpaper-modal-close:hover {
    background: #ef4444;
    border-color: #ef4444;
    transform: scale(1.08);
}

/* Shelf Grid */
.nxtpaper-shelf-wrap {
    margin: 30px 0;
}

.nxtpaper-shelf-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.nxtpaper-filter-btn {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #475569;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.nxtpaper-filter-btn:hover {
    border-color: #0284c7;
    color: #0284c7;
}

.nxtpaper-filter-btn.active {
    background: #0284c7;
    border-color: #0284c7;
    color: #ffffff;
}

.nxtpaper-shelf-grid {
    display: grid;
    gap: 24px;
}

.nxtpaper-shelf-grid.cols-1 { grid-template-columns: 1fr; }
.nxtpaper-shelf-grid.cols-2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.nxtpaper-shelf-grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.nxtpaper-shelf-grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.nxtpaper-shelf-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.3s ease;
}

.nxtpaper-shelf-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 28px -10px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(2, 132, 199, 0.2);
}

.nxtpaper-card-cover-wrap {
    height: 240px;
    background: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    perspective: 800px;
}

.nxtpaper-card-cover-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease, filter 0.3s ease;
}

.nxtpaper-shelf-card:hover .nxtpaper-card-cover-wrap img {
    transform: scale(1.04) rotateY(-4deg);
    filter: brightness(1.03);
}

.nxtpaper-card-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.nxtpaper-card-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.nxtpaper-card-cat-tag {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #0284c7;
    background: rgba(2, 132, 199, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.nxtpaper-card-title {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 8px 0;
    line-height: 1.35;
}

.nxtpaper-card-title a {
    color: inherit;
    text-decoration: none;
}

.nxtpaper-card-title a:hover {
    color: #0284c7;
}

.nxtpaper-card-desc {
    font-size: 12.5px;
    color: #64748b;
    margin: 0 0 16px 0;
    line-height: 1.5;
    flex: 1;
}

.nxtpaper-card-actions {
    display: flex;
    gap: 8px;
}

.nxtpaper-btn-open {
    flex: 1;
    background: #0284c7;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s;
}

.nxtpaper-btn-open:hover {
    background: #0369a1;
    color: #ffffff;
}

.nxtpaper-btn-details {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nxtpaper-btn-details:hover {
    background: #e2e8f0;
}

/* Single Book CPT Template Styling (Direct Menu Link) */
.nxtpaper-single-wrapper {
    width: 100%;
    min-height: 80vh;
    padding: 30px 20px 60px 20px;
    box-sizing: border-box;
}

.nxtpaper-single-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.nxtpaper-single-header {
    margin-bottom: 20px;
    text-align: center;
}

.nxtpaper-single-categories {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.nxtpaper-single-cat-badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #0284c7;
    background: rgba(2, 132, 199, 0.08);
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid rgba(2, 132, 199, 0.2);
}

.nxtpaper-single-title {
    font-size: 30px;
    font-weight: 800;
    color: #0f172a;
    margin: 0;
    line-height: 1.3;
}

.nxtpaper-single-player-wrap {
    width: 100%;
    margin-bottom: 24px;
}

.nxtpaper-single-meta-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 20px;
    margin-bottom: 30px;
}

.nxtpaper-single-pills {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.nxtpaper-pill {
    font-size: 13.5px;
    font-weight: 600;
    color: #475569;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.nxtpaper-btn-download-hero {
    background: #0284c7;
    color: #ffffff !important;
    text-decoration: none !important;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s ease, transform 0.15s ease;
}

.nxtpaper-btn-download-hero:hover {
    background: #0369a1;
    transform: translateY(-1px);
}

.nxtpaper-single-description {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 28px 32px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.04);
}

.nxtpaper-single-description h3 {
    font-size: 19px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 14px 0;
}

.nxtpaper-desc-content {
    color: #475569;
    line-height: 1.75;
    font-size: 15px;
}

@media (max-width: 768px) {
    .nxtpaper-single-title {
        font-size: 24px;
    }
    .nxtpaper-single-meta-strip {
        flex-direction: column;
        align-items: flex-start;
    }
    .nxtpaper-btn-download-hero {
        width: 100%;
        justify-content: center;
    }
}
