/* Category Header Filters */

/* Layout adjustments for no-sidebar */
.category-layout.no-sidebar {
    display: block !important;
    grid-template-columns: 1fr !important;
}

.category-layout.no-sidebar .products-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
}

/* Filter Header Controls */
.filter-header-controls {
    position: static;
    top: 70px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: saturate(140%) blur(6px);
    -webkit-backdrop-filter: saturate(140%) blur(6px);
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 24px;
    border: 1px solid #e9ecef;
    transition: box-shadow 0.2s ease, background 0.2s ease;
}

.filter-header-controls.is-sticky {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.95);
}

.filter-controls-wrapper {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.filter-controls-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px 16px;
    align-items: end;
}

.filter-controls-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    border-top: 1px solid #e9ecef;
    padding-top: 18px;
    margin-top: 40px;
    width: 100%;
}

/* Force ads-style grid for dropdowns on pages that include this header (e.g., Featured Sellers) */
.filter-header-controls .filter-controls-row {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
    gap: 16px 16px !important;
    align-items: end !important;
}

/* Make selects match ads page light style and height */
.filter-header-controls .form-select {
    height: 52px !important;
    padding: 12px 18px !important;
    border: 2px solid #e9ecef !important;
    border-radius: 12px !important;
    background: #fff !important;
    color: #111827 !important;
    font-weight: 500 !important;
}

.filter-header-controls .form-select:hover {
    border-color: #2563eb !important;
    color: #2563eb !important;
    background: rgba(37, 99, 235, 0.05) !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15) !important;
}

.filter-header-controls .form-select:focus {
    outline: none !important;
    border-color: #2563eb !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1) !important;
}

@media (max-width: 992px) {
    .filter-header-controls .form-select {
        height: 44px !important;
        padding: 10px 14px !important;
    }
}

@media (max-width: 768px) {
    .filter-header-controls .form-select {
        height: 40px !important;
        padding: 8px 12px !important;
        font-size: 0.9rem !important;
    }

    /* Stack actions and make buttons equal full width */
    .filter-controls-actions {
        align-items: stretch !important;
        justify-content: center !important;
    }
    .filter-controls-actions .btn-apply-filters,
    .filter-controls-actions .btn-reset-filters {
        width: 100% !important;
        min-width: 0 !important;
        text-align: center !important;
    }
}

.filter-dropdown-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #2d3748;
}

.filter-label i {
    color: #2563eb;
    font-size: 1rem;
}

.filter-select {
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    background: #fff;
    color: #2d3748;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    height: 52px;
}

.filter-select:hover {
    border-color: #2563eb;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.filter-select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Price Range Filter */
.price-range-filter {
    grid-column: span 1;
    max-width: 280px;
}

.price-range-inputs-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.price-input-header {
    flex: 1;
    min-width: 0;
    max-width: 120px;
    padding: 12px 12px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    background: #fff;
    color: #2d3748;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    outline: none;
    transition: all 0.3s ease;
    height: 48px;
}

/* Ensure header buttons are not full-width by default */
.filter-header-controls .btn-apply-filters,
.filter-header-controls .btn-reset-filters {
    width: auto !important;
    flex: 0 0 auto !important;
    align-self: flex-start !important;
}

.price-input-header:hover {
    border-color: #2563eb;
}

.price-input-header:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.price-input-header::placeholder {
    color: #94a3b8;
}

.price-separator {
    color: #64748b;
    font-weight: 600;
}

/* Action Buttons */
.btn-apply-filters,
.btn-reset-filters {
    padding: 12px 28px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
}

/* Focus accessibility ring */
.btn-apply-filters:focus-visible,
.btn-reset-filters:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18), 0 0 0 1px #2563eb;
}

.btn-apply-filters {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    min-width: 180px;
}

.btn-apply-filters:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.btn-apply-filters:active {
    transform: translateY(0);
}

/* Apply button loading/success states */
.btn-apply-filters.loading,
.btn-apply-filters:disabled {
    opacity: 0.8;
    cursor: not-allowed;
}

.btn-apply-filters.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.7);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-apply-filters.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.filter-header-controls .btn-reset-filters {
    background: transparent;
    color: #2563eb !important;
    border: 2px solid rgba(37, 99, 235, 0.6) !important;
    min-width: 120px;
}

.filter-header-controls .btn-reset-filters:hover {
    background: rgba(37, 99, 235, 0.08);
    border-color: #2563eb !important;
    color: #1e40af !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2) !important;
}

.filter-header-controls .btn-reset-filters:active {
    transform: translateY(0) !important;
}

.filter-header-controls .btn-reset-filters:disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Results Header Update */
.results-header {
    margin-bottom: 30px !important;
}

/* Active filter chips */
.filter-active-chips {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 4px;
}

.filter-active-chips .chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-chip,
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    color: #334155;
    transition: all 0.2s ease;
}

.filter-chip:hover,
.chip:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.filter-chip .chip-remove,
.chip .chip-remove {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-weight: 700;
}

.chips-clear-all {
    background: transparent;
    border: none;
    color: #ef4444;
    font-weight: 700;
    cursor: pointer;
}

/* Toast styles */
.filter-toast {
    position: fixed;
    top: 18px;
    right: 18px;
    background: rgba(17, 24, 39, 0.95);
    color: #fff;
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transform: translateY(-8px);
    transition: all 0.25s ease;
    z-index: 2147483000; /* very high to overlay everything */
    font-weight: 700;
    line-height: 1.2;
}

.filter-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.filter-toast.confirm {
    left: 50%;
    right: auto;
    top: 18px;
    transform: translate(-50%, -8px);
    display: flex;
    align-items: center;
    gap: 12px;
}

.filter-toast.confirm .msg { flex: 1; }

.filter-toast.confirm .actions { display: flex; gap: 8px; }

.filter-toast.confirm .confirm {
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    font-weight: 700;
    cursor: pointer;
}

.filter-toast.confirm .cancel {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.35);
    color: #fff;
    border-radius: 8px;
    padding: 8px 12px;
    font-weight: 700;
    cursor: pointer;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .filter-controls-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .filter-controls-row {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Tablet: standardize min-widths */
    .btn-apply-filters,
    .filter-header-controls .btn-reset-filters {
        min-width: 150px;
    }
}

@media (max-width: 768px) {
    .filter-header-controls {
        padding: 16px;
    }

    .filter-controls-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .price-range-filter {
        max-width: 100%;
    }

    .price-input-header {
        max-width: none;
    }

    .btn-apply-filters,
    .btn-reset-filters {
        width: 100%;
        min-width: 0;
    }

    .filter-label {
        font-size: 0.85rem;
    }

    .filter-select,
    .price-input-header {
        padding: 10px 14px;
        font-size: 0.9rem;
    }
}

@media (max-width: 576px) {
    /* Icon-only buttons on small mobile */
    .btn-apply-filters span,
    .btn-reset-filters span {
        display: none;
    }

    .btn-apply-filters,
    .btn-reset-filters {
        padding: 12px 20px;
        justify-content: center;
        width: auto;
        min-width: 0;
    }
}
