/* ===========================
   LAYOUT: thumbs left, big image right (desktop)
   =========================== */

.my-product-gallery {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    /* Prevent horizontal scroll bleed */
    overflow: hidden;
}

/* Left column: vertical thumbnails */
.my-product-gallery__thumbs {
    flex: 0 0 130px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 520px;
    overflow-y: auto;
    position: relative;
    /* Smooth scroll for iOS */
    -webkit-overflow-scrolling: touch;
}

/* ⭐ ADD THIS - Thumb list wrapper (for both desktop & mobile) */
.my-thumb-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Thumbnail buttons */
.my-thumb {
    border: none;
    padding: 0;
    background: none;
    cursor: pointer;
    opacity: 0.7;
    width: 100%;
    text-align: left;
    /* Prevent layout shift */
    flex-shrink: 0;
    transition: opacity 0.2s ease;
}

.my-thumb img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 6px;
    /* Prevent image drag on mobile */
    -webkit-user-drag: none;
    user-select: none;
}

.my-thumb.is-active {
    opacity: 1;
}

/* Right column: main image area */
.my-product-gallery__main {
    flex: 1 1 auto;
    position: relative;
    /* Prevent layout shift during animation */
    overflow: hidden;
}

/* ===========================
   BIG IMAGES – only ONE visible
   =========================== */

.my-main-image {
    display: none !important;
    width: 100%;
    /* GPU acceleration for smoother animation */
    will-change: opacity, transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.my-main-image.is-active {
    display: block !important;
    opacity: 1;
    transform: scale(1);
}

/* Smooth fade + slight zoom when image changes */
.my-main-image.is-active.is-fade-in {
    animation: myFadeInZoom 0.35s ease-out forwards;
}

@keyframes myFadeInZoom {
    0% {
        opacity: 0;
        transform: scale(0.96) translateZ(0);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateZ(0);
    }
}

.my-main-image.is-active img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 10px;
    transition: transform 0.25s ease;
    /* Prevent image breaking */
    max-width: 100%;
}

.my-main-image.is-active:hover img {
    transform: scale(1.03);
}

/* ===========================
   DESKTOP: scroll arrows for thumbs
   =========================== */

.my-thumb-scroll {
    border: none;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    width: 130px;
    height: 26px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.25rem;
    border-radius: 4px;
}

.my-thumb-scroll--down {
    margin-top: 0.25rem;
}

@media (max-width: 768px) {
    .my-thumb-scroll {
        display: none;
    }
}

/* ===========================
   MOBILE / TABLET - FIXED VERSION
   =========================== */

@media (max-width: 768px) {

    .my-product-gallery {
        flex-direction: column;
        gap: 1rem;
        max-width: 100%;
        overflow: hidden; /* ⭐ Changed from overflow-x */
    }

    .my-product-gallery__main {
        order: 1;
        width: 100%;
    }

    .my-product-gallery__thumbs {
        order: 2;
        flex-direction: row;
        max-height: none;
        width: 100%;
        overflow-y: hidden;
        overflow-x: auto;
        flex: 0 0 auto;
        flex-wrap: nowrap;
        /* ⭐ Smooth horizontal scroll */
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        /* ⭐ Hide scrollbar but keep functionality */
        scrollbar-width: none;
        -ms-overflow-style: none;
        /* ⭐ Prevent accidental vertical scroll */
        overscroll-behavior-x: contain;
    }

    /* ⭐ Hide scrollbar for webkit browsers */
    .my-product-gallery__thumbs::-webkit-scrollbar {
        display: none;
    }

    /* ⭐ Thumb list horizontal layout */
    .my-thumb-list {
        display: flex;
        flex-direction: row;
        gap: 12px;
        padding: 4px 0;
        /* Prevent shrinking */
        flex-shrink: 0;
    }

    .my-thumb {
        flex: 0 0 75px;
        min-width: 75px;
        width: 75px;
    }

    .my-thumb img {
        width: 75px;
        height: 75px;
        object-fit: cover;
        border-radius: 8px;
    }

    /* ⭐ Active thumb highlight on mobile */
    .my-thumb.is-active img {
        box-shadow: 0 0 0 2px #333;
    }

    /* Remove hover effects on mobile */
    .my-main-image.is-active:hover img {
        transform: none;
    }

    /* ⭐ Faster animation on mobile */
    .my-main-image.is-active.is-fade-in {
        animation-duration: 0.25s;
    }
}

/* ===========================
   EXTRA SMALL SCREENS
   =========================== */

@media (max-width: 400px) {
    .my-thumb {
        flex: 0 0 65px;
        min-width: 65px;
        width: 65px;
    }

    .my-thumb img {
        width: 65px;
        height: 65px;
    }
}