/* Секция галереи */
.gallery-section {
    padding: 20px 20px;
    background: #f8f9fa;
    margin: 40px 0;
    overflow: hidden; /* Добавлено */
}

.gallery-section h2 {
    text-align: center;
    color: #ff8243;
    margin-bottom: 40px;
    font-size: 2rem;
}

/* Контейнер галереи */
.gallery-container {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    overflow: hidden;
    padding: 0 60px 60px 60px; /* Добавлены боковые отступы */
}

/* Карусель */
.gallery-carousel {
    display: flex;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    gap: 20px;
    width: 100%;
}

/* Элемент галереи */
.gallery-item {
    flex: 0 0 calc(33.333% - 13.33px); /* Исправлено: 33.333% минус gap */
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
    background: white;
    height: 350px;
    min-width: 0; /* Важно для flex-shrink */
}

.gallery-item:hover {
    transform: translateY(-5px);
}

/* Изображение */
.gallery-link {
    display: block;
    text-decoration: none;
    color: inherit;
    position: relative;
    height: 100%;
    width: 100%;
}

.gallery-image {
    width: 100%;
    height: 250px;
    object-fit: contain;
    display: block;
    padding: 15px;
    background: white;
}

/* Наложение */
.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 130, 67, 0.9), rgba(255, 130, 67, 0.8));
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    color: white;
    text-align: center;
    padding: 20px;
    pointer-events: none;
}

.gallery-item:hover .image-overlay {
    opacity: 1;
}

.zoom-icon {
    font-size: 2.5rem;
    margin-bottom: 15px;
}

.image-title {
    font-weight: bold;
    font-size: 1.2rem;
}

/* Кнопки карусели */
.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #ff8243;
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1.8rem;
    cursor: pointer;
    z-index: 100;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.carousel-btn:hover:not(:disabled) {
    background: #e6733c;
    transform: translateY(-40%) scale(1.03); /* Уменьшил увеличение */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); /* Добавил тень для эффекта */
}
.carousel-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.prev-btn {
    left: 0;
}

.next-btn {
    right: 0;
}

/* Индикаторы */
.carousel-indicators {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 30px;
}

.indicator {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ddd;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.indicator:hover {
    background: #ff8243;
    transform: scale(1.2);
}

.indicator.active {
    background: #ff8243;
    transform: scale(1.2);
    border-color: #fff;
    box-shadow: 0 0 0 2px #ff8243;
}

/* МОДАЛЬНОЕ ОКНО ГАЛЕРЕИ */
.gallery-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.gallery-modal-content {
    background: white;
    border-radius: 15px;
    max-width: 800px;
    max-height: 90vh;
    position: relative;
    overflow: hidden;
    margin: 0 auto;
}

.gallery-close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 2.5rem;
    color: white;
    cursor: pointer;
    z-index: 3001;
    background: rgba(0,0,0,0.6);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: none;
    padding: 0;
}

.gallery-close-modal:hover {
    background: rgba(255, 130, 67, 0.9);
    transform: scale(1.1);
}

.gallery-modal-image {
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
    display: block;
    padding: 30px;
    background: white;
}

.gallery-modal-caption {
    padding: 25px;
    text-align: center;
    background: white;
    border-top: 3px solid #ff8243;
}

.gallery-modal-title {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.4rem;
}

.gallery-modal-link {
    display: inline-block;
    padding: 12px 25px;
    background: #ff8243;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.gallery-modal-link:hover {
    background: #e6733c;
    transform: translateY(-2px);
}

/* Анимация */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Адаптивность */
@media (max-width: 1024px) {
    .gallery-container {
        padding: 0 50px 60px 50px;
    }
    
    .gallery-item {
        flex: 0 0 calc(50% - 10px); /* 50% минус gap */
        height: 320px;
    }
    
    .gallery-modal-content {
        max-width: 90vw;
    }
}

@media (max-width: 768px) {
    .gallery-section {
        padding: 30px 15px;
    }
    
    .gallery-container {
        padding: 0 40px 60px 40px;
    }
    
    .gallery-item {
        flex: 0 0 calc(50% - 7.5px); /* 50% минус уменьшенный gap */
        height: 300px;
    }
    
    .gallery-carousel {
        gap: 15px;
    }
    
    .gallery-image {
        height: 200px;
    }
    
    .carousel-btn {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }
    
    .gallery-modal-content {
        max-width: 95vw;
    }
}

@media (max-width: 576px) {
    .gallery-container {
        padding: 0 40px 60px 40px;
    }
    
    .gallery-item {
        flex: 0 0 100%;
        height: 280px;
    }
    
    .gallery-image {
        height: 180px;
    }
    
    .carousel-indicators {
        margin-top: 30px;
    }
}