/* ==================== DRAWER (ВЫДВИЖНАЯ ПАНЕЛЬ) ==================== */
.filter-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.filter-drawer-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.filter-drawer-content {
    position: absolute;
    top: 16px;
    bottom: 16px;
    right: -400px;
    height: calc(100% - 32px);
    width: 360px;
    border-radius: 24px;
    background: var(--white, #ffffff);
    box-shadow: -5px 5px 30px rgba(15, 23, 42, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.filter-drawer-overlay.is-open .filter-drawer-content {
    right: 16px;
}

/* Шапка Drawer */
.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}

.drawer-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 500;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.btn-close-drawer {
    border: none;
    background: transparent;
    font-size: 1.4rem;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-close-drawer:hover {
    background: var(--bg-content, #f8fafc);
    color: #0f172a;
    transform: rotate(90deg);
}

/* Тело Drawer */
.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.drawer-body::-webkit-scrollbar {
    width: 5px;
}

.drawer-body::-webkit-scrollbar-track {
    background: transparent;
}

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

/* Подвал Drawer */
.drawer-footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(226, 232, 240, 0.8);
    display: flex;
    gap: 12px;
    background: var(--white, #ffffff);
}

.btn-drawer-apply,
.btn-drawer-reset {
    height: 38px;
    padding: 0 16px;
    border: none;
    background: transparent;
    border-radius: 9px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-drawer-apply {
    flex: 1.5;
    background: var(--white, #ffffff);
    color: var(--primary-light, #2563eb);
    box-shadow: 0 0 3px 1px var(--primary, #2563eb);
}

.btn-drawer-apply:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(37, 99, 235, 0.15), 0 0 3px 1px var(--primary, #2563eb);
}

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

.btn-drawer-reset {
    flex: 1;
    color: #64748b;
}

.btn-drawer-reset:hover {
    color: #334155;
    background: var(--bg-content, #f8fafc);
}

/* Кнопка открытия Drawer */
.btn-filter-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 37px;
    background: var(--white);
    color: var(--primary-light);
    border: 1px solid rgba(37, 99, 235, 0.08);
    border-radius: 12px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 0 3px 1px var(--primary, #2563eb);
}

.btn-filter-trigger:hover {
    background: var(--bg-content, #f8fafc);
    transform: translateY(-2px);
}

.btn-filter-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    flex-shrink: 0;
}

.filter-group {
    margin-bottom: 24px;
}

.filter-group-title {
    font-size: 0.9rem;
    font-weight: 550;
    color: #0f172a;
    margin-bottom: 12px;
}

/* ==================== ПОЛЯ ФИЛЬТРОВ ==================== */

.filter-drawer-content .form-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #e2e8f0;
    font-size: 0.85rem;
    border-radius: 12px;
    font-family: inherit;
    color: #1e293b;
    background-color: #ffffff;
    outline: none;
    cursor: text;
    box-sizing: border-box;

    box-shadow: 0 0 8px 3px rgba(59, 130, 246, 0),
    0 4px 20px rgba(59, 130, 246, 0);

    transition: border-color 0.45s cubic-bezier(0.25, 0.8, 0.25, 1),
    box-shadow 0.45s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.filter-drawer-content .form-input::placeholder {
    font-size: 0.85rem;
    color: #94a3b8;
    font-weight: 400;
    opacity: 0.8;
}

.filter-drawer-content .form-input:focus {
    border-color: rgba(59, 130, 246, 0.5);
    background-color: #ffffff;

    box-shadow: 0 0 8px 2px rgba(59, 130, 246, 0.3),
    0 4px 15px rgba(59, 130, 246, 0.1);
}


/* ==================== ЗАРПЛАТА ==================== */

.salary-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.salary-input-group .form-input {
    flex: 1;
    min-width: 0;
}

.currency-select-inline {
    width: 100px;
    flex-shrink: 0;
    padding: 14px 28px 14px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background-color: #f8fafc;
    font-family: inherit;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    text-align: left;
    font-size: 0.85rem;
    outline: none;

    box-sizing: border-box;

    transition: background-color 0.2s ease,
    border-color 0.2s ease;

    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;

    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 5px center;
    background-size: 12px;
}

.currency-select-inline:hover {
    background-color: #f1f5f9;
}

.currency-select-inline:focus {
    border-color: rgba(59, 130, 246, 0.5);
    background-color: #ffffff;
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filter-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 400;
    font-size: 0.84rem;
    user-select: none;
    max-width: 100%;
}

.filter-checkbox-label span {
    color: var(--text-gray);
    transition: color 0.30s ease;
}

.filter-checkbox-label:hover span {
    color: #0f172a;
}

.filter-checkbox-label input[type="checkbox"]:checked + span {
    color: var(--primary-light);
    font-weight: 550;
}

.filter-checkbox-label input[type="checkbox"] {
    width: 15px;
    height: 15px;
    margin-top: 2px;
    cursor: pointer;
    accent-color: var(--primary-light);
}

.truncate-text {
    white-space: nowrap; /* Запрещаем перенос строки */
    overflow: hidden; /* Прячем всё, что не поместилось */
    text-overflow: ellipsis; /* Добавляем три точки в конец */
    flex: 1; /* Занимает всё доступное пространство */
}

/* Поле зарплаты в десктопных фильтрах */
#vacanciesFiltersContent .form-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #e2e8f0;
    font-size: 0.85rem;
    border-radius: 12px;
    font-family: inherit;
    color: #1e293b;
    background-color: #ffffff;
    outline: none;
    cursor: text;
    box-sizing: border-box;
}

#vacanciesFiltersContent .form-input::placeholder {
    color: #94a3b8;
}

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

/* Десктоп: поле зарплаты шире выбора валюты */
#vacanciesFiltersContent .salary-input-group {
    display: flex;
    gap: 8px;
}

#vacanciesFiltersContent .salary-input-group .form-input {
    flex: 1;
    min-width: 0;
    width: auto;
}

#vacanciesFiltersContent .salary-input-group .currency-select-inline {
    flex: 0 0 64px;
    width: 64px;
}

/* =========================================================
   MOBILE FILTER DRAWER
   ========================================================= */

@media (max-width: 576px) {

    :root {
        --drawer-mobile-gap: 12px;
        --drawer-mobile-bottom-gap: 16px;
        --drawer-mobile-radius: 22px;
    }

    /* Затемнение фона */
    .filter-drawer-overlay {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;

        padding: 0;
        overflow: hidden;

        background: rgba(15, 23, 42, 0.36);
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
        overscroll-behavior: none;
    }

    /* Панель фильтров */

    .filter-drawer-content {
        --drawer-top-gap: calc(
                12px + env(safe-area-inset-top, 0px)
        );

        --drawer-bottom-gap: calc(
                12px + env(safe-area-inset-bottom, 0px)
        );

        top: calc(
                var(--drawer-viewport-top, 0px)
                + var(--drawer-top-gap)
        );

        height: min(
                82dvh,
                calc(
                        var(--drawer-viewport-height, 100dvh)
                        - var(--drawer-top-gap)
                        - var(--drawer-bottom-gap)
                )
        );

        max-height: calc(
                var(--drawer-viewport-height, 100dvh)
                - var(--drawer-top-gap)
                - var(--drawer-bottom-gap)
        );

        box-sizing: border-box;
        min-height: 0;
    }


    .filter-drawer-overlay.is-open .filter-drawer-content {
        right: var(--drawer-mobile-gap);
        bottom: auto;

        transform: translateY(0);
        opacity: 1;
    }

    /* Шапка */
    .drawer-header {
        flex: 0 0 auto;

        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;

        padding: 17px 20px;

        border-bottom: 1px solid #f1f5f9;
        background: var(--white, #fff);
    }

    .drawer-header h3 {
        margin: 0;
        font-size: 1.05rem;
        line-height: 1.4;
        font-weight: 600;
        color: #0f172a;
    }

    .btn-close-drawer {
        flex: 0 0 36px;

        width: 36px;
        height: 36px;
        min-width: 36px;

        border-radius: 10px;
        font-size: 1.5rem;

        -webkit-tap-highlight-color: transparent;
    }

    .btn-close-drawer:hover {
        transform: none;
    }

    /* Прокручивается только список фильтров */
    .drawer-body {
        flex: 1 1 auto;
        min-height: 0;

        padding: 20px;

        overflow-x: hidden;
        overflow-y: auto;

        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;

        scrollbar-width: thin;
        scrollbar-color: #cbd5e1 transparent;
    }

    .drawer-body::-webkit-scrollbar {
        width: 4px;
    }

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

    /* Группы фильтров */
    .filter-group {
        margin-bottom: 24px;
    }

    .filter-group:last-child {
        margin-bottom: 4px;
    }

    .filter-group-title {
        margin-bottom: 12px;

        font-size: 0.9rem;
        line-height: 1.45;
        font-weight: 600;
    }

    /* Поля ввода: 16px предотвращают автозум в iOS */
    .filter-drawer-content .form-input,
    .filter-drawer-content .currency-select-inline {
        min-height: 48px;
        font-size: 16px;
        border-radius: 12px;
    }

    .filter-drawer-content .form-input {
        padding: 12px 14px;
    }

    .filter-drawer-content .form-input::placeholder {
        font-size: 16px;
    }

    .salary-input-group {
        gap: 8px;
    }

    .currency-select-inline {
        width: 96px;
        padding: 12px 24px 12px 10px;
    }

    /* Чекбоксы — удобная зона нажатия */
    .filter-options {
        gap: 2px;
    }

    /* Строка фильтра */
    .filter-checkbox-label {
        min-height: 32px;
        gap: 10px;
        padding: 2px 0;
        font-size: 0.88rem;
        line-height: 1.4;

        -webkit-tap-highlight-color: transparent;
    }

    .filter-checkbox-label input[type="checkbox"] {
        flex: 0 0 18px;

        width: 18px;
        height: 18px;
        margin: 0;

        accent-color: var(--primary-light, #2563eb);
    }

    .truncate-text {
        min-width: 0;
    }

    /* Нижняя панель действий всегда остаётся видимой */
    .drawer-footer {
        position: relative;
        z-index: 1;

        flex: 0 0 auto;

        display: flex;
        align-items: center;
        gap: 10px;

        padding: 14px 20px;

        padding-bottom: max(
                14px,
                env(safe-area-inset-bottom, 0px)
        );

        border-top: 1px solid #f1f5f9;
        background: var(--white, #fff);

        box-shadow: 0 -5px 16px rgba(15, 23, 42, 0.025);
    }

    .btn-drawer-apply,
    .btn-drawer-reset {
        min-width: 0;
        min-height: 46px;
        height: 46px;

        border-radius: 12px;
        font-size: 0.9rem;

        -webkit-tap-highlight-color: transparent;
    }

    .btn-drawer-apply {
        flex: 1.5;
        box-shadow: 0 0 0 1px var(--primary, #2563eb);
    }

    .btn-drawer-reset {
        flex: 1;
    }

    .btn-drawer-apply:hover,
    .btn-drawer-reset:hover {
        transform: none;
    }

    /* Плавающая кнопка открытия фильтров */
    .btn-filter-trigger {
        position: fixed;
        left: auto;
        right: 16px;
        bottom: calc(
                20px + env(safe-area-inset-bottom, 0px)
        );
        z-index: 900;
        width: 52px;
        height: 52px;
        min-width: 52px;
        min-height: 52px;

        padding: 0;
        border-radius: 16px;

        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: var(--white, #fff);
        color: var(--primary-light, #2563eb);
        box-shadow: 0 3px 16px rgba(37, 99, 235, 0.18);
        -webkit-tap-highlight-color: transparent;
    }

    .btn-filter-trigger span {
        display: none;
    }

    .btn-filter-trigger .btn-filter-icon {
        width: 22px;
        height: 22px;
    }

    .btn-filter-trigger:hover,
    .btn-filter-trigger:active {
        transform: none;
    }
}

/* Маленькие экраны и невысокие окна */
@media (max-width: 576px) and (max-height: 650px) {
    .filter-drawer-content {
        height: min(
                88dvh,
                calc(
                        var(--drawer-viewport-height, 100dvh)
                        - var(--drawer-viewport-top, 0px)
                        - var(--drawer-top-gap)
                        - var(--drawer-bottom-gap)
                )
        );
    }

    .drawer-header {
        padding-top: 12px;
        padding-bottom: 12px;
    }

    .drawer-body {
        padding-top: 14px;
        padding-bottom: 14px;
    }

    .filter-group {
        margin-bottom: 18px;
    }

    .drawer-footer {
        padding-top: 10px;
        padding-bottom: max(
                10px,
                env(safe-area-inset-bottom, 0px)
        );
    }
}

/* Уважаем системную настройку уменьшения анимации */
@media (prefers-reduced-motion: reduce) {
    .filter-drawer-content {
        transition: none;
    }
}