/**
 * CSS pour shortcodes marques - Design épuré
 * CSS Grid fixe + filtres AJAX
 * 
 * @package Woodmart Child
 * @version 1.0
 */

/* ==========================================================================
   VARIABLES CSS
   ========================================================================== */
:root {
    --brand-primary: #0000;
    --brand-secondary: #F09837;
    --brand-text: #000000;
    --brand-border: #ddd;
    --brand-radius: 8px;
    --brand-transition: all 0.3s ease;
    --brand-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    --brand-hover-shadow: 0 8px 25px rgba(240, 152, 55, 0.15);
}

/* ==========================================================================
   CSS GRID - CATÉGORIES HIÉRARCHIQUES
   ========================================================================== */
.brand-categories-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-gap: 20px;
    margin-bottom: 30px;
    padding: 20px 0;
}

/* ==========================================================================
   CARDS CATÉGORIES
   ========================================================================== */
.category-card {
    background: white;
    border: 1px solid var(--brand-border);
    border-radius: var(--brand-radius);
    overflow: hidden;
    transition: var(--brand-transition);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    min-height: 160px;
    position: relative;
}

.category-card:hover {
    border-color: var(--brand-secondary);
    box-shadow: var(--brand-hover-shadow);
    transform: translateY(-3px);
}

/* Catégorie parente - Style distinctif */
.category-card.category-parent {
    border-color: var(--brand-primary);
    border-width: 3px;
    background: #f8f9fa;
}


.category-card.category-parent:hover {
    background: var(--brand-secondary);
    color: white;
    transform: translateY(-5px) scale(1.02);
}

.category-card.category-parent:hover .category-name,
.category-card.category-parent:hover .product-count {
    color: white;
}

.category-card.category-parent:hover::before {
    background: rgba(255, 255, 255, 0.2);
}

/* Sous-catégories expandables (niveau 1 avec enfants niveau 2) */
.category-card.category-child-expandable {
    border-color: #e0e0e0;
    background: white;
    position: relative;
}

.category-card.category-child-expandable::before {
    content: '+';
    position: absolute;
    top: 8px;
    right: 8px;
    background: #3498db;
    color: white;
    font-size: 16px;
    font-weight: bold;
    padding: 4px 11px;
    border-radius: 100px;
    letter-spacing: 0.5px;
    z-index: 2;
}

.category-card.category-child-expandable:hover::before {
    background: var(--brand-secondary);
}

/* ==========================================================================
   SOUS-SOUS-CATÉGORIES NIVEAU 2
   ========================================================================== */
.subcategories-level2 {
    grid-column: 1 / -1; /* Prend toute la largeur de la grille */
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: var(--brand-radius);
    padding: 20px;
    margin-top: 20px;
    animation: slideDown 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.level2-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 15px;
}

.close-level2 {
    background: var(--brand-text);
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: var(--brand-transition);
    line-height: 1;
}

.close-level2:hover {
    background: var(--brand-secondary);
    transform: scale(1.1);
}

.level2-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.level2-category {
    background: white;
    border: 1px solid var(--brand-border);
    border-radius: var(--brand-radius);
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: var(--brand-transition);
    min-width: 120px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.level2-category:hover {
    border-color: var(--brand-secondary);
    box-shadow: var(--brand-hover-shadow);
    transform: translateY(-2px);
}

.level2-category img {
    max-width: 40px;
    max-height: 40px;
    object-fit: contain;
    margin-bottom: 8px;
    border-radius: 4px;
}

.level2-category .category-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--brand-primary);
    margin-bottom: 4px;
}

.level2-category .product-count {
    font-size: 11px;
    color: #7f8c8d;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* État actif après clic */
.category-card.active {
    border-color: var(--brand-secondary);
    background: #fff8f0;
    box-shadow: var(--brand-hover-shadow);
}

.category-card.category-parent.active {
    background: var(--brand-secondary);
    color: white;
}

.category-card.active .category-name {
    color: var(--brand-secondary);
    font-weight: bold;
}

.category-card.category-parent.active .category-name,
.category-card.category-parent.active .product-count {
    color: white;
}

/* ==========================================================================
   CONTENU DES CARDS
   ========================================================================== */
.category-link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    padding: 15px;
    text-align: center;
    height: 100%;
    box-sizing: border-box;
    cursor: pointer;
}

.category-image {
    flex: 0 0 auto;
    margin-bottom: 12px;
    height: 70px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.category-image img {
    max-width: 60px;
    max-height: 60px;
    object-fit: contain;
    border-radius: 6px;
    transition: var(--brand-transition);
}

.category-card:hover .category-image img {
    transform: scale(1.1);
}

.category-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

.category-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--brand-primary);
    margin: 0 0 6px 0;
    line-height: 1.2;
    transition: var(--brand-transition);
}

.category-card.category-parent .category-name {
    font-size: 16px;
    font-weight: bold;
}

.product-count {
    color: #7f8c8d;
    font-size: 12px;
    font-weight: 400;
    transition: var(--brand-transition);
}

/* ==========================================================================
   BOUTON RESET FILTRES
   ========================================================================== */
.reset-filter {
    display: inline-block;
    background: var(--brand-primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--brand-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 30px;
    transition: var(--brand-transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.reset-filter:hover {
    background: var(--brand-secondary);
    transform: translateY(-2px);
    box-shadow: var(--brand-shadow);
}

/* ==========================================================================
   GRILLE DE PRODUITS
   ========================================================================== */
#brand-products-container {
    margin-top: 20px;
}

.brand-products-shortcode {
    width: 100%;
}

.brand-products-shortcode .woocommerce {
    margin: 0;
}

.brand-products-shortcode .products {
    display: grid !important;
    gap: 20px;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none;
}

/* Colonnes selon les attributs */
.brand-products-shortcode.columns-2 .products {
    grid-template-columns: repeat(2, 1fr);
}

.brand-products-shortcode.columns-3 .products {
    grid-template-columns: repeat(3, 1fr);
}

.brand-products-shortcode.columns-4 .products {
    grid-template-columns: repeat(4, 1fr);
}

.brand-products-shortcode.columns-5 .products {
    grid-template-columns: repeat(5, 1fr);
}

.brand-products-shortcode .product {
    margin: 0 !important;
    border: 1px solid var(--brand-border);
    border-radius: var(--brand-radius);
    overflow: hidden;
    transition: var(--brand-transition);
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.brand-products-shortcode .product:hover {
    border-color: var(--brand-secondary);
    box-shadow: var(--brand-hover-shadow);
    transform: translateY(-3px);
}

/* ==========================================================================
   ÉTATS DE CHARGEMENT ET MESSAGES
   ========================================================================== */
.loading {
    text-align: center;
    padding: 40px 20px;
    color: #7f8c8d;
    font-style: italic;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: var(--brand-radius);
}

.loading::after {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--brand-secondary);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

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

.no-products,
.no-categories,
.error {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    padding: 30px 20px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: var(--brand-radius);
    margin: 20px 0;
}

.error {
    color: #e74c3c;
    background: #fdf2f2;
    border-color: #f5c6cb;
}

/* ==========================================================================
   ANIMATIONS D'APPARITION
   ========================================================================== */
.category-card {
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

.category-card[style*="grid-area: 1"] { animation-delay: 0.1s; }
.category-card[style*="/ 2 /"] { animation-delay: 0.15s; }
.category-card[style*="/ 3 /"] { animation-delay: 0.2s; }
.category-card[style*="/ 4 /"] { animation-delay: 0.25s; }
.category-card[style*="/ 5 /"] { animation-delay: 0.3s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

/* Tablette */
@media (max-width: 1024px) {
    .brand-categories-grid {
        grid-template-columns: repeat(4, 1fr);
        grid-gap: 15px;
    }
    
    .category-card {
        min-height: 140px;
    }
    
    .category-name {
        font-size: 14px;
    }
    
    .category-card.category-parent .category-name {
        font-size: 15px;
    }
    
    .brand-products-shortcode.columns-5 .products,
    .brand-products-shortcode.columns-4 .products {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mobile */
@media (max-width: 768px) {
    .brand-categories-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-gap: 12px;
    }
    
    .category-card {
        min-height: 120px;
    }
    
    .category-link {
        padding: 12px;
    }
    
    .category-image {
        height: 50px;
        margin-bottom: 8px;
    }
    
    .category-image img {
        max-width: 45px;
        max-height: 45px;
    }
    
    .category-name {
        font-size: 13px;
        line-height: 1.1;
    }
    
    .category-card.category-parent .category-name {
        font-size: 14px;
    }
    
    .category-card::before {
        font-size: 8px;
        padding: 3px 6px;
        top: 6px;
        right: 6px;
    }
    
    .product-count {
        font-size: 11px;
    }
    
    .brand-products-shortcode.columns-5 .products,
    .brand-products-shortcode.columns-4 .products,
    .brand-products-shortcode.columns-3 .products {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .reset-filter {
        padding: 10px 20px;
        font-size: 13px;
    }
}

/* Mobile très petit */
@media (max-width: 480px) {
    .brand-categories-grid {
        grid-template-columns: 1fr;
        grid-gap: 10px;
    }
    
    .category-card {
        min-height: 100px;
    }
    
    .brand-products-shortcode .products {
        grid-template-columns: 1fr !important;
    }
}

/* ==========================================================================
   COMPATIBILITÉ ELEMENTOR
   ========================================================================== */
.elementor-widget-shortcode .brand-categories-grid,
.elementor-widget-shortcode #brand-products-container {
    max-width: 100%;
}

.elementor-section .brand-categories-grid *,
.elementor-section .brand-products-shortcode * {
    box-sizing: border-box;
}

/* ==========================================================================
   ACCESSIBILITÉ
   ========================================================================== */
.category-link:focus {
    outline: 2px solid var(--brand-secondary);
    outline-offset: 2px;
}

.reset-filter:focus {
    outline: 2px solid var(--brand-secondary);
    outline-offset: 2px;
}

/* Réduction des mouvements */
@media (prefers-reduced-motion: reduce) {
    .category-card,
    .category-image img,
    .reset-filter {
        animation: none !important;
        transition: none !important;
    }
    
    .category-card:hover,
    .reset-filter:hover {
        transform: none !important;
    }
}