/* Контейнеры для зум-эффекта с лупой */
.zoom-container {
    position: relative !important;
    overflow: hidden !important;
    display: block !important;
}

.zoom-container img {
    transition: transform 0.2s ease, transform-origin 0s ease;
    cursor: crosshair;
    transform-origin: center center;
    will-change: transform, transform-origin;
}

/* Зум для основных изображений в галерее */
.gallery .owl-item a,
.gallery a {
    position: relative;
    overflow: hidden;
    display: block;
}

.gallery img {
    max-width: 100%;
    height: auto;
}

/* Стили для инициализированных элементов зума */
.zoom-initialized {
    position: relative;
}

.zoom-initialized img {
    transition: transform 0.2s ease, transform-origin 0s ease;
    cursor: crosshair;
}

/* Зум для миниатюр */
.gallery-mini .g_m_img {
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.gallery-mini .g_m_img img {
    transition: transform 0.2s ease, transform-origin 0s ease;
    cursor: crosshair;
    transform-origin: center center;
    will-change: transform, transform-origin;
}

/* Стили для модального окна lightcase с зумом */
.lightcase-contentInner {
    position: relative;
    overflow: hidden;
}

.lightcase-contentInner.zoom-enabled {
    cursor: crosshair;
}

.lightcase-contentInner img {
    transition: transform 0.2s ease, transform-origin 0s ease;
    max-width: 100%;
    height: auto;
    transform-origin: center center;
    user-select: none;
    will-change: transform, transform-origin;
}

.lightcase-contentInner.zoom-enabled img {
    cursor: crosshair;
}

/* Стили для увеличенного изображения в модальном окне */
.lightcase-contentInner img.zoomed {
    cursor: zoom-out;
}

/* Переопределяем встроенные стили lightcase для правильной работы зума */
.lightcase-contentInner img[style*="max-width"],
.lightcase-contentInner img[style*="max-height"] {
    max-width: none !important;
    max-height: none !important;
    width: auto !important;
    height: auto !important;
}

/* Отключение зума на мобильных устройствах */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
    /* Отключаем все эффекты трансформации на мобильных */
    .zoom-container img,
    .gallery .owl-item a img,
    .gallery-mini .g_m_img img,
    .lightcase-contentInner img {
        transform: none !important;
        transition: none !important;
        cursor: default !important;
    }

    /* Убираем hover эффекты на мобильных */
    .zoom-container:hover img,
    .gallery .owl-item a:hover img,
    .gallery-mini .g_m_img:hover img,
    .lightcase-contentInner img:hover {
        transform: none !important;
    }

    /* Отключаем курсор crosshair на мобильных */
    .zoom-container,
    .gallery .owl-item a,
    .gallery-mini .g_m_img,
    .lightcase-contentInner,
    .lightcase-contentInner.zoom-enabled {
        cursor: default !important;
    }
}

/* Адаптивность для планшетов (средний размер) */
@media (min-width: 769px) and (max-width: 1024px) {
    .zoom-container:hover img {
        transform: scale(1.8);
    }

    .gallery-mini .g_m_img:hover img {
        transform: scale(1.4);
    }

    .lightcase-contentInner.zoom-enabled img:hover {
        transform: scale(1.4);
    }

    .lightcase-contentInner img.zoomed {
        transform: scale(2.2);
    }
}

/* Стили для правильного отображения lightcase на мобильных устройствах */
@media (max-width: 768px) {
    /* Основные стили для модального окна lightcase */
    .lightcase-contentInner {
        max-width: 100vw !important;
        max-height: 100vh !important;
        padding: 5px !important;
        box-sizing: border-box !important;
    }

    /* Стили для изображений в lightcase */
    .lightcase-contentInner img {
        max-width: 100% !important;
        max-height: calc(100vh - 10px) !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
        display: block !important;
        margin: 0 auto !important;
    }

    /* Стили для контейнера lightcase */
    .lightcase-case {
        max-width: 100vw !important;
        max-height: 100vh !important;
        overflow: hidden !important;
    }

    /* Стили для внутреннего контейнера */
    .lightcase-content {
        max-width: 100vw !important;
        max-height: 100vh !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Отключаем встроенные ограничения lightcase */
    .lightcase-contentInner img[style*="max-width"],
    .lightcase-contentInner img[style*="max-height"],
    .lightcase-contentInner img[style*="width"],
    .lightcase-contentInner img[style*="height"] {
        max-width: 100% !important;
        max-height: calc(100vh - 10px) !important;
        width: auto !important;
        height: auto !important;
    }
}

/* Дополнительные стили для очень маленьких экранов */
@media (max-width: 480px) {
    .lightcase-contentInner {
        padding: 2px !important;
    }

    .lightcase-contentInner img {
        max-height: calc(100vh - 4px) !important;
    }

    .lightcase-contentInner img[style*="max-width"],
    .lightcase-contentInner img[style*="max-height"],
    .lightcase-contentInner img[style*="width"],
    .lightcase-contentInner img[style*="height"] {
        max-height: calc(100vh - 4px) !important;
    }
}

/* ===== КАСТОМНОЕ МОДАЛЬНОЕ ОКНО ===== */

/* Оверлей модального окна */
.custom-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: rgba(0, 0, 0, 0.9) !important;
    display: none !important;
    justify-content: center !important;
    align-items: center !important;
    z-index: 10000 !important;
    backdrop-filter: blur(2px) !important;
    -webkit-backdrop-filter: blur(2px) !important;
}

/* Контент модального окна */
.custom-modal-content {
    position: relative !important;
    max-width: 90vw !important;
    max-height: 90vh !important;
    background-color: transparent !important;
    border-radius: 8px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px !important;
    box-sizing: border-box !important;
}

/* Кнопка закрытия */
.custom-modal-close {
    position: absolute !important;
    top: -15px !important;
    right: -15px !important;
    width: 40px !important;
    height: 40px !important;
    background-color: rgba(255, 255, 255, 0.9) !important;
    border: none !important;
    border-radius: 50% !important;
    color: #333 !important;
    font-size: 24px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease !important;
    z-index: 10001 !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
}

.custom-modal-close:hover {
    background-color: #fff !important;
    transform: scale(1.1) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
}

/* Тело модального окна */
.custom-modal-body {
    position: relative !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    max-width: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
    border-radius: 4px !important;
}

/* Изображение в модальном окне */
#custom-modal-image {
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    border-radius: 4px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5) !important;
    transition: transform 0.2s ease, transform-origin 0.2s ease !important;
    cursor: zoom-in !important;
    user-select: none !important;
    -webkit-user-drag: none !important;
}

/* Навигационные кнопки */
.custom-modal-navigation {
    position: absolute !important;
    top: 50% !important;
    left: 0 !important;
    right: 0 !important;
    transform: translateY(-50%) !important;
    display: flex !important;
    justify-content: space-between !important;
    pointer-events: none !important;
    padding: 0 20px !important;
    box-sizing: border-box !important;
}

.custom-nav-btn {
    width: 50px !important;
    height: 50px !important;
    background-color: rgba(255, 255, 255, 0.9) !important;
    border: none !important;
    border-radius: 50% !important;
    color: #333 !important;
    font-size: 24px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease !important;
    pointer-events: auto !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
}

.custom-nav-btn:hover {
    background-color: #fff !important;
    transform: scale(1.1) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
}

.custom-nav-btn:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

/* Стили для увеличенного изображения */
#custom-modal-image.zoomed {
    cursor: grab !important;
}

#custom-modal-image.zoomed:active {
    cursor: grabbing !important;
}

/* Анимации для модального окна */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.custom-modal-overlay {
    animation: modalFadeIn 0.3s ease-out;
}

/* Скрытие навигации при одиночном изображении */
.custom-modal-navigation.single-image {
    display: none;
}

/* Стили для body при открытом модальном окне */
body.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

/* Гарантируем правильное позиционирование модального окна */
.custom-modal-overlay[style*="display: flex"],
.custom-modal-overlay.showing {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: rgba(0, 0, 0, 0.9) !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    z-index: 10000 !important;
    backdrop-filter: blur(2px) !important;
    -webkit-backdrop-filter: blur(2px) !important;
}

/* Отзывчивость для кастомного модального окна */
@media (max-width: 768px) {
    .custom-modal-content {
        max-width: 95vw !important;
        max-height: 95vh !important;
        padding: 10px !important;
    }

    .custom-modal-close {
        top: -10px !important;
        right: -10px !important;
        width: 35px !important;
        height: 35px !important;
        font-size: 20px !important;
    }

    .custom-nav-btn {
        width: 40px !important;
        height: 40px !important;
        font-size: 20px !important;
    }

    .custom-modal-navigation {
        padding: 0 10px !important;
    }
}

@media (max-width: 480px) {
    .custom-modal-content {
        max-width: 98vw !important;
        max-height: 98vh !important;
        padding: 5px !important;
    }

    .custom-modal-close {
        top: -8px !important;
        right: -8px !important;
        width: 30px !important;
        height: 30px !important;
        font-size: 18px !important;
    }

    .custom-nav-btn {
        width: 35px !important;
        height: 35px !important;
        font-size: 18px !important;
    }

    .custom-modal-navigation {
        padding: 0 5px !important;
    }
}

/* Модальное окно работает на всех устройствах, включая мобильные */

/* Стили для плавных переходов */
.custom-modal-overlay.showing {
    animation: modalFadeIn 0.3s ease-out !important;
}

.custom-modal-overlay.hiding {
    animation: modalFadeOut 0.3s ease-out !important;
}

@keyframes modalFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

/* Дополнительные гарантии для правильного отображения */
#custom-image-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 10000 !important;
}