/* rs-filter — остров фильтра раздела каталога (js/catalog-filter/catalog-filter.js).
   Токены — rs-theme.css (--rs-a, --rs-t, --rs-m, --rs-b, --rs-c, --rs-bg). */

#rs-filter-root {
  position: relative;
  z-index: 60; /* панель значений поверх карточек (у карточек свой z-index при наведении) */
  margin: 0 0 20px;
}

.rsf {
  --rsf-r: 8px;
  color: var(--rs-t, #2a2a2a);
  font: inherit;
  font-size: 14px;
  transition: opacity 0.15s;
}

.rsf.is-loading .rsf-opt__cnt,
.rsf.is-loading .rsf-apply {
  opacity: 0.55;
}

/* Строка: кнопки-свойства слева (переносятся), «В наличии» — всегда справа на своём месте */
.rsf-bar {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.rsf-props {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.rsf-item {
  position: relative;
}

.rsf-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--rs-b, #e6e8eb);
  border-radius: var(--rsf-r);
  background: var(--rs-c, #fff);
  color: inherit;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.rsf-trigger:hover,
.rsf-item.is-open .rsf-trigger {
  border-color: var(--rs-m, #737373);
}

.rsf-trigger.is-active {
  border-color: var(--rs-a, #da532c);
  color: var(--rs-ad, #b8431f);
}

.rsf-trigger:focus-visible,
.rsf-chip:focus-visible,
.rsf-btn:focus-visible,
.rsf-reset:focus-visible {
  outline: 2px solid var(--rs-a, #da532c);
  outline-offset: 2px;
}

.rsf-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--rs-a, #da532c);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  box-sizing: border-box;
}

.rsf-caret {
  width: 7px;
  height: 7px;
  margin-left: 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  opacity: 0.6;
}

.rsf-item.is-open .rsf-caret {
  transform: translateY(1px) rotate(-135deg);
}

/* Переключатель «В наличии» */
.rsf-stock {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  height: 36px;
  margin-left: auto;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.rsf-stock input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.rsf-switch {
  position: relative;
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: var(--rs-b, #e6e8eb);
  transition: background 0.15s;
}

.rsf-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s;
}

.rsf-stock input:checked + .rsf-switch {
  background: var(--rs-a, #da532c);
}

.rsf-stock input:checked + .rsf-switch::after {
  transform: translateX(14px);
}

.rsf-stock input:focus-visible + .rsf-switch {
  outline: 2px solid var(--rs-a, #da532c);
  outline-offset: 2px;
}

/* Выпадающая панель значений (компьютер) */
.rsf-panel {
  position: absolute;
  z-index: 100;
  top: calc(100% + 6px);
  left: 0;
  width: 300px;
  max-width: calc(100vw - 32px);
  padding: 8px;
  border: 1px solid var(--rs-b, #e6e8eb);
  border-radius: var(--rsf-r);
  background: var(--rs-c, #fff);
  box-shadow: 0 8px 24px rgba(26, 26, 26, 0.12);
  box-sizing: border-box;
}

.rsf .rsf-search {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 36px;
  min-height: 36px;
  line-height: normal;
  margin: 0 0 6px;
  padding: 0 10px;
  border: 1px solid var(--rs-b, #e6e8eb);
  border-radius: 6px;
  font: inherit;
  box-sizing: border-box;
}

.rsf .rsf-search:focus {
  outline: none;
  border-color: var(--rs-a, #da532c);
}

.rsf-list {
  max-height: 300px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.rsf-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.3;
}

.rsf-opt:hover {
  background: var(--rs-bg, #f5f6f8);
}

/* Свой квадратик: CSS сайта сбрасывает чекбоксы в appearance: none. */
.rsf-opt input {
  flex: none;
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1.5px solid var(--rs-m, #737373);
  border-radius: 4px;
  background: var(--rs-c, #fff) center / 12px 12px no-repeat;
  cursor: inherit;
}

.rsf-opt input:checked {
  border-color: var(--rs-a, #da532c);
  background-color: var(--rs-a, #da532c);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-4.9' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.rsf-opt input:focus-visible {
  outline: 2px solid var(--rs-a, #da532c);
  outline-offset: 2px;
}

.rsf-opt__name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.rsf-opt__cnt {
  flex: none;
  color: var(--rs-m, #737373);
  font-size: 12px;
}

.rsf-opt.is-off {
  cursor: default;
  opacity: 0.45;
}

.rsf-empty {
  padding: 10px 6px;
  color: var(--rs-m, #737373);
}

/* Чипсы выбранного + «Показать N» */
.rsf-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.rsf-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.rsf-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 8px 0 10px;
  border: 0;
  border-radius: 14px;
  background: var(--rs-hero-badge-bg, rgba(218, 83, 44, 0.1));
  color: var(--rs-ad, #b8431f);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.rsf-chip span {
  font-size: 16px;
  line-height: 1;
}

.rsf-reset {
  border: 0;
  background: none;
  padding: 0 4px;
  color: var(--rs-m, #737373);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

.rsf-btn {
  height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--rsf-r);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.rsf-btn--primary {
  background: var(--rs-a, #da532c);
  color: #fff;
}

.rsf-btn--primary:hover {
  background: var(--rs-ad, #b8431f);
}

.rsf-btn:disabled {
  background: var(--rs-b, #e6e8eb);
  color: var(--rs-m, #737373);
  cursor: default;
}

.rsf-x {
  width: 32px;
  height: 32px;
  border: 0;
  background: none;
  font-size: 24px;
  line-height: 1;
  color: var(--rs-m, #737373);
  cursor: pointer;
}

/* Телефон: строка кнопок листается, значения — шторкой снизу */
@media (max-width: 767px) {
  /* Телефон: одна листаемая строка, «В наличии» первым */
  .rsf-props {
    display: contents;
  }

  .rsf-bar {
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    margin: 0 -16px;
    padding: 0 16px 4px;
    scrollbar-width: none;
  }

  .rsf-bar::-webkit-scrollbar {
    display: none;
  }

  .rsf-trigger,
  .rsf-stock {
    flex: none;
  }

  .rsf-apply {
    width: 100%;
  }

  .rsf-sheet {
    position: fixed;
    inset: 0;
    z-index: 10050; /* выше #toTop и нижней панели избранного/корзины */
  }

  /* «В наличии» — первым: до него не нужно листать строку */
  .rsf-stock {
    order: -1;
    margin-left: 0;
    margin-right: 4px;
  }

  .rsf-sheet__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
  }

  .rsf-sheet .rsf-panel {
    position: absolute;
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: none;
    max-height: 75vh;
    display: flex;
    flex-direction: column;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    border: 0;
    border-radius: 14px 14px 0 0;
  }

  .rsf-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
  }

  .rsf-panel__title {
    font-weight: 600;
    font-size: 16px;
  }

  .rsf-sheet .rsf-list {
    flex: 1;
    max-height: none;
  }

  .rsf-opt {
    padding: 10px 4px;
  }

  .rsf-panel__foot {
    padding-top: 10px;
  }

  .rsf-panel__foot .rsf-btn {
    width: 100%;
  }
}

body.rsf-sheet-open {
  overflow: hidden;
}

body.rsf-sheet-open #toTop {
  display: none !important;
}

/* #rs-filter-root (z-index 60) — свой контекст наложения: без подъёма шторка внутри него
   оказывается под нижней панелью сайта (.header_user, z-index 1000). */
body.rsf-sheet-open #rs-filter-root {
  z-index: 10050;
}

/* Мгновенное применение: список товаров подгружается без перезагрузки */
#rs-catalog-list {
  transition: opacity 0.15s;
}

#rs-catalog-list.rsf-list-loading {
  opacity: 0.45;
  pointer-events: none;
}

.rsf-found {
  color: var(--rs-m, #737373);
  font-size: 13px;
  white-space: nowrap;
}
