/********************* gallery ************************/

/* Основное изображение в товарной галерее (без изменений) */
.gallery-main-image {
    width: 100%;
    height: auto;
    border-radius: 5px;
    transition: opacity 0.3s ease;
}

.gallery-container {
    /*margin: 0 auto;*/
}

.single-images__item-main {
    width: 100%;
    cursor: pointer;
}

.single-images__image-main {
    width: 100%;
    height: auto;
    border-radius: 5px;
}

.gallery-item {
    cursor: pointer;
}

.thumbnail-container {
    display: flex;
    gap: 10px;
}

.single-images__item {
    width: 25%;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.single-images__item:hover {
    opacity: 1;
}

.single-images__item img {
    width: 100%;
    height: auto;
    border-radius: 6px;
}

.single-images__item.active {
    opacity: 1;
}

/* ========== Модальное окно (исправлено) ========== */
.gallery-modal {
    display: none;
    position: fixed;
    /* Должен быть выше бургер-меню (.mobile-menu z-index: 9999999), чтобы
       не перекрывать кнопку закрытия галереи на мобильных. */
    z-index: 10000000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;           /* прокрутка, если изображение всё же выходит */
    background-color: rgba(0,0,0,0.9);
}

.gallery-modal-content {
    position: relative;
    width: 100%;
    height: 100%;             /* растягиваем на всю высоту окна */
    display: flex;
    align-items: center;      /* вертикальное центрирование */
    justify-content: center;  /* горизонтальное центрирование */
    padding: 0;
}

.gallery-mySlides {
    display: none;
    text-align: center;
    width: 100%;
}

.gallery-mySlides img {
    max-height: 90vh;         /* ограничение по высоте – 80% высоты окна */
    max-width: 90%;           /* небольшой отступ по ширине */
    height: auto;
    width: auto;
    display: block;
    margin: 0 auto;
}

/* Кнопка закрытия */
.gallery-close {
    color: white;
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
}

.gallery-close:hover {
    color: #ccc;
}

/* Стрелки вперед/назад */
a.gallery-prev, a.gallery-next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);  /* точное вертикальное центрирование */
    padding: 16px;
    color: white;
    background-color: var(--elem_color1);
    font-weight: bold;
    font-size: 20px;
    transition: 0.3s;
    user-select: none;
    text-decoration: none;
    z-index: 1001;
}

.gallery-next {
    right: 0;
    border-radius: 3px 0 0 3px;
}

.gallery-prev {
    left: 0;
    border-radius: 0 3px 3px 0;
}

.gallery-prev:hover, .gallery-next:hover {
    background-color: var(--hovelem_color1);
}

/* Адаптив для маленьких экранов */
@media (max-width: 600px) {
    .gallery-mySlides img {
        max-height: 70vh;
    }
    .gallery-close {
        top: 10px;
        right: 15px;
        font-size: 30px;
    }
    a.gallery-prev, a.gallery-next {
        padding: 10px;
        font-size: 18px;
    }
}