/* PDF Flipbook Styles */

.bg-pdf-flipbook-wrapper {
    position: relative;
    width: 100%;
    margin: 20px auto;
    background: #f4f4f4;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    overflow: hidden;
    color: #333;
    font-family: inherit;
}

/* Controls Header */
.bg-pdf-flipbook-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 12px 20px;
    background: #ffffff;
    border-bottom: 1px solid #e5e5e5;
    z-index: 10;
}

.bg-flipbook-btn {
    background: #111111;
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
}

.bg-flipbook-btn:hover {
    background: #333333;
    transform: translateY(-1px);
}

.bg-flipbook-page-info {
    font-size: 14px;
    font-weight: 600;
    color: #555;
    background: #fafafa;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid #e5e5e5;
}

/* Container */
.bg-pdf-flipbook-container {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
    min-height: 400px;
    margin: 0 auto;
}

/* Pages Wrap */
.bg-flipbook-pages {
    display: none; /* Hidden until loaded */
    width: 100% !important;
    height: 100% !important;
}

/* PageFlip Wrapper Overrides */
.stf__parent {
    width: 100% !important;
    height: 100% !important;
}

.stf__item {
    background: #fff;
}

.bg-flipbook-page {
    background-color: #ffffff !important;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.bg-flipbook-page canvas {
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* Loader */
.bg-pdf-flipbook-loader {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0; left: 0;
    background: #ffffff;
    z-index: 5;
}

.bg-pdf-flipbook-loader .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0,0,0,0.1);
    border-top-color: #111111;
    border-radius: 50%;
    animation: bg-spin 0.8s linear infinite;
    margin-bottom: 15px;
}

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

/* Fullscreen Mode - Wrapper Based */
.bg-pdf-flipbook-wrapper.is-fullscreen {
    position: fixed;
    top: 0; 
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100% !important;
    z-index: 999999;
    background: #555555; /* Neutral grey, DearFlip style */
    display: flex;
    flex-direction: column;
    margin: 0 !important;
    border-radius: 0;
}

.bg-pdf-flipbook-wrapper.is-fullscreen .bg-pdf-flipbook-container {
    flex: 1;
    background: transparent;
    height: 100% !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* Force edge-to-edge pages with no spacing/shadow dividers in Fullscreen */
.bg-pdf-flipbook-wrapper.is-fullscreen .bg-flipbook-pages {
    padding: 0 !important;
}

.bg-pdf-flipbook-wrapper.is-fullscreen .bg-flipbook-page {
    box-shadow: none !important; /* Prevents visual separation gap created by page-level dropshadows */
    background: #fff !important;
}

.bg-pdf-flipbook-wrapper.is-fullscreen .bg-flipbook-page canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: fill !important; /* Force expansion into Absolute item box coordinates fully */
}

/* Toolbar at Bottom in Fullscreen */
.bg-pdf-flipbook-wrapper.is-fullscreen .bg-pdf-flipbook-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.85) !important;
    border: none;
    z-index: 1000001;
    justify-content: center;
    border-radius: 0;
    padding: 12px;
}

.bg-pdf-flipbook-wrapper.is-fullscreen .bg-pdf-flipbook-controls .bg-flipbook-btn {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
}

.bg-pdf-flipbook-wrapper.is-fullscreen .bg-pdf-flipbook-controls .bg-flipbook-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* Absolute Floating Arrows in Fullscreen */
.bg-pdf-flipbook-wrapper.is-fullscreen .bg-flipbook-prev {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000002;
    font-size: 18px;
    padding: 15px;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bg-pdf-flipbook-wrapper.is-fullscreen .bg-flipbook-next {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000002;
    font-size: 18px;
    padding: 15px;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Close Fullscreen Button absolutely placed on wrapper now */
.bg-pdf-flipbook-wrapper.is-fullscreen .bg-flipbook-close-fullscreen {
    display: block !important;
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6) !important;
    color: #ffffff;
    border: none;
    font-size: 32px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1000005;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.bg-pdf-flipbook-wrapper.is-fullscreen .bg-flipbook-close-fullscreen:hover {
    background: rgba(0, 0, 0, 0.8) !important;
    transform: rotate(90deg);
}

/* Close Fullscreen Button */
.bg-pdf-flipbook-container.is-fullscreen .bg-flipbook-close-fullscreen {
    display: block !important;
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6) !important;
    color: #ffffff;
    border: none;
    font-size: 32px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1000000;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.bg-pdf-flipbook-container.is-fullscreen .bg-flipbook-close-fullscreen:hover {
    background: rgba(0, 0, 0, 0.8) !important;
    transform: rotate(90deg);
}

.bg-flipbook-download {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #0073aa; /* Standard WP blue or suitable accent */
}

.bg-flipbook-download:hover {
    background: #006192;
}

/* Responsive Overrides */
@media (max-width: 767px) {
    .bg-pdf-flipbook-controls {
        flex-wrap: wrap;
        gap: 10px;
        padding: 10px;
    }
    
    .bg-flipbook-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .bg-pdf-flipbook-container {
        height: auto !important;
        aspect-ratio: 3/4; /* Better for mobile viewport height calculation */
    }
}
