/**
 * Asa Rad Shop Widgets — Single product gallery stabilizer.
 * Scoped to WooCommerce single-product image widgets only.
 */

.single-product .elementor-widget-woocommerce-product-images,
.single-product .elementor-widget-woocommerce-product-images > .elementor-widget-container {
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.single-product .asw-product-gallery {
    --asw-gallery-bg: #f7f8f6;
    --asw-gallery-border: #e6ebe7;
    --asw-gallery-radius: 26px;
    --asw-gallery-shadow: 0 18px 55px rgba(30, 55, 43, 0.08);
    --asw-gallery-stage-height: clamp(500px, 42vw, 720px);
    --asw-gallery-image-max-width: 620px;

    position: relative;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    box-sizing: border-box;
    isolation: isolate;
}

.single-product .asw-product-gallery,
.single-product .asw-product-gallery * {
    box-sizing: border-box;
}

/* The main Swiper must remain a flexible, measurable child of vertical galleries. */
.single-product .asw-product-gallery .woocommerce-product-gallery__slider {
    position: relative;
    display: block;
    flex: 1 1 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden;
    background: var(--asw-gallery-bg);
    border: 1px solid var(--asw-gallery-border);
    border-radius: var(--asw-gallery-radius);
    box-shadow: var(--asw-gallery-shadow);
}

.single-product .asw-product-gallery .woocommerce-product-gallery__wrapper {
    width: 100% !important;
    min-width: 0 !important;
    min-height: var(--asw-gallery-stage-height);
    align-items: stretch;
}

.single-product .asw-product-gallery .woocommerce-product-gallery__image {
    min-width: 0;
    min-height: var(--asw-gallery-stage-height);
    overflow: hidden;
    background: transparent;
}

.single-product .asw-product-gallery .woocommerce-product-gallery__image > a {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: var(--asw-gallery-stage-height);
    padding: clamp(28px, 4vw, 68px);
    text-decoration: none;
}

.single-product .asw-product-gallery .woocommerce-product-gallery__image img {
    display: block !important;
    width: auto !important;
    height: auto !important;
    max-width: min(100%, var(--asw-gallery-image-max-width)) !important;
    max-height: calc(var(--asw-gallery-stage-height) - clamp(56px, 8vw, 136px)) !important;
    margin: auto !important;
    object-fit: contain;
    object-position: center;
    border-radius: 0;
    box-shadow: none;
}

/* A one-image product must never inherit stale Swiper dimensions. */
.single-product .asw-product-gallery--single .woocommerce-product-gallery__wrapper {
    display: flex !important;
    height: auto !important;
    min-height: var(--asw-gallery-stage-height) !important;
    transform: translate3d(0, 0, 0) !important;
}

.single-product .asw-product-gallery--single .woocommerce-product-gallery__image {
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 !important;
}

.single-product .asw-product-gallery--single .swiper-button,
.single-product .asw-product-gallery--single .swiper-fraction,
.single-product .asw-product-gallery--single .flex-control-nav,
.single-product .asw-product-gallery--single .woocommerce-product-gallery__trigger + .flex-control-nav {
    display: none !important;
}

/* Multiple images: keep theme navigation but enforce a stable stage. */
.single-product .asw-product-gallery--multiple .woocommerce-product-gallery__slider {
    min-height: var(--asw-gallery-stage-height);
}

.single-product .asw-product-gallery--multiple .woocommerce-product-gallery__image {
    display: flex;
    align-items: stretch;
}

/* Polished lightbox trigger; it stays inside the gallery stage. */
.single-product .asw-product-gallery .glozin-button--product-lightbox,
.single-product .asw-product-gallery .woocommerce-product-gallery__trigger {
    top: 18px !important;
    inset-inline-end: 18px !important;
    right: auto;
    left: auto;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: #294f3c;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(49, 95, 73, 0.14);
    border-radius: 50%;
    box-shadow: 0 10px 30px rgba(25, 49, 37, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 8;
}

.single-product .asw-product-gallery .glozin-button--product-lightbox:hover,
.single-product .asw-product-gallery .woocommerce-product-gallery__trigger:hover {
    color: #ffffff;
    background: #315f49;
    border-color: #315f49;
}

.single-product .asw-product-gallery .swiper-button {
    width: 44px;
    height: 44px;
    color: #315f49;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(49, 95, 73, 0.14);
    border-radius: 50%;
    box-shadow: 0 8px 26px rgba(25, 49, 37, 0.1);
}

.single-product .asw-product-gallery .swiper-button-disabled {
    opacity: 0.35;
}

/* Thumbnail rails should not force the main slider to collapse. */
.single-product .asw-product-gallery .woocommerce-product-gallery__thumbs,
.single-product .asw-product-gallery .woocommerce-product-gallery__thumbnails,
.single-product .asw-product-gallery .flex-control-thumbs {
    flex: 0 0 86px;
    width: 86px;
    min-width: 86px;
}

.single-product .asw-product-gallery .flex-control-thumbs img,
.single-product .asw-product-gallery .woocommerce-product-gallery__thumbs img,
.single-product .asw-product-gallery .woocommerce-product-gallery__thumbnails img {
    width: 100% !important;
    height: 86px !important;
    padding: 8px;
    object-fit: contain;
    background: #ffffff;
    border: 1px solid var(--asw-gallery-border);
    border-radius: 14px;
}

@media (max-width: 1024px) {
    .single-product .asw-product-gallery {
        --asw-gallery-stage-height: clamp(440px, 58vw, 620px);
        --asw-gallery-radius: 22px;
    }
}

@media (max-width: 767px) {
    .single-product .asw-product-gallery {
        --asw-gallery-stage-height: clamp(360px, 112vw, 520px);
        --asw-gallery-radius: 18px;
        --asw-gallery-shadow: 0 12px 36px rgba(30, 55, 43, 0.07);
    }

    .single-product .asw-product-gallery .woocommerce-product-gallery__image > a {
        padding: 22px;
    }

    .single-product .asw-product-gallery .woocommerce-product-gallery__image img {
        max-height: calc(var(--asw-gallery-stage-height) - 44px) !important;
    }

    .single-product .asw-product-gallery .glozin-button--product-lightbox,
    .single-product .asw-product-gallery .woocommerce-product-gallery__trigger {
        top: 12px !important;
        inset-inline-end: 12px !important;
        width: 40px;
        height: 40px;
    }

    .single-product .asw-product-gallery .woocommerce-product-gallery__thumbs,
    .single-product .asw-product-gallery .woocommerce-product-gallery__thumbnails,
    .single-product .asw-product-gallery .flex-control-thumbs {
        width: 100%;
        min-width: 0;
        flex-basis: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .single-product .asw-product-gallery *,
    .single-product .asw-product-gallery *::before,
    .single-product .asw-product-gallery *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
