/* YooAI Filter — витрина */
.yooai-filter {
  --yf-accent: #2563EB;
  --yf-radius: 12px;
  --yf-bg: #f1f5f9;
  --yf-border: #e2e8f0;
  --yf-text: #0f172a;
  --yf-muted: #64748b;
  font-family: inherit;
  color: var(--yf-text);
  margin-bottom: 16px;
}
.yooai-filter *, .yooai-filter *::before, .yooai-filter *::after { box-sizing: border-box; }

.yooai-filter--sidebar {
  background: #fff;
  border: 1px solid var(--yf-border);
  border-radius: var(--yf-radius);
  padding: 14px 14px 10px;
}
.yooai-filter--sidebar.is-sticky { position: sticky; top: 16px; }

.yooai-filter__head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid #f1f5f9;
}
.yooai-filter__title {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px;
}
.yooai-filter__title svg { color: var(--yf-muted); }
.yooai-filter__count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--yf-accent); color: #fff; font-size: 11px; font-weight: 700;
}
.yooai-filter__found {
  font-size: 13px; font-weight: 600; color: var(--yf-muted, #64748b); white-space: nowrap;
}
.yooai-filter__reset {
  border: none; background: transparent; color: var(--yf-muted); font-size: 12.5px;
  font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: 8px;
}
.yooai-filter__reset:hover { color: var(--yf-accent); background: #eff6ff; }
.yooai-filter__apply {
  width: 100%; height: 42px; border: none; border-radius: var(--yf-radius);
  background: var(--yf-accent); color: #fff; font-weight: 700; font-size: 14px; cursor: pointer;
}
.yooai-filter__foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid #f1f5f9; }

/* Facet */
.yooai-facet { margin-bottom: 10px; }
.yooai-facet__head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13.5px; font-weight: 700; padding: 6px 13px 6px 2px; cursor: default; color: var(--yf-text);
}
.yooai-facet.is-collapsible .yooai-facet__head { cursor: pointer; }
.yooai-facet.is-collapsible.is-collapsed .yooai-facet__body { display: none; }
.yooai-facet.is-collapsible.is-collapsed .yooai-facet__head svg { transform: rotate(-90deg); }
.yooai-facet__head svg { transition: transform 0.15s ease; color: var(--yf-muted); }
.yooai-facet__values {
  display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow: auto;
  padding-right: 12px;
}

.yooai-check {
  position: relative;
  display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-radius: 8px;
  cursor: pointer; font-size: 13px; user-select: none;
}
.yooai-check:hover { background: #f8fafc; }
.yooai-check input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; margin: 0; }
.yooai-check__box {
  width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid #cbd5e1; flex-shrink: 0;
  background: #fff; position: relative; box-sizing: border-box;
}
.yooai-check input:checked + .yooai-check__box {
  background: var(--yf-accent, #2563EB); border-color: var(--yf-accent, #2563EB);
}
.yooai-check input:checked + .yooai-check__box::after {
  content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 9px;
  box-sizing: content-box;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.yooai-check__label { flex: 1; color: var(--yf-text); font-weight: 400; }
.yooai-check__count { color: var(--yf-muted); font-size: 11.5px; font-weight: 600; }

.yooai-facet-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; margin: 0; padding: 6px 2px; background: transparent; border-radius: 0;
  cursor: pointer; font-weight: inherit;
}
.yooai-facet-toggle__name { font-size: 13.5px; font-weight: 700; }
.yooai-ios { position: relative; display: inline-flex; }
.yooai-ios input { position: absolute; opacity: 0; width: 0; height: 0; }
.yooai-ios__track {
  width: 42px; height: 24px; border-radius: 999px; background: #cbd5e1; position: relative; transition: background 0.2s;
}
.yooai-ios__track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.15); transition: transform 0.2s;
}
.yooai-ios input:checked + .yooai-ios__track { background: var(--yf-accent); }
.yooai-ios input:checked + .yooai-ios__track::after { transform: translateX(18px); }

.yooai-price__inputs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px;
}
.yooai-price__inputs label {
  display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0;
  font-size: 11px; color: var(--yf-muted); font-weight: 600;
}
.yooai-filter .yooai-price__inputs input,
.yooai-filter-drawer .yooai-price__inputs input {
  display: block; width: 100%; height: 36px; margin: 0; padding: 0 10px;
  border: 1px solid var(--yf-border, #e2e8f0) !important; border-radius: 10px !important;
  background: #fff !important; box-shadow: none; color: var(--yf-text);
  font-size: 13px; line-height: 34px; appearance: auto; -webkit-appearance: auto;
}
/* Один визуальный трек, два handle */
.yooai-price-slider {
  position: relative; height: 28px; margin: 4px 2px 8px;
}
.yooai-price-slider__track {
  position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px;
  background: #e2e8f0; border-radius: 999px; pointer-events: none;
}
.yooai-price-slider__range {
  position: absolute; top: 0; bottom: 0; background: var(--yf-accent); border-radius: 999px;
}
.yooai-price-slider input[type="range"] {
  position: absolute; left: 0; width: 100%; top: 50%; margin: 0;
  transform: translateY(-50%);
  appearance: none; -webkit-appearance: none; background: none; pointer-events: none; height: 28px;
}
.yooai-price-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; pointer-events: auto; cursor: pointer;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  border: 2px solid var(--yf-accent); box-shadow: 0 1px 4px rgba(15,23,42,0.15);
}
.yooai-price-slider input[type="range"]::-moz-range-thumb {
  pointer-events: auto; cursor: pointer;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  border: 2px solid var(--yf-accent); box-shadow: 0 1px 4px rgba(15,23,42,0.15);
}
.yooai-price-slider input[type="range"]::-webkit-slider-runnable-track {
  -webkit-appearance: none; height: 4px; background: transparent; border: none; box-shadow: none;
}
.yooai-price-slider input[type="range"]::-moz-range-track { background: transparent; height: 4px; border: none; }
/* iOS Safari рисует свой высокий трек и сажает кружки на его края */
@supports (font: -apple-system-body) {
  .yooai-price-slider { overflow: visible; }
  .yooai-price-slider input[type="range"] {
    top: 50%; height: 4px; margin: -2px 0 0; transform: none; accent-color: transparent;
  }
  .yooai-price-slider input[type="range"]::-webkit-slider-thumb { margin-top: -7px; }
}

/* Top chips */
.yooai-filter--top { position: relative; margin: 0 0 14px; }
.yooai-filter-topbar {
  display: flex; align-items: center; gap: 10px;
}
.yooai-filter-topbar .yooai-filter-chips { flex: 1; min-width: 0; }
.yooai-filter-chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 16px; scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.yooai-filter-drawer__foot {
  display: flex; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--yf-border);
}
.yooai-filter-drawer__foot .yooai-filter__apply { flex: 1; }
.yooai-filter-drawer-source[hidden] { display: none !important; }
.yooai-filter-chip {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  height: 36px; padding: 0 14px; border: none; border-radius: 999px;
  background: var(--yf-bg); color: var(--yf-text); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.yooai-filter-chip:hover { background: #e2e8f0; }
.yooai-filter-chip.is-active { background: var(--yf-accent); color: #fff; }
.yooai-filter-chip.is-active svg { stroke: #fff; }

.yooai-filter-active {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px;
}
.yooai-filter-active[hidden] { display: none !important; }
.yooai-filter-tag {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border-radius: 999px; background: #eff6ff; color: var(--yf-accent); font-size: 12px; font-weight: 600;
}
.yooai-filter-tag button {
  border: none; background: transparent; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0;
}

.yooai-filter-popover {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; min-width: 260px; max-width: 340px;
  background: #fff; border: 1px solid var(--yf-border); border-radius: var(--yf-radius);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12); padding: 12px;
}
.yooai-filter-popover[hidden] { display: none !important; }

/* Кнопка «Все фильтры»: в ряду чипов, тот же вид */
.yooai-filter-mbtn {
  display: none; align-items: center; justify-content: center; gap: 6px; flex-shrink: 0;
  height: 36px; padding: 0 14px; border: none; border-radius: 999px;
  background: var(--yf-bg); color: var(--yf-text); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.yooai-filter-mbtn:hover { background: #e2e8f0; }
.yooai-filter-mbtn .yooai-filter__count {
  min-width: 18px; height: 18px; padding: 0 5px; font-size: 11px;
}
.yooai-filter-mbtn--floating {
  position: fixed; right: 16px; bottom: 20px; height: 44px; padding: 0 16px;
  background: #fff; box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12); z-index: 50;
}
.yooai-filter-mbtn--floating:hover { background: #f8fafc; }

.yooai-filter-drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 100000;
}
.yooai-filter-drawer-backdrop[hidden] { display: none !important; }
.yooai-filter-drawer,
.yooai-filter-drawer *,
.yooai-filter-drawer *::before,
.yooai-filter-drawer *::after { box-sizing: border-box; }
.yooai-filter-drawer {
  --yf-accent: #2563EB;
  --yf-radius: 12px;
  --yf-bg: #f1f5f9;
  --yf-border: #e2e8f0;
  --yf-text: #0f172a;
  --yf-muted: #64748b;
  position: fixed; top: 0; left: 0; bottom: 0; width: min(100%, 320px); z-index: 100010;
  background: #fff; display: flex; flex-direction: column; color: var(--yf-text);
  box-shadow: 12px 0 40px rgba(15, 23, 42, 0.18);
}
.yooai-filter-drawer[hidden] { display: none !important; }
.yooai-filter-drawer__bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--yf-border);
}
.yooai-filter-drawer__x {
  width: 36px; height: 36px; border: none; border-radius: 10px; background: var(--yf-bg);
  font-size: 22px; cursor: pointer; line-height: 1;
}
.yooai-filter-drawer__body { flex: 1; overflow: auto; padding: 12px 8px 12px 14px; }

/* Тонкий скролл: Firefox (scrollbar-*) и Chrome/Safari/Edge (webkit) */
.yooai-facet__values,
.yooai-filter-drawer__body {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.yooai-facet__values::-webkit-scrollbar,
.yooai-filter-drawer__body::-webkit-scrollbar { width: 8px; height: 8px; }
.yooai-facet__values::-webkit-scrollbar-track,
.yooai-filter-drawer__body::-webkit-scrollbar-track { background: transparent; }
.yooai-facet__values::-webkit-scrollbar-thumb,
.yooai-filter-drawer__body::-webkit-scrollbar-thumb {
  background: #cbd5e1; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box;
}

/* Админ-bar на витрине: drawer под bar+шапкой (переменная --yf-safe-top задаёт тема) */
body.yooai-bar .yooai-filter-drawer-backdrop {
  top: var(--yf-safe-top, var(--yab-root-height, var(--yab-height, 32px)));
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100000;
}
body.yooai-bar .yooai-filter-drawer {
  top: var(--yf-safe-top, var(--yab-root-height, var(--yab-height, 32px)));
  bottom: 0;
  height: auto;
  z-index: 100010;
}

#yooai-filter-products.is-loading { opacity: 0.45; pointer-events: none; transition: opacity 0.15s; }

@media (max-width: 767px) {
  .yooai-filter--sidebar { display: none; }
  .yooai-filter-mbtn { display: inline-flex; }
}
@media (min-width: 768px) {
  .yooai-filter-mbtn { display: none !important; }
  .yooai-filter-drawer, .yooai-filter-drawer-backdrop { display: none !important; }
  .yooai-filter--top:not(:has(.yooai-filter-chip)) { display: none; }
  .yooai-filter--sidebar { margin-bottom: 32px; }
}
