/* Main Gallery Styles */
.madwoo-product-gallery {
    margin-bottom: 2em;
    position: relative;
    width: 100%;
}

/* Main Slider */
.madwoo-slider-for {
    margin-bottom: 20px;
    width: 100%;
}

.madwoo-slider-for .woocommerce-product-gallery__image {
    position: relative;
    text-align: center;
    width: 100%;
}

.madwoo-slider-for .woocommerce-product-gallery__image img {
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

/* Thumbnails */
.madwoo-slider-nav {
    margin: 0 -5px;
}

.madwoo-gallery-fallback {
    display: block;
}

.madwoo-gallery-fallback .woocommerce-product-gallery__image {
    display: none;
}

.madwoo-gallery-fallback .woocommerce-product-gallery__image.madwoo-active-slide {
    display: block;
}

.madwoo-gallery-fallback-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0;
}

.madwoo-gallery-fallback-nav .madwoo-thumb {
    flex: 0 0 80px;
    padding: 0;
}

.madwoo-slider-nav .madwoo-thumb {
    padding: 5px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.madwoo-slider-nav .madwoo-thumb.active,
.madwoo-slider-nav .madwoo-thumb:hover {
    opacity: 1;
}

.madwoo-slider-nav .madwoo-thumb img {
    max-width: 100%;
    height: auto;
}

/* Video Slides */
.madwoo-video-slide {
    position: relative;
    display: block;
    width: 100%;
    padding-bottom: 0;
    height: auto;
    overflow: hidden;
    background: #000;
}

.madwoo-video-slide iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
    z-index: 2;
    pointer-events: auto;
}

.madwoo-video-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 320px;
}

.madwoo-video-play {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: #000;
    cursor: pointer;
    z-index: 3;
}

.madwoo-video-poster {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.madwoo-video-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    z-index: 4;
}

.madwoo-video-play-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 54%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 14px 0 14px 22px;
    border-color: transparent transparent transparent #fff;
}

.madwoo-video-wrapper.madwoo-video-loaded .madwoo-video-play {
    display: none;
}

/* Video Thumbnails */
.madwoo-thumb[data-type="video"] {
    position: relative;
}

.madwoo-thumb[data-type="video"] .video-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 15px 0 15px 25px;
    border-color: transparent transparent transparent rgba(255,255,255,0.8);
}

/* Navigation Arrows */
.slick-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--madwoo-arrow-bg-color, #fff);
    border: none;
    color: var(--madwoo-arrow-color, #000);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.slick-prev {
    left: 10px;
}

.slick-next {
    right: 10px;
}

/* Zoom */
.zoomContainer {
    z-index: 99;
}

/* Vertical Layout */
.madwoo-product-gallery[data-layout="vertical"] {
    display: flex;
    gap: 20px;
}

.madwoo-product-gallery[data-layout="vertical"] .madwoo-slider-nav {
    width: 100px;
    margin: 0;
}

.madwoo-product-gallery[data-layout="vertical"] .madwoo-slider-for {
    flex: 1;
    margin-bottom: 0;
}

/* Divi Builder Compatibility */
.et-fb-iframe-ancestor .madwoo-product-gallery {
    pointer-events: none;
}

.et-fb-iframe-ancestor .madwoo-slider-for,
.et-fb-iframe-ancestor .madwoo-slider-nav {
    opacity: 0.5;
}

/* Responsive Design */
@media (max-width: 767px) {
    .madwoo-product-gallery[data-layout="vertical"] {
        flex-direction: column;
    }

    .madwoo-product-gallery[data-layout="vertical"] .madwoo-slider-nav {
        width: 100%;
    }

    .slick-arrow {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
}

/* Grid Layout (when not using slider) */
.madwoo-thumnails-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 20px;
}

/* Fancybox Customization */
.fancybox-bg {
    background: #000;
}

.fancybox-is-open .fancybox-bg {
    opacity: 0.9;
}

/* Fix for Divi Builder */
.et-fb .madwoo-product-gallery {
    display: block !important;
}

.et-fb .madwoo-slider-for,
.et-fb .madwoo-slider-nav {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* WooCommerce Compatibility */
.woocommerce-product-gallery {
    opacity: 1 !important;
}

.woocommerce div.product div.images .madwoo-video-slide,
.woocommerce div.product div.images .madwoo-video-wrapper {
    max-width: 100%;
}

.woocommerce div.product div.images .woocommerce-product-gallery__trigger,
.woocommerce div.product div.images .flex-control-thumbs {
    display: none !important;
}

.woocommerce div.product div.images .madwoo-slider-for,
.woocommerce div.product div.images .madwoo-slider-for .woocommerce-product-gallery__image,
.woocommerce div.product div.images .madwoo-video-wrapper,
.woocommerce div.product div.images .madwoo-video-slide,
.woocommerce div.product div.images .madwoo-video-slide iframe,
.woocommerce div.product div.images .madwoo-video-play {
    pointer-events: auto !important;
}

@media (max-width: 767px) {
    .madwoo-video-wrapper {
        min-height: 220px;
    }

    .madwoo-gallery-fallback-nav .madwoo-thumb {
        flex-basis: 64px;
    }

    .madwoo-video-play-icon {
        width: 56px;
        height: 56px;
    }
}
