/* ========== 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); }
}
