/* Products Filter Styles */
.products-filter-section {
    background: transparent;
    padding: clamp(16px, 4vw, 24px) 0;
    border-bottom: none;
}

/* Mobile Filter Toggle Button */
.mobile-filter-toggle {
    display: none;
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #ff6600 0%, #e65c00 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    box-shadow: 0 4px 12px rgba(255, 102, 0, 0.25);
    transition: all 0.3s ease;
}

.mobile-filter-toggle:active {
    transform: scale(0.98);
}

.mobile-filter-toggle .toggle-icon {
    transition: transform 0.3s ease;
}

.mobile-filter-toggle[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
}

@media (max-width: 768px) {
    .mobile-filter-toggle {
        display: flex;
    }
    
    /* Hide by default on mobile */
    .products-filter-form,
    .mobile-filter-content {
        display: none !important;
        animation: slideDown 0.3s ease-out;
    }
    
    /* Show when toggled */
    .products-filter-form.show {
        display: block !important;
    }
    
    .mobile-filter-content.show {
        display: flex !important;
    }
}

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

.products-filter-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(16px, 4vw, 24px);
}

.products-filter-form {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: clamp(20px, 5vw, 28px);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.06),
        0 2px 8px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
}

.products-filter-form::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255, 102, 0, 0.4), transparent);
    border-radius: 16px 16px 0 0;
}

/* Search Row */
.filter-search-row {
    margin-bottom: clamp(20px, 5vw, 24px);
}

.filter-search-wrapper {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.filter-search-field {
    width: 100%;
    padding: 18px 24px 18px 56px;
    border: 2px solid transparent;
    border-radius: 14px;
    font-size: clamp(15px, 3.5vw, 17px);
    font-weight: 500;
    color: #1e293b;
    background: 
        linear-gradient(white, white) padding-box,
        linear-gradient(135deg, #e2e8f0, #cbd5e1) border-box;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    box-sizing: border-box;
}

.filter-search-field::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.filter-search-field:focus {
    border-color: #ff6600;
    box-shadow: 
        0 0 0 4px rgba(255, 102, 0, 0.12),
        0 6px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.filter-search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    font-size: 18px;
    pointer-events: none;
    transition: color 0.3s ease;
}

.filter-search-field:focus + .filter-search-icon {
    color: #ff6600;
}

/* Search submit button (hidden on desktop, shown on mobile inside input) */
.filter-search-submit-btn {
    display: none;
}

/* Options Row */
.filter-options-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: clamp(16px, 4vw, 20px);
    margin-bottom: clamp(20px, 5vw, 24px);
}

.filter-item-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-item-label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.filter-dropdown-select {
    padding: 16px 20px;
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: clamp(14px, 3.5vw, 15px);
    font-weight: 500;
    color: #1e293b;
    background: 
        linear-gradient(white, white) padding-box,
        linear-gradient(135deg, #e2e8f0, #cbd5e1) border-box;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    box-sizing: border-box;
    outline: none;
}

.filter-dropdown-select:focus {
    border-color: #ff6600;
    box-shadow: 
        0 0 0 4px rgba(255, 102, 0, 0.12),
        0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23ff6600' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.filter-dropdown-select:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* Dropdown wrapper for custom checkbox dropdowns */
.filter-dropdown {
    position: relative;
}

.filter-dropdown-btn {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    background: linear-gradient(white, white) padding-box, linear-gradient(135deg, #e2e8f0, #cbd5e1) border-box;
    border: 2px solid transparent;
    color: #1e293b;
    font-weight: 600;
    cursor: pointer;
    box-sizing: border-box;
}

.filter-dropdown-btn i {
    margin-left: 8px;
    color: #64748b;
}

.filter-dropdown-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    max-width: 420px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(2,6,23,0.12);
    padding: 12px;
    /* Place dropdown above product cards and most site overlays */
    z-index: 13000;
    display: none;
}

.filter-dropdown-panel .filter-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@media (max-width: 639px) {
    .filter-dropdown-panel { position: static; box-shadow: none; padding: 8px 0; max-width: none; }
}

/* Styled checkboxes for condition filter (match dropdown look) */
.filter-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.filter-checkbox-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px 10px 42px;
    border-radius: 12px;
    background: linear-gradient(white, white) padding-box, linear-gradient(135deg, #e2e8f0, #cbd5e1) border-box;
    border: 1px solid rgba(203, 213, 225, 0.8);
    color: #1e293b;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.4,0,0.2,1);
    user-select: none;
}

.filter-checkbox-item input[type="checkbox"] {
    position: absolute;
    left: 14px;
    width: 20px;
    height: 20px;
    margin: 0;
    z-index: 2;
    opacity: 0; /* visually hide native checkbox but keep accessible */
}

.filter-checkbox-item span {
    display: inline-block;
}

.filter-checkbox-item::before {
    content: '';
    position: absolute;
    left: 14px;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid rgba(100,116,139,0.25);
    background: white;
    box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset;
    transition: all 0.12s ease;
}

/* Checked visual — use :has() when available */
@supports(selector(:has(*))) {
    .filter-checkboxes label:has(input:checked) {
        background: linear-gradient(135deg, #ff6600 0%, #e65c00 100%);
        color: white;
        border-color: rgba(255,102,0,0.6);
        box-shadow: 0 6px 18px rgba(230, 92, 0, 0.18);
    }
    .filter-checkboxes label:has(input:checked)::before {
        border-color: rgba(255,255,255,0.0);
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: center;
        background-size: 12px 12px;
        background-color: rgba(255,255,255,0.08);
    }
}

/* Fallback class applied by JS for browsers without :has() */
.filter-checkbox-item.checked {
    background: linear-gradient(135deg, #ff6600 0%, #e65c00 100%);
    color: white;
    border-color: rgba(255,102,0,0.6);
    box-shadow: 0 6px 18px rgba(230, 92, 0, 0.18);
}
.filter-checkbox-item.checked::before {
    border-color: rgba(255,255,255,0.0);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 12px 12px;
    background-color: rgba(255,255,255,0.08);
}

.filter-checkbox-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0,0,0,0.06);
}

/* Price Group */
.filter-price-group {
    min-width: 240px;
}

.filter-price-range {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filter-price-field {
    flex: 1;
    padding: 16px 18px;
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: clamp(14px, 3.5vw, 15px);
    font-weight: 500;
    color: #1e293b;
    background: 
        linear-gradient(white, white) padding-box,
        linear-gradient(135deg, #e2e8f0, #cbd5e1) border-box;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    box-sizing: border-box;
    min-width: 0;
}

.filter-price-field::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.filter-price-field:focus {
    border-color: #ff6600;
    box-shadow: 
        0 0 0 4px rgba(255, 102, 0, 0.12),
        0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.filter-price-separator {
    color: #64748b;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

/* Actions Row */
.filter-actions-row {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-submit-btn,
.filter-reset-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 16px 28px;
    border-radius: 12px;
    font-size: clamp(14px, 3.5vw, 15px);
    font-weight: 600;
    letter-spacing: 0.025em;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    position: relative;
    overflow: hidden;
    min-width: 140px;
    justify-content: center;
    outline: none;
}

.filter-submit-btn::before,
.filter-reset-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.filter-submit-btn:hover::before,
.filter-reset-btn:hover::before {
    left: 100%;
}

/* Submit Button */
.filter-submit-btn {
    background: linear-gradient(135deg, #ff6600 0%, #e65c00 100%);
    color: white;
    box-shadow: 
        0 4px 14px rgba(255, 102, 0, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.1);
}

.filter-submit-btn:hover {
    background: linear-gradient(135deg, #e65c00 0%, #cc5200 100%);
    transform: translateY(-3px);
    box-shadow: 
        0 8px 20px rgba(255, 102, 0, 0.4),
        0 4px 8px rgba(0, 0, 0, 0.15);
}

.filter-submit-btn:active {
    transform: translateY(-1px);
}

/* Reset Button */
.filter-reset-btn {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    color: white;
    box-shadow: 
        0 4px 14px rgba(100, 116, 139, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.1);
}

.filter-reset-btn:hover {
    background: linear-gradient(135deg, #475569 0%, #334155 100%);
    transform: translateY(-3px);
    box-shadow: 
        0 8px 20px rgba(100, 116, 139, 0.4),
        0 4px 8px rgba(0, 0, 0, 0.15);
}

.filter-reset-btn:active {
    transform: translateY(-1px);
}

/* Button Icons */
.filter-submit-btn i,
.filter-reset-btn i {
    font-size: 14px;
    transition: transform 0.3s ease;
}

.filter-submit-btn:hover i,
.filter-reset-btn:hover i {
    transform: scale(1.1);
}

/* Results Info */
.filter-results-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 16px 20px;
    background: rgba(248, 250, 252, 0.7);
    border-radius: 12px;
    border: 1px solid rgba(226, 232, 240, 0.5);
    flex-wrap: wrap;
    gap: 12px;
}

.filter-results-count {
    font-size: clamp(14px, 3.5vw, 16px);
    color: #1e293b;
    font-weight: 600;
}

.filter-clear-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #64748b;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.filter-clear-link:hover {
    color: #ff6600;
    background-color: rgba(255, 102, 0, 0.1);
}

.filter-clear-link i {
    font-size: 13px;
}

/* Responsive Design */
@media (max-width: 639px) {
    .products-filter-container {
        padding: 0 12px;
    }
    
    .products-filter-form {
        border-radius: 12px;
        padding: 16px;
    }
    
    .filter-search-field,
    .filter-dropdown-select,
    .filter-price-field {
        font-size: 16px; /* Prevents iOS zoom */
        padding: 18px 20px;
    }
    
    .filter-search-field {
        padding-left: 50px;
        padding-right: 60px; /* Место для кнопки */
    }
    
    .filter-search-icon {
        display: none; /* Скрываем иконку на мобильном */
    }
    
    .filter-search-submit-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        right: 6px;
        top: 50%;
        transform: translateY(-50%);
        width: 48px;
        height: calc(100% - 12px);
        background: linear-gradient(135deg, #ff6600, #e65c00);
        border: none;
        border-radius: 10px;
        color: white;
        font-size: 18px;
        cursor: pointer;
        transition: all 0.3s ease;
        box-shadow: 0 2px 8px rgba(255, 102, 0, 0.3);
    }
    
    .filter-search-submit-btn:hover {
        background: linear-gradient(135deg, #ff7700, #f06d00);
        box-shadow: 0 4px 12px rgba(255, 102, 0, 0.4);
    }
    
    .filter-search-submit-btn:active {
        transform: translateY(-50%) scale(0.95);
    }
    
    .filter-options-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .filter-price-range {
        flex-direction: column;
        gap: 10px;
    }
    
    .filter-price-separator {
        display: none;
    }
    
    .filter-actions-row {
        flex-direction: column;
        gap: 12px;
    }
    
    .filter-submit-btn,
    .filter-reset-btn {
        width: 100%;
        padding: 18px 24px;
        font-size: 16px;
    }
    
    .filter-results-info {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 12px;
    }
}

@media (min-width: 640px) and (max-width: 1023px) {
    .filter-options-row {
        grid-template-columns: 1fr 1fr;
    }
    
    .filter-price-group {
        grid-column: 1 / -1;
        max-width: 300px;
        justify-self: center;
    }
}

@media (min-width: 1024px) {
    .filter-options-row {
        grid-template-columns: 1fr 1fr 1fr 1fr;
    }
    
    .filter-price-group {
        min-width: 220px;
    }
}

@media (min-width: 1280px) {
    .filter-options-row {
        grid-template-columns: 1.2fr 1fr 1fr 1fr;
        gap: 24px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .products-filter-section {
        background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
        border-bottom-color: rgba(71, 85, 105, 0.4);
    }
    
    .products-filter-form {
        background: rgba(30, 41, 59, 0.95);
        border-color: rgba(255, 255, 255, 0.08);
    }
    
    .products-filter-form::before {
        background: linear-gradient(90deg, transparent, rgba(255, 102, 0, 0.6), transparent);
    }
    
    .filter-search-field,
    .filter-dropdown-select,
    .filter-price-field {
        background: 
            linear-gradient(#334155, #334155) padding-box,
            linear-gradient(135deg, #475569, #64748b) border-box;
        color: #f8fafc;
    }
    
    .filter-search-field::placeholder,
    .filter-price-field::placeholder {
        color: #94a3b8;
    }
    
    .filter-item-label {
        color: #cbd5e1;
    }
    
    .filter-search-icon {
        color: #94a3b8;
    }
    
    .filter-search-field:focus + .filter-search-icon {
        color: #ff6600;
    }
    
    .filter-price-separator {
        color: #94a3b8;
    }
    
    .filter-results-info {
        background: rgba(15, 23, 42, 0.7);
        border-color: rgba(71, 85, 105, 0.4);
    }
    
    .filter-results-count {
        color: #f8fafc;
    }
    
    .filter-clear-link {
        color: #94a3b8;
    }
    
    .filter-clear-link:hover {
        color: #ff6600;
        background-color: rgba(255, 102, 0, 0.2);
    }
}

/* Loading State */
.products-filter-form.loading {
    opacity: 0.7;
    pointer-events: none;
}

.products-filter-form.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border: 3px solid #f3f4f6;
    border-top: 3px solid #dc2626;
    border-radius: 50%;
    animation: filterSpin 1s linear infinite;
    z-index: 10;
}

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

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .products-filter-form,
    .filter-search-field,
    .filter-dropdown-select,
    .filter-price-field,
    .filter-submit-btn,
    .filter-reset-btn,
    .filter-clear-link {
        transition: none;
    }
    
    .filter-submit-btn::before,
    .filter-reset-btn::before {
        display: none;
    }
    
    .products-filter-form.loading::after {
        animation: none;
    }
}