/**
 * Fixed CSS for Product Gallery
 */

.woocommerce-product-gallery--custom-swiper {
    position: relative;
    width: 100%;
}

.custom-gallery-wrapper {
    display: flex;
    gap: 20px;
    direction: rtl;
}

/* ========== Thumbnails ========== */
.gallery-thumbs-wrapper {
    width: 80px;
    flex-shrink: 0;
}

.gallery-thumbs {
    height: 350px;
    max-height: 350px;
    direction: rtl;
    overflow: hidden; /* مهم */
}

.gallery-thumbs .swiper-wrapper {
    direction: rtl;
}

.gallery-thumbs .swiper-slide {
    width: 80px !important;
    height: 80px !important;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    border-radius: 16px;
    overflow: hidden;
    flex-shrink: 0; /* مهم برای جلوگیری از shrink */
}

.gallery-thumbs .swiper-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-thumbs .swiper-slide-thumb-active {
    opacity: 1;
    border-color: var(--primary-color, #007bff);
}

.gallery-thumbs .swiper-slide:hover {
    opacity: 1;
}

/* ========== Main Image ========== */
.gallery-main-wrapper {
    flex: 1;
    min-width: 0;
    width: 100%; /* مهم */
}

.gallery-main {
    width: 100% !important; /* Force full width */
    height: 350px;
    max-height: 350px;
    border-radius: 16px;
    overflow: hidden;
    direction: rtl;
}

.gallery-main .swiper-wrapper {
    direction: rtl;
    height: 100%;
}

.gallery-main .swiper-slide {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100% !important; /* Force full width */
}

.gallery-main .swiper-slide a {
    display: block;
    width: 100%;
    height: 100%;
}

.gallery-main .swiper-slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 16px;
    transition: transform 0.3s ease;
}

.gallery-main .swiper-slide a:hover img {
    transform: scale(1.05);
}

/* ========== Mobile ========== */
@media (max-width: 768px) {
    .custom-gallery-wrapper {
        flex-direction: column;
        gap: 15px;
    }

    .gallery-main-wrapper {
        order: 1;
        width: 100%;
    }

    .gallery-main {
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        min-height: 300px;
    }
    
    .gallery-main .swiper-slide {
        height: auto !important;
        width: 100% !important;
    }
.gallery-main .swiper-slide img{
    object-fit:cover
}
    .gallery-thumbs-wrapper {
        order: 2;
        width: 100%;
        height: 80px;
    }

    .gallery-thumbs {
        height: 80px !important;
        width: 100%;
    }

    .gallery-thumbs .swiper-slide {
        width: 80px !important;
        height: 80px !important;
    }
}

/* ========== RTL Fix ========== */
.swiper-rtl .swiper-slide {
    text-align: inherit;
}

/* رفع مشکل عرض در loop mode */
.gallery-main .swiper-slide-duplicate {
    width: 100% !important;
}

/* رفع مشکل margin در RTL */
.swiper-rtl .gallery-thumbs .swiper-slide {
    margin-left: 0 !important;
}

.swiper-rtl.gallery-thumbs.swiper-horizontal > .swiper-wrapper > .swiper-slide {
    margin-left: 0 !important;
}

/* Animation */
.gallery-main .swiper-slide {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-main .swiper-slide-active {
    opacity: 1;
}