/*
  Панель фильтра раздела каталога (тема lepirate) — FilterPanel, screens/category.tpl, partials/filter-*.tpl;
  поведение — js/filter-panel.js. Перенесено из утверждённого прототипа design/proto-storefront-filter.html
  (design/proto/storefront-filter.css, 2026-11-05). Подключается только на странице с панелью (layout/header.tpl).
  Компьютер: строка кнопок в колонке товаров под тегами «Бренды» (стили кнопок — образец заказчика с oskelly.ru), выпадающие списки;
  телефон (≤ 800px, как колонка темы): «Фильтр» рядом с сортировкой под кнопкой «Бренды» и шторка на весь экран.
*/

/* ── Строка над товарами: фильтр слева, сортировка справа ── */
/* У темы до 1100px строка — узкая (640px) по центру с переносом; с фильтром — на всю ширину. */
.category-utility.has-filter {
    display: flex; flex-wrap: nowrap; align-items: flex-start; justify-content: space-between; gap: 16px;
    max-width: none; margin: 1.555rem 0 30px;
}
.has-filter .actionBar { margin: 0; }
.has-filter .category-sort-container { flex: none; width: 245px; }
.sf-bar { flex: 1 1 auto; }
.sf-bar { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }

/* Кнопки — как на oskelly.ru (образец заказчика 2026-11-05): его стили (38px, рамка #dbdbdb, 14px / 500);
   наведение и открытая — серая заливка тегов; с выбором — чёрная рамка. Строка — над колонкой товаров (колонка темы — 80% справа), край —
   по тегам «Бренды»; от строки до тегов — не меньше 30px. */
.sf-bar { gap: 10px; align-self: center; }

/* Строка — в колонке товаров под тегами «Бренды» (partials/category-utility.tpl; решения заказчика 2026-11-06):
   слева — как у тегов (у ul темы margin-left: 1.15rem), справа — по краю колонки. */
.category-utility.sf-row { margin: 20px 0 30px 1.15rem; }   /* от тегов «Бренды» (у тегов снизу 10px) и до товаров */
.sf-chips.sf-row { margin-left: 1.15rem; }
.sf-drop { position: relative; }
.sf-drop.is-open { z-index: 10000; }   /* выше «сердечек» карточек (у темы z-index 9999) */
.sf-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex-shrink: 0;
    height: 38px; min-height: 36px; padding: 0 12px; position: relative; box-sizing: border-box;
    background: transparent; border: 1px solid #dbdbdb; border-radius: 2px; outline: 0; color: #000;
    font: inherit; font-size: 14px; line-height: 16px; font-weight: 500; letter-spacing: 0; text-transform: none;
    cursor: pointer; white-space: nowrap; transition: background-color .2s linear, border-color .2s linear;
}
/* У темы button:focus и button:hover — голубые (#00a6ce): у кнопок панели этого быть не должно (заказчик 2026-11-05) */
.sf-btn:focus, .sf-btn:active { background: transparent; color: #000; }
.sf-open:focus, .sf-open:hover, .sf-open:active { background: #fff; color: #000; }
.sf-sec-head:focus, .sf-sec-head:hover, .sf-sec-head:active,
.sf-sheet-close:focus, .sf-sheet-close:hover, .sf-sheet-close:active { background: none; color: #000; }
/* Наведение и открытый список — серая заливка, как у тегов «Бренды» (#ededed), шрифт чёрный (заказчик 2026-11-05) */
.sf-btn:hover, .sf-drop.is-open .sf-btn { background: #ededed; border-color: #ededed; color: #000; }
.sf-btn.has-value { border-color: #000; }
.sf-badge {
    display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
    background: #000; color: #fff; border-radius: 10px; font-size: 11px; letter-spacing: 0;
}

/* Узкий компьютер: кнопки плотнее, чтобы строка помещалась */
@media (min-width: 801px) and (max-width: 1099px) {
    .sf-btn { padding: 0 10px; }
    .sf-bar { gap: 6px; }
}

/* Выпадающий список значения */
.sf-pop {
    display: none; position: absolute; left: 0; top: calc(100% + 4px); min-width: 280px;
    background: #fff; border: 1px solid #ddd; box-shadow: 0 8px 24px rgba(0, 0, 0, .06);
}
.sf-drop.is-open .sf-pop { display: block; }
.sf-pop-list { max-height: 360px; overflow-y: auto; padding: 8px 0; }

.sf-opt {
    display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 8px 16px; color: #000;
    font-size: 14px; text-decoration: none; cursor: pointer;
}
.sf-opt:hover { background: #f6f6f6; color: #000; }
.sf-check {
    flex: none; width: 18px; height: 18px; border: 1px solid #000; background: #fff; position: relative;
}
.sf-opt.is-selected .sf-check { background: #000; }
.sf-opt.is-selected .sf-check::after {
    content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px;
    border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.sf-name { flex: 1; }
.sf-count { color: #949494; font-size: 12px; }
.sf-opt.is-empty { color: #bbb; cursor: default; pointer-events: none; }
.sf-opt.is-empty .sf-check { border-color: #ccc; }

/* Размеры — квадратами, как в карточке товара (.ct_sizes) */
.sf-sizes { display: grid; grid-template-columns: repeat(5, 56px); gap: 6px; padding: 16px; }
.sf-size {
    display: flex; flex-direction: column; align-items: center; justify-content: center; height: 56px;
    border: 1px solid #ccc; color: #000; font-size: 14px; text-decoration: none; cursor: pointer;
}
.sf-size small { color: #949494; font-size: 10px; line-height: 1.2; }
.sf-size:hover { border-color: #000; color: #000; }
.sf-size.is-selected { background: #000; border-color: #000; color: #fff; }
.sf-size.is-selected small { color: #ccc; }
.sf-size.is-empty { color: #ccc; border-color: #eee; pointer-events: none; text-decoration: line-through; }

/* Цена — «от» и «до» */
.sf-price { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px; width: 300px; box-sizing: border-box; }
.sf-price label { flex: 1 1 0; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #666; }
.sf-price input { width: 100%; height: 44px; box-sizing: border-box; }
.sf-price .button { flex: 1 0 100%; margin: 4px 0 0; }

/* ── Выбранные значения ── */
.sf-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -14px 0 30px; }   /* 16px под строкой, 30px до товаров */
.sf-chips:empty { display: none; }
.sf-chip {
    display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px 7px 12px; background: #000; color: #fff;
    border-radius: 2px; font-size: 12px; text-transform: uppercase; text-decoration: none; cursor: pointer;
}
.sf-chip:hover { background: #333; color: #fff; }
/* × — линиями, а не символом: символ шрифта сидит ниже середины (правка заказчика 2026-11-05) */
.sf-chip-x { display: block; flex: none; width: 9px; height: 9px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.sf-reset { color: #000; font-size: 12px; text-transform: uppercase; text-decoration: underline; cursor: pointer; margin-left: 4px; }
.sf-found { flex: none; color: #949494; font-size: 12px; text-transform: uppercase; white-space: nowrap; margin-right: 4px; }

/* Кнопка шторки и сама шторка — только на телефоне */
.sf-open, .sf-sheet { display: none; }

/* ── Телефон ── */
@media (max-width: 800px) {
    /* телефон: строка — под кнопкой «Бренды» (заказчик 2026-11-06), на всю ширину */
    /* до товаров — 24px (заказчик 2026-11-06: «чуть больше»); между строкой и плашками — 14px, как было */
    .category-utility.has-filter.sf-row { margin: 14px 0 24px; }
    .sf-chips.sf-row { margin: -10px -16px 24px; }
    .sf-row-sort .sf-bar { display: none; }   /* без панели — одна сортировка на всю ширину */
    .sf-row-sort .category-sort-container { flex: 1 1 auto; }
    /* до «Подразделов» — как между «Подразделами» и «Брендами» темы (14px) */
    .category-utility.has-filter { gap: 8px; margin: 1rem 0 14px; }
    .has-filter > * { flex: 1 1 0; min-width: 0; }
    .has-filter .category-sort-container { width: auto; }
    .has-filter .actionBar-section, .has-filter .actionBar-section .form-select { width: 100%; }
    .sf-drop { display: none; }
    .sf-bar { margin-left: 0; }
    .sf-open {
        display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 50px;
        background: #fff; border: 1px solid #ccc; color: #000; font: inherit; font-size: 12px; letter-spacing: .04em;
        text-transform: uppercase; cursor: pointer;
    }
    .sf-open.has-value { border-color: #000; }
    .sf-icon { flex: none; width: 18px; height: 18px; }
    .sf-chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 14px -16px; padding: 0 16px 4px; scrollbar-width: none; }
    .sf-chips::-webkit-scrollbar { display: none; }
    .sf-chip, .sf-reset { flex: none; }
    /* телефон: без «Найдено: N», «Сбросить всё» — первым (заказчик 2026-11-05) */
    .sf-found { display: none; }
    .sf-reset { order: -1; margin: 0 4px 0 0; }

    .sf-sheet {
        position: fixed; inset: 0; z-index: 100000; display: flex; flex-direction: column; background: #fff;
        transform: translateY(100%); transition: transform .25s ease; visibility: hidden;
    }
    .sf-sheet.is-open { transform: none; visibility: visible; }
    body.sf-locked { overflow: hidden; }
    /* выбор в шторке подгружает новую шторку (js/filter-panel.js) — пока ждём, она бледнее и не нажимается */
    .sf-sheet.is-loading .sf-sheet-body, .sf-sheet.is-loading .sf-sheet-foot { opacity: .5; pointer-events: none; transition: opacity .15s .1s; }
    .sf-show.is-disabled { opacity: .5; pointer-events: none; }
    .sf-sheet-head {
        flex: none; display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 4px 0 16px;
        border-bottom: 1px solid #eee; font-size: 16px; font-weight: 700; text-transform: uppercase;
    }
    .sf-sheet-close {
        display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; padding: 0; border: 0;
        background: none; font-size: 28px; font-weight: 400; line-height: 1; cursor: pointer; color: #000;
    }
    .sf-sec .sf-pop-list { max-height: none; overflow: visible; padding: 0; }
    .sf-sheet-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .sf-sec { border-bottom: 1px solid #eee; }
    .sf-sec-head {
        display: flex; align-items: center; gap: 8px; width: 100%; min-height: 56px; padding: 0 16px; border: 0;
        background: none; color: #000; font: inherit; font-size: 14px; text-transform: uppercase; text-align: left; cursor: pointer;
    }
    .sf-sec-head .sf-name { flex: 1; }
    .sf-sec-sum { color: #949494; font-size: 12px; text-transform: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sf-sec-head::after {
        content: ""; flex: none; width: 12px; height: 7px; transition: transform .15s;
        background: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2016.88%209.15%22%3E%3Cpolyline%20points%3D%2216.53%200.35%208.44%208.44%200.35%200.35%22%20style%3D%22fill%3Anone%3Bstroke%3A%23000%22/%3E%3C/svg%3E") no-repeat center / contain;
    }
    .sf-sec.is-open .sf-sec-head::after { transform: rotate(180deg); }
    .sf-sec-body { display: none; padding: 0 0 12px; }
    .sf-sec.is-open .sf-sec-body { display: block; }
    .sf-sec .sf-opt { min-height: 44px; }
    .sf-sec .sf-sizes { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); padding: 4px 16px 8px; }
    .sf-sec .sf-price { width: auto; padding: 4px 16px 8px; }
    .sf-sheet-foot {
        flex: none; display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
        border-top: 1px solid #eee; background: #fff;
    }
    .sf-sheet-foot .button { margin: 0; height: 50px; padding: 0 16px; letter-spacing: .02em; white-space: nowrap; }
    .sf-sheet-foot .sf-show { flex: 1; min-width: 0; }
}
