/* === ФОТОГАЛЕРЕЯ === */

/* Компактная галерея на странице */
.photo-gallery-compact {
    position: relative;
}

.photo-gallery-compact .photo-clickable {
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: block;
    width: 100%;
    height: 100%;
}

.photo-gallery-compact .photo-clickable:hover {
    filter: brightness(0.92);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

/* Основное фото */
.main-photo-wrapper {
    position: relative;
    cursor: pointer;
    user-select: none;
}

.main-photo-wrapper .badge {
    vertical-align: middle;
}

.main-photo-wrapper .ratio {
    position: relative;
}

.main-photo-wrapper .photo-clickable {
    cursor: pointer;
    pointer-events: all;
    position: static !important;
    z-index: 1;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

/* Bootstrap ratio не должен конфликтовать */
.main-photo-wrapper .ratio > .photo-clickable {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.main-photo-wrapper .position-absolute {
    pointer-events: none;
    z-index: 10;
}

.main-photo-wrapper .position-absolute .open-gallery-modal {
    pointer-events: all;
    z-index: 11;
    transition: all 0.3s ease;
    border: 1px solid rgba(255,255,255,0.3) !important;
    backdrop-filter: blur(8px);
}

/* Дополнительные фото */
.additional-photos {
    margin-top: 1rem;
}

.photo-gallery-compact .additional-photo {
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    position: relative;
    background: #f8f9fa;
    aspect-ratio: 1 / 1;
}

.photo-gallery-compact .additional-photo .photo-clickable {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.photo-gallery-compact .additional-photo:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    z-index: 2;
}

.photo-gallery-compact .additional-photo::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s;
    z-index: 1;
    pointer-events: none;
}

.photo-gallery-compact .additional-photo:hover::before {
    transform: translateX(100%);
}

.remaining-photos-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
    z-index: 3;
    border-radius: inherit;
}

.remaining-photos-overlay .text-white {
    font-size: 0.9rem;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* === МОДАЛЬНОЕ ОКНО === */
#photoGalleryModal .modal-dialog {
    max-width: 95vw;
    width: 95vw;
    height: 95vh;
    max-height: 95vh;
    margin: 2.5vh auto;
}

#photoGalleryModal .modal-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

#photoGalleryModal .modal-body {
    flex: 1;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#photoCarousel {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-height: 85%;
}

#photoGalleryModal .carousel-inner {
    flex: 1;
    display: flex;
}

#photoGalleryModal .carousel-item {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 1rem;
}

.max-height-gallery {
    max-height: 80vh;
    max-width: 90vw;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    transition: opacity 0.3s ease;
}

/* Контролы карусели */
#photoGalleryModal .carousel-control-prev,
#photoGalleryModal .carousel-control-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 5%;
    opacity: 0.7;
    z-index: 15;
    transition: opacity 0.3s ease;
}

#photoGalleryModal .carousel-control-prev {
    left: 15px;
}

#photoGalleryModal .carousel-control-next {
    right: 15px;
}

#photoCarousel .carousel-control-prev:hover,
#photoCarousel .carousel-control-next:hover {
    opacity: 1;
}

/* Миниатюры */
.gallery-thumbnails {
    background: #000;
    padding: 1rem;
    border-top: 1px solid #333;
    max-height: 100px;
    overflow-y: hidden;
    overflow-x: hidden;
}

.gallery-thumbnails .d-flex {
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-width: 100%;
    overflow: hidden;
}

.thumbnail-clickable {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.thumbnail-clickable:hover,
.thumbnail-clickable.active {
    opacity: 1;
    border-color: #0d6efd;
    transform: scale(1.1);
}

.thumbnail-clickable:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transform: scale(1.15);
}

.thumbnail-clickable.active {
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
}

/* Индикаторы карусели */
#photoGalleryModal .modal-content.bg-dark .carousel-indicators [data-bs-target] {
    background-color: rgba(255,255,255,0.5);
    border: 1px solid rgba(255,255,255,0.8);
}

#photoGalleryModal .modal-content.bg-dark .carousel-indicators .active {
    background-color: rgba(255,255,255,0.9);
}

/* === АДАПТИВНОСТЬ ГАЛЕРЕИ === */
@media (max-width: 768px) {
    .max-height-gallery {
        max-height: 70vh;
        max-width: 95vw;
    }
    
    #photoGalleryModal .carousel-item {
        min-height: 50vh;
        padding: 0.5rem;
    }
    
    #photoGalleryModal .carousel-control-prev,
    #photoGalleryModal .carousel-control-next {
        width: 15%;
    }
    
    .gallery-thumbnails {
        max-height: 80px;
    }
    
    .thumbnail-clickable {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 576px) {
    #photoGalleryModal .modal-dialog {
        max-width: 100vw;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
    }
    
    .additional-photos .col-4 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }
    
    .thumbnail-clickable {
        width: 35px;
        height: 35px;
    }
}
