/* Полноэкранная галерея */
.fullscreen-gallery {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: none;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.fullscreen-gallery.active {
    display: flex;
    opacity: 1;
    visibility: visible;
}

.fullscreen-gallery-overlay {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.fullscreen-gallery-container {
    width: 100%;
    height: 100%;
    max-width: 1400px;
    display: grid;
    grid-template-rows: auto 1fr auto;
    grid-template-areas: 
        "header"
        "main"
        "thumbnails";
    gap: 20px;
    position: relative;
}

/* Заголовок */
.fullscreen-gallery-header {
    grid-area: header;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    color: white;
}

.fullscreen-gallery-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.gallery-counter {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    font-weight: normal;
}

.fullscreen-gallery-close {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.fullscreen-gallery-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Основная область изображения */
.fullscreen-gallery-main {
    grid-area: main;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 12px;
}

.fullscreen-main-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: grab;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
}

.fullscreen-main-image-container.dragging {
    cursor: grabbing;
}

.fullscreen-main-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease, opacity 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    opacity: 0;
}

.fullscreen-main-image.loaded {
    opacity: 1;
}

/* Навигационные кнопки */
.fullscreen-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10;
}

.fullscreen-nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.fullscreen-prev-btn {
    left: 20px;
}

.fullscreen-next-btn {
    right: 20px;
}

/* Индикатор загрузки */
.fullscreen-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 2rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.fullscreen-loading.active {
    opacity: 1;
}

/* Панель управления зумом */
.fullscreen-zoom-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 30px;
    padding: 10px 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.zoom-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.zoom-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.zoom-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.zoom-level {
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 50px;
    text-align: center;
}

/* Миниатюры */
.fullscreen-gallery-thumbnails {
    grid-area: thumbnails;
    padding: 0 20px;
}

.fullscreen-thumbnails-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    overflow-x: auto;
    padding: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.fullscreen-thumbnails-container::-webkit-scrollbar {
    height: 6px;
}

.fullscreen-thumbnails-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.fullscreen-thumbnails-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.fullscreen-thumbnails-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.fullscreen-thumbnail {
    width: 80px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    flex-shrink: 0;
    position: relative;
}

.fullscreen-thumbnail:hover {
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.fullscreen-thumbnail.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(89, 197, 112, 0.5);
}

.fullscreen-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.fullscreen-thumbnail:hover img {
    transform: scale(1.1);
}

/* Мобильные стили */
@media (max-width: 768px) {
    .fullscreen-gallery-overlay {
        padding: 10px;
    }
    
    .fullscreen-gallery-container {
        gap: 15px;
    }
    
    .fullscreen-gallery-header {
        padding: 0 10px;
    }
    
    .fullscreen-gallery-close {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
    
    .fullscreen-nav-btn {
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
        /* Предотвращаем дёргание на мобильных */
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -khtml-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        touch-action: manipulation;
        /* Отключаем transform анимации на мобильных */
        transition: background-color 0.2s ease !important;
    }
    
    /* Отключаем hover эффекты на мобильных */
    .fullscreen-nav-btn:hover {
        background: rgba(255, 255, 255, 0.2);
        transform: translateY(-50%) !important;
    }
    
    /* Убираем активные состояния которые могут вызывать скачки */
    .fullscreen-nav-btn:active {
        transform: translateY(-50%) !important;
        background: rgba(255, 255, 255, 0.3);
    }
    
    .fullscreen-prev-btn {
        left: 10px;
    }
    
    .fullscreen-next-btn {
        right: 10px;
    }
    
    .fullscreen-zoom-controls {
        bottom: 10px;
        padding: 8px 15px;
        gap: 8px;
    }
    
    .zoom-btn {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }
    
    .fullscreen-thumbnail {
        width: 70px;
        height: 50px;
    }
    
    .fullscreen-thumbnails-container {
        gap: 8px;
        padding: 8px;
    }
    
    .fullscreen-gallery-thumbnails {
        padding: 0 10px;
    }
}

/* Очень маленькие экраны */
@media (max-width: 480px) {
    .fullscreen-gallery-title {
        font-size: 1.1rem;
    }
    
    .gallery-counter {
        font-size: 0.9rem;
    }
    
    .fullscreen-nav-btn {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
        /* Отключаем transform анимации на очень маленьких экранах */
        transition: background-color 0.2s ease !important;
    }
    
    /* Отключаем hover и active эффекты на очень маленьких экранах */
    .fullscreen-nav-btn:hover,
    .fullscreen-nav-btn:active {
        background: rgba(255, 255, 255, 0.2);
        transform: translateY(-50%) !important;
    }
    
    .fullscreen-zoom-controls {
        padding: 6px 12px;
        gap: 6px;
    }
    
    .zoom-btn {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }
    
    .zoom-level {
        font-size: 0.8rem;
        min-width: 45px;
    }
    
    .fullscreen-thumbnail {
        width: 60px;
        height: 45px;
    }
}

/* Анимации */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fullscreen-gallery.active .fullscreen-gallery-container {
    animation: fadeInScale 0.3s ease;
}

.fullscreen-gallery.active .fullscreen-gallery-thumbnails {
    animation: slideInUp 0.3s ease 0.1s both;
}

/* Стили для сенсорных устройств */
@media (hover: none) {
    .fullscreen-nav-btn:hover,
    .fullscreen-gallery-close:hover,
    .zoom-btn:hover,
    .fullscreen-thumbnail:hover {
        transform: none;
    }
    
    /* Убираем все transform эффекты для кнопок навигации на сенсорных устройствах */
    .fullscreen-nav-btn:active {
        transform: translateY(-50%) !important;
        background: rgba(255, 255, 255, 0.3);
    }
    
    .fullscreen-gallery-close:active,
    .zoom-btn:active {
        background: rgba(255, 255, 255, 0.3);
        transform: none;
    }
    
    .fullscreen-thumbnail:active {
        transform: none;
        opacity: 0.8;
    }
}
