/* Optimisations pour l'affichage des photos de produits */

/* Variables CSS pour la cohérence */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --shadow-light: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-medium: 0 4px 15px rgba(0,0,0,0.1);
    --shadow-heavy: 0 8px 25px rgba(0,0,0,0.15);
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

/* Galeries de produits - Version desktop */
.product-gallery-thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
    justify-content: center;
}

.product-gallery-thumbnails-mobile {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    justify-content: center;
}

/* Éléments de miniature */
.thumbnail-item, .thumbnail-item-mobile {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: var(--shadow-light);
    transition: var(--transition);
    cursor: pointer;
}

.thumbnail-item:hover, .thumbnail-item-mobile:hover {
    box-shadow: var(--shadow-heavy);
    transform: translateY(-2px);
}

.thumbnail-item img, .thumbnail-item-mobile img {
    border-radius: 8px;
    object-fit: cover;
    transition: var(--transition);
}

.thumbnail-item:hover img, .thumbnail-item-mobile:hover img {
    transform: scale(1.05);
}

/* Image principale du produit */
.photoAlbum {
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    transition: var(--transition);
    max-width: 100%;
    height: auto;
}

.photoAlbum:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-heavy);
}

/* Cartes de produits */
.product-card {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-medium);
    transition: var(--transition);
    background: white;
    margin-bottom: 20px;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-heavy);
}

.product-image-container {
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.product-image-container img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: var(--transition);
}

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

/* Overlay pour les actions sur les produits */
.product-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.product-card:hover .product-overlay {
    opacity: 1;
}

.product-actions {
    text-align: center;
}

.preview-btn {
    background: rgba(255,255,255,0.9);
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-weight: 600;
    transition: var(--transition);
    color: #333;
}

.preview-btn:hover {
    background: white;
    transform: scale(1.05);
}

/* Corps des cartes */
.card-body {
    padding: 20px;
}

.cardtitle {
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
}

/* Boutons d'action */
.btnChoix {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border: none;
    border-radius: 25px;
    padding: 10px 20px;
    color: white;
    font-weight: 600;
    transition: var(--transition);
    margin-top: 10px;
    cursor: pointer;
}

.btnChoix:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Animation de chargement */
.loading-placeholder {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Indicateur de chargement pour les images */
.image-loading {
    position: relative;
    background: #f0f0f0;
    border-radius: 8px;
}

.image-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #ccc;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Optimisations responsive */
@media (max-width: 768px) {
    .product-gallery-thumbnails {
        gap: 6px;
    }
    
    .thumbnail-item {
        flex: 0 0 calc(25% - 6px);
    }
    
    .thumbnail-item-mobile {
        flex: 0 0 calc(20% - 6px);
    }
    
    .product-image-container img {
        height: 150px;
    }
    
    .card-body {
        padding: 15px;
    }
    
    .photoAlbum {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .thumbnail-item {
        flex: 0 0 calc(33.333% - 6px);
    }
    
    .thumbnail-item-mobile {
        flex: 0 0 calc(25% - 6px);
    }
    
    .product-gallery-thumbnails {
        gap: 4px;
    }
    
    .product-gallery-thumbnails-mobile {
        gap: 4px;
    }
}

/* Améliorations pour l'accessibilité */
.thumbnail-item:focus,
.thumbnail-item-mobile:focus,
.product-card:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Support pour les préférences de mouvement réduit */
@media (prefers-reduced-motion: reduce) {
    .thumbnail-item,
    .thumbnail-item-mobile,
    .product-card,
    .photoAlbum,
    .btnChoix,
    .preview-btn {
        transition: none;
    }
    
    .thumbnail-item:hover,
    .thumbnail-item-mobile:hover,
    .product-card:hover {
        transform: none;
    }
}

/* Mode sombre (si supporté) */
@media (prefers-color-scheme: dark) {
    .product-card {
        background: #2d2d2d;
        color: #fff;
    }
    
    .cardtitle {
        color: #fff;
    }
    
    .loading-placeholder {
        background: linear-gradient(90deg, #404040 25%, #505050 50%, #404040 75%);
    }
}

/* Optimisations pour les performances */
.product-card,
.thumbnail-item,
.thumbnail-item-mobile {
    will-change: transform;
}

/* Styles pour les images en cours de chargement */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* Amélioration des transitions d'images */
.image-transition {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.image-transition.loading {
    opacity: 0.7;
    transform: scale(0.95);
}

.image-transition.loaded {
    opacity: 1;
    transform: scale(1);
}
