/* ==========================================================================
   Book Preview Modal — PDF.js + image gallery viewer (Modal Popup)
   ========================================================================== */

/* Fullscreen Backdrop overlay */
.book-preview-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: bpFadeIn 0.2s ease-out;
}

@keyframes bpFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Centered Modal Dialog Card */
.book-preview-modal-dialog {
    position: relative;
    width: 100%;
    max-width: 960px;
    height: 90vh;
    max-height: 900px;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    animation: bpScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .book-preview-modal-dialog {
    background: #0f172a;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.12);
}

@keyframes bpScaleUp {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Header bar */
.book-preview-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

[data-theme="dark"] .book-preview-header {
    background: #1e293b;
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.book-preview-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.book-preview-title {
    flex: 1 1 auto;
    font-size: 1.02rem;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

[data-theme="dark"] .book-preview-title {
    color: #f8fafc;
}

.book-preview-label {
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(37, 99, 235, 0.1);
    border: 1px solid rgba(37, 99, 235, 0.25);
    color: #2563eb;
    padding: 0.25rem 0.75rem;
    border-radius: 50rem;
    white-space: nowrap;
    flex-shrink: 0;
}

[data-theme="dark"] .book-preview-label {
    background: rgba(37, 99, 235, 0.25);
    border-color: rgba(96, 165, 250, 0.4);
    color: #93c5fd;
}

.book-preview-close {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.18s;
    padding: 0;
}

.book-preview-close:hover {
    background: #fee2e2;
    border-color: #ef4444;
    color: #ef4444;
}

[data-theme="dark"] .book-preview-close {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    color: #94a3b8;
}

[data-theme="dark"] .book-preview-close:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
    color: #ef4444;
}

/* Body — where PDF canvas or images live */
.book-preview-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1rem 3rem;
    gap: 1.5rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    background: #f1f5f9;
}

[data-theme="dark"] .book-preview-body {
    background: #090d16;
}

/* Document Flow Container */
.book-preview-doc-flow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    padding-bottom: 2rem;
}

/* Page Slot */
.book-preview-page-slot {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
    min-height: 480px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

[data-theme="dark"] .book-preview-page-slot {
    background: #1e293b;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* Page Skeleton / Loader */
.book-preview-page-skeleton {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-height: 480px;
    width: 100%;
    color: #64748b;
    font-size: 0.88rem;
    font-weight: 600;
    background: transparent;
}

.book-preview-spinner.sm {
    width: 28px;
    height: 28px;
    border-width: 2.5px;
    border-color: rgba(37, 99, 235, 0.2);
    border-top-color: #2563eb;
}

/* PDF Canvas */
.book-preview-pdf-page {
    display: block;
    max-width: 100%;
    height: auto !important;
    background: var(--surface-card);
}

/* Image pages */
.book-preview-image-page {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 0.75rem;
    background: var(--surface-card);
}

/* Page Number Badge */
.book-preview-page-badge {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 50rem;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Header Page Pill */
.book-preview-page-pill {
    font-size: 0.78rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 0.25rem 0.75rem;
    border-radius: 50rem;
    white-space: nowrap;
}

/* End-of-preview Card */
.book-preview-end-card {
    text-align: center;
    background: #ffffff;
    border: 1.5px dashed #cbd5e1;
    border-radius: 1rem;
    padding: 2.25rem 1.5rem;
    width: 100%;
    max-width: 820px;
    color: #1e293b;
    margin-top: 1.5rem;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .book-preview-end-card {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.book-preview-end-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.12);
    color: #2563eb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 0.85rem;
    border: 1.5px solid rgba(37, 99, 235, 0.25);
}

[data-theme="dark"] .book-preview-end-icon {
    background: rgba(37, 99, 235, 0.25);
    color: #60a5fa;
    border-color: rgba(96, 165, 250, 0.35);
}

.book-preview-end-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 0.4rem;
}

[data-theme="dark"] .book-preview-end-title {
    color: #ffffff !important;
}

.book-preview-end-desc {
    font-size: 0.95rem;
    color: #64748b;
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.5;
}

[data-theme="dark"] .book-preview-end-desc {
    color: #cbd5e1 !important;
}

.js-preview-order-btn {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
    border: none !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 0.95rem !important;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4) !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

.js-preview-order-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.6) !important;
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%) !important;
    color: #ffffff !important;
}

/* Loading state */
.book-preview-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 3rem 1rem;
    color: #64748b;
}

[data-theme="dark"] .book-preview-loading {
    color: rgba(255,255,255,0.7);
}

.book-preview-spinner {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.12);
    border-top-color: #60a5fa;
    animation: book-preview-spin 0.8s linear infinite;
}

@keyframes book-preview-spin {
    to { transform: rotate(360deg); }
}

.book-preview-loading-text {
    font-size: 0.88rem;
    font-weight: 600;
}
    color: rgba(255,255,255,0.35);
    margin-top: 0.5rem;
    padding-bottom: 0.5rem;
}

/* Mobile tweaks */
@media (max-width: 575.98px) {
    .book-preview-header { padding: 0.6rem 0.85rem; }
    .book-preview-body { padding: 1rem 0.5rem; }
    .book-preview-title { font-size: 0.85rem; }
}

/* ==========================================================================
   "বইটি বিস্তারিত পড়ে দেখুন" — Custom Card Box & Topic Chips
   ========================================================================== */
.book-preview-card-box {
    position: relative;
    border: 2px solid #e11d48;
    border-radius: 12px;
    padding: 22px 16px 16px;
    background: var(--surface-card);
    margin-top: 1.25rem;
    box-shadow: 0 4px 16px -4px rgba(225, 29, 72, 0.08);
}
.book-preview-card-header {
    position: absolute;
    top: -13px;
    left: 16px;
    background: var(--surface-card);
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    z-index: 2;
}
.book-preview-card-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--color-text-main);
    letter-spacing: -0.01em;
}
.book-preview-card-body {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: center;
}
.book-preview-topic-chip {
    background: var(--surface-card);
    border: 1.5px solid var(--color-border);
    border-radius: 8px;
    padding: 6px 14px;
    color: var(--color-text-main);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.3;
}
.book-preview-topic-chip:hover {
    border-color: #e11d48;
    background: rgba(225, 29, 72, 0.08);
    color: #e11d48;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.15);
}
.book-preview-topic-chip:active {
    transform: translateY(0);
}

[data-theme="dark"] .book-preview-card-box {
    background: var(--surface-card) !important;
    border-color: #f43f5e !important;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3) !important;
}
[data-theme="dark"] .book-preview-card-header {
    background: var(--surface-card) !important;
}
[data-theme="dark"] .book-preview-card-title {
    color: #ffffff !important;
}
[data-theme="dark"] .book-preview-topic-chip {
    background: rgba(255, 255, 255, 0.04) !important;
    border-color: var(--color-border) !important;
    color: #ffffff !important;
}
[data-theme="dark"] .book-preview-topic-chip:hover {
    border-color: #f43f5e !important;
    background: rgba(244, 63, 94, 0.2) !important;
    color: #fda4af !important;
}
