/**
 * CSS RESPONSIVE AMÉLIORÉ - ELZZA FASHION
 * Correction de l'affichage des produits sur laptop et tous écrans
 */

/* ==================== VARIABLES CSS ==================== */
:root {
    --grid-gap-mobile: 16px;
    --grid-gap-tablet: 20px;
    --grid-gap-laptop: 24px;
    --grid-gap-desktop: 28px;
    
    --card-min-width-mobile: 280px;
    --card-min-width-tablet: 240px;
    --card-min-width-laptop: 260px;
    --card-min-width-desktop: 280px;
}

/* ==================== GRILLES RESPONSIVE PRINCIPALES ==================== */

/* Mobile First - Base */
.products-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--grid-gap-mobile);
    margin-bottom: 40px;
    width: 100%;
}

/* Mobile Small (max 480px) */
@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: var(--grid-gap-mobile);
        padding: 0 10px;
    }
}

/* Mobile Large / Phablet (481px - 576px) */
@media (min-width: 481px) and (max-width: 576px) {
    .products-grid {
        grid-template-columns: repeat(auto-fit, minmax(var(--card-min-width-mobile), 1fr));
        gap: var(--grid-gap-mobile);
    }
}

/* Tablet Portrait (577px - 768px) */
@media (min-width: 577px) and (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--grid-gap-tablet);
        max-width: 600px;
        margin: 0 auto 40px;
    }
}

/* Tablet Landscape (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--grid-gap-tablet);
        max-width: 900px;
        margin: 0 auto 40px;
    }
}

/* Laptop / Small Desktop (1025px - 1366px) - CORRECTION PRINCIPALE */
@media (min-width: 1025px) and (max-width: 1366px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: var(--grid-gap-laptop);
        max-width: 1200px;
        margin: 0 auto 40px;
    }
    
    .container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 20px;
    }
}

/* Large Desktop (1367px - 1600px) */
@media (min-width: 1367px) and (max-width: 1600px) {
    .products-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: var(--grid-gap-desktop);
        max-width: 1400px;
        margin: 0 auto 40px;
    }
}

/* Extra Large Screens (1601px+) */
@media (min-width: 1601px) {
    .products-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: var(--grid-gap-desktop);
        max-width: 1600px;
        margin: 0 auto 40px;
    }
}

/* ==================== CARTES PRODUITS AMÉLIORÉES ==================== */

.product-card {
    background: var(--white);
    border-radius: var(--radius-large);
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    border: 1px solid var(--border-color);
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    border-color: var(--primary-color);
}

/* Image container avec ratio fixe et optimisé */
.product-image {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.4s ease;
    background: var(--white);
}

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

/* Badges repositionnés et stylisés */
.product-badges {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.badge {
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

.badge-new {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: var(--white);
}

.badge-bestseller {
    background: linear-gradient(135deg, #ffc107, #fd7e14);
    color: var(--white);
}

.badge-sale {
    background: linear-gradient(135deg, #dc3545, #e83e8c);
    color: var(--white);
}

/* Actions produit repositionnées */
.product-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.3s ease;
    z-index: 3;
}

.product-card:hover .product-actions {
    opacity: 1;
    transform: translateX(0);
}

.action-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.95);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0,0,0,0.1);
}

.action-btn:hover {
    background: var(--primary-color);
    color: var(--white);
    transform: scale(1.1);
}

.whatsapp-btn:hover {
    background: #25D366;
}

/* Informations produit améliorées */
.product-info {
    padding: 20px 16px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
}

.product-category {
    margin-bottom: 6px;
}

.product-category a {
    font-size: 0.8rem;
    color: var(--text-light);
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: 0.8px;
    text-decoration: none;
    transition: color 0.3s ease;
}

.product-category a:hover {
    color: var(--primary-color);
}

.product-name {
    margin-bottom: 12px;
    font-size: 1rem;
    line-height: 1.4;
    font-weight: 600;
    color: var(--text-primary);
}

.product-name-link {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s ease;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-name-link:hover {
    color: var(--primary-color);
}

/* Prix améliorés */
.product-price {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.price-current {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.price-original {
    font-size: 0.95rem;
    color: var(--text-light);
    text-decoration: line-through;
}

/* Boutons d'action */
.product-buttons {
    margin-top: auto;
    display: flex;
    gap: 8px;
}

.btn-add-cart {
    flex: 1;
    padding: 12px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-medium);
    transition: all 0.3s ease;
}

.btn-whatsapp {
    padding: 12px 14px;
    font-size: 0.9rem;
    min-width: auto;
    border-radius: var(--radius-medium);
}

/* ==================== GRILLES SPÉCIFIQUES PAR PAGE ==================== */

/* Page d'accueil - Sections spéciales */
.hero-categories {
    display: grid;
    gap: 24px;
    margin: 40px 0;
}

@media (max-width: 768px) {
    .hero-categories {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .hero-categories {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1025px) {
    .hero-categories {
        grid-template-columns: repeat(3, 1fr);
        max-width: 1200px;
        margin: 40px auto;
    }
}

/* Produits vedettes sur la page d'accueil */
.featured-products .products-grid {
    max-width: 1200px;
    margin: 0 auto 40px;
}

@media (min-width: 1025px) {
    .featured-products .products-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Nouveautés et bestsellers */
.new-arrivals .products-grid,
.best-sellers .products-grid {
    max-width: 900px;
    margin: 0 auto 40px;
}

@media (min-width: 769px) {
    .new-arrivals .products-grid,
    .best-sellers .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==================== GRILLES EN MODE LISTE ==================== */

.products-grid.list-view {
    grid-template-columns: 1fr;
    gap: 20px;
}

.products-grid.list-view .product-card {
    display: grid;
    grid-template-columns: 200px 1fr auto;
    gap: 20px;
    align-items: center;
    height: auto;
    min-height: 200px;
}

@media (max-width: 768px) {
    .products-grid.list-view .product-card {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .products-grid.list-view .product-image {
        width: 100%;
        aspect-ratio: 16/9;
    }
}

/* ==================== SIDEBAR RESPONSIVE ==================== */

.catalog-content {
    display: grid;
    gap: 30px;
    margin-bottom: 40px;
}

@media (min-width: 993px) {
    .catalog-content {
        grid-template-columns: 280px 1fr;
        gap: 40px;
        max-width: 1400px;
        margin: 0 auto 40px;
    }
}

@media (max-width: 992px) {
    .catalog-content {
        grid-template-columns: 1fr;
    }
    
    .catalog-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 320px;
        height: 100vh;
        z-index: 1001;
        background: var(--white);
        transition: left 0.3s ease;
        overflow-y: auto;
        padding: 20px;
        box-shadow: 2px 0 20px rgba(0,0,0,0.1);
    }
    
    .catalog-sidebar.active {
        left: 0;
    }
    
    .filter-toggle {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 12px 20px;
        background: var(--primary-color);
        color: var(--white);
        border: none;
        border-radius: var(--radius-medium);
        font-weight: 600;
        cursor: pointer;
        margin-bottom: 20px;
        transition: background 0.3s ease;
    }
    
    .filter-toggle:hover {
        background: var(--primary-dark);
    }
}

/* ==================== AMÉLIORATIONS SPÉCIFIQUES ==================== */

/* Collections grid pour pages catégories */
.collections-grid,
.subcategories-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 40px;
}

@media (max-width: 576px) {
    .collections-grid,
    .subcategories-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 577px) and (max-width: 768px) {
    .collections-grid,
    .subcategories-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .collections-grid,
    .subcategories-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1025px) {
    .collections-grid,
    .subcategories-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Hero sections responsive */
.hero-content {
    display: grid;
    gap: 30px;
    align-items: center;
    padding: 40px 0;
}

@media (max-width: 768px) {
    .hero-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 20px;
        padding: 30px 0;
    }
    
    .hero-promises {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}

@media (min-width: 769px) {
    .hero-content {
        grid-template-columns: 1fr 1fr;
    }
    
    .hero-promises {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

/* ==================== ANIMATIONS ET TRANSITIONS ==================== */

/* Animation d'apparition pour les cartes */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.product-card {
    animation: fadeInUp 0.6s ease-out;
    animation-fill-mode: both;
}

/* Délai d'animation pour un effet cascade */
.product-card:nth-child(1) { animation-delay: 0.1s; }
.product-card:nth-child(2) { animation-delay: 0.2s; }
.product-card:nth-child(3) { animation-delay: 0.3s; }
.product-card:nth-child(4) { animation-delay: 0.4s; }
.product-card:nth-child(5) { animation-delay: 0.5s; }
.product-card:nth-child(6) { animation-delay: 0.6s; }

/* ==================== OPTIMISATIONS PERFORMANCE ==================== */

.product-card {
    will-change: transform;
    contain: layout style paint;
}

.product-image img {
    will-change: transform;
}

/* Réduction des animations sur les appareils avec préférences de mouvement réduit */
@media (prefers-reduced-motion: reduce) {
    .product-card,
    .product-image img,
    .action-btn {
        animation: none;
        transition: none;
    }
    
    .product-card:hover {
        transform: none;
    }
    
    .product-card:hover .product-image img {
        transform: none;
    }
}

/* ==================== STYLES POUR CHARGEMENT D'IMAGES ==================== */

.product-image {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

.product-image img {
    transition: opacity 0.3s ease;
}

.product-image img[data-loaded="true"] {
    opacity: 1;
}

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

.product-image img:not([src]),
.product-image img[src=""],
.product-image img[src*="placeholder"] {
    opacity: 0;
}

/* ==================== CORRECTIONS SPÉCIFIQUES ==================== */

/* Fix pour les images manquantes */
.product-image img[onerror] {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border: 2px dashed #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 2rem;
}

/* Amélioration de la lisibilité */
.product-name-link {
    word-break: break-word;
    hyphens: auto;
}

/* Espacements cohérents */
.container {
    padding-left: clamp(16px, 4vw, 40px);
    padding-right: clamp(16px, 4vw, 40px);
}

@media (min-width: 1200px) {
    .container {
        max-width: 1200px;
        margin: 0 auto;
    }
}

/* ==================== ÉTATS SPÉCIAUX ==================== */

/* Produits en rupture de stock */
.product-card.out-of-stock {
    opacity: 0.7;
}

.product-card.out-of-stock .product-image::after {
    content: "Épuisé";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    z-index: 2;
}

/* Focus pour l'accessibilité */
.product-card:focus-within {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.action-btn:focus,
.btn-add-cart:focus,
.btn-whatsapp:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}