.woocommerce-product-gallery {
    position: relative;
    max-width: 600px;
    margin: 0 auto 1em;
}

/* Основной слайдер */
.woocommerce-product-gallery__main {
    margin-bottom: 10px;
}

.woocommerce-product-gallery__main .splide__slide {
    width: 100%;
    height: auto;
    aspect-ratio: 1/1;
}

.woocommerce-product-gallery__main .splide__slide img,
.woocommerce-product-gallery__main .splide__slide video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

/* Поддержка Retina */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
       only screen and (min--moz-device-pixel-ratio: 1.5),
       only screen and (-o-min-device-pixel-ratio: 3/2),
       only screen and (min-device-pixel-ratio: 1.5) {
    .woocommerce-product-gallery__main .splide__slide img {
        -webkit-backface-visibility: hidden;
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Стрелки */
button.splide__arrow.your-class-arrow {
    background: none;
}

button.splide__arrow.your-class-arrow svg {
    fill: #dc9814;
    width: 2.5rem;
    height: 2.5rem;
}

/* Миниатюры */
.woocommerce-product-gallery__thumbnails {
    margin-top: 10px;
}

.woocommerce-product-gallery__thumbnails .splide__slide {
    margin: 0 5px;
    opacity: 0.6;
    transition: opacity 0.3s;
}

.woocommerce-product-gallery__thumbnails .splide__slide.is-active {
    opacity: 1;
}

.woocommerce-product-gallery__thumbnails .video-thumbnail:after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: url('../img/play-button.png') no-repeat center center;
    background-size: contain;
    opacity: 0.8;
}

.splide__track--nav>.splide__list>.splide__slide.is-active {
    border: 2px solid #e0b154;
}

.splide__list{
    align-items: center;
}

/* Стили для админки вариаций */
.variation-gallery-wrapper {
    margin: 10px 0;
    padding: 10px;
    border: 1px solid #eee;
}

.variation-gallery-images {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.variation-image {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 10px 10px 0;
    border: 1px solid #ddd;
}

.variation-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-variation-image {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #e35a5a;
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    text-align: center;
    line-height: 18px;
    cursor: pointer;
}

.variation-video-wrapper {
    margin-top: 15px;
}

.variation-video-preview {
    margin: 10px 0;
}

/* Анимация загрузки для галереи */
.woocommerce-product-gallery.loading:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    z-index: 10;
}

.woocommerce-product-gallery.loading:after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #dc9814;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 11;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Lightbox стили */
.wsg-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.wsg-lightbox__content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 85vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    margin: auto;
    padding: 40px 20px;
}

.wsg-lightbox[style*="display: block"] {
    display: flex !important;
}

.wsg-lightbox__slider video {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    background: #000;
}

.wsg-lightbox__close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: white;
    font-size: 30px;
    cursor: pointer;
    z-index: 10;
}

.wsg-lightbox__slider {
    width: 100%;
    height: 100%;
}

.wsg-lightbox__slider .splide__slide {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.wsg-lightbox__slider img,
.wsg-lightbox__slider video {
    max-width: 70%;
    max-height: 90vh;
    /*max-width: 100%;
    max-height: 100%;*/
    object-fit: contain;
}

.wsg-lightbox__slider .splide__arrows {
    position: absolute;
    top: 50%;
    width: 100%;
}

.wsg-lightbox__slider .splide__arrow {
    background: rgba(0, 0, 0, 0.5);
    width: 50px;
    height: 50px;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.wsg-lightbox__slider .splide__arrow:hover {
    opacity: 1;
}

.wsg-lightbox__slider .splide__arrow--prev {
    left: 20px;
}

.wsg-lightbox__slider .splide__arrow--next {
    right: 20px;
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .woocommerce-product-gallery {
        max-width: 100%;
        padding: 0px;
        margin: 15px auto !important;
    }
    
    .woocommerce-product-gallery__main .splide__slide {
        aspect-ratio: 1/1;
    }
    
    .woocommerce-product-gallery__thumbnails .splide__slide {
        width: 50px !important;
        height: 50px !important;
    }
}

@media (max-width: 480px) {
    .woocommerce-product-gallery__thumbnails .splide__slide {
        width: 40px !important;
        height: 40px !important;
    }
}
