/* VK Gallery Styles */

/* Container Styles */
.vk-gallery {
    margin: 20px 0;
    position: relative;
}


/* Slider Styles */
.vk-gallery-slider {
    position: relative;
}

.vk-slider-container {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.vk-slider-wrapper {
    display: flex;
    transition: transform 0.5s ease;
    width: 100%;
    height: 100%;
}

.vk-slider-slide {
    min-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    /* ИСПРАВЛЕНО: убираем opacity, используем transform для переключения */
}

.vk-slider-slide.active {
    /* Активный слайд остается видимым */
}

.vk-slider-slide img {
    width: 100%;
    height: 400px;
    object-fit: cover;
    cursor: pointer;
}

.vk-slider-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: white;
    padding: 20px 15px 15px;
    font-size: 14px;
    line-height: 1.4;
}

/* Navigation Buttons - ИСПРАВЛЕНО ПОЗИЦИОНИРОВАНИЕ */
.vk-slider-nav {
    position: absolute; /* ВАЖНО: абсолютное позиционирование относительно vk-slider-container */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none; /* Не блокируем клики по изображениям */
    z-index: 5; /* Поверх изображений */
}

.vk-slider-prev,
.vk-slider-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
    color: #333;
}

.vk-slider-prev:hover,
.vk-slider-next:hover {
    background: white;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.vk-slider-prev {
    left: 15px;
}

.vk-slider-next {
    right: 15px;
}

/* Pagination Indicators */
.vk-slider-pagination {
    text-align: center;
    margin-top: 15px;
}

.vk-slider-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ddd;
    margin: 0 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.vk-slider-indicator.active,
.vk-slider-indicator:hover {
    background: #007cba;
    transform: scale(1.2);
}

/* Grid Gallery Styles - ПОЛНОСТЬЮ ИСПРАВЛЕНО */
/* MASONRY: НЕ используем CSS Grid - позиционирование через JavaScript */
.vk-album-container.vk-gallery-masonry {
    display: block; /* НЕ grid! */
    position: relative;
    margin: 20px 0;
    width: 100%;
    /* JavaScript управляет позиционированием элементов */
}

/* Если masonry галерея БЕЗ album-container (прямые фото в vk-gallery) */
.vk-gallery.vk-gallery-masonry.vk-gallery-photos {
    display: block; /* НЕ grid! */
    position: relative;
    margin: 20px 0;
    width: 100%;
    /* JavaScript управляет позиционированием элементов */
}

/* GRID: Используем CSS Grid для обычной сетки */
.vk-album-container.vk-gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    width: 100%;
}

/* Если grid галерея БЕЗ album-container (прямые фото в vk-gallery) */
.vk-gallery.vk-gallery-grid.vk-gallery-photos {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    width: 100%;
}

/* MASONRY: Фотографии позиционируются через JavaScript */
.vk-gallery-masonry .vk-photo {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    /* JavaScript устанавливает position: absolute, width, left, top */
}

/* GRID: Фотографии позиционируются через CSS Grid */
.vk-gallery-grid .vk-photo,
.vk-gallery-grid .vk-album-container .vk-photo,
.vk-gallery.vk-gallery-grid > .vk-photo {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    position: relative;
    width: auto !important; /* КРИТИЧНО: переопределяем JS установленную ширину */
    height: auto !important; /* КРИТИЧНО: переопределяем JS установленную высоту */
    top: auto !important; /* КРИТИЧНО: убираем JS позиционирование */
    left: auto !important; /* КРИТИЧНО: убираем JS позиционирование */
}

.vk-gallery-masonry .vk-photo:hover,
.vk-gallery-grid .vk-photo:hover,
.vk-gallery-grid .vk-album-container .vk-photo:hover,
.vk-gallery.vk-gallery-grid > .vk-photo:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.vk-gallery-masonry .vk-photo img,
.vk-gallery-grid .vk-photo img,
.vk-gallery-grid .vk-album-container .vk-photo img,
.vk-gallery.vk-gallery-grid > .vk-photo img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

.vk-gallery-masonry .vk-photo-caption,
.vk-gallery-grid .vk-photo-caption,
.vk-gallery-grid .vk-album-container .vk-photo-caption,
.vk-gallery.vk-gallery-grid > .vk-photo .vk-photo-caption {
    padding: 12px;
    background: white;
    font-size: 13px;
    line-height: 1.4;
    color: #333;
}

/* Load More Button - VK Album Style (как в версии 3.2.3) */
.vk-album-load-more-wrapper {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
}

.vk-album-load-more {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.05));
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 12px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.vk-album-load-more:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.1));
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 1);
}

.vk-album-load-more:active {
    transform: translateY(0);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.vk-album-load-more:disabled {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.4);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Совместимость со старым стилем */
.vk-load-more {
    text-align: center;
    margin: 20px 0;
}

.vk-load-more button {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.05));
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.vk-load-more button:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.1));
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.vk-load-more button:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.4);
    cursor: not-allowed;
    transform: none;
}

/* 🎨 ENHANCED Modal Window Styles - Modern Full Screen Experience */
.vk-gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(0px);
}

.vk-gallery-modal.vk-gallery-modal-active {
    opacity: 1;
    visibility: visible;
    backdrop-filter: blur(2px);
}

/* 🌙 Enhanced backdrop with stronger overlay */
.vk-gallery-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.96);
    cursor: pointer;
    transition: background 0.4s ease;
}

/* Enhanced backdrop gradient effect */
.vk-gallery-modal-backdrop::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, transparent 0%, rgba(0, 0, 0, 0.3) 100%);
    pointer-events: none;
}

/* 🖼️ Improved modal content - full screen approach */
.vk-gallery-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95vw;
    height: 95vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
}

/* 🖼️ Image container - optimized for full screen */
.vk-gallery-modal-image-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
}

/* 📸 Main image - 95% screen coverage with smart scaling */
.vk-gallery-modal-content img,
.vk-gallery-modal-image {
    max-width: 95vw;
    max-height: 95vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    animation: modalFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Smart image sizing classes */
.vk-gallery-modal-image.landscape {
    width: 95vw;
    height: auto;
    max-height: 95vh;
}

.vk-gallery-modal-image.portrait {
    height: 95vh;
    width: auto;
    max-width: 95vw;
}

/* ❌ Close button - moved to top right corner */
.vk-gallery-modal-close {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 24px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    z-index: 10002;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

.vk-gallery-modal-close:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
}

/* 🔄 Navigation buttons - positioned outside image area */
.vk-gallery-modal-prev,
.vk-gallery-modal-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 24px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    z-index: 10002;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    opacity: 0.8;
}

.vk-gallery-modal-prev {
    left: 30px;
}

.vk-gallery-modal-next {
    right: 30px;
}

.vk-gallery-modal-prev:hover,
.vk-gallery-modal-next:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-50%) scale(1.15);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
    opacity: 1;
}

/* Enhanced hover effects with direction */
.vk-gallery-modal-prev:hover {
    transform: translateY(-50%) scale(1.15) translateX(-5px);
}

.vk-gallery-modal-next:hover {
    transform: translateY(-50%) scale(1.15) translateX(5px);
}

/* Скрываем навигацию если только одно изображение */
.vk-gallery-modal-single .vk-gallery-modal-prev,
.vk-gallery-modal-single .vk-gallery-modal-next {
    display: none;
}

/* Отключенные кнопки */
.vk-gallery-modal-prev.disabled,
.vk-gallery-modal-next.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* 📊 Counter - stylish bottom position */
.vk-gallery-modal-counter {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 8px 16px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    z-index: 10002;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* 💬 Caption - floating overlay style */
.vk-gallery-modal-caption {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 70vw;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 15px;
    line-height: 1.5;
    text-align: center;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 10002;
    word-wrap: break-word;
    opacity: 0.9;
}

/* 🎭 Animation enhancements */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* Loading States */
.vk-gallery-loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

.vk-gallery-error {
    text-align: center;
    padding: 20px;
    color: #d32f2f;
    background: #ffebee;
    border: 1px solid #ffcdd2;
    border-radius: 4px;
    margin: 10px 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* ТОЛЬКО для grid layout - planшеты 3 колонки */
    .vk-album-container.vk-gallery-grid,
    .vk-gallery.vk-gallery-grid.vk-gallery-photos {
        grid-template-columns: repeat(3, 1fr); /* ИСПРАВЛЕНО: планшеты - 3 колонки согласно настройкам */
        gap: 10px;
    }
    
    /* Masonry layout остается на JavaScript управлении */
    .vk-album-container.vk-gallery-masonry,
    .vk-gallery.vk-gallery-masonry.vk-gallery-photos {
        /* JavaScript управляет количеством колонок и позиционированием */
    }
    
    /* 📱 Mobile responsive adjustments for modal - Touch-friendly */
    .vk-gallery-modal-content {
        width: 100vw;
        height: 100vh;
    }
    
    .vk-gallery-modal-content img,
    .vk-gallery-modal-image {
        max-width: 95vw;
        max-height: 90vh;
        border-radius: 4px;
    }
    
    /* Larger touch targets for mobile */
    .vk-gallery-modal-close {
        top: 15px;
        right: 15px;
        width: 55px;
        height: 55px;
        font-size: 26px;
    }
    
    .vk-gallery-modal-prev,
    .vk-gallery-modal-next {
        width: 60px;
        height: 60px;
        font-size: 24px;
        top: auto;
        bottom: 80px;
        transform: none;
    }
    
    .vk-gallery-modal-prev {
        left: 20px;
    }
    
    .vk-gallery-modal-next {
        right: 20px;
    }
    
    /* Revert hover transform for mobile bottom buttons */
    .vk-gallery-modal-prev:hover {
        transform: scale(1.15) translateX(-5px);
    }
    
    .vk-gallery-modal-next:hover {
        transform: scale(1.15) translateX(5px);
    }
    
    .vk-gallery-modal-counter {
        bottom: 20px;
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .vk-gallery-modal-caption {
        bottom: 150px;
        max-width: 85vw;
        padding: 8px 16px;
        font-size: 14px;
        border-radius: 16px;
    }
    
    /* Swipe indicator for mobile */
    .vk-gallery-modal-swipe-hint {
        position: fixed;
        bottom: 140px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(255, 255, 255, 0.9);
        color: #333;
        padding: 6px 12px;
        border-radius: 20px;
        font-size: 11px;
        font-weight: 500;
        z-index: 10003;
        opacity: 0.8;
        backdrop-filter: blur(10px);
        pointer-events: none;
        animation: swipeHintFade 3s ease-in-out infinite;
    }
    
    @keyframes swipeHintFade {
        0%, 100% { opacity: 0.8; }
        50% { opacity: 0.4; }
    }
    
    .vk-slider-prev,
    .vk-slider-next {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .vk-slider-prev {
        left: 10px;
    }
    
    .vk-slider-next {
        right: 10px;
    }

}

@media (max-width: 480px) {
    /* ТОЛЬКО для grid layout - мобильные 2 колонки */
    .vk-album-container.vk-gallery-grid,
    .vk-gallery.vk-gallery-grid.vk-gallery-photos {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    /* Masonry layout остается на JavaScript управлении */
    .vk-album-container.vk-gallery-masonry,
    .vk-gallery.vk-gallery-masonry.vk-gallery-photos {
        /* JavaScript управляет количеством колонок и позиционированием */
    }
}

/* Дополнительные responsive правила для больших экранов */
@media (min-width: 1200px) {
    /* ТОЛЬКО для grid layout - большие экраны 4 колонки */
    .vk-album-container.vk-gallery-grid,
    .vk-gallery.vk-gallery-grid.vk-gallery-photos {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
    
    /* Masonry layout остается на JavaScript управлении */
    .vk-album-container.vk-gallery-masonry,
    .vk-gallery.vk-gallery-masonry.vk-gallery-photos {
        /* JavaScript управляет количеством колонок и позиционированием */
    }
    
    /* 🖥️ Large screen optimizations for modal */
    .vk-gallery-modal-prev,
    .vk-gallery-modal-next {
        width: 70px;
        height: 70px;
        font-size: 28px;
    }
    
    .vk-gallery-modal-prev {
        left: 40px;
    }
    
    .vk-gallery-modal-next {
        right: 40px;
    }
    
    .vk-gallery-modal-close {
        top: 30px;
        right: 30px;
        width: 60px;
        height: 60px;
        font-size: 28px;
    }
}

@media (min-width: 1600px) {
    /* ТОЛЬКО для grid layout - очень большие экраны 4 колонки */
    .vk-album-container.vk-gallery-grid,
    .vk-gallery.vk-gallery-grid.vk-gallery-photos {
        grid-template-columns: repeat(4, 1fr); /* ИСПРАВЛЕНО: используем настройки плагина (4), а не 5 */
        gap: 25px;
    }
    
    /* Masonry layout остается на JavaScript управлении */
    .vk-album-container.vk-gallery-masonry,
    .vk-gallery.vk-gallery-masonry.vk-gallery-photos {
        /* JavaScript управляет количеством колонок и позиционированием */
    }
}

/* Hidden class for elements that should not be visible */
.vk-hidden {
    display: none !important;
}

/* Shimmer animation for loading placeholders */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.vk-photo-placeholder {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: default;
}

.vk-photo-placeholder .vk-photo-shimmer {
    animation: shimmer 1.5s ease-in-out infinite;
}

/* Focus styles for accessibility */
.vk-slider-prev:focus,
.vk-slider-next:focus,
.vk-slider-indicator:focus,
.vk-load-more button:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}