/* =========================================
   SEARCH & FILTER LAYOUT (2-COLUMN)
========================================= */
.bfai-search-container {
    margin-top: 80px !important;
    padding-top: 40px !important;
    padding-bottom: 80px !important;
}

.search-layout-2col {
    display: grid;
    /* Fixed 320px Sidebar / Remaining fluid Content split */
    grid-template-columns: 320px 1fr;
    gap: var(--space-8);
    align-items: start;
}

@media (min-width: 1400px) {
    .search-layout-2col {
        grid-template-columns: 280px 1fr;
    }
}

/* Base Mobile Overrides */
.mobile-filter-header,
.mobile-filter-toggle-wrapper {
    display: none;
}

/* Mobile Filter Drawer System */
@media (max-width: 992px) {
    .search-layout-2col {
        grid-template-columns: 1fr;
    }

    /* Off-Canvas Wrapper */
    .search-sidebar-wrapper {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 85%;
        max-width: 360px;
        background: var(--bg-base);
        z-index: 1000;
        transform: translateX(0);
        transition: left 0.3s ease-in-out;
        display: flex;
        flex-direction: column;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }

    [data-theme="light"] .search-sidebar-wrapper {
        background: #ffffff;
        box-shadow: 5px 0 20px rgba(0, 0, 0, 0.1);
    }

    .search-sidebar-wrapper.is-open {
        left: 0;
    }

    /* Fixed Height internally scrollable filter wrapper */
    .sidebar-sticky-container {
        position: static;
        flex: 1;
        overflow-y: auto;
        padding-bottom: var(--space-8);
        -webkit-overflow-scrolling: touch;
    }

    .filter-sidebar-premium {
        border: none;
        box-shadow: none;
        padding: var(--space-4);
        background: transparent;
    }

    /* Mobile Headers and Triggers */
    .mobile-filter-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: var(--space-4) var(--space-6);
        border-bottom: 1px solid var(--border-subtle);
        background: var(--surface-1);
        position: sticky;
        top: 0;
        z-index: 10;
    }

    [data-theme="light"] .mobile-filter-header {
        background: #f8fafc;
        border-color: #e2e8f0;
    }

    .mobile-filter-header h4 {
        margin: 0;
        font-size: var(--text-lg);
        color: var(--text-primary);
    }

    .btn-close-filters {
        background: transparent;
        border: none;
        color: var(--text-secondary);
        cursor: pointer;
        padding: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        transition: all 0.2s;
    }

    .btn-close-filters:hover {
        background: var(--surface-2);
        color: var(--text-primary);
    }

    .mobile-filter-toggle-wrapper {
        display: block;
        margin-bottom: var(--space-6);
    }

    .btn-mobile-filter {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: var(--space-3) var(--space-4);
        background: var(--surface-2);
        border: 1px solid var(--border-subtle);
        color: var(--text-primary);
        font-size: var(--text-sm);
        font-weight: var(--weight-medium);
        border-radius: 12px;
        cursor: pointer;
        transition: all 0.2s;
    }

    [data-theme="light"] .btn-mobile-filter {
        background: #ffffff;
        border-color: #e2e8f0;
    }

    .btn-mobile-filter:hover {
        background: var(--surface-3);
        border-color: var(--brand-primary);
        color: var(--brand-primary);
    }
}

/* Mobile Dark Backdrop */
.mobile-filter-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

[data-theme="light"] .mobile-filter-overlay {
    background: rgba(255, 255, 255, 0.3);
}

.mobile-filter-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* Main Content Grid */
.search-main-content .bfai-tool-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    /* Enforce 3 columns on desktop explicitly */
    gap: var(--space-6);
}

@media (max-width: 768px) {
    .search-main-content .bfai-tool-grid {
        grid-template-columns: 1fr;
    }
}

/* Sidebar Standard Layout (Non-Sticky) */
.sidebar-sticky-container {
    position: relative;
    /* Removed sticky and scroll behavior per user request */
}

/* Premium Sidebar Styling */
.filter-sidebar-premium {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
}

[data-theme="light"] .filter-sidebar-premium {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.filter-sidebar-premium .sidebar-section {
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-6);
    border-bottom: 1px solid var(--border-subtle);
}

.filter-sidebar-premium .sidebar-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.filter-sidebar-premium .sidebar-title {
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-4);
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.sidebar-header-icon {
    color: var(--brand-primary);
    opacity: 0.9;
}

/* Filter Options & Hierarchy */
.filter-hierarchy-group {
    margin-bottom: var(--space-2);
}

.parent-category-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
}

.parent-category-link,
.child-category-link,
a.filter-option {
    display: flex;
    align-items: center;
    padding: var(--space-2) var(--space-3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    text-decoration: none;
    flex: 1;
}

.parent-category-link:hover,
.child-category-link:hover,
a.filter-option:hover {
    background: var(--surface-2);
}

[data-theme="light"] .parent-category-link:hover,
[data-theme="light"] .child-category-link:hover,
[data-theme="light"] a.filter-option:hover {
    background: #f1f5f9;
}

/* Base Active Backgrounds */
.child-category-link.active,
a.filter-option.active {
    background: rgba(var(--brand-primary-rgb, 124, 58, 237), 0.1);
}

/* Category Accent Colors */
.parent-category-row.active .parent-category-link,
.parent-category-link:hover {
    background: rgba(var(--category-accent, 255, 255, 255), 0.1);
}

[data-theme="light"] .parent-category-row.active .parent-category-link,
[data-theme="light"] .parent-category-link:hover {
    background: rgba(var(--category-accent, 0, 0, 0), 0.05);
}

/* Filter Specific Icons */
.filter-icon {
    margin-right: var(--space-2);
    color: var(--text-muted);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
}

/* Hover and Active states for generic filters */
a.filter-option:hover .filter-icon {
    color: var(--brand-primary);
    transform: scale(1.1);
}

a.filter-option.active .filter-icon {
    color: var(--brand-primary);
}

/* Accent states for categories */
.parent-category-link:hover .filter-icon,
.parent-category-row.active .parent-category-link .filter-icon,
.child-category-link:hover .filter-icon,
.child-category-link.active .filter-icon {
    color: rgb(var(--category-accent, 255, 255, 255));
    transform: scale(1.1);
}

/* Specific taxonomy icon colors on active/hover */
a.filter-option[data-tax="tool_pricing"]:hover .filter-icon,
a.filter-option[data-tax="tool_pricing"].active .filter-icon {
    color: var(--state-success);
}

a.filter-option[data-tax="tool_status"]:hover .filter-icon,
a.filter-option[data-tax="tool_status"].active .filter-icon {
    color: var(--state-warning);
}

.filter-label {
    flex: 1;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Slide animation on hover */
.parent-category-link:hover .filter-label,
.child-category-link:hover .filter-label,
a.filter-option:hover .filter-label {
    color: var(--text-primary);
    transform: translateX(4px);
}

.parent-category-row.active .filter-label,
.child-category-link.active .filter-label,
a.filter-option.active .filter-label {
    color: var(--text-primary);
    font-weight: var(--weight-medium);
}

/* Subcategory Toggle Chevron */
.btn-toggle-subcats {
    background: transparent;
    border: none;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    margin-left: 2px;
}

.btn-toggle-subcats:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

.filter-hierarchy-group.is-expanded .btn-toggle-subcats svg {
    transform: rotate(180deg);
}

/* Scrollable Fixed-Height Subcategories */
.filter-children-scroll-wrapper {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.filter-hierarchy-group.is-expanded .filter-children-scroll-wrapper {
    max-height: 250px;
    /* Fixed height for scrollable children */
}

.filter-children-group {
    padding-left: var(--space-4);
    margin-top: var(--space-1);
    margin-bottom: var(--space-2);
    padding-bottom: var(--space-1);
    max-height: 250px;
    overflow-y: auto;
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--border-subtle) transparent;
}

.filter-children-group::-webkit-scrollbar {
    width: 4px;
}

.filter-children-group::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 4px;
}

.filter-count {
    font-size: var(--text-xs);
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 2px 8px;
    border-radius: 12px;
}

[data-theme="light"] .filter-count {
    background: #f1f5f9;
    color: #64748b;
}

.filter-option.active .filter-count {
    background: var(--brand-primary);
    color: #ffffff;
}

/* Children Indentation */
.filter-children-group {
    padding-left: var(--space-6);
    margin-top: 2px;
    border-left: 1px solid var(--border-subtle);
    margin-left: 14px;
}

/* Show More Button */
.btn-show-more-cats {
    width: 100%;
    margin-top: var(--space-4);
    font-size: var(--text-xs);
    justify-content: center;
}

/* Active Filters Header Box */
.active-filters-box {
    background: rgba(var(--brand-primary-rgb, 124, 58, 237), 0.05);
    /* Adjust opacity for subtle glow */
    border: 1px solid rgba(var(--brand-primary-rgb, 124, 58, 237), 0.2);
    border-radius: 12px;
    padding: var(--space-4) !important;
}

.active-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.active-filters-title {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--brand-primary);
}

.btn-clear-all {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s ease;
}

.btn-clear-all:hover {
    color: var(--state-danger);
}

/* Submit CTA Box inside Sidebar */
.sidebar-cta-box {
    text-align: center;
    background: var(--surface-2);
    padding: var(--space-6);
    border-radius: 12px;
    border: 1px dashed var(--border-subtle);
}

[data-theme="light"] .sidebar-cta-box {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.sidebar-cta-box .cta-icon {
    stroke: var(--brand-primary);
    stroke-width: 1.5px;
    margin-bottom: var(--space-4);
}

.sidebar-cta-box h4 {
    font-size: var(--text-base);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.sidebar-cta-box p {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: var(--space-4);
}

/* Empty State Styling */
.no-results-premium-glass {
    text-align: center;
    padding: var(--space-16) var(--space-6);
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: 24px;
    box-shadow: var(--shadow-md);
    margin-top: var(--space-8);
    position: relative;
    overflow: hidden;
}

[data-theme="light"] .no-results-premium-glass {
    background: #ffffff;
    border-color: #e2e8f0;
}

.no-results-premium-glass::before {
    content: '';
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 250px;
    height: 100px;
    background: rgba(var(--brand-primary-rgb, 124, 58, 237), 0.3);
    filter: blur(60px);
    z-index: 0;
}

.empty-state-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    color: var(--brand-primary);
    margin-bottom: var(--space-6);
    position: relative;
    z-index: 1;
}

[data-theme="light"] .empty-state-icon {
    background: #f1f5f9;
}

.no-results-premium-glass h3 {
    font-size: var(--text-3xl);
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    margin-bottom: var(--space-4);
    position: relative;
    z-index: 1;
    letter-spacing: -0.02em;
}

.no-results-premium-glass p {
    font-size: var(--text-base);
    color: var(--text-secondary);
    margin-bottom: var(--space-8);
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    z-index: 1;
    line-height: 1.6;
}

.no-results-premium-glass .btn-primary {
    position: relative;
    z-index: 1;
}

