/* ========== SYSTÈME DE ZOOM PROFESSIONNEL POUR MODAL IMAGE ========== */

/* ===== CONTENEUR PRINCIPAL ===== */
.image-modal-content {
    position: relative;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.4),
        0 2px 10px rgba(0, 0, 0, 0.3),
        0 0 1px rgba(0, 0, 0, 0.5);

    /* S'adapter à la taille de l'image */
    width: auto;
    max-width: 92vw;
    height: auto;
    max-height: 92vh;
    display: inline-flex;
    flex-direction: column;
}

/* ===== BOUTON FERMETURE X - EN DEHORS DU CADRE ===== */
/* Le modal .image-zoom-modal doit être position:relative pour ancrer le bouton */
.image-zoom-modal {
    position: fixed !important;
}

.image-modal-close {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 10010;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    color: #1a1a1a;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.35), 0 1px 4px rgba(0,0,0,0.2);
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    padding: 0;
    /* Légère animation d'entrée */
    animation: closeBtnAppear 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes closeBtnAppear {
    from { opacity: 0; transform: scale(0.6); }
    to   { opacity: 1; transform: scale(1); }
}

.image-modal-close:hover {
    background: #ff4444;
    color: #ffffff;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(255, 68, 68, 0.45), 0 2px 6px rgba(0,0,0,0.2);
}

.image-modal-close:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    .image-modal-close {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
        font-size: 20px;
    }
}

.image-modal-body {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== CONTENEUR D'IMAGE AVEC ZOOM ===== */
.image-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: zoom-in;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    /* S'adapter à l'image */
    width: fit-content;
    height: fit-content;
    max-width: 92vw;
    max-height: 85vh;
}

.image-container.zoomed {
    cursor: grab;
}

.image-container.zoomed:active {
    cursor: grabbing;
}

.image-container.panning {
    cursor: grabbing !important;
}

/* ===== IMAGE ZOOMABLE ===== */
.modal-zoom-img {
    display: block;
    max-width: 92vw;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: opacity 0.3s ease;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

/* État de zoom */
.modal-zoom-img.zoomed {
    max-width: none;
    max-height: none;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== CONTRÔLES DE ZOOM - SUPPRIMÉS ===== */
/* Les boutons de zoom ont été supprimés */

/* ===== INDICATEUR DE ZOOM ===== */
.zoom-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.zoom-indicator.show {
    opacity: 1;
}

.zoom-indicator-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-percentage {
    font-weight: 700;
    color: #3B82F6;
    min-width: 50px;
    text-align: right;
}

/* ===== AIDE INTERACTIVE ===== */
.zoom-help {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px 24px;
    border-radius: 25px;
    color: #ffffff;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    z-index: 999;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.zoom-help.show {
    opacity: 1;
    animation: helpBounce 2s ease-in-out infinite;
}

@keyframes helpBounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-5px); }
}

.zoom-help-icon {
    font-size: 18px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

/* ===== EFFET DE MINIMAP (OPTIONNEL) ===== */
.zoom-minimap {
    position: absolute;
    bottom: 80px;
    left: 20px;
    width: 120px;
    height: 90px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 999;
}

.zoom-minimap.show {
    opacity: 1;
}

.minimap-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0.5;
}

.minimap-viewport {
    position: absolute;
    border: 2px solid #3B82F6;
    background: rgba(59, 130, 246, 0.2);
    pointer-events: none;
}

/* ===== NOM DU PRODUIT — PANNEAU LATÉRAL DESKTOP ===== */
.image-title-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px 10px;
    background: rgba(0,0,0,0.35);
    border-top: 1px solid rgba(255,255,255,0.08);
    text-align: center;
}

.image-title-container #modalImageName {
    font-size: 0.8rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.4;
    word-break: break-word;
}

.image-title-container #modalImageCounter {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.45);
}

/* Panneau latéral visible uniquement sur desktop */
.image-name-sidebar {
    display: none;
}

@media (min-width: 769px) {
    /* Le contenu du modal devient une ligne : image | panneau */
    .image-modal-content {
        flex-direction: row !important;
        align-items: stretch !important;
        width: auto;
        max-width: 92vw;
    }

    /* Masquer le bloc titre/ref/OEM sous l'image sur desktop (panneau latéral prend le relais) */
    .image-title-container {
        display: none;
    }

    .image-modal-body {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Panneau droit avec le nom */
    .image-name-sidebar {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: flex-start;
        width: 220px;
        min-width: 180px;
        max-width: 260px;
        padding: 2rem 1.5rem;
        background: rgba(0, 0, 0, 0.35);
        border-left: 1px solid rgba(255, 255, 255, 0.08);
        gap: 0.8rem;
        flex-shrink: 0;
    }

    .image-name-sidebar .sidebar-label {
        font-size: 0.6rem;
        font-weight: 700;
        letter-spacing: 2px;
        text-transform: uppercase;
        color: #F7B801;
        opacity: 0.85;
    }

    .image-name-sidebar .sidebar-product-name {
        font-size: 0.95rem;
        font-weight: 700;
        color: #ffffff;
        line-height: 1.45;
        word-break: break-word;
        text-shadow: 0 1px 4px rgba(0,0,0,0.4);
    }

    .image-name-sidebar .sidebar-counter {
        font-size: 0.7rem;
        color: rgba(255,255,255,0.45);
        font-weight: 500;
        margin-top: auto;
        padding-top: 1rem;
        border-top: 1px solid rgba(255,255,255,0.08);
        width: 100%;
    }
}

/* ===== RESPONSIVE MOBILE ===== */
@media (max-width: 768px) {
    .image-zoom-modal {
        padding: 0 12px;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }

    .image-modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 92vh;
        border-radius: 16px;
        overflow: hidden;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
    }

    .image-modal-body {
        width: 100%;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .image-container {
        width: 100%;
        max-width: 100%;
        max-height: 68vh;
        overflow: hidden;
    }

    .modal-zoom-img {
        width: 100%;
        max-width: 100%;
        max-height: 68vh;
        height: auto;
        object-fit: contain;
    }
    
    .zoom-indicator {
        top: 15px;
        right: 15px;
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .zoom-help {
        bottom: 100px;
        font-size: 12px;
        padding: 10px 20px;
    }
    
    .zoom-minimap {
        display: none;
    }
}

/* ===== FLÈCHES DE NAVIGATION — MASQUÉES PAR DÉFAUT, AFFICHÉES UNIQUEMENT SI PLUSIEURS IMAGES ===== */
/* Les flèches sont contrôlées par JS (display:flex si >1 image, display:none sinon) */
/* Ce CSS assure un état par défaut sûr (masqué) avant que le JS s'exécute */
.mobile-nav-buttons {
    display: none;
}
.image-nav-prev.desktop-nav,
.image-nav-next.desktop-nav {
    display: none;
}
/* ===== FIN FLÈCHES ===== */

/* ===== ANIMATIONS DE TRANSITION ===== */
.modal-zoom-img.changing {
    opacity: 0;
    transform: none !important;
    transform-origin: 50% 50% !important;
    transition: opacity 0.2s ease !important;
    /* ✅ CORRECTION MOBILE : empêcher tout will-change ou couche composite
       qui peut déclencher un zoom sur flèche de navigation mobile */
    will-change: auto !important;
    -webkit-transform: none !important;
    -webkit-transform-origin: 50% 50% !important;
}

.modal-zoom-img.changed {
    animation: imageAppear 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: 50% 50% !important;
    -webkit-transform-origin: 50% 50% !important;
}

@keyframes imageAppear {
    0% {
        opacity: 0;
        transform: none;
        -webkit-transform: none;
        transform-origin: 50% 50%;
    }
    100% {
        opacity: 1;
        transform: none;
        -webkit-transform: none;
        transform-origin: 50% 50%;
    }
}

/* ===== CURSEUR PERSONNALISÉ ===== */
.image-container.zoom-cursor-in {
    cursor: zoom-in;
}

.image-container.zoom-cursor-out {
    cursor: zoom-out;
}

/* ===== EFFET DE FOCUS ===== */
.image-container::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    background: radial-gradient(
        circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(59, 130, 246, 0.1) 0%,
        transparent 50%
    );
}

.image-container:hover::before {
    opacity: 1;
}

/* ===== PROTECTION CONTRE LA SÉLECTION ===== */
.image-modal-content * {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* ===== OVERLAY DE CHARGEMENT ===== */
.zoom-loading {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1001;
}

.zoom-loading.show {
    opacity: 1;
    pointer-events: all;
}

.zoom-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #3B82F6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Visualiseur plein écran (fiche produit, batterie, suivi de commande) — refonte 08/11/2026
   Image + flèches + miniatures dans le même cadre, panneau d'infos à droite.
   Portée limitée à #imageZoomModal.pd-viewer : les autres pages ne sont pas touchées.
   ═══════════════════════════════════════════════════════════════════════════ */
#imageZoomModal.pd-viewer .pd-viewer-stage { position: relative; display: flex; flex: none; width: 100%; }
#imageZoomModal.pd-viewer .pd-viewer-count {
    position: absolute; top: 12px; left: 12px; z-index: 5; padding: .25rem .7rem; border-radius: 999px;
    font-size: .75rem; font-weight: 700; letter-spacing: .04em; color: #fff; background: rgba(0,51,102,.88);
    box-shadow: 0 4px 12px rgba(0,0,0,.25); pointer-events: none;
}

/* Miniatures */
#imageZoomModal.pd-viewer .pd-viewer-thumbs {
    position: relative; display: flex; flex: none; gap: 10px; padding: 4px 2px; overflow-x: auto; scrollbar-width: none;
}
#imageZoomModal.pd-viewer .pd-viewer-thumbs::-webkit-scrollbar { display: none; }
#imageZoomModal.pd-viewer .pd-viewer-thumb {
    flex: none; width: 64px; height: 64px; padding: 3px; border: 2px solid rgba(255,255,255,.22); border-radius: 10px;
    background: #fff; cursor: pointer; opacity: .72;
    transition: opacity .2s ease, border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
#imageZoomModal.pd-viewer .pd-viewer-thumb:first-child { margin-left: auto; }
#imageZoomModal.pd-viewer .pd-viewer-thumb:last-child  { margin-right: auto; }
#imageZoomModal.pd-viewer .pd-viewer-thumb img { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: 6px; pointer-events: none; }
#imageZoomModal.pd-viewer .pd-viewer-thumb:hover { opacity: 1; border-color: rgba(247,184,1,.85); transform: translateY(-2px); }
#imageZoomModal.pd-viewer .pd-viewer-thumb:focus-visible { outline: 3px solid #F7B801; outline-offset: 2px; }
#imageZoomModal.pd-viewer .pd-viewer-thumb[aria-current="true"] { opacity: 1; border-color: #F7B801; box-shadow: 0 0 0 3px rgba(247,184,1,.28); }

/* Références : un groupe « Référence » et un groupe « Références OEM » en pastilles qui passent à la ligne */
#imageZoomModal.pd-viewer .pd-meta { display: flex; flex-direction: column; gap: 14px; }
#imageZoomModal.pd-viewer .pd-meta-label { display: block; font-size: .62rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #F7B801; opacity: .9; }
#imageZoomModal.pd-viewer .pd-meta-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
#imageZoomModal.pd-viewer .pd-meta-chip {
    font-family: ui-monospace, Consolas, Menlo, monospace; font-size: .85rem; font-weight: 700; color: #fff;
    background: rgba(247,184,1,.15); border: 1px solid rgba(247,184,1,.5); padding: 4px 10px; border-radius: 8px; white-space: nowrap;
}

/* ── Desktop ── */
@media (min-width: 769px) {
    #imageZoomModal.pd-viewer .pd-viewer-stage { flex: 1 1 0; min-height: 0; }
    #imageZoomModal.pd-viewer .image-modal-content { width: min(1120px, 94vw); height: min(760px, 88vh); max-width: none; max-height: none; }
    #imageZoomModal.pd-viewer .image-modal-body {
        flex: 1 1 auto; min-width: 0; height: 100%; padding: 20px; box-sizing: border-box;
        flex-direction: column; align-items: stretch; justify-content: flex-start; overflow: hidden;
    }
    #imageZoomModal.pd-viewer .image-container {
        flex: 1 1 auto; width: 100%; height: 100%; max-width: none; max-height: none; min-height: 0;
        background: #fff; border-radius: 14px;
    }
    #imageZoomModal.pd-viewer .modal-zoom-img,
    #imageZoomModal.pd-viewer .modal-zoom-img.zoomed {
        width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; padding: 18px; box-sizing: border-box;
    }
    #imageZoomModal.pd-viewer .pd-viewer-thumbs { margin-top: 12px; }

    /* Flèches : DANS le cadre de l'image, centrées verticalement, bien visibles sur fond blanc */
    #imageZoomModal.pd-viewer .image-nav-btn.desktop-nav {
        position: absolute; top: 50%; transform: translateY(-50%); z-index: 6; width: 46px; height: 46px; padding: 0;
        border: 2px solid #fff; border-radius: 50%; color: #fff; background: rgba(0,51,102,.88);
        box-shadow: 0 6px 18px rgba(0,0,0,.3); align-items: center; justify-content: center;
        transition: background .2s ease, color .2s ease, transform .2s ease;
    }
    #imageZoomModal.pd-viewer .image-nav-prev.desktop-nav { left: 14px; right: auto; }
    #imageZoomModal.pd-viewer .image-nav-next.desktop-nav { right: 14px; left: auto; }
    #imageZoomModal.pd-viewer .image-nav-btn.desktop-nav:hover { background: #F7B801; color: #1a1a1a; transform: translateY(-50%) scale(1.08); }
    #imageZoomModal.pd-viewer .image-nav-btn.desktop-nav:focus-visible { outline: 3px solid #F7B801; outline-offset: 3px; }

    /* Panneau d'informations : largeur fixe, rien n'est coupé */
    #imageZoomModal.pd-viewer .image-name-sidebar {
        width: 300px; min-width: 300px; max-width: 300px; padding: 28px 24px; gap: 14px; box-sizing: border-box;
        justify-content: flex-start; align-items: stretch; overflow-y: auto;
    }
    #imageZoomModal.pd-viewer .image-name-sidebar .sidebar-product-name { font-size: 1.05rem; }
    #imageZoomModal.pd-viewer .image-name-sidebar .sidebar-counter { display: none; }
    #imageZoomModal.pd-viewer #sidebarMeta { margin-top: 6px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.1); }
}
@media (min-width: 769px) and (max-width: 1000px) {
    #imageZoomModal.pd-viewer .image-name-sidebar { width: 240px; min-width: 240px; max-width: 240px; padding: 22px 18px; }
}

/* ── Mobile : mêmes miniatures sous l'image, références centrées ── */
@media (max-width: 768px) {
    #imageZoomModal.pd-viewer .pd-viewer-stage { display: block; }
    #imageZoomModal.pd-viewer .pd-viewer-count { display: none; }
    #imageZoomModal.pd-viewer .pd-viewer-thumbs { gap: 8px; padding: 10px 12px 2px; }
    #imageZoomModal.pd-viewer .pd-viewer-thumb { width: 52px; height: 52px; }
    #imageZoomModal.pd-viewer .image-title-container .pd-meta { align-items: center; margin-top: 6px; }
    #imageZoomModal.pd-viewer .image-title-container .pd-meta-chips { justify-content: center; }
}

/* Une seule photo : pas de flèches mobiles (styles.css impose display:flex!important, ce qui écrasait le masquage fait par le JS) */
#imageZoomModal.pd-viewer .mobile-nav-buttons[style*="display:none"],
#imageZoomModal.pd-viewer .mobile-nav-buttons[style*="display: none"] { display: none !important; }

/* ── Mobile : titre et références plus compacts dans le visualiseur ── */
@media (max-width: 768px) {
    #imageZoomModal.pd-viewer .image-title-container #modalImageName { font-size: .68rem !important; line-height: 1.3; font-weight: 700; }
    #imageZoomModal.pd-viewer .image-title-container #modalImageCounter { font-size: .58rem !important; padding: 1px 7px; }
    #imageZoomModal.pd-viewer .image-title-container .pd-meta { gap: 6px; margin-top: 4px; }
    #imageZoomModal.pd-viewer .image-title-container .pd-meta-label { font-size: .5rem; letter-spacing: .1em; }
    #imageZoomModal.pd-viewer .image-title-container .pd-meta-chips { gap: 4px; margin-top: 3px; }
    #imageZoomModal.pd-viewer .image-title-container .pd-meta-chip { font-size: .6rem; padding: 2px 7px; border-radius: 6px; }
}

/* ── Petits écrans : le cadre laisse la place aux flèches fixes du bas, compteur sur une ligne ── */
@media (max-width: 768px) {
    #imageZoomModal.pd-viewer .image-modal-content { max-height: calc(100vh - 140px); max-height: calc(100dvh - 140px); }
    #imageZoomModal.pd-viewer .image-container {
        width: 100%; height: min(calc(100vw - 44px), calc(100vh - 390px)); height: min(calc(100vw - 44px), calc(100dvh - 390px));
        max-height: none; min-height: 0;
    }
    #imageZoomModal.pd-viewer .image-container .modal-zoom-img,
    #imageZoomModal.pd-viewer .image-container .modal-zoom-img.zoomed { width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; }
    #imageZoomModal.pd-viewer .image-title-container { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px; }
    #imageZoomModal.pd-viewer .image-title-container #modalImageCounter { white-space: nowrap; flex: none; }
    #imageZoomModal.pd-viewer .image-title-container .pd-meta { flex: 1 1 100%; }
}

/* ── Mobile : titre sur UNE ligne, badge « 1 / 4 » en pastille visible au bas de l'image ── */
@media (max-width: 768px) {
    #imageZoomModal.pd-viewer .image-title-container #modalImageName {
        display: block; flex: 1 1 100%; min-width: 0; max-width: 100%; text-align: center;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    /* le compteur n'est plus dans le bloc de titre : il passe sur l'image */
    #imageZoomModal.pd-viewer .image-title-container #modalImageCounter { display: none !important; }
    #imageZoomModal.pd-viewer .pd-viewer-count {
        display: block; top: auto; left: 50%; right: auto; bottom: 10px; transform: translateX(-50%); z-index: 5;
        padding: 4px 12px; font-size: .72rem; font-weight: 800; letter-spacing: .06em; line-height: 1.2; white-space: nowrap;
        color: #fff; background: rgba(0,51,102,.92); border: 1px solid rgba(255,255,255,.75);
        box-shadow: 0 3px 10px rgba(0,0,0,.35);
    }
}

/* ── Mobile : le bloc de titre ne dépasse jamais la largeur du cadre (permet la troncature « … » du titre) ── */
@media (max-width: 768px) {
    #imageZoomModal.pd-viewer .image-title-container { width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; overflow: hidden; flex: none; }
}
