.custom-lightbox {
    position: fixed;
    inset: 0;
    background: #fff;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.single-product div.product .woocommerce-product-gallery .woocommerce-product-gallery__image > a > img {
    border-radius: 24px !important;
    display: block;
}

/* ===== LIGHTBOX ICON FIX ===== */

.custom-lightbox .lightbox-close,
.custom-lightbox .lightbox-nav {
    width: 80px !important;
    height: 80px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    opacity: 1 !important;
}

.custom-lightbox .lightbox-close svg,
.custom-lightbox .lightbox-nav svg {
    width: 50px !important;
    height: 50px !important;
    stroke-width: 2.2;
    display: block;
    stroke: currentColor;
}

.custom-lightbox .lightbox-close:hover,
.custom-lightbox .lightbox-nav:hover {
    color: #000 !important;
    opacity: 0.7 !important;
}

.lightbox-open {
    overflow: hidden;
}

.lightbox-inner {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 1400px;
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox-image-wrap {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 80px 20px;
}

.lightbox-image-wrap img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 20px;
}

.lightbox-close,
.lightbox-nav {
    border: none;
    background: transparent;
    color: #111;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-close {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 20;
    width: 56px;
    height: 56px;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    width: 56px;
    height: 56px;
}

.lightbox-prev {
    left: 24px;
}

.lightbox-next {
    right: 24px;
}

.lightbox-thumbs {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 20px 24px 28px;
    overflow-x: auto;
}

.lightbox-thumbs button {
    width: 72px;
    height: 72px;
    border: 1px solid #ddd;
    background: #fff;
    padding: 4px;
    border-radius: 10px;
    cursor: pointer;
    flex: 0 0 auto;
}

.lightbox-thumbs button.is-active {
    border-color: #111;
}

.lightbox-thumbs img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

/* =========================================================
   WooCommerce Product Gallery - custom no-flexslider version
   ========================================================= */

.single-product div.product {
    display: grid;
    grid-template-columns: minmax(0, 60%) minmax(320px, 1fr);
    gap: 48px 5%;
    align-items: start;
}

.single-product div.product .images,
.single-product div.product .woocommerce-product-gallery {
    width: 100% !important;
    max-width: 100%;
    min-width: 0;
    float: none !important;
    margin: 0;
}

.single-product div.product .summary {
    width: 100% !important;
    min-width: 0;
    float: none !important;
    clear: none !important;
    margin: 0;
}

.single-product div.product .woocommerce-product-gallery {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    position: relative;
}

/* ÜHE PILDIGA TOODE — kui thumbnail wrapper puudub */
.single-product div.product .woocommerce-product-gallery:not(:has(.custom-gallery-thumbs-wrap)) {
    grid-template-columns: 1fr !important;
}

.single-product div.product .woocommerce-product-gallery:not(:has(.custom-gallery-thumbs-wrap)) .custom-gallery-viewport {
    grid-column: 1 / -1 !important;
    grid-row: auto !important;
    width: 100% !important;
}

/* Peida tühi Woo wrapper */
.single-product div.product .woocommerce-product-gallery .woocommerce-product-gallery__wrapper:empty {
    display: none !important;
}

.single-product div.product span.onsale {
    z-index: 2;
}

.single-product div.product .woocommerce-product-gallery .custom-gallery-viewport {
    grid-column: 2;
    grid-row: 1 / span 2;
    background: #fafafa;
    border-radius: 28px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.single-product div.product .woocommerce-product-gallery .woocommerce-product-gallery__wrapper {
    display: contents;
}

.single-product div.product .woocommerce-product-gallery .woocommerce-product-gallery__image {
    display: none;
    width: 100%;
    height: 100%;
    margin: 0 !important;
    float: none !important;
    position: relative;
    overflow: hidden;
    text-align: center;
    border-radius: 20px;
}

.single-product div.product .woocommerce-product-gallery .woocommerce-product-gallery__image.is-active {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    overflow: hidden;
}

.single-product div.product .woocommerce-product-gallery .woocommerce-product-gallery__image > a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 20px;
}

.single-product div.product .custom-gallery-viewport .onsale {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
}

.single-product div.product .woocommerce-product-gallery .woocommerce-product-gallery__image > a > img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    object-fit: contain;
    transform: none !important;
    transition: none !important;
    box-shadow: none !important;
    filter: brightness(0.98);
    border-radius: 20px;
}

.single-product div.product .woocommerce-product-gallery .zoomImg {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    max-width: none !important;
}

.single-product div.product .woocommerce-product-gallery .custom-gallery-trigger,
.custom-gallery-trigger {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
    width: 42px;
    height: 42px;
    padding: 3px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0);
    backdrop-filter: blur(6px);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-gallery-trigger:hover {
    background: #111;
    color: #fff;
    transform: translateX(0);
}

.custom-gallery-trigger svg {
    display: block;
}

/* Thumbnail column */
.single-product .custom-gallery-thumbs-wrap {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-height: 420px;
}

.single-product .custom-gallery-thumbs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.single-product .custom-gallery-thumbs::-webkit-scrollbar {
    display: none;
}

.single-product .custom-gallery-thumbs li {
    width: 120px;
    margin: 3px;
    flex: 0 0 auto;
}

.single-product .custom-gallery-thumbs button {
    display: block;
    width: 120px;
    height: 120px;
    padding: 4px;
    border-radius: 14px;
    border: 1px solid #e6e6e6;
    background: #fff;
    cursor: pointer;
}

.single-product .custom-gallery-thumbs button:hover {
    transform: translateX(0);
}

.single-product .custom-gallery-thumbs button.is-active {
    border-color: #e6e6e6;
    border: solid 2px #bcbcbc;
    box-shadow: 0px 0px 2px #00000000;
}

.single-product .custom-gallery-thumbs img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 10px;
    opacity: 0.55;
    transition: opacity 0.25s ease;
}

.single-product .custom-gallery-thumbs button:hover img,
.single-product .custom-gallery-thumbs button.is-active img {
    opacity: 1;
}

/* Thumb arrows */
.single-product .gallery-thumb-arrow {
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    color: #111;
    font-size: 22px !important;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.single-product .gallery-thumb-arrow--up {
    transform: rotate(90deg);
}

.single-product .gallery-thumb-arrow--down {
    transform: rotate(-90deg);
}

.single-product .gallery-thumb-arrow svg {
    display: block;
}

.single-product .gallery-thumb-arrow:hover {
    opacity: 0.7;
}

.single-product .gallery-thumb-arrow:disabled {
    opacity: 0.25;
    cursor: default;
    font-size: 22px;
}

/* Tablet */
@media (max-width: 1000px) {
    .single-product .custom-gallery-thumbs {
        max-width: 400px;
        display: flex;
        flex-direction: row;
    }

    .single-product div.product .woocommerce-product-gallery {
        display: flex;
        flex-direction: column-reverse;
    }

    .single-product .custom-gallery-thumbs-wrap {
        min-height: auto;
        margin-top: 0;
    }
}

@media (max-width: 844px) {
    .single-product .custom-gallery-thumbs {
        max-width: 263px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .lightbox-image-wrap {
        padding: 20px 20px 10px;
    }

    .custom-lightbox .lightbox-next {
        right: 10px;
    }

    .custom-lightbox .lightbox-prev {
        left: 10px;
    }

    .custom-lightbox .lightbox-close,
    .custom-lightbox .lightbox-nav {
        width: 60px !important;
        height: 60px !important;
    }

    .single-product .site-main-inside {
        padding: 10px 0% 0px;
    }

    .single-product div.product {
        display: block;
    }

    .single-product .custom-gallery-thumbs {
        max-width: 340px;
    }

    .single-product div.product .summary {
        margin-top: 24px;
    }

    .single-product div.product .woocommerce-product-gallery {
        display: flex;
        flex-direction: column-reverse;
    }

    .single-product div.product .woocommerce-product-gallery .custom-gallery-viewport {
        margin-bottom: 0;
        border-radius: 20px;
        width: 100%;
    }

    .single-product .custom-gallery-thumbs-wrap {
        min-height: auto;
        margin-top: 0;
    }

    .single-product .gallery-thumb-arrow {
        display: none;
    }

    .single-product .custom-gallery-thumbs {
        flex-direction: row;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 6px;
    }

    .single-product .custom-gallery-thumbs li,
    .single-product .custom-gallery-thumbs button {
        width: 103px;
        height: 103px;
    }
}