/* استایل‌های دسته‌بندی چند سطحی */

/* Category Tree Container */
.category-tree {
    padding: 0;
    margin: 0;
    list-style: none; /* اضافه شد */
    width: 100%; /* اضافه شد */
}

/* Category Item */
.category-item {
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #f0f0f0;
    width: 100%; /* اضافه شد برای اطمینان از عرض کامل */
    display: block; /* اضافه شد */
    clear: both; /* اضافه شد */
}

.category-item:last-child {
    border-bottom: none;
}

/* Category Wrapper */
.category-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    width: 100%; /* اضافه شد برای اطمینان از عرض کامل */
}

/* Category Link */
.category-link {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    color: #4a5568;
    text-decoration: none;
    transition: all 0.3s ease;
    border-radius: 8px;
    margin: 0;
}

.category-link:hover {
    background-color: #f7fafc;
    color: #0da487;
    transform: translateX(-3px);
}

.category-link.active {
    background-color: #0da487;
    color: #fff;
    font-weight: 600;
}

.category-link.active .category-icon {
    filter: brightness(0) invert(1);
}

/* Category Name */
.category-name {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 500;
}

/* Category Icon */
.category-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    margin-right: 0.5rem;
}

/* Category Toggle Button */
.category-toggle {
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: none;
    color: #718096;
    cursor: pointer;
    transition: color 0.3s ease; /* فقط رنگ تغییر کند نه rotation */
    margin-left: 0.5rem;
    flex-shrink: 0; /* جلوگیری از فشرده شدن دکمه */
}

.category-toggle:hover {
    color: #0da487;
    /* حذف transform: rotate(180deg); */
}

.category-toggle i {
    font-size: 0.875rem;
    transition: transform 0.3s ease;
    display: inline-block; /* برای اعمال transform */
}

/* فقط وقتی دکمه کلیک شده و باز است، آیکون چرخش پیدا کند */
.category-toggle[aria-expanded="true"] i {
    transform: rotate(180deg);
}

/* Sub Category List */
.sub-category-list {
    padding-right: 1.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    border-right: 2px solid #e2e8f0;
    width: 100%; /* اضافه شد */
    display: block; /* اضافه شد */
}

.sub-category-list .category-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

.sub-category-list .category-icon {
    width: 20px;
    height: 20px;
}

/* Third Level Categories */
.sub-category-list .sub-category-list {
    padding-right: 1rem;
    border-right: 2px solid #edf2f7;
}

.sub-category-list .sub-category-list .category-link {
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
}

/* Collapse Animation */
.category-children {
    overflow: hidden;
    transition: all 0.3s ease-in-out;
    width: 100%; /* اضافه شد */
    display: block; /* اضافه شد */
    clear: both; /* اضافه شد */
}

.category-children.collapsing {
    transition: height 0.3s ease;
}

/* Accordion Customization */
.custom-accordion .accordion-button {
    background-color: #f7fafc;
    color: #2d3748;
    font-weight: 600;
    padding: 1rem 1.25rem;
    border-radius: 8px;
}

.custom-accordion .accordion-button:not(.collapsed) {
    background-color: #0da487;
    color: #fff;
    box-shadow: none;
}

.custom-accordion .accordion-button:focus {
    box-shadow: none;
    border-color: transparent;
}

.custom-accordion .accordion-button::after {
    margin-right: auto;
    margin-left: 0;
}

.custom-accordion .accordion-body {
    padding: 1rem 0.5rem;
}

.custom-accordion .accordion-item {
    border: none;
    margin-bottom: 1rem;
}

/* Responsive Design */
@media (max-width: 991px) {
    .category-link {
        padding: 0.6rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .sub-category-list {
        padding-right: 1rem;
    }
    
    .category-icon {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 576px) {
    .category-link {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
    
    .category-name {
        font-size: 0.85rem;
    }
    
    .sub-category-list {
        padding-right: 0.75rem;
    }
}

/* Loading State */
.category-tree.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Empty State */
.category-tree .text-muted {
    padding: 1rem;
    text-align: center;
    color: #a0aec0;
    font-style: italic;
}

/* Hover Effects for Better UX */
.category-item:hover .category-toggle {
    opacity: 1;
}

.category-toggle {
    opacity: 0.7;
}

/* Active Category Highlight */
.category-item.active-parent > .category-wrapper > .category-link {
    background-color: #f7f7f7;
    color: #0da487;
    font-weight: 600;
    border-radius: 8px !important;
}

/* Smooth Transitions */
* {
    transition: background-color 0.2s ease, color 0.2s ease;
}

