/* ============================================
   GESTION DES IMAGES
   Placeholders, lazy loading, gestion d'erreurs
   ============================================ */

/* Image avec placeholder */
.img-wrapper {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 100%; /* Ratio 1:1 par défaut */
    overflow: hidden;
    background-color: var(--gray-100);
    border-radius: var(--radius-md);
}

.img-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity var(--transition-base);
}

/* Placeholder pendant le chargement */
.img-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        var(--gray-200) 0%, 
        var(--gray-100) 50%, 
        var(--gray-200) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    z-index: 1;
}

.img-wrapper img.loaded {
    opacity: 1;
    z-index: 2;
}

.img-wrapper img:not(.loaded) {
    opacity: 0;
}

/* Animation shimmer pour le placeholder */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Image avec icône de chargement */
.img-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--gray-100);
    color: var(--gray-400);
}

.img-loading::after {
    content: '📷';
    font-size: 2rem;
    opacity: 0.5;
}

/* Gestion des erreurs d'image */
.img-error {
    background-color: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
}

.img-error::after {
    content: 'Image non disponible';
    font-size: var(--text-sm);
    color: var(--gray-500);
    text-align: center;
    padding: var(--spacing-4);
}

/* Lazy loading */
img[loading="lazy"] {
    opacity: 1 !important; /* Forcer l'opacité à 1 pour les images lazy */
    transition: opacity var(--transition-base);
}

img[loading="lazy"].loaded {
    opacity: 1 !important;
}

/* Images responsives */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Ratios d'aspect personnalisés */
.img-wrapper-16-9 {
    padding-bottom: 56.25%; /* 16:9 */
}

.img-wrapper-4-3 {
    padding-bottom: 75%; /* 4:3 */
}

.img-wrapper-3-2 {
    padding-bottom: 66.67%; /* 3:2 */
}

/* Optimisation pour les cartes produits */
.product-card-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background-color: var(--gray-100);
    border-radius: var(--radius-md);
}

/* Supprimer le fond gris sur les produits de décoration dans index.html */
#featuredProductsGrid2 .product-card-image-wrapper {
    background-color: transparent !important;
}

/* Supprimer le fond gris sur TOUTES les pages catégories */
.products-grid .product-card-image-wrapper,
.products-grid .product-card .product-card-image-wrapper,
.products-grid .product-card-large .product-card-image-wrapper {
    background-color: transparent !important;
    background: transparent !important;
    border-radius: 0 !important;
}

.product-card-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.product-card:hover .product-card-image-wrapper img {
    transform: scale(1.05);
}

/* Image avec overlay pour les erreurs */
.img-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.img-wrapper:hover .img-overlay {
    opacity: 1;
}


