/* Overlay commun */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);

    /* Activer le scroll si le contenu est trop grand */
    overflow-y: auto;

    display: flex;
    justify-content: center;
    /* CHANGEMENT ICI : center au lieu de baseline */
    align-items: center;

    opacity: 0;
    visibility: hidden;
    /* Ajout d'un padding pour éviter que la modale touche les bords sur mobile */
    padding: 20px;
}

/* Classe pour afficher la modale */
.modal-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* Empêche l'image de déborder du cadre blanc lors du zoom */
.modal-overlay.is-zoomed .modal-content {
    overflow: hidden !important; /* Bloque l'apparition de l'ascenseur interne */
/*    max-height: calc(100vh - 40px); /* Maintient la hauteur de sécurité  */
    width: 95%;
    height: 95%;
}

/* Animation du contenu (léger zoom à l'ouverture) */
.modal-content {
    background: white;
    /* CHANGEMENT ICI : Supprimer ou mettre à 0 */
    margin: 0;
    padding: 5px 30px 25px;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
    position: relative;
    /* Sécurité pour le contenu très long */
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    transform: scale(0.9);

    display: flex;
    flex-direction: column; /* Aligne le titre et la galerie verticalement */
}

.modal-overlay.is-open .modal-content {
    transform: scale(1);
    transition: transform 0.3s ease-in-out;
}

/* Zoom image */
#hd-image {
    cursor: zoom-in;
    touch-action: none;
    user-select: none;
    -webkit-user-drag: none;
}

#hd-image.zoomed {
    cursor: zoom-out;
}

#hd-image.is-dragging,
#hd-image.is-swiping {
    cursor: grabbing;
}

/* Variante blister (large fixe) */
.modal-large {
    width: 1000px;
    max-width: 95%;
}

/* Variante HD (taille automatique) */
.modal-fit {
    position: relative; /* point d’ancrage des flèches */
    width: fit-content;
    max-width: 95%;
    max-height: 95%;
    transition: max-width 0.3s ease, width 0.3s ease;
    text-align: center;
}

/* Image HD */
.modal-fit img {
    max-width: 100%;
    max-height: 80vh; /* Garde la hauteur initiale même en mode zoom  */
    display: block;
    margin: 0 auto;
    object-fit: contain; /* Assure que l'image ne se déforme pas */
}

/* Croix commune */
.modal-close {
    cursor: pointer;
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 22px;
    font-weight: bold;
    color: #666;
    z-index: 10;
}

.modal-close:hover {
    color: #000;
}

#iframe_ebay {
    overflow-y: scroll;
    max-height: 400px;
}

.ebay-ad-title {
    text-align: center;
    margin: 0;
    padding: 3px;
    background-color: #cccccc;
}

.ebay-ad-img {
    max-width: 140px;
    max-height: 140px;
}

.ebay-ad-no-img {
    width: 140px;
    height: 140px;
    background: #eee;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ebay-ad-price {
    color: #800000;
    font-size: 16px;
}

.ebay-ad-empty {
    text-align: center;
    padding: 15px;
}

.clickable-hd {
    cursor: zoom-in;
    margin-bottom: 20px;
}

.hd-title {
    font-family: Verdana, Helvetica, sans-serif;
    font-size: 10pt;
    color: gray;
    font-weight: bold;
    margin-bottom: 10px;
    text-align: center;
}

.hd-gallery {
    position: relative;
    margin: 0 auto;
    overflow: visible;
    /* AJOUTS POUR LE CENTRAGE */
    flex: 1; /* Prend tout l'espace disponible sous le titre */
    display: flex;
    align-items: center;     /* Centrage vertical */
    justify-content: center;  /* Centrage horizontal */
    width: 100%;
}

.hd-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    color: #666;
    background: rgba(255,255,255,0.7);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    z-index: 10;
}

#hd-prev { left: 0; }
#hd-next { right: 0; }

.hd-arrow:hover {
    color: #000;
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

.hd-arrow {
    display: none; /* masquées par défaut */
    opacity: 0.6;
    transition: all 0.2s ease;
}

.blister-details {
    margin-top: 30px;
}

/* ============================================================
   RESPONSIVE — modales sous 980px
   ============================================================ */
@media (max-width: 979px) {
    .modal-overlay {
        padding: 8px;
        align-items: flex-start;
    }

    .modal-content {
        padding: 5px 12px 20px;
        max-height: calc(100vh - 16px);
    }

    /* Modale blister : pleine largeur */
    .modal-large {
        width: 100%;
        max-width: 100%;
    }

    /* Annonces eBay : pleine largeur en dessous */
    #iframe_ebay {
        width: 100%;
        max-height: 350px;
        overflow-y: auto;
    }

    #iframe_ebay table {
        width: 100%;
    }

    /* Blister centré dans la modale */
    .blister-details .left-column {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .blister-details .left-column img {
        max-width: 90%;
        height: auto;
    }
}
