.cpt-gallery-flex {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
}

.cpt-gallery-item {
    flex: 1 1 calc(33.333% - 10px); /* Trois éléments par ligne */
    max-width: calc(33.333% - 10px); /* Limite la largeur maximale */
    max-height: 350px; /* Fixe une hauteur uniforme pour toutes les images */
    overflow: hidden;
    box-sizing: border-box;
}

.cpt-gallery-item img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover; /* Assure que les images remplissent l'espace sans déformation */
    display: block;
}

/* Grille 2 colonnes sur mobile */
@media (max-width: 768px) {
    .cpt-gallery-item {
        flex: 1 1 calc(50% - 10px); /* 2 éléments par ligne sur les petits écrans */
    }

    .popup-content {
        max-width: 90% !important;
    }

    .cpt-gallery-popup .prev {
        right: 0px !important;
    }

    .cpt-gallery-popup .next {
        left: 0px !important;
    }
}

.cpt-gallery-popup {
    display: none;
    position: fixed;
    z-index: 10000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
}

.popup-content {
    position: relative;
    max-width: 70%;
    max-height: 100%;
    margin: auto;
    top: 50%;
    transform: translateY(-50%);
    padding: 20px;
    background: none;
    text-align: center;
}

.cpt-gallery-popup img {
    width: auto;
    /* max-height: 58%; */
    /* height: 800px; */
    max-height: 785px;
    object-fit: contain;
}

.cpt-gallery-popup .close {
    position: absolute;
    top: -10px;
    right: -10px;
    color: #fff;
    cursor: pointer;
    font-size: 20px;
}

.cpt-gallery-popup .prev, .cpt-gallery-popup .next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    cursor: pointer;
    font-size: 30px;
}

.cpt-gallery-popup .prev, .cpt-gallery-popup .next {
    width: 30px;
    height: 30px;
    background-size: contain;
    background-repeat: no-repeat;
    background-color: transparent;
}

.cpt-gallery-popup .prev {
    right: -25px;
}

.cpt-gallery-popup .next {
    left: -25px;
}
