.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.lightbox-overlay.active {
    display: flex;
}

.lightbox-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

.lightbox-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
    user-select: none;
}

.lightbox-nav:hover {
    background: rgba(0, 0, 0, 0.8);
}

.lightbox-prev {
    left: -70px;
}

.lightbox-next {
    right: -70px;
}

.lightbox-counter {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.5);
    padding: 5px 10px;
    border-radius: 15px;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .lightbox-container {
        max-width: 95vw;
        max-height: 85vh;
    }
    
    .lightbox-close {
        top: -35px;
        right: -5px;
        font-size: 24px;
        width: 35px;
        height: 35px;
    }
    
    .lightbox-nav {
        font-size: 20px;
        width: 40px;
        height: 40px;
    }
    
    .lightbox-prev {
        left: -50px;
    }
    
    .lightbox-next {
        right: -50px;
    }
    
    .lightbox-counter {
        bottom: -35px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .lightbox-prev {
        left: 10px;
        top: 10px;
        transform: none;
    }
    
    .lightbox-next {
        right: 10px;
        top: 10px;
        transform: none;
    }
    
    .lightbox-close {
        top: 10px;
        right: 50%;
        transform: translateX(50%);
    }
    
    .lightbox-counter {
        bottom: 10px;
    }
}

/* Улучшенная галерея */
.gallery {
    padding: 2rem 1rem;
    max-width: 95%;
    margin: 0 auto;
    background: #f8f9fa;
    border-radius: 8px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    grid-auto-rows: 200px;
    grid-auto-flow: dense;    
    gap: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.gallery__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 50%;
    display: block;
    cursor: pointer;
    border-radius: 4px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery__img:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.gallery__img_stretch_v {
    grid-row: span 2;
}

.gallery__img_stretch_h {
    grid-column: span 2;
}

.gallery__img_stretch_all {
    grid-row: span 2;
    grid-column: span 2;
}

@media(max-width: 768px) {
    .gallery {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        grid-auto-rows: 150px;
        padding: 1rem;
    }
    
    .gallery__img_stretch_v,
    .gallery__img_stretch_h,
    .gallery__img_stretch_all {
        grid-row: span 1;
        grid-column: span 1;
    }
}

@media(max-width: 480px) {
    .gallery {
        grid-template-columns: 1fr;
        grid-auto-rows: 200px;
    }
}
