/* Outer Flipbook Container (Zero excess padding) */
.mfb-container {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 !important; /* Strips container padding */
    background-color: #515558;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
    user-select: none;
}

/* Viewport Window */
.mfb-container .mfb-viewport {
    position: relative;
    width: 100%;
    perspective: 2000px;
    -webkit-perspective: 2000px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 !important; /* Strips top/bottom viewport padding */
    margin: 20px 0 0 0 !important; /* <--- ADDED TOP MARGIN FOR CANVAS SPACING */
    overflow: visible !important;
}

.mfb-container .mfb-viewport.is-zoomed { cursor: grab; }
.mfb-container .mfb-viewport.is-dragging { cursor: grabbing !important; }

/* 2-Page Spread Book Canvas */
.mfb-container .mfb-book {
    position: relative;
    width: 100%;
    max-width: 1050px;
    aspect-ratio: 1.414 / 1; /* Standard 2-page brochure ratio */
    height: auto !important;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
}

/* 3D Page Leaves */
.mfb-container .mfb-page {
    position: absolute;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    transform-origin: left top;
    -webkit-transform-origin: left top;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    cursor: pointer;
}

.mfb-container .mfb-page-face {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background: transparent !important; /* Prevents white flash/gaps */
    overflow: hidden;
    border: none !important; /* Removes page border gaps */
    box-sizing: border-box !important;
    padding: 0 !important;
    margin: 0 !important;
}

.mfb-container .mfb-page-front {
    background: linear-gradient(to right, #d9d9d9 0%, #f9f9f9 3%, #ffffff 8%, #ffffff 100%);
}

.mfb-container .mfb-page-back {
    transform: rotateY(-180deg);
    background: linear-gradient(to right, #ffffff 0%, #ffffff 92%, #f9f9f9 97%, #d9d9d9 100%);
}

/* --- FIX: STRETCH IMAGES EDGE-TO-EDGE (ELIMINATES ALL TOP, BOTTOM, LEFT, RIGHT WHITE SPACE) --- */
.mfb-container .mfb-viewport .mfb-book .mfb-page .mfb-page-face img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: fill !important; /* Stretches image edge-to-edge with 0 white gaps */
    object-position: center !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
    pointer-events: none;
}

/* Elementor Override Fixes */
.elementor-widget-shortcode,
.elementor-widget-container,
.elementor-shortcode {
    padding: 0 !important;
    margin: 0 !important;
}

/* --- BOTTOM CORNER FOLD OVERLAYS --- */
.mfb-container .mfb-fold-right {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0px;
    height: 0px;
    background: linear-gradient(135deg, #fefefe 0%, #e8e8e8 49%, #ffffff 50%, #ffffff 100%);
    border-top: 1px solid #CCCCCC;
    border-left: 1px solid #CCCCCC;
    box-shadow: -6px -6px 12px rgba(0, 0, 0, 0.25);
    transition: width 0.35s cubic-bezier(0.25, 1, 0.5, 1), height 0.35s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 30;
    pointer-events: none;
}

.mfb-container .mfb-page-front:hover .mfb-fold-right {
    width: 50px;
    height: 50px;
}

.mfb-container .mfb-fold-left {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0px;
    height: 0px;
    background: linear-gradient(45deg, #ffffff 0%, #ffffff 50%, #e8e8e8 51%, #fefefe 100%);
    border-top: 1px solid #CCCCCC;
    border-right: 1px solid #CCCCCC;
    box-shadow: 6px -6px 12px rgba(0, 0, 0, 0.25);
    transition: width 0.35s cubic-bezier(0.25, 1, 0.5, 1), height 0.35s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 30;
    pointer-events: none;
}

.mfb-container .mfb-page-back:hover .mfb-fold-left {
    width: 50px;
    height: 50px;
}

/* --- ARROWS --- */
.mfb-container .mfb-arrow {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 99999 !important;
    background: transparent !important;
    color: #ffffff !important;
    font-size: 48px !important;
    font-weight: 900 !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer !important;
    width: 50px !important;
    height: 50px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: color 0.2s ease, transform 0.2s ease, opacity 0.2s ease !important;
    line-height: 1 !important;
    text-shadow: 0px 2px 10px rgba(0, 0, 0, 0.9) !important;
}

.mfb-container .mfb-arrow:hover:not(:disabled) {
    color: #ffd700 !important;
    transform: translateY(-50%) scale(1.2) !important;
}

.mfb-container .mfb-arrow:disabled {
    opacity: 0.15 !important;
    cursor: not-allowed !important;
}

.mfb-container .mfb-arrow-prev { left: 8px !important; }
.mfb-container .mfb-arrow-next { right: 8px !important; }

/* Control Toolbar */
.mfb-container .mfb-controls {
    margin-top: 10px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    padding: 6px 16px;
    border-radius: 30px;
    z-index: 1000;
}

.mfb-container .mfb-btn-icon {
    padding: 5px 12px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
}

.mfb-container .mfb-page-num { font-size: 13px; color: #e0e0e0; }

/* Mobile Optimizations */
@media screen and (max-width: 768px) {
    .mfb-container {
        padding: 0 !important;
        margin: 5px auto !important;
    }
    
    .mfb-container .mfb-viewport {
        padding: 0 !important;
        margin: 12px 0 0 0 !important; /* Slightly smaller top gap on mobile */
    }
    
    .mfb-container .mfb-book {
        width: 100% !important;
        max-width: 100% !important;
        aspect-ratio: 1.35 / 1 !important;
    }

    .mfb-container .mfb-arrow {
        font-size: 32px !important;
        width: 36px !important;
        height: 36px !important;
    }

    .mfb-container .mfb-arrow-prev { left: 2px !important; }
    .mfb-container .mfb-arrow-next { right: 2px !important; }

    .mfb-container .mfb-controls {
        gap: 6px;
        padding: 4px 10px;
    }

    .mfb-container .mfb-btn-icon {
        padding: 4px 8px;
        font-size: 12px;
    }
}