/* Galerie : vignettes + navigation modale */
.gallery-thumbnail {
    transition: transform 0.3s;
}

.gallery-thumbnail:hover {
    transform: scale(1.05);
}

.gallery-thumbnail img,
.gallery-thumbnail video {
    transition: opacity 0.3s;
}

.gallery-thumbnail:hover img,
.gallery-thumbnail:hover video {
    opacity: 0.9;
}

.media-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1070;
    width: 50px !important;
    height: 50px !important;
    min-width: 50px !important;
    min-height: 50px !important;
    max-width: 50px !important;
    max-height: 50px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 0.7;
    transition: opacity 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: none !important;
    background: white !important;
    cursor: pointer;
    pointer-events: auto;
    padding: 0 !important;
}

/* Position par défaut : dans .media-modal-view (voir plus bas) */
.media-nav-prev {
    left: 0.65rem;
}

.media-nav-next {
    right: 0.65rem;
}

.modal-content:hover .media-nav-btn,
.media-nav-btn:hover {
    opacity: 1;
}

.media-nav-btn:hover {
    background: #f8f9fa !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.media-nav-btn i {
    font-size: 1.5rem;
    color: #333;
}

.media-nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}

@media (max-width: 768px) {
    .media-nav-btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        max-width: 40px !important;
        max-height: 40px !important;
        opacity: 0.8;
    }

    .media-nav-prev {
        left: 0.35rem;
    }

    .media-nav-next {
        right: 0.35rem;
    }
}

.gallery-modal-media {
    border-radius: 10px;
}

/* Modale : limiter à la fenêtre (photos portrait / paysage) */
#mediaModal .media-modal-dialog {
    width: min(96vw, 1140px);
    max-width: min(96vw, 1140px);
    max-height: 92vh;
    max-height: 92dvh;
    margin: 0.75rem auto;
}

#mediaModal .modal-content {
    max-height: 92vh;
    max-height: 92dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#mediaModal .modal-header {
    flex-shrink: 0;
}

#mediaModal .modal-body.media-modal-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding-bottom: 1rem;
}

/* Zone image / vidéo : les flèches sont centrées verticalement sur le média, pas sur tout le modal */
#mediaModal .media-modal-view {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

#mediaModal .media-modal-view .media-nav-btn {
    z-index: 2;
}

#mediaContent {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
    width: 100%;
    position: relative;
    z-index: 1;
}

/* Photo : tenir dans la zone visible (sans w-100 côté JS) */
#mediaContent > img.gallery-modal-media {
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: calc(92vh - 9rem);
    max-height: calc(92dvh - 9rem);
    object-fit: contain;
}

/* Vidéo / iframe : largeur limitée pour que la hauteur 16:9 reste dans l’écran */
#mediaContent > .ratio {
    width: 100%;
    max-width: min(100%, calc((92vh - 10rem) * 16 / 9));
    max-width: min(100%, calc((92dvh - 10rem) * 16 / 9));
    margin-left: auto;
    margin-right: auto;
}

#mediaModal .media-modal-description {
    flex-shrink: 0;
    max-height: 28vh;
    overflow-y: auto;
}
