/* ========== Desktop sidebar ========== */
.vaf-wrap {
  margin-top: 20px;
}

.vaf-mobile-toggle {
  display: none;
}

.vaf-overlay {
  display: none;
}

.vaf-filters {
  padding: 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.vaf-filters__panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.vaf-filters__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.vaf-filters__head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vaf-filters__title {
  font-weight: 700;
  font-size: 16px;
  color: #fff;
}

.vaf-filters__reset {
  appearance: none;
  border: 0;
  background: transparent;
  color: #c3272e;
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  text-decoration: underline;
}

.vaf-filters__close {
  display: none;
}

.vaf-filters__found {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 12px;
  min-height: 1em;
}

.vaf-filters__hint {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  margin: 0;
}

.vaf-filters__foot {
  display: none;
}

.vaf-facet {
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 12px;
}

.vaf-facet:last-child {
  margin-bottom: 0;
  border-bottom: 0;
  padding-bottom: 0;
}

.vaf-facet__title {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0 0 10px;
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  cursor: pointer;
  text-align: left;
}

.vaf-facet__chevron {
  width: 10px;
  height: 10px;
  border-right: 2px solid rgba(255, 255, 255, 0.55);
  border-bottom: 2px solid rgba(255, 255, 255, 0.55);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex: 0 0 auto;
  margin-top: -4px;
}

.vaf-facet.is-collapsed .vaf-facet__chevron {
  transform: rotate(-135deg);
  margin-top: 2px;
}

.vaf-facet.is-collapsed .vaf-facet__list {
  display: none;
}

.vaf-facet__list {
  list-style: none;
  margin: 0;
  padding: 0 10px 0 0;
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: rgba(195, 39, 46, 0.85) rgba(255, 255, 255, 0.08);
}

/* Кастомный скроллбар (WebKit/Blink) */
.vaf-facet__list::-webkit-scrollbar {
  width: 6px;
}

.vaf-facet__list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.vaf-facet__list::-webkit-scrollbar-thumb {
  background: rgba(195, 39, 46, 0.85);
  border-radius: 999px;
  transition: background 0.15s ease;
}

.vaf-facet__list::-webkit-scrollbar-thumb:hover,
.vaf-facet__list::-webkit-scrollbar-thumb:active {
  background: #c3272e;
}

/* Полоса заметна только когда список реально скроллится */
.vaf-facet__list:not(:hover)::-webkit-scrollbar-thumb {
  background: rgba(195, 39, 46, 0.55);
}

.vaf-facet__item {
  margin: 0 0 8px;
}

.vaf-facet__item label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  line-height: 1.35;
  user-select: none;
}

.vaf-facet__item input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* Custom checkbox */
.vaf-facet__box {
  position: relative;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.vaf-facet__box::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.15s ease;
}

.vaf-facet__item label:hover .vaf-facet__box {
  border-color: rgba(195, 39, 46, 0.8);
}

.vaf-facet__item input[type="checkbox"]:focus-visible + .vaf-facet__box {
  box-shadow: 0 0 0 3px rgba(195, 39, 46, 0.35);
}

.vaf-facet__item input[type="checkbox"]:checked + .vaf-facet__box {
  background: #c3272e;
  border-color: #c3272e;
}

.vaf-facet__item input[type="checkbox"]:checked + .vaf-facet__box::after {
  transform: rotate(45deg) scale(1);
}

.vaf-facet__name {
  flex: 1 1 auto;
}

.vaf-facet__count {
  opacity: 0.55;
  font-size: 12px;
}

.col-9.vaf-is-loading,
.vaf-is-loading #products-cont,
.vaf-is-loading .facetwp-template {
  position: relative;
  pointer-events: none;
  opacity: 0.55;
  transition: opacity 0.2s ease;
}

.vaf-empty {
  padding: 24px;
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
}

.vaf-pagination {
  margin-top: 24px;
}

/* ========== Mobile panel ========== */
@media (max-width: 991px) {
  .vaf-wrap {
    margin-top: 0;
  }

  /* Кнопка «Фильтры» */
  .vaf-mobile-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px;
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    justify-content: center;
  }

  .vaf-mobile-toggle__icon {
    display: inline-flex;
  }

  .vaf-mobile-toggle__badge {
    display: none;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #c3272e;
    color: #fff;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
  }

  .vaf-mobile-toggle__badge.is-visible {
    display: inline-block;
  }

  /* Сам блок фильтров — выезжающая панель снизу */
  .category-sidebar .vaf-filters,
  .vaf-wrap .vaf-filters {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 100050;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 16px 16px 0 0;
    background: #1a1a1a;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
    transform: translateY(110%);
    transition: transform 0.28s ease;
    max-height: min(88vh, 720px);
    display: flex;
    flex-direction: column;
  }

  body.vaf-panel-open .vaf-wrap .vaf-filters {
    transform: translateY(0);
  }

  .vaf-filters__panel {
    max-height: min(88vh, 720px);
    height: 100%;
  }

  .vaf-filters__head {
    padding: 16px 16px 10px;
    margin: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex: 0 0 auto;
  }

  .vaf-filters__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
  }

  .vaf-filters__found {
    padding: 8px 16px 0;
    margin: 0;
  }

  .vaf-filters__body {
    flex: 1 1 auto;
    overflow: auto;
    padding: 12px 16px 8px;
    -webkit-overflow-scrolling: touch;
  }

  .vaf-filters__foot {
    display: block;
    flex: 0 0 auto;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: #1a1a1a;
  }

  .vaf-filters__apply {
    width: 100%;
    height: 48px;
    border: 0;
    border-radius: 8px;
    background: #c3272e;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
  }

  .vaf-filters__apply:hover {
    background: #a82025;
    color: #fff;
  }

  .vaf-facet__list {
    max-height: none;
    padding-right: 0;
    overflow: visible;
  }

  /* На мобилке скроллится вся панель — тот же стиль полосы */
  .vaf-filters__body {
    scrollbar-width: thin;
    scrollbar-color: rgba(195, 39, 46, 0.85) rgba(255, 255, 255, 0.08);
  }

  .vaf-filters__body::-webkit-scrollbar {
    width: 6px;
  }

  .vaf-filters__body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
  }

  .vaf-filters__body::-webkit-scrollbar-thumb {
    background: rgba(195, 39, 46, 0.85);
    border-radius: 999px;
  }

  /* Overlay */
  .vaf-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 100040;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
  }

  body.vaf-panel-open .vaf-overlay {
    opacity: 1;
    visibility: visible;
  }

  body.vaf-panel-open {
    overflow: hidden;
  }

  /* Перенос кнопки фильтров выше списка товаров на мобилке через order, если в одном flex-ряду */
  .category-row__line {
    display: flex;
    flex-wrap: wrap;
  }

  .category-row__line > .col-3.category-sidebar {
    width: 100%;
    order: 1;
  }

  .category-row__line > .col-9 {
    width: 100%;
    order: 2;
  }

  /* Дерево категорий остаётся, кнопка фильтров — сразу под ним / перед товарами */
  .category-sidebar .pcat-widget {
    margin-bottom: 12px;
  }
}
