/* ==========================================================================
   ACF Product Gallery — Styles
   ========================================================================== */

/* --- Conteneur principal ------------------------------------------------ */
.apg-gallery {
    width: 100%;
    max-width: 900px;
    margin: 0 auto 2rem;
    font-family: inherit;
    box-sizing: border-box;
}

.apg-gallery *,
.apg-gallery *::before,
.apg-gallery *::after {
    box-sizing: border-box;
}

/* --- Image principale ---------------------------------------------------- */
.apg-main-wrap {
    width: 100%;
    margin-bottom: 12px;
}

.apg-main-image {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 6px;
    cursor: zoom-in;
    background: #f0f0f0;
    line-height: 0;
}

.apg-main-img {
    width: 500px !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: none !important;
    object-fit: contain !important;
    display: block !important;
    transition: transform 0.25s ease, opacity 0.2s ease;
}

.apg-main-image:hover .apg-main-img {
    transform: scale(1.02);
}

/* Icône zoom */
.apg-zoom-hint {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.apg-main-image:hover .apg-zoom-hint {
    opacity: 1;
}

/* État de transition de l'image principale */
.apg-main-img.is-loading {
    opacity: 0;
}

/* --- Points de navigation ----------------------------------------------- */
.apg-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 10px 0 4px;
}

.apg-dot {
    width: 10px !important;
    height: 10px !important;
    border-radius: 50% !important;
    background: #ccc !important;
    border: none !important;
    padding: 0 !important;
    cursor: pointer !important;
    transition: background 0.2s ease, transform 0.2s ease;
    flex-shrink: 0 !important;
}

.apg-dot:hover {
    background: #999 !important;
    transform: scale(1.2) !important;
}

.apg-dot.active {
    background: #333 !important;
    transform: scale(1.2) !important;
}

/* --- Miniatures ---------------------------------------------------------- */
.apg-thumbs-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.apg-thumbs-wrap {
    position: relative !important;
}

/* Flèches overlay sur les thumbs — desktop uniquement */
.apg-thumb-nav {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 3 !important;
    width: 36px !important;
    height: 36px !important;
    background: #fff !important;
    border: 1px solid #ddd !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    font-size: 13px !important;
    align-items: center !important;
    justify-content: center !important;
    color: black !important;
    padding: 0 !important;
}

.apg-thumb-nav:hover {
    background: #fff !important;
    color: black !important;

}

.apg-thumb-nav i {
    pointer-events: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
}

.apg-thumb-prev { left: 4px !important; }
.apg-thumb-next { right: 4px !important; }

/* Affichage au survol sur desktop */
@media (min-width: 769px) {
    .apg-thumb-nav {
        display: flex !important;
    }
    .apg-thumbs-wrap:hover .apg-thumb-nav {
        /* opacity: 1 !important; */
    }
    .apg-thumbs-wrap:hover .apg-thumb-nav:disabled {
        /* opacity: 0.25 !important; */
        cursor: default !important;
        box-shadow: none !important;
    }
    /* Dots cachés sur desktop */
    .apg-dots {
        display: none !important;
    }
}

.apg-thumbs {
    display: flex;
    gap: 8px;
    overflow: hidden;
    flex: 1;
}

.apg-thumb {
    flex: 0 0 calc((100% - 16px) / 3) !important;
    cursor: pointer !important;
    border-radius: 4px !important;
    overflow: hidden !important;
    border: 2px solid transparent !important;
    transition: border-color 0.2s ease, opacity 0.2s ease;
    line-height: 0 !important;
    opacity: 0.7 !important;
    aspect-ratio: 1 / 1 !important;
    min-width: 0 !important;
}

.apg-thumb img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    transition: transform 0.2s ease;
}

.apg-thumb:hover {
    opacity: 1;
    border-color: #aaa;
}

.apg-thumb:hover img {
    transform: scale(1.05);
}

.apg-thumb.active {
    border-color: #333;
    opacity: 1;
}

/* --- Lightbox ------------------------------------------------------------ */
.apg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.apg-lightbox[hidden] {
    display: none;
}

.apg-lightbox-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    cursor: zoom-out;
}

.apg-lightbox-inner {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 60px 80px;
}

.apg-lightbox-img-wrap {
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.apg-lightbox-img {
    max-width: 100%;
    max-height: calc(100vh - 120px);
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    transition: opacity 0.2s ease;
    display: block;
}

.apg-lightbox-img.is-loading {
    opacity: 0;
}

/* Bouton fermer */
.apg-lightbox-close {
    position: absolute !important;
    top: 16px !important;
    right: 20px !important;
    background: rgba(255, 255, 255, 0.15) !important;
    border: none !important;
    color: #fff !important;
    font-size: 20px !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s ease;
    z-index: 2 !important;
}

.apg-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}

/* Boutons prev / next lightbox */
.apg-lightbox-prev,
.apg-lightbox-next {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    background: #fff !important;
    border: 1px solid rgba(255,255,255,0.3) !important;
    color: #555 !important;
    font-size: 14px !important;
    width: 42px !important;
    height: 42px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    z-index: 2 !important;
    padding: 0 !important;
    line-height: 1 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35) !important;
}

.apg-lightbox-prev i,
.apg-lightbox-next i {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    pointer-events: none !important;
}

.apg-lightbox-prev { left: 20px !important; }
.apg-lightbox-next { right: 20px !important; }

.apg-lightbox-prev:hover,
.apg-lightbox-next:hover {
    background: #f0f0f0 !important;
    box-shadow: 0 3px 12px rgba(0,0,0,0.45) !important;
}

.apg-lightbox-prev:disabled,
.apg-lightbox-next:disabled {
    opacity: 0.25 !important;
    cursor: default !important;
}

/* Compteur lightbox */
.apg-lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.75);
    font-size: 14px;
    font-family: sans-serif;
    user-select: none;
}

/* --- Erreur ------------------------------------------------------------- */
.apg-error {
    color: #c00;
    padding: 8px;
    border: 1px solid #c00;
    border-radius: 4px;
}

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 600px) {
    .apg-lightbox-inner {
        padding: 50px 16px;
    }

    .apg-lightbox-prev { left: 6px; }
    .apg-lightbox-next { right: 6px; }

    .apg-thumb img {
        height: 60px;
    }

    .apg-main-img {
        max-height: 300px;
    }
}
