/* ============================================
   Filters Sidebar - Enhanced Modern Design
   ============================================ */

/* Catalog Sidebar Container */
.catalog-sidebar {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 0; /* Remove padding to allow filters-sidebar to fill */
    height: fit-content;
    position: sticky;
    top: 160px;
    overflow: hidden; /* Prevent content overflow */
}

.filters-sidebar {
    background: #ffffff;
    border-radius: 12px;
    padding: 0;
    width: 100%; /* Take full width */
    height: 100%; /* Take full height */
    overflow: visible;
}

/* Sidebar Filter Section */
.sidebar-filter {
    border-bottom: 1px solid #eef2f7;
    padding: 16px 12px;
    transition: all 0.3s ease;
}

.sidebar-filter:first-child {
    border-radius: 12px 12px 0 0; /* Match parent border radius at top */
}

.sidebar-filter:last-child {
    border-bottom: none;
    border-radius: 0 0 12px 12px; /* Match parent border radius at bottom */
}

.sidebar-filter:hover {
    background-color: #fafbfc;
}

/* Filter Title */
/* Filter Title - More Clear and Prominent */
.sidebar-title {
    font-size: 15px; /* Increased from 14px */
    font-weight: 700; /* Increased from 600 to make it bolder */
    color: #0f172a; /* Darker color for better contrast */
    margin: 0 0 16px 0; /* Increased bottom margin from 12px */
    display: flex;
    align-items: center;
    gap: 10px; /* Increased from 8px */
    letter-spacing: -0.3px; /* Slightly more letter spacing */
    text-transform: uppercase; /* Makes it stand out more */
    padding-bottom: 12px; /* Add padding at bottom */
    border-bottom: 2px solid #e5e7eb; /* Add bottom border for separation */
}

.sidebar-title i {
    color: #0066cc;
    font-size: 14px; /* Increased from 13px */
    opacity: 1; /* Increased from 0.8 for more visibility */
}

/* Filter Options Container */
.filter-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: none; /* Show all content */
    overflow: visible;
}

/* Individual Filter Option */
.filter-option {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: transparent;
    border: 1px solid transparent;
    position: relative;
    min-height: 36px; /* Ensure adequate touch target */
}

.filter-option:hover {
    background-color: #f5f8fa;
    border-color: #e1e8ed;
    transform: translateX(2px);
}

.filter-option input[type="checkbox"],
.filter-option input[type="radio"] {
    width: 16px;
    height: 16px;
    margin: 0 10px 0 0;
    cursor: pointer;
    accent-color: #0066cc;
    flex-shrink: 0;
    border-radius: 4px;
}

.filter-option span {
    flex: 1;
    font-size: 13px;
    color: #3e4555;
    display: flex;
    justify-content: space-between;
    align-items: center;
    line-height: 1.4;
    gap: 12px; /* Increased gap to push count further */
    word-break: break-word;
}

/* Type Value Text - Takes available space */
.filter-option span .type_value {
    flex: 1;
    font-weight: bold;
    overflow-wrap: break-word;
    margin: 0;
    text-align: left;
}

.filter-option span .label-text {
    flex: 1;
    overflow-wrap: break-word;
}

/* Count Badge - Smaller and at the very end */
.count {
    background-color: #eef2f7;
    color: #6c7a89;
    padding: 1px 4px; /* Further reduced padding */
    border-radius: 8px; /* Smaller border radius */
    font-size: 10px;
    font-weight: 600;
    margin-left: auto;
    margin-right: -2px; /* Push closer to the right edge */
    flex-shrink: 0;
    min-width: 18px; /* Further reduced minimum width */
    max-width: fit-content; /* Only as wide as needed */
    text-align: center;
    transition: all 0.2s ease;
    align-self: center;
}

.filter-option:hover .count {
    background-color: #dfe6ee;
    color: #4a5568;
}

.filter-option input:checked ~ span .count {
    background-color: #0066cc;
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 102, 204, 0.2);
}

/* Checked State */
.filter-option input:checked ~ span {
    color: #0066cc;
    font-weight: 600;
}

.filter-option:has(input:checked) {
    background-color: #f0f7ff;
    border-color: #b3d9ff;
}

/* Show More/Less Button */
.show-more-btn {
    margin-top: 12px;
    padding: 8px 12px;
    background-color: #f5f7fa;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    color: #0066cc;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    text-align: center;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
}

.show-more-btn:hover {
    background-color: #e8f2ff;
    border-color: #0066cc;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 102, 204, 0.15);
}
.show-more-btn:active {
    transform: translateY(0);
}
.show-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}
.show-more-btn i {
    font-size: 12px;
    transition: transform 0.2s ease;
}

.show-more-btn:hover i {
    transform: translateY(2px);
}
/* Loading Spinner for Show More Button */
.show-more-btn .btn-spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid #e1e8ed;
    border-top: 2px solid #0066cc;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.show-more-btn.loading .btn-spinner {
    display: inline-block;
}
.show-more-btn.loading .show-less-text {
    display: none !important;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.hidden-option {
    display: none !important; /* Changed to none to hide by default */
    animation: fadeIn 0.3s ease;
}

.hidden-option.show {
    display: flex !important; /* Show when toggled */
}
/* Empty State */
.filter-options:empty::after {
    content: 'No filters available';
    color: #9ca3af;
    font-size: 13px;
    font-style: italic;
    padding: 12px;
    display: block;
    text-align: center;
}

/* RTL Support */
[dir="rtl"] .filter-option {
    transform-origin: right;
}

[dir="rtl"] .filter-option:hover {
    transform: translateX(-2px);
}

[dir="rtl"] .filter-option input[type="checkbox"],
[dir="rtl"] .filter-option input[type="radio"] {
    margin: 0 0 0 10px;
}

[dir="rtl"] .filter-option span .type_value {
    text-align: right;
}

[dir="rtl"] .count {
    margin-left: -2px;
    margin-right: auto;
}

/* Scrollbar Styling (for very long lists) */
.filter-options::-webkit-scrollbar {
    width: 6px;
}

.filter-options::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.filter-options::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.filter-options::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Responsive Design */
@media (max-width: 992px) {
    .filters-sidebar {
        border-radius: 10px;
    }

    .sidebar-filter {
        padding: 14px 12px;
    }
}

/* ── Search loading bar ── */
.catalog-main {
    position: relative;
}

.search-loading-bar {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #F6B933 0%, #e9a000 50%, #F6B933 100%);
    background-size: 200% 100%;
    animation: search-bar-slide 1.2s ease-in-out infinite;
    border-radius: 0 0 3px 3px;
    z-index: 10;
}

@keyframes search-bar-slide {
    0%   { background-position: 200% 0; opacity: 1; }
    100% { background-position: -200% 0; opacity: 1; }
}

.catalog-main.is-loading {
    opacity: 0.45;
    pointer-events: none;
    transition: opacity 0.2s;
}

.catalog-sidebar.is-loading {
    opacity: 0.55;
    pointer-events: none;
    transition: opacity 0.2s;
}

@media (max-width: 768px) {
    .filters-sidebar {
        border-radius: 8px;
        box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
    }

    .sidebar-filter {
        padding: 12px 10px;
    }

    .sidebar-title {
        font-size: 13px;
    }

    .filter-option {
        padding: 7px 8px;
        min-height: 34px;
    }

    .filter-option span {
        font-size: 12px;
        gap: 10px;
    }

    .count {
        font-size: 9px;
        padding: 1px 3px;
        min-width: 16px;
    }
}

@media (max-width: 480px) {
    .sidebar-filter {
        padding: 10px 8px;
    }

    .sidebar-title {
        font-size: 12px;
        gap: 6px;
    }

    .sidebar-title i {
        font-size: 11px;
    }

    .filter-option {
        padding: 6px 8px;
    }

    .show-more-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* Animation for expanding/collapsing */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading State */
.filters-sidebar.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.filters-sidebar.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #0066cc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

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

/* Focus States for Accessibility */
.filter-option input:focus-visible {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

.show-more-btn:focus-visible {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .filters-sidebar {
        box-shadow: none;
        border: 1px solid #e1e8ed;
    }

    .show-more-btn {
        display: none;
    }

    .hidden-option {
        display: flex !important;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .filter-option,
    .show-more-btn,
    .sidebar-filter {
        transition: none;
    }
    .filter-option:hover {
        transform: none;
    }
    @keyframes fadeIn {
        from, to {
            opacity: 1;
            transform: none;
        }
    }
}

