/**
 * Обновленные стили для фильтров продуктов (Выбирай.ру)
 */

/* --- Главная карточка фильтра --- */
.products__filter {
    background: #fff;
    border-radius: 20px;
    padding: 35px 40px;
    margin-bottom: 40px;
    box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.04); /* Легкая тень, как у остальных панелей */
}

.filter-title__in {
    margin-bottom: 30px;
}

.product-filter__title {
    font-size: 28px;
    font-weight: 700;
    line-height: 120%;
    color: #000;
    margin: 0;
}

/* --- Сетка формы --- */
.filter-form {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px 15px;
    align-items: flex-end; /* Выравниваем поля и кнопку по нижнему краю */
}

.form-group {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.form-group label {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #2f343a;
}

/* --- Инпуты и Селекты --- */
.form-group input[type="number"],
.form-group select {
    width: 100%;
    height: 64px;
    padding: 0 20px;
    border: 1px solid #f3f3f3;
    border-radius: 15px;
    font-size: 16px;
    font-weight: 500;
    color: #000;
    background-color: #f3f3f3;
    transition: all 0.3s ease;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

/* Кастомная стрелочка для select */
.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%232F343A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 20px center;
    padding-right: 45px;
    cursor: pointer;
}

.form-group input[type="number"]:focus,
.form-group select:focus {
    border-color: #8654cd;
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(134, 84, 205, 0.1);
}

/* --- Стили для слайдера (Сумма) --- */
.form-group--slider {
    margin-bottom: 0;
}

.products__filter .selection_row {
    width: 100%;
    height: 64px;
    background: #f3f3f3;
    border: 1px solid #f3f3f3;
    border: none;
    border-radius: 15px;
    padding: 0 20px;
    margin: 0;
    display: flex;
    align-items: center;
    position: relative;
}

.products__filter .selection_row_header {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    margin: 0;
}

.products__filter .selection_row_header_right {
    font-size: 18px;
    font-weight: 600;
    color: #000;
}

.products__filter .selection_row_input {
    position: absolute;
    bottom: -6px; /* Чтобы ползунок висел на нижней границе рамки */
    left: 15px;
    right: 15px;
    width: calc(100% - 30px);
}

/* Раскрашиваем ползунок в фиолетовый */
input[type="range"].slider-progress {
    --range: calc(var(--max) - var(--min));
    --ratio: calc((var(--value) - var(--min)) / var(--range));
    --sx: calc(0.5 * 24px + var(--ratio) * (100% - 24px));
    height: 2px;
    background: linear-gradient(#8654cd, #8654cd) 0 / var(--sx) 100% no-repeat transparent;
}

input[type="range"].styled-slider::-webkit-slider-thumb {
    border-color: #8654cd; /* Фиолетовое кольцо */
}
input[type="range"].styled-slider::-moz-range-thumb {
    border-color: #8654cd;
}

/* --- Кнопка "Подобрать" --- */
.filter-submit-btn {
    width: 100%;
    height: 64px;
    border-radius: 15px;
    background: linear-gradient(116deg, #9c6dff 0%, #6b25ff 100%);
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: opacity 0.3s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-submit-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

/* --- Дополнительные фильтры --- */
.additional-filters {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px 30px;
    border-top: 1px solid #f0f0f0;
    padding-top: 25px;
    margin-top: 5px;
}

/* --- Ссылки "Все фильтры" и "Сбросить" --- */
.js-toggle-filters {
    grid-column: 1 / 2;
    justify-self: start;
    font-size: 15px;
    font-weight: 500;
    color: #8654cd;
    text-decoration: none;
    border-bottom: 1px dashed rgba(134, 84, 205, 0.4);
    transition: all 0.3s ease;
    margin-top: 10px;
}

.js-reset-filter {
    grid-column: 3 / 4;
    justify-self: end;
    font-size: 15px;
    font-weight: 500;
    color: #999;
    text-decoration: none;
    border-bottom: 1px dashed rgba(153, 153, 153, 0.4);
    transition: all 0.3s ease;
    margin-top: 10px;
}

.js-toggle-filters:hover {
    color: #6b25ff;
    border-bottom-color: #6b25ff;
}

.js-reset-filter:hover {
    color: #ff3333;
    border-bottom-color: #ff3333;
}

/* --- Загрузка и пустые результаты --- */
.loading {
    text-align: center;
    padding: 40px;
    font-size: 16px;
    font-weight: 500;
    color: #8654cd;
}

.no-results {
    width: 100%;
    text-align: center;
    padding: 60px 20px;
    background-color: #fff;
    border-radius: 20px;
    margin: 20px 0;
    box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.04);
}

.no-results p {
    font-size: 18px;
    font-weight: 500;
    color: #747474;
    margin: 0;
}

.error {
    text-align: center;
    padding: 30px;
    font-size: 16px;
    color: #fff;
    background-color: #ff4d4d;
    border-radius: 15px;
}

.filter-form.filter-form--4cols {
    grid-template-columns: repeat(4, 1fr);
}

.filter-form.filter-form--4cols .additional-filters {
    grid-template-columns: repeat(4, 1fr);
}

.filter-form.filter-form--4cols .js-reset-filter {
    grid-column: 4 / 5; /* Переносим кнопку сброса под 4-ю колонку */
}

/* --- Адаптивность --- */
@media (max-width: 991px) {
    .filter-form,
    .additional-filters,
    .filter-form.filter-form--4cols,
    .filter-form.filter-form--4cols .additional-filters {
        grid-template-columns: 1fr 1fr; /* На планшетах по 2 в ряд */
    }
    
    .filter-form > .filter-submit-btn,
    .filter-form.filter-form--4cols > .filter-submit-btn {
        grid-column: 1 / -1; /* Кнопка на всю ширину */
    }
    
    .js-toggle-filters {
        grid-column: 1 / 2;
    }
    
    .js-reset-filter,
    .filter-form.filter-form--4cols .js-reset-filter {
        grid-column: 2 / 3; /* Ссылка "Сбросить" под правую колонку */
    }
}

@media (max-width: 768px) {
    .products__filter {
        padding: 25px 20px;
    }
    
    .product-filter__title {
        font-size: 24px;
    }

    .filter-form,
    .additional-filters,
    .filter-form.filter-form--4cols,
    .filter-form.filter-form--4cols .additional-filters {
        grid-template-columns: 1fr; /* На мобилках все друг под другом */
        gap: 15px;
    }
    
    .js-toggle-filters,
    .js-reset-filter,
    .filter-form.filter-form--4cols .js-reset-filter {
        grid-column: 1 / -1;
        justify-self: center;
    }
    
    .js-reset-filter,
    .filter-form.filter-form--4cols .js-reset-filter {
        margin-top: 5px;
    }
}