/* =============================================================
   Book Preview Plugin — Frontend Styles
   WoodMart Compatible
   ============================================================= */

/* ---------- Hide raw data placeholder ---------- */
.bp-product-data {
    display: none !important;
}

/* ---------- 3D Scene (applied dynamically by JS) ---------- */
.bp-scene {
    display: block;
    position: relative;
    transform-style: preserve-3d;
    will-change: transform;
}

/* ---------- COVER OPENING EFFECT ---------- */

/* Image কে cover বানাই */
.bp-scene img {
    position: relative;
    z-index: 2;
    transform-origin: left center;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1), box-shadow 0.6s ease;
}

/* Inner page — cover খুললে যা দেখা যাবে */
.bp-inner-page {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f5f1e8 0%, #e8e0d0 100%);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    box-shadow:
        inset 8px 0 12px -8px rgba(0,0,0,0.4),
        inset 0 0 60px rgba(139, 90, 43, 0.08);
    overflow: hidden;
}

/* Inner page এ subtle book lines (পৃষ্ঠার মত) */
.bp-inner-page::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent 18px,
            rgba(139, 90, 43, 0.06) 18px,
            rgba(139, 90, 43, 0.06) 19px
        );
    pointer-events: none;
}

.bp-inner-content {
    text-align: center;
    padding: 20px;
    z-index: 2;
    position: relative;
}

.bp-inner-icon {
    font-size: 42px;
    margin-bottom: 10px;
    opacity: 0.7;
}

.bp-inner-text {
    font-size: 14px;
    color: #6b4423;
    font-weight: 600;
    line-height: 1.5;
}

/* WoodMart sometimes wraps image in overflow:hidden — fix it */
.bp-has-preview .product-image-wrap,
.bp-has-preview .wd-product-grid-item-img,
.bp-has-preview .product-element-top {
    overflow: visible !important;
}

/* ---------- "একটু পড়ে দেখুন" Badge ---------- */
.bp-preview-badge {
    position: absolute !important;
    top: 12px;
    left: 12px;
    z-index: 9;
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    background: #c0392b !important;
    color: #fff !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    padding: 6px 11px 6px 8px !important;
    border: none !important;
    border-radius: 4px !important;
    cursor: pointer;
    line-height: 1.2 !important;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.25);
    transition: background 0.2s, transform 0.15s;
    white-space: nowrap;
    text-decoration: none !important;
    font-family: inherit;
    pointer-events: auto;
}
.bp-preview-badge:hover,
.bp-preview-badge:focus {
    background: #a93226 !important;
    transform: translateY(-1px);
    color: #fff !important;
}
.bp-preview-badge:active {
    transform: translateY(0);
}
.bp-preview-badge svg {
    width: 14px !important;
    height: 14px !important;
    flex-shrink: 0;
    display: inline-block !important;
}
.bp-preview-badge span {
    line-height: 1.2;
}

/* Arrow */
.bp-badge-arrow {
    position: absolute;
    bottom: -6px;
    left: 15px;
    width: 0 !important;
    height: 0 !important;
    border-left:  6px solid transparent;
    border-right: 6px solid transparent;
    border-top:   6px solid #c0392b;
    padding: 0 !important;
    margin: 0 !important;
}

/* Single product page — badge slightly bigger */
.single-product .bp-preview-badge {
    font-size: 13px !important;
    padding: 7px 13px 7px 10px !important;
    top: 16px;
    left: 16px;
}

/* ---------- PDF MODAL ---------- */
/* Sizing:
   - Desktop:  width 750px, height 92vh
   - Mobile:   width 95vw,  height 95vh
*/
#bp-pdf-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(10, 10, 20, 0.85);
    z-index: 999999 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    transition: opacity 0.28s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
#bp-pdf-overlay[hidden] {
    display: none !important;
}
#bp-pdf-overlay.bp-active {
    opacity: 1;
}
#bp-pdf-overlay.bp-active #bp-pdf-modal {
    transform: scale(1) translateY(0);
}

/* Modal — desktop: 750px fixed width */
#bp-pdf-modal {
    background: #fff;
    border-radius: 10px;
    width: 750px;
    height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: visible;
    box-shadow: 0 30px 80px rgba(0,0,0,0.6);
    transform: scale(0.93) translateY(20px);
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

/* Inner sections clip themselves since modal is overflow:visible (for tooltip) */
#bp-pdf-modal-header {
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}
#bp-pdf-modal-footer {
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
}
#bp-pdf-body {
    overflow: hidden;
}

/* Header — slim & compact */
#bp-pdf-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    background: #1a1a2e;
    color: #fff;
    flex-shrink: 0;
    min-height: 32px;
}
#bp-pdf-modal-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    color: #fff;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}
#bp-modal-book-title {
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}

/* Header right-side: pages info + close */
#bp-pdf-header-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 12px;
}
#bp-pdf-pages-info {
    font-size: 11px;
    color: rgba(255,255,255,0.7);
    font-weight: 500;
    white-space: nowrap;
}
#bp-pdf-pages-info strong {
    color: #fff;
    font-weight: 700;
}

#bp-pdf-close {
    background: rgba(255,255,255,0.1);
    border: none !important;
    border-radius: 5px;
    color: #fff !important;
    width: 24px;
    height: 24px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
    padding: 0 !important;
}
#bp-pdf-close:hover {
    background: rgba(255,255,255,0.22);
    color: #fff !important;
}
#bp-pdf-close svg {
    width: 12px;
    height: 12px;
}

/* PDF viewer area — যত বেশি space তত ভালো */
#bp-pdf-body {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: #525659;
    min-height: 0;  /* important: flex children can shrink */
}
#bp-pdf-viewer-wrap {
    width: 100%;
    height: 100%;
    position: relative;
}
#bp-pdf-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    transition: opacity 0.3s;
    background: #fff;
}
#bp-pdf-loading {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #525659;
    color: #fff;
    font-size: 13px;
}
.bp-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255,255,255,0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: bp-spin 0.7s linear infinite;
}
@keyframes bp-spin {
    to { transform: rotate(360deg); }
}

/* Footer — compact, single line */
#bp-pdf-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f8f8f8;
    border-top: 1px solid #e5e5e5;
    gap: 10px;
    flex-shrink: 0;
    min-height: 52px;
}
#bp-pdf-footer-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #444;
    min-width: 0;
    flex: 1;
}
#bp-pdf-footer-info-label {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
}
#bp-pdf-price {
    font-weight: 700;
    color: #c0392b;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Developer credit — with hover tooltip */
#bp-credit {
    position: relative;
    font-size: 11px;
    color: #999;
    margin-left: 12px;
    font-weight: 400;
    white-space: nowrap;
    border-left: 1px solid #ddd;
    padding-left: 12px;
    cursor: help;
    transition: color 0.2s;
}
#bp-credit:hover,
#bp-credit:focus {
    color: #1a1a2e;
    outline: none;
}
#bp-credit strong {
    color: #666;
    font-weight: 600;
}
#bp-credit:hover strong,
#bp-credit:focus strong {
    color: #2e7d32;
}

/* Tooltip popup — appears ABOVE credit, aligned to LEFT side of credit */
/* এতে tooltip বইয়ের ভিতরে থাকবে, বাইরে যাবে না */
.bp-credit-tooltip {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 0;
    background: #1a1a2e;
    color: #fff;
    padding: 12px 14px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    width: 260px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.25s, transform 0.25s, visibility 0.25s;
    z-index: 1000000;
    text-align: left;
    white-space: normal;
    pointer-events: none;
}
#bp-credit:hover .bp-credit-tooltip,
#bp-credit:focus .bp-credit-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* Tooltip arrow — pointing down, on LEFT side */
.bp-credit-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 24px;
    border: 7px solid transparent;
    border-top-color: #1a1a2e;
}

.bp-tooltip-icon {
    display: inline-block;
    font-size: 16px;
    margin-right: 4px;
    vertical-align: middle;
}
.bp-tooltip-text {
    display: block;
    font-size: 12px;
    line-height: 1.5;
    color: #fff;
}
.bp-tooltip-phone {
    display: block;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.15);
    color: #4ade80;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
#bp-pdf-footer-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.bp-btn-primary,
.bp-btn-secondary {
    padding: 8px 14px !important;
    border-radius: 6px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    cursor: pointer;
    border: none !important;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    transition: background 0.2s, transform 0.15s;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.2 !important;
}
.bp-btn-primary {
    background: #2e7d32 !important;
    color: #fff !important;
}
.bp-btn-primary:hover,
.bp-btn-primary:focus {
    background: #1b5e20 !important;
    color: #fff !important;
    transform: translateY(-1px);
    text-decoration: none !important;
}
.bp-btn-secondary {
    background: #eee !important;
    color: #333 !important;
}
.bp-btn-secondary:hover {
    background: #ddd !important;
    color: #333 !important;
}

/* ---------- WoodMart Specific Fixes ---------- */

/* Prevent WoodMart's hover swap from breaking tilt */
.bp-has-preview .wd-product-grid-item-img:hover img.wp-post-image {
    opacity: 1 !important;
}

/* Don't let WoodMart's hover overlay block badge */
.bp-has-preview .wd-buttons,
.bp-has-preview .wd-add-btn,
.bp-has-preview .product-element-bottom {
    z-index: 4;
}

/* Make sure product card has positioning for badge */
.bp-has-preview {
    position: relative;
}

/* Don't break quick view / wishlist buttons */
.bp-has-preview .wd-quick-view,
.bp-has-preview .wd-wishlist-btn {
    z-index: 8;
}

/* ----- HIDE WooCommerce zoom plugin's overlay image ----- */
/* WooCommerce uses jQuery.zoom() which adds an absolute-positioned
   .zoomImg over the product image. This kills our 3D effect. */
.bp-scene img.zoomImg,
.bp-scene .zoomImg {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Force bp-scene to allow overflow for 3D cover opening */
figure.bp-scene,
.bp-scene {
    overflow: visible !important;
}

/* ----- Disable WoodMart's image zoom on bp-scene ----- */
/* WoodMart has hover zoom effect that conflicts with our 3D cover opening */
.bp-scene img,
.bp-scene:hover img,
.woocommerce-product-gallery__image .bp-scene img:hover {
    /* Reset WoodMart's transform — JS will apply our 3D rotateY */
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1), box-shadow 0.6s ease !important;
}

/* Disable WoodMart's zoom-image-hover class effect */
.woodmart-zoom-image-hover .bp-scene img:hover,
.image-action-zoom .bp-scene img:hover,
.wd-gallery-images .bp-scene img:hover {
    transform: none !important;
}

/* Override any scale transform on parent that affects our img */
.bp-scene:hover {
    transform: none !important;
}

/* Single product gallery — disable WoodMart's image action zoom on our scene */
.single-product .bp-scene {
    transform-origin: center center;
}

/* WoodMart's wd-fill class makes image cover the container — let it but allow our 3D */
.bp-scene .wd-fill,
.bp-scene img.wd-fill {
    transform-origin: left center !important;
}

/* Fullscreen button (the small expand icon) — hide it on our 3D image */
.bp-scene + .wd-action-btn,
.bp-scene .wd-action-btn-fullscreen,
.bp-scene ~ .wd-fullscreen-btn,
.elementor-widget-wd_single_product_gallery .wd-action-btn-fullscreen {
    display: none !important;
}

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
    .bp-preview-badge {
        font-size: 11px !important;
        padding: 5px 9px 5px 7px !important;
        top: 8px;
        left: 8px;
    }
    .bp-preview-badge svg {
        width: 12px !important;
        height: 12px !important;
    }
    .bp-inner-text { font-size: 12px; }
    .bp-inner-icon { font-size: 32px; }
    .bp-credit-tooltip { width: 220px; }
}

/* Mobile (≤600px) — 95% width × 95% height */
@media (max-width: 600px) {
    #bp-pdf-modal {
        width: 95vw;
        height: 95vh;
        border-radius: 10px;
        overflow: hidden;
    }
    #bp-pdf-modal-header { padding: 5px 10px; min-height: 28px; }
    #bp-pdf-modal-title { font-size: 12px; }
    #bp-pdf-pages-info { font-size: 10px; }
    #bp-pdf-modal-footer { padding: 8px 12px; min-height: 48px; }
    #bp-pdf-price { font-size: 14px; }
    #bp-pdf-footer-info-label { font-size: 11px; }
    #bp-credit { display: none; }
    .bp-btn-primary { padding: 8px 12px !important; font-size: 12px !important; }

    .bp-scene img { transform: none !important; }
}

@media (hover: none) {
    .bp-scene img:hover,
    .bp-scene:hover img { transform: none !important; }
    .bp-inner-page { display: none !important; }
}
