/**
 * AJAX Product Filter Styles
 * 
 * @package Cargozen
 */

/* Loading Indicator */
.cargozen-loading-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    background: #f9f9f9;
    border-radius: 8px;
}

.cargozen-loading-spinner {
    text-align: center;
}

.cargozen-loading-spinner .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.cargozen-loading-spinner p {
    color: #666;
    margin: 0;
    font-size: 14px;
}

/* Filter Categories Widget */
.cargozen-product-filter {
    background: #fff;
    /* border: 1px solid #e1e1e1; */
    border-radius: 8px;
    /* padding: 20px; */
    margin-bottom: 30px;
}

.cargozen-product-filter h3 {
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.cargozen-filter-categories {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cargozen-filter-categories li {
    margin-bottom: 5px;
    position: relative;
}

/* Hierarchical styles */
.cargozen-filter-categories.hierarchical .cat-item {
    position: relative;
}

.cargozen-filter-categories .cat-item-all {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

/* Category Toggle Button */
.category-toggle {
    background: none;
    border: none;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    transition: all 0.3s ease;
    border-radius: 3px;
    margin-left: auto;
    flex-shrink: 0;
}

.category-toggle:hover {
    background: #f0f0f0;
    color: #333;
}

/* Icon mặc định: mũi tên trái < (fa-chevron-left) */
.category-toggle i {
    font-size: 12px;
    transition: transform 0.3s ease;
    transform: rotate(0deg); /* Mặc định: mũi tên trái < */
}

/* Khi expand: quay 90 độ thành mũi tên xuống v */
.category-toggle[aria-expanded="true"] i {
    transform: rotate(90deg); /* Quay từ < thành v */
}

/* Children categories */
.cargozen-filter-categories .children {
    display: none;
    padding-left: 15px;
    margin-left: 10px;
    margin-top: 5px;
}

.cargozen-filter-categories .children.expanded {
    display: block;
}

/* Category Link Styles */
.cargozen-filter-category {
    display: flex;
    background-color: #f8f9fa;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 5px;
    color: #666;
    text-decoration: none;
    border-radius: 5px;
    transition: all 0.3s ease;
    cursor: pointer;
    width: 100%;
    gap: 10px;
}

/* Category Image */
.category-image {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    overflow: hidden;
    background: #f5f5f5;
}

.category-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.category-image-default {
    background: #e1e1e1;
    color: #999;
    font-size: 12px;
}

/* Category Info */
.category-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    gap: 8px;
}

.category-name {
    flex: 1;
    font-weight: 500;
}

.category-count {
    background: rgba(0,0,0,0.1);
    color: inherit;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
}

.cargozen-filter-category:hover {
    background-color: rgb(223, 246, 255);
    color: #333;
    text-decoration: none;
}

.cargozen-filter-category.active,
.current-cat > .cargozen-filter-category {
    background-color: var(--primary-color, #007cba);
    color: #fff;
}

.current-cat-ancestor > .cargozen-filter-category {
    background-color: rgba(0, 124, 186, 0.1);
    color: var(--primary-color, #007cba);
    font-weight: 500;
}

.cargozen-filter-category.active .category-count,
.current-cat > .cargozen-filter-category .category-count {
    background: rgba(255,255,255,0.2);
}

.cargozen-filter-category.active .category-image-default,
.current-cat > .cargozen-filter-category .category-image-default {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* Children Categories */
.cargozen-filter-categories .children {
    list-style: none;
    margin: 0;
    padding: 0;
    margin-left: 35px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.cargozen-filter-categories .children.expanded {
    max-height: 1000px; /* Large enough value */
}

.cargozen-filter-categories .children li {
    margin-bottom: 3px;
}

.cargozen-filter-categories .children .cargozen-filter-category {
    padding: 8px 12px;
    font-size: 14px;
    border-left: 2px solid #eee;
}

.cargozen-filter-categories .children .current-cat > .cargozen-filter-category {
    border-left-color: var(--primary-color, #007cba);
}

.cargozen-filter-categories .children .category-image {
    width: 20px;
    height: 20px;
}

/* Nested children */
.cargozen-filter-categories .children .children {
    margin-left: 30px;
}

.cargozen-filter-categories .children .children .cargozen-filter-category {
    font-size: 13px;
    padding: 6px 12px;
    border-left-color: #ddd;
}

.cargozen-filter-categories .children .children .category-image {
    width: 18px;
    height: 18px;
}

/* Loading States */
.cargozen-filter-loader {
    position: relative;
    text-align: center;
    padding: 40px 20px;
    background: rgba(255,255,255,0.9);
    border-radius: 8px;
    margin-bottom: 20px;
}

.loader-spinner {
    display: inline-block;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color, #007cba);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader-spinner p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

/* Products Container Loading State */
.products-container.loading {
    opacity: 0.6;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Results Count */
.cargozen-results-count {
    margin-bottom: 20px;
    color: #666;
    font-size: 14px;
}

/* Pagination Styles */
.cargozen-pagination {
    margin-top: 40px;
    text-align: center;
}

.cargozen-pagination .page-numbers {
    display: inline-block;
    padding: 8px 12px;
    margin: 0 3px;
    color: #666;
    text-decoration: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.cargozen-pagination .page-numbers:hover,
.cargozen-pagination .page-numbers.current {
    background-color: var(--primary-color, #007cba);
    color: #fff;
    border-color: var(--primary-color, #007cba);
}

.cargozen-pagination .page-numbers.prev,
.cargozen-pagination .page-numbers.next {
    font-weight: bold;
}

/* Error States */
.filter-error {
    text-align: center;
    padding: 40px 20px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    margin-bottom: 20px;
}

.no-products-found {
    text-align: center;
    padding: 40px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
}

.no-products-found p {
    margin: 0;
    color: #666;
    font-size: 16px;
}

/* Products Grid Wrapper */
.products-grid-wrapper {
    position: relative;
}

/* Responsive Design */
@media (max-width: 768px) {
    .cargozen-product-filter {
        padding: 15px;
    }
    
    .cargozen-filter-category {
        padding: 8px 10px;
        font-size: 14px;
        gap: 8px;
    }
    
    .category-image {
        width: 20px;
        height: 20px;
    }
    
    .category-toggle {
        width: 18px;
        height: 18px;
        font-size: 11px;
    }
    
    .cargozen-filter-categories .children {
        margin-left: 25px;
    }
    
    .cargozen-filter-categories .children .children {
        margin-left: 20px;
    }
    
    .cargozen-filter-categories .children .category-image {
        width: 18px;
        height: 18px;
    }
    
    .cargozen-filter-categories .children .children .category-image {
        width: 16px;
        height: 16px;
    }
    
    .cargozen-pagination .page-numbers {
        padding: 6px 10px;
        font-size: 14px;
    }
}

/* Animation for smooth transitions */
.products-container {
    transition: opacity 0.3s ease;
}

.cargozen-filter-category {
    transform: translateX(0);
    transition: all 0.3s ease;
}

/* .cargozen-filter-category:hover {
    transform: translateX(2px);
} */

/* Custom scrollbar for filter list if needed */
.cargozen-filter-categories {
    /* max-height: 300px; */
    overflow-y: auto;
}

.cargozen-filter-categories::-webkit-scrollbar {
    width: 6px;
}

.cargozen-filter-categories::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.cargozen-filter-categories::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.cargozen-filter-categories::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* No Products Found Message */
.no-products-found {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    padding: 40px 20px;
    text-align: center;
    background: #f9f9f9;
    border-radius: 8px;
    margin: 20px 0;
}

.no-products-message {
    max-width: 400px;
}

.no-products-message i {
    display: block;
    margin: 0 auto 20px;
    font-size: 48px !important;
    color: #ddd !important;
}

.no-products-message h3 {
    color: #666;
    font-size: 24px;
    margin: 0 0 15px 0;
    font-weight: 600;
}

.no-products-message p {
    color: #999;
    font-size: 16px;
    margin: 0 0 20px 0;
    line-height: 1.5;
}

.no-products-message a {
    display: inline-block;
    color: #007cba !important;
    text-decoration: none !important;
    font-weight: 500;
    padding: 8px 16px;
    border: 2px solid #007cba;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.no-products-message a:hover {
    background: #007cba;
    color: white !important;
    transform: translateY(-1px);
}

/* Fallback container styles */
.cargozen-products-container {
    margin: 20px 0;
}

.products-grid-container {
    min-height: 200px;
}
