/**
 * ADW Sous-catégories Sidebar - Styles avec Accordéon
 */

/* Container principal */
#adw-subcategories-sidebar {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: var(--adw-buttons-radius-small);
    padding: 20px;
    margin-bottom: 30px;
}

/* Titre */
#adw-subcategories-sidebar .category-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #4A4745;
    margin: 0 0 20px 0;
    padding-bottom: 15px;
    border-bottom: 2px solid #E6254F;
}

/* Liste principale */
#adw-subcategories-sidebar .category-tree {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Items de catégorie */
#adw-subcategories-sidebar .category-item {
    margin-bottom: 5px;
    position: relative;
}

#adw-subcategories-sidebar .category-item:last-child {
    margin-bottom: 0;
}

/* Row contenant la flèche et le lien */
#adw-subcategories-sidebar .category-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Bouton toggle (flèche) */
#adw-subcategories-sidebar .category-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
    flex-shrink: 0;
    background: #f0f0f0;
}

#adw-subcategories-sidebar .category-toggle:hover {
    background: #E6254F;
    color: white;
}

/* Icône flèche */
#adw-subcategories-sidebar .toggle-icon {
    transition: transform 0.3s ease;
    color: #666;
}

#adw-subcategories-sidebar .category-toggle:hover .toggle-icon {
    color: white;
}

/* Rotation de la flèche quand ouvert */
#adw-subcategories-sidebar .category-item.open .toggle-icon {
    transform: rotate(90deg);
}

/* Liens de catégorie */
#adw-subcategories-sidebar .category-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    background: #f8f9fa;
    border: 1px solid #e5e5e5;
    border-radius: 5px;
    color: #4A4745;
    text-decoration: none;
    transition: all 0.3s ease;
    font-weight: 500;
    flex: 1;
}

#adw-subcategories-sidebar .category-link:hover {
    background: #E6254F;
    color: white;
    border-color: #E6254F;
}

/* Catégories sans enfants - pas de marge pour la flèche */
#adw-subcategories-sidebar .category-item:not(.has-children) .category-row {
    padding-left: 0;
}

/* Catégories avec enfants */
#adw-subcategories-sidebar .category-item.has-children .category-link {
    /* Le lien prend tout l'espace restant */
}

/* Nom de la catégorie */
#adw-subcategories-sidebar .category-name {
    flex: 1;
}

/* Compteur de produits */
#adw-subcategories-sidebar .category-count {
    font-size: 0.875rem;
    color: #999;
    margin-left: 10px;
}

#adw-subcategories-sidebar .category-link:hover .category-count {
    color: rgba(255, 255, 255, 0.8);
}

/* Sous-catégories de niveau 2 - FERMÉES par défaut */
#adw-subcategories-sidebar .category-sub-tree {
    list-style: none;
    margin: 0;
    padding: 0;
    padding-left: 32px;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease-out;
}

/* Quand ouvert */
#adw-subcategories-sidebar .category-item.open .category-sub-tree {
    margin-top: 8px;
}

#adw-subcategories-sidebar .category-sub-item {
    margin-bottom: 4px;
    position: relative;
}

#adw-subcategories-sidebar .category-sub-item:last-child {
    margin-bottom: 0;
}

/* Ligne verticale pour indiquer la hiérarchie */
#adw-subcategories-sidebar .category-sub-item::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 50%;
    width: 12px;
    height: 1px;
    background: #e5e5e5;
}

/* Liens sous-catégories niveau 2 */
#adw-subcategories-sidebar .category-sub-link {
    display: block;
    padding: 8px 12px;
    color: #666;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    border-radius: 4px;
    background: #fafafa;
    border: 1px solid transparent;
}

#adw-subcategories-sidebar .category-sub-link:hover {
    color: #E6254F;
    background: #fff;
    border-color: #E6254F;
    padding-left: 18px;
}

/* État actif pour sous-catégorie */
#adw-subcategories-sidebar .category-sub-link.active {
    color: #E6254F;
    font-weight: 600;
    border-color: #E6254F;
}

/* Animation d'entrée */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#adw-subcategories-sidebar .category-item {
    animation: slideInLeft 0.3s ease forwards;
}

#adw-subcategories-sidebar .category-item:nth-child(1) { animation-delay: 0.05s; }
#adw-subcategories-sidebar .category-item:nth-child(2) { animation-delay: 0.1s; }
#adw-subcategories-sidebar .category-item:nth-child(3) { animation-delay: 0.15s; }
#adw-subcategories-sidebar .category-item:nth-child(4) { animation-delay: 0.2s; }
#adw-subcategories-sidebar .category-item:nth-child(5) { animation-delay: 0.25s; }

/* Animation des sous-catégories quand elles s'ouvrent */
#adw-subcategories-sidebar .category-item.open .category-sub-item {
    animation: slideInLeft 0.2s ease forwards;
}

#adw-subcategories-sidebar .category-item.open .category-sub-item:nth-child(1) { animation-delay: 0.05s; }
#adw-subcategories-sidebar .category-item.open .category-sub-item:nth-child(2) { animation-delay: 0.1s; }
#adw-subcategories-sidebar .category-item.open .category-sub-item:nth-child(3) { animation-delay: 0.15s; }
#adw-subcategories-sidebar .category-item.open .category-sub-item:nth-child(4) { animation-delay: 0.2s; }
#adw-subcategories-sidebar .category-item.open .category-sub-item:nth-child(5) { animation-delay: 0.25s; }

/* Responsive */
@media (max-width: 767px) {
    #adw-subcategories-sidebar {
        padding: 15px;
        margin-bottom: 20px;
    }

    #adw-subcategories-sidebar .category-title {
        font-size: 1.125rem;
    }

    #adw-subcategories-sidebar .category-link {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    #adw-subcategories-sidebar .category-sub-link {
        font-size: 0.85rem;
        padding: 6px 10px;
    }

    #adw-subcategories-sidebar .category-toggle {
        width: 28px;
        height: 28px;
    }
    
    #adw-subcategories-sidebar .category-sub-tree {
        padding-left: 28px;
    }
}

/* Style alternatif : flèche à droite */
/*
#adw-subcategories-sidebar .category-row {
    flex-direction: row-reverse;
}

#adw-subcategories-sidebar .category-toggle {
    margin-left: auto;
}
*/

/* Indicateur visuel pour catégories avec enfants */
#adw-subcategories-sidebar .category-item.has-children .category-link::after {
    content: none; /* Désactivé car on a la flèche */
}