/**
 * Modern Professional Category Filter Styles
 * Enhanced UI for category filtering with modern design principles
 */

/* === Main Card Styling === */
.modern-category-filter-card {
    border: none;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.98);
}

.modern-category-filter-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1) !important;
}

/* === Header Styling === */
.modern-gradient-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
}

.modern-gradient-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255,255,255,0.1) 0%, transparent 100%);
    pointer-events: none;
}

.header-actions .badge {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    border-radius: 50px;
}

/* === Search Container === */
.category-search-container {
    background: linear-gradient(to bottom, #f8f9fa, #ffffff);
}

.category-search-container .input-group-text {
    border: 1px solid #e9ecef;
    border-right: none;
}

.category-search-container .form-control {
    border: 1px solid #e9ecef;
    border-left: none;
    transition: all 0.2s ease;
}

.category-search-container .form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.15);
}

/* === Category Items === */
.category-filter-content {
    max-height: 500px;
    overflow-y: auto;
}

/* Webkit browsers (Chrome, Safari, Edge) - Primary support */
.category-filter-content::-webkit-scrollbar {
    width: 6px;
}

.category-filter-content::-webkit-scrollbar-track {
    background: #f7fafc;
}

.category-filter-content::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.category-filter-content::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Firefox - Progressive enhancement */
@supports (scrollbar-width: thin) {
    .category-filter-content {
        scrollbar-width: thin;
        scrollbar-color: #cbd5e0 #f7fafc;
    }
}

/* === Modern Category Item === */
.modern-category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 1px solid #f1f5f9;
    position: relative;
    background: white;
}

.modern-category-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: transparent;
    transition: all 0.3s ease;
}

.modern-category-item:hover {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    transform: translateX(4px);
}

.modern-category-item:hover::before {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.modern-category-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateX(4px);
}

.modern-category-item.active::before {
    background: #ffffff;
}

.modern-category-item.active .category-count {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

.modern-category-item.active .expand-icon {
    color: white;
}

/* === Category Content Layout === */
.category-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.category-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    transition: all 0.3s ease;
}

.modern-category-item:hover .category-icon-wrapper {
    background: linear-gradient(135deg, #667eea, #764ba2);
    transform: scale(1.1);
}

.modern-category-item.active .category-icon-wrapper {
    background: rgba(255, 255, 255, 0.2);
}

.category-emoji {
    font-size: 1.2rem;
    line-height: 1;
}

.category-icon {
    font-size: 1rem;
    color: #64748b;
    transition: all 0.3s ease;
}

.modern-category-item:hover .category-icon,
.modern-category-item.active .category-icon {
    color: white;
}

.category-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.category-name {
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.2;
    color: #1e293b;
    transition: color 0.3s ease;
}

.modern-category-item.active .category-name {
    color: white;
}

.subcategory-hint {
    font-size: 0.75rem;
    color: #64748b;
    transition: color 0.3s ease;
}

.modern-category-item.active .subcategory-hint {
    color: rgba(255, 255, 255, 0.8);
}

/* === Category Meta === */
.category-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-count {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35em 0.65em;
    border-radius: 50px;
    transition: all 0.3s ease;
}

.expand-icon {
    font-size: 0.8rem;
    color: #64748b;
    transition: all 0.3s ease;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.expand-icon:hover {
    background-color: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.modern-category-item.expanded .expand-icon {
    transform: rotate(180deg);
    color: #667eea;
}

.category-meta {
    cursor: pointer;
}

/* === Children Container === */
.children-container {
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.children-container.hidden {
    max-height: 0;
    opacity: 0;
}

.children-container:not(.hidden) {
    max-height: 500px;
    opacity: 1;
}

.children-wrapper {
    padding: 8px 0;
    border-top: 1px solid #e2e8f0;
}

/* === Subcategory Items === */
.modern-subcategory-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px 12px 60px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.modern-subcategory-item::before {
    content: '';
    position: absolute;
    left: 40px;
    top: 50%;
    width: 12px;
    height: 1px;
    background: #cbd5e0;
    transform: translateY(-50%);
}

.modern-subcategory-item:hover {
    background: rgba(102, 126, 234, 0.05);
    transform: translateX(4px);
}

.modern-subcategory-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.modern-subcategory-item.active .category-count {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

.subcategory-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.subcategory-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
}

.modern-subcategory-item:hover .subcategory-icon-wrapper {
    background: rgba(102, 126, 234, 0.2);
}

.modern-subcategory-item.active .subcategory-icon-wrapper {
    background: rgba(255, 255, 255, 0.2);
}

.subcategory-name {
    font-weight: 500;
    font-size: 0.85rem;
    color: #475569;
    transition: color 0.3s ease;
}

.modern-subcategory-item.active .subcategory-name {
    color: white;
}

/* === No Results State === */
.no-categories-found {
    animation: fadeIn 0.3s ease;
}

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

/* === Responsive Design === */
@media (max-width: 768px) {
    .modern-category-item {
        padding: 14px 16px;
    }

    .category-icon-wrapper {
        width: 36px;
        height: 36px;
    }

    .modern-subcategory-item {
        padding: 10px 16px 10px 52px;
    }

    .category-filter-content {
        max-height: 400px;
    }
}

/* === Loading States === */
.category-filter-container.loading {
    position: relative;
    pointer-events: none;
}

.category-filter-container.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: 100;
}

.category-filter-container.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 101;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* === Enhanced Accessibility === */
.modern-category-item:focus,
.modern-subcategory-item:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.modern-category-item[aria-expanded="true"] .expand-icon {
    transform: rotate(180deg);
}

/* === Category Statistics === */
.category-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 4px;
}

.category-stats .stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.category-stats .stat-icon {
    font-size: 0.7rem;
}

/* === Enhanced Badges === */
.category-count.updated {
    animation: countUpdate 0.4s ease;
}

@keyframes countUpdate {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); background-color: #10b981; }
    100% { transform: scale(1); }
}

.category-count.zero {
    opacity: 0.5;
    background-color: #e5e7eb !important;
    color: #9ca3af !important;
}

/* === Search Highlighting === */
.search-highlight {
    background: linear-gradient(120deg, #fef3c7 0%, #fde68a 100%);
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 600;
}

/* === Animation Classes === */
.category-item-enter {
    animation: slideInUp 0.3s ease forwards;
}

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

.category-item-exit {
    animation: slideOutDown 0.3s ease forwards;
}

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

/* === Pulse Animation for Active Items === */
.modern-category-item.active {
    animation: activePulse 2s ease-in-out infinite;
}

@keyframes activePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(102, 126, 234, 0); }
}

/* === Improved Scrollbar === */
.category-filter-content::-webkit-scrollbar {
    width: 8px;
}

.category-filter-content::-webkit-scrollbar-track {
    background: #f8fafc;
    border-radius: 4px;
}

.category-filter-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #cbd5e0, #a0aec0);
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}

.category-filter-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #a0aec0, #718096);
}
