/* =========================================================
   Italica single-product image gallery
   Vertical 4-thumbnail rail + navigation controls.
   Scoped only to WooCommerce single-product galleries.
   ========================================================= */

.single-product .italica-product-gallery {
    --italica-thumb-size: 78px;
    --italica-thumb-gap: 10px;
    --italica-gallery-gap: 16px;
    position: relative;
    display: grid !important;
    grid-template-columns: var(--italica-thumb-size) minmax(0, 1fr);
    grid-template-areas: "thumbs stage";
    align-items: start;
    gap: var(--italica-gallery-gap);
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
}

.single-product .italica-product-gallery--no-thumbs {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "stage";
}

/* Main product image stage. */
.single-product .italica-product-gallery > .flex-viewport,
.single-product .italica-product-gallery > .woocommerce-product-gallery__wrapper {
    grid-area: stage;
    position: relative !important;
    min-width: 0;
    width: 100% !important;
    margin: 0 !important;
    background: #ffffff;
    border: 1px solid #e1e8ef;
    border-radius: 10px;
    overflow: hidden !important;
}

.single-product .italica-product-gallery .woocommerce-product-gallery__wrapper {
    margin: 0 !important;
}

.single-product .italica-product-gallery .woocommerce-product-gallery__image {
    overflow: hidden !important;
}

.single-product .italica-product-gallery .woocommerce-product-gallery__image > a {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100% !important;
    min-height: 0 !important;
    padding: 16px;
    overflow: hidden !important;
    background: #ffffff;
}

.single-product .italica-product-gallery .woocommerce-product-gallery__image > a > img:not(.zoomImg) {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 auto !important;
    object-fit: contain !important;
    object-position: center center !important;
}

.single-product .italica-product-gallery img.zoomImg {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* =========================================================
   Thumbnail rail — exactly four thumbnails visible on desktop.
   ========================================================= */
.single-product .italica-product-gallery .italica-product-gallery__thumb-column {
    grid-area: thumbs;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 7px;
    width: var(--italica-thumb-size);
    min-width: 0;
}

.single-product .italica-product-gallery .flex-control-thumbs {
    display: flex !important;
    flex-direction: column;
    gap: var(--italica-thumb-gap);
    width: var(--italica-thumb-size) !important;
    max-height: calc((var(--italica-thumb-size) * 4) + (var(--italica-thumb-gap) * 3));
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    overscroll-behavior: contain;
}

.single-product .italica-product-gallery .flex-control-thumbs::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.single-product .italica-product-gallery--many-thumbs .flex-control-thumbs {
    height: calc((var(--italica-thumb-size) * 4) + (var(--italica-thumb-gap) * 3));
}

.single-product .italica-product-gallery .flex-control-thumbs li {
    float: none !important;
    flex: 0 0 auto;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.single-product .italica-product-gallery .flex-control-thumbs img {
    display: block;
    width: 100% !important;
    height: var(--italica-thumb-size) !important;
    margin: 0 !important;
    padding: 7px;
    background: #ffffff;
    border: 1px solid #dce6ee;
    border-radius: 8px;
    object-fit: contain !important;
    object-position: center !important;
    opacity: 1 !important;
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.single-product .italica-product-gallery .flex-control-thumbs img:hover,
.single-product .italica-product-gallery .flex-control-thumbs img.flex-active {
    border-color: #034e94;
    box-shadow: 0 0 0 2px rgba(3, 78, 148, 0.10);
}

/* Up/down controls for galleries with more than four images. */
.single-product .italica-product-gallery .italica-product-gallery__thumb-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 28px;
    min-height: 28px;
    padding: 0;
    color: #034e94;
    background: #f6f9fc;
    border: 1px solid #dce6ef;
    border-radius: 8px;
    box-shadow: none;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.single-product .italica-product-gallery .italica-product-gallery__thumb-arrow[hidden] {
    display: none !important;
}

.single-product .italica-product-gallery .italica-product-gallery__thumb-arrow svg {
    width: 16px;
    height: 16px;
}

.single-product .italica-product-gallery .italica-product-gallery__thumb-arrow:hover:not(:disabled) {
    color: #ffffff;
    background: #034e94;
    border-color: #034e94;
}

.single-product .italica-product-gallery .italica-product-gallery__thumb-arrow:disabled {
    opacity: 0.34;
    cursor: default;
}

/* =========================================================
   Previous / next controls on the main feature image.
   ========================================================= */
.single-product .italica-product-gallery .italica-product-gallery__nav {
    position: absolute;
    z-index: 12;
    top: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    color: #034e94;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #d7e3ed;
    border-radius: 50%;
    box-shadow: 0 6px 20px rgba(25, 51, 76, 0.10);
    transform: translateY(-50%);
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.single-product .italica-product-gallery .italica-product-gallery__nav[hidden] {
    display: none !important;
}

.single-product .italica-product-gallery .italica-product-gallery__nav--prev {
    left: 14px;
}

.single-product .italica-product-gallery .italica-product-gallery__nav--next {
    right: 14px;
}

.single-product .italica-product-gallery .italica-product-gallery__nav svg {
    width: 20px;
    height: 20px;
}

.single-product .italica-product-gallery .italica-product-gallery__nav:hover {
    color: #ffffff;
    background: #034e94;
    border-color: #034e94;
    box-shadow: 0 8px 22px rgba(3, 78, 148, 0.18);
}

/* Existing lightbox control. */
.single-product .italica-product-gallery .italica-product-gallery__zoom {
    position: absolute !important;
    z-index: 8;
    top: auto !important;
    right: auto !important;
    bottom: 16px !important;
    left: calc(50% + 47px) !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: auto !important;
    height: 31px !important;
    min-width: 0 !important;
    padding: 0 12px !important;
    color: #034e94 !important;
    background: rgba(255, 255, 255, 0.94) !important;
    border: 1px solid #d9e5ef !important;
    border-radius: 999px !important;
    box-shadow: 0 5px 18px rgba(28, 52, 76, 0.10) !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    text-decoration: none !important;
    transform: translateX(-50%) !important;
}

.single-product .italica-product-gallery--no-thumbs .italica-product-gallery__zoom {
    left: 50% !important;
}

.single-product .italica-product-gallery .italica-product-gallery__zoom::before,
.single-product .italica-product-gallery .italica-product-gallery__zoom::after {
    display: none !important;
    content: none !important;
}

.single-product .italica-product-gallery .italica-product-gallery__zoom svg {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
}

/* =========================================================
   Mobile
   Main image arrows remain available; thumbnails return to
   a horizontal swipe/scroll rail.
   ========================================================= */
@media (max-width: 767px) {
    .single-product .italica-product-gallery,
    .single-product .italica-product-gallery--no-thumbs {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "stage"
            "thumbs";
        gap: 12px;
    }

    .single-product .italica-product-gallery .woocommerce-product-gallery__image > a {
        padding: 12px;
    }

    .single-product .italica-product-gallery .italica-product-gallery__thumb-column {
        width: 100%;
        display: block;
    }

    .single-product .italica-product-gallery .italica-product-gallery__thumb-arrow {
        display: none !important;
    }

    .single-product .italica-product-gallery .flex-control-thumbs,
    .single-product .italica-product-gallery--many-thumbs .flex-control-thumbs {
        flex-direction: row;
        width: 100% !important;
        height: auto;
        max-height: none;
        padding: 0 0 3px !important;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        scroll-snap-type: x proximity;
    }

    .single-product .italica-product-gallery .flex-control-thumbs li {
        flex: 0 0 70px;
        width: 70px !important;
        scroll-snap-align: start;
    }

    .single-product .italica-product-gallery .flex-control-thumbs img {
        height: 70px !important;
    }

    .single-product .italica-product-gallery .italica-product-gallery__nav {
        width: 38px;
        height: 38px;
    }

    .single-product .italica-product-gallery .italica-product-gallery__nav--prev {
        left: 10px;
    }

    .single-product .italica-product-gallery .italica-product-gallery__nav--next {
        right: 10px;
    }

    .single-product .italica-product-gallery .italica-product-gallery__zoom {
        left: 50% !important;
        bottom: 88px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .single-product .italica-product-gallery .flex-control-thumbs {
        scroll-behavior: auto;
    }

    .single-product .italica-product-gallery .italica-product-gallery__nav,
    .single-product .italica-product-gallery .italica-product-gallery__thumb-arrow {
        transition: none;
    }
}
