.product-gallery-wrapper {
    max-width: 100%;
    margin: 0 auto;
    direction: rtl;
}

.gallery-main-layout {
    display: block;
}

/* عکس شاخص */
.featured-image {
    width: 100%;
    margin-bottom: 20px;
    cursor: pointer;
    overflow: hidden;
    display: flex;
}

.featured-image img {
    width: 100%;
    transition: transform 0.3s, opacity 0.3s, filter 0.3s;
}

/* افکت‌های هاور عکس شاخص */
.hover-effect-zoom .featured-image:hover img {
    transform: scale(1.05);
}

.hover-effect-opacity .featured-image:hover img {
    opacity: 0.8;
}

.hover-effect-grayscale .featured-image:hover img {
    filter: grayscale(100%);
}

.hover-effect-none .featured-image:hover img {
    transform: none;
}

/* کانتینر گالری */
.gallery-container {
    position: relative;
    display: flex;
    align-items: center;
}

/* گالری - پیش‌فرض افقی */
.gallery-slider {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scrollbar-width: none;
    direction: rtl;
    width: 100%;
}

.gallery-slider::-webkit-scrollbar {
    display: none;
}

/* آیتم‌های گالری */
.gallery-item {
    flex: 0 0 auto;
    cursor: pointer;
    overflow: hidden;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    transition: transform 0.3s, filter 0.3s;
}

/* افکت‌های هاور گالری */
.gallery-hover-zoom .gallery-item:hover img {
    transform: scale(1.1);
}

.gallery-hover-lift .gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.gallery-hover-none .gallery-item:hover img {
    transform: none;
}

/* دکمه‌های نویگیشن */
.gallery-nav {
    position: absolute;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    top: 50%;
    transform: translateY(-50%);
}

.gallery-nav:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.gallery-prev {
    right: 10px;
}

.gallery-next {
    left: 10px;
}

/* مخفی کردن فلش‌ها اگر نیاز نیست */
.gallery-nav.hidden {
    display: none;
}

/* مخفی کردن navigation اگر از تنظیمات غیرفعال شده */
.hide-navigation .gallery-nav {
    display: none !important;
}

/* غیرفعال کردن لایت‌باکس */
.lightbox-disabled .featured-image,
.lightbox-disabled .gallery-item {
    cursor: default;
}

.lightbox-disabled .lightbox {
    display: none !important;
}

/* کم رنگ کردن فلش اگر به انتها رسیده */
.gallery-nav.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* ==================== لی‌اوت عمودی دسکتاپ ==================== */
.product-gallery-wrapper[data-desktop-direction="vertical"] .gallery-main-layout {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

/* موقعیت تصویر اصلی در چپ */
.product-gallery-wrapper[data-desktop-direction="vertical"][data-desktop-position="left"] .gallery-main-layout {
    flex-direction: row-reverse;
}

/* موقعیت تصویر اصلی در راست */
.product-gallery-wrapper[data-desktop-direction="vertical"][data-desktop-position="right"] .gallery-main-layout {
    flex-direction: row;
}

.product-gallery-wrapper[data-desktop-direction="vertical"] .featured-image {
    flex: 1;
    margin-bottom: 0;
}

.product-gallery-wrapper[data-desktop-direction="vertical"] .gallery-container {
    flex-direction: column;
    width: auto;
    align-items: stretch;
}

.product-gallery-wrapper[data-desktop-direction="vertical"] .gallery-slider {
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: 500px;
    width: auto;
}

.product-gallery-wrapper[data-desktop-direction="vertical"] .gallery-nav {
    left: 50%;
    transform: translateX(-50%);
    right: auto;
    top: auto;
}

.product-gallery-wrapper[data-desktop-direction="vertical"] .gallery-prev {
    top: 5px;
}

.product-gallery-wrapper[data-desktop-direction="vertical"] .gallery-next {
    bottom: 5px;
}

.product-gallery-wrapper[data-desktop-direction="vertical"] .gallery-prev svg {
    transform: rotate(-90deg);
}

.product-gallery-wrapper[data-desktop-direction="vertical"] .gallery-next svg {
    transform: rotate(-90deg);
}

/* لایت‌باکس */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 20px;
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 70vh;
    margin-bottom: 20px;
    cursor: grab;
}

.lightbox-content.dragging {
    cursor: grabbing;
}

.lightbox-image {
    display: none;
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    user-select: none;
    pointer-events: none;
}

.lightbox-image.active {
    display: block;
    animation: fadeIn 0.3s;
}

/* تامبنیل‌های پایین لایت‌باکس */
.lightbox-thumbnails {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    max-width: 90%;
    padding: 10px;
    direction: rtl;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.lightbox-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.lightbox-thumbnails::-webkit-scrollbar-track {
    background: transparent;
}

.lightbox-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.lightbox-thumbnails::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.lightbox-thumbnail {
    flex: 0 0 auto;
    width: 80px;
    height: 80px;
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: all 0.3s;
    opacity: 0.6;
}

.lightbox-thumbnail:hover {
    opacity: 0.9;
    border-color: rgba(255, 255, 255, 0.3);
}

.lightbox-thumbnail.active {
    opacity: 1;
    border-color: white;
}

.lightbox-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.lightbox-close {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100000;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-nav {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
    right: 20px;
}

.lightbox-next {
    left: 20px;
}

/* ==================== موبایل ==================== */
@media (max-width: 1024px) {
    /* لی‌اوت افقی موبایل */
    .product-gallery-wrapper[data-mobile-direction="horizontal"] .gallery-main-layout {
        display: block;
    }

    .product-gallery-wrapper[data-mobile-direction="horizontal"] .featured-image {
        margin-bottom: 15px;
    }

    .product-gallery-wrapper[data-mobile-direction="horizontal"] .gallery-container {
        flex-direction: row;
        width: 100%;
    }

    .product-gallery-wrapper[data-mobile-direction="horizontal"] .gallery-slider {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        max-height: none;
    }

    .product-gallery-wrapper[data-mobile-direction="horizontal"] .gallery-nav {
        top: 50%;
        transform: translateY(-50%);
        left: auto;
        right: auto;
        bottom: auto;
    }

    .product-gallery-wrapper[data-mobile-direction="horizontal"] .gallery-prev {
        right: 10px;
        top: 50%;
    }

    .product-gallery-wrapper[data-mobile-direction="horizontal"] .gallery-next {
        left: 10px;
        top: 50%;
    }

    .product-gallery-wrapper[data-mobile-direction="horizontal"] .gallery-prev svg,
    .product-gallery-wrapper[data-mobile-direction="horizontal"] .gallery-next svg {
        transform: none;
    }

    /* لی‌اوت عمودی موبایل */
    .product-gallery-wrapper[data-mobile-direction="vertical"] .gallery-main-layout {
        display: flex;
        gap: 10px;
        align-items: flex-start;
    }

    /* موقعیت تصویر اصلی در چپ */
    .product-gallery-wrapper[data-mobile-direction="vertical"][data-mobile-position="left"] .gallery-main-layout {
        flex-direction: row-reverse;
    }

    /* موقعیت تصویر اصلی در راست */
    .product-gallery-wrapper[data-mobile-direction="vertical"][data-mobile-position="right"] .gallery-main-layout {
        flex-direction: row;
    }

    .product-gallery-wrapper[data-mobile-direction="vertical"] .featured-image {
        flex: 1;
        margin-bottom: 0;
    }

    .product-gallery-wrapper[data-mobile-direction="vertical"] .gallery-container {
        flex-direction: column;
        width: 80px;
        align-items: stretch;
    }

    .product-gallery-wrapper[data-mobile-direction="vertical"] .gallery-slider {
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: auto;
        max-height: 264px;
        width: 100%;
    }

    .product-gallery-wrapper[data-mobile-direction="vertical"] .gallery-nav {
        width: 24px;
        height: 24px;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        right: auto;
        top: auto;
    }

    .product-gallery-wrapper[data-mobile-direction="vertical"] .gallery-prev {
        top: 5px;
    }

    .product-gallery-wrapper[data-mobile-direction="vertical"] .gallery-next {
        bottom: 5px;
        left: 50%;
    }

    .product-gallery-wrapper[data-mobile-direction="vertical"] .gallery-nav svg {
        width: 18px;
        height: 18px;
    }

    .product-gallery-wrapper[data-mobile-direction="vertical"] .gallery-prev svg {
        transform: rotate(-90deg);
    }

    .product-gallery-wrapper[data-mobile-direction="vertical"] .gallery-next svg {
        transform: rotate(-90deg);
    }

    /* تنظیمات لایت‌باکس برای موبایل */
    .lightbox-close {
        top: 10px;
        left: 10px;
        width: 40px;
        height: 40px;
    }

    .lightbox-nav {
        width: 40px;
        height: 40px;
    }

    .lightbox-prev {
        right: 10px;
    }

    .lightbox-next {
        left: 10px;
    }
}

/* موبایل کوچکتر */
@media (max-width: 480px) {
    .product-gallery-wrapper[data-mobile-direction="vertical"] .gallery-container {
        width: 70px;
    }

    .product-gallery-wrapper[data-mobile-direction="vertical"] .gallery-slider {
        max-height: 264px;
    }
}

/* ==================== اسلایدر موبایل (slider mode) ==================== */
.mobile-fullslider {
    display: block; /* پیش‌فرض نمایش - JS فقط در موبایل inject می‌کنه */
    position: relative;
    width: 100%;
    overflow: hidden;
    user-select: none;
    touch-action: pan-y;
}

.mobile-fullslider-track {
    display: flex;
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

.mobile-fullslider-slide {
    flex: 0 0 100%;
    width: 100%;
    overflow: hidden;
    cursor: pointer;
}

/* Pagination dots */
.mobile-fullslider-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 12px 0 4px;
}

.mobile-fullslider-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all 0.3s;
    flex-shrink: 0;
}

.mobile-fullslider-dot.active {
    background: rgba(0, 0, 0, 0.7);
    width: 24px;
    border-radius: 4px;
}

.mobile-fullslider-dot:hover {
    background: rgba(0, 0, 0, 0.45);
}

/* در موبایل slider mode: مخفی کردن layout اصلی (JS slider رو inject می‌کنه) */
@media (max-width: 1024px) {
    .product-gallery-wrapper[data-mobile-direction="slider"] .gallery-desktop-only {
        display: none !important;
    }
}

/* در دسکتاپ: layout اصلی نمایش داده می‌شه (JS slider رو destroy می‌کنه) */
@media (min-width: 1025px) {
    .product-gallery-wrapper[data-mobile-direction="slider"] .gallery-desktop-only {
        display: block;
    }

    .product-gallery-wrapper[data-mobile-direction="slider"][data-desktop-direction="vertical"] .gallery-desktop-only {
        display: flex;
    }
}

/* ارتفاع slide توسط JS از featured-image ست می‌شه */
.mobile-fullslider-slide img {
    width: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    user-select: none;
    height: 300px; /* fallback */
}
