/* ============================================================
   Каталог: фильтр + сортировка + сетка
   ============================================================ */

.catalog-head {
  margin-top: var(--s-6);
  margin-bottom: var(--s-7);
}
.catalog-head h1 {
  font-size: 44px;
  font-weight: var(--fw-bold);
  margin: 0 0 var(--s-2);
  letter-spacing: var(--ls-tight);
  line-height: 1.1;
}
.catalog-head .found {
  font-size: var(--fs-base);
  color: var(--c-text-muted);
}
.catalog-head .found strong {
  color: var(--c-text);
  font-weight: var(--fw-semibold);
}
@media (max-width: 767px) {
  .catalog-head h1 { font-size: var(--fs-5xl); }
}

/* ---------- Категории с подкатегориями (на /catalog/) ---------- */
.catalog-categories {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  margin-bottom: var(--s-10);
}
.catalog-category {
  background: #fff;
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-6);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.catalog-category:hover {
  border-color: var(--c-border-strong);
  box-shadow: var(--sh-md);
}
.catalog-category__head {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  color: var(--c-text);
  text-decoration: none;
  padding-bottom: var(--s-4);
  margin-bottom: var(--s-4);
  border-bottom: 1px solid var(--c-border-soft);
}
/* Если нет блока подкатегорий — убираем линию и нижний отступ под названием */
.catalog-category__head:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: 0;
}
.catalog-category__icon {
  width: 52px;
  height: 52px;
  border-radius: var(--r-md);
  background: var(--c-bg-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--c-primary);
  overflow: hidden;
}
/* Кастомная PNG-иконка из UF — занимает весь блок, как на главной */
.catalog-category__icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.catalog-category__name {
  flex: 1;
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-tight);
  margin: 0;
  transition: color var(--dur-fast) var(--ease);
}
.catalog-category__head:hover .catalog-category__name { color: var(--c-primary); }
.catalog-category__arrow {
  color: var(--c-text-subtle);
  flex-shrink: 0;
  transition: color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.catalog-category__head:hover .catalog-category__arrow {
  color: var(--c-primary);
  transform: translateX(3px);
}

.catalog-category__subs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px var(--s-6);
  list-style: none;
  padding: 0;
  margin: 0;
}
.catalog-category__subs a {
  display: block;
  padding: 6px 0;
  font-size: var(--fs-sm);
  color: var(--c-text);
  text-decoration: none;
  line-height: 1.35;
  transition: color var(--dur-fast) var(--ease);
}
.catalog-category__subs a:hover { color: var(--c-primary); }

@media (max-width: 1023px) {
  .catalog-category__subs { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 767px) {
  .catalog-category__subs { grid-template-columns: repeat(2, 1fr); }
  .catalog-category { padding: var(--s-4) var(--s-5); }
  .catalog-category__name { font-size: var(--fs-lg); }
}
@media (max-width: 480px) {
  .catalog-category__subs { grid-template-columns: 1fr; }
}

/* ---------- Сетка: фильтр + контент ---------- */
.catalog-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: var(--s-6);
  align-items: flex-start;
}

/* ---------- Фильтр ---------- */
.filter {
  position: sticky;
  top: calc(var(--h-header) + var(--s-4));
  background: #fff;
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}
.filter__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--s-4);
  border-bottom: 1px solid var(--c-border-soft);
  margin-bottom: var(--s-4);
}
.filter__head h3 {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
}
.filter__reset {
  font-size: var(--fs-sm);
  color: var(--c-primary);
  font-weight: var(--fw-medium);
  transition: color var(--dur-fast) var(--ease);
}
.filter__reset:hover { color: var(--c-primary-hover); }

.filter__section {
  padding-block: var(--s-4);
  border-bottom: 1px solid var(--c-border-soft);
}
.filter__section:last-child { border-bottom: 0; }
.filter__section h4 {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--s-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.filter__section h4::after {
  content: '';
  width: 10px; height: 10px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='3,5 6,8 9,5'/></svg>") center / contain no-repeat;
  transition: transform var(--dur-fast) var(--ease);
}
.filter__section.is-collapsed h4::after { transform: rotate(-90deg); }
.filter__section.is-collapsed .filter__body { display: none; }

.filter__list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.filter__list .checkbox { width: 100%; }

.filter__more {
  font-size: var(--fs-sm);
  color: var(--c-primary);
  font-weight: var(--fw-medium);
  margin-top: var(--s-3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.filter__more:hover { color: var(--c-primary-hover); }

/* Цена */
.price-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
.price-range .input {
  height: 36px;
  font-size: var(--fs-sm);
  padding-inline: var(--s-3);
}

.range-slider {
  position: relative;
  height: 4px;
  background: var(--c-border);
  border-radius: var(--r-pill);
  margin-block: var(--s-3) var(--s-1);
}
.range-slider__fill {
  position: absolute;
  height: 100%;
  background: var(--c-primary);
  border-radius: var(--r-pill);
  left: 10%;
  right: 25%;
}
.range-slider__handle {
  position: absolute;
  top: 50%;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--c-primary);
  transform: translate(-50%, -50%);
  cursor: grab;
}
.range-slider__handle--min { left: 10%; }
.range-slider__handle--max { left: 75%; }

/* Поиск внутри фильтра (брендов) */
.filter__search {
  margin-bottom: var(--s-3);
}
.filter__search .input {
  height: 36px;
  font-size: var(--fs-sm);
  background: var(--c-bg-soft);
  border-color: transparent;
}

/* ---------- Тулбар сверху сетки: сортировка + чипы ---------- */
.catalog-toolbar {
  background: #fff;
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-lg);
  padding: var(--s-3) var(--s-4);
  margin-bottom: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.catalog-sort {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--fs-sm);
}
.catalog-sort .label {
  color: var(--c-text-muted);
}
.catalog-sort .select {
  border: 0;
  background: transparent;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--c-primary);
  cursor: pointer;
  padding-right: 18px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%232C5281' stroke-width='2' stroke-linecap='round'><polyline points='3,5 6,8 9,5'/></svg>") right center / 10px 10px no-repeat;
  appearance: none;
}

.catalog-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.catalog-chips .reset-all {
  margin-left: var(--s-3);
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.catalog-chips .reset-all:hover { color: var(--c-primary); }

/* ---------- Сетка карточек в каталоге ---------- */
.catalog-grid-products {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-4);
}

.catalog-pagination {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  margin-top: var(--s-9);
}

/* ---------- Шаблон пагинатора aquatrade ---------- */
.aq-pager {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-4);
  width: 100%;
}
.aq-pager__info {
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
}
.aq-pager__info strong {
  color: var(--c-text);
  font-weight: var(--fw-semibold);
}
.aq-pager__nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}
.aq-pager__btn,
.aq-pager__page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--c-text);
  text-decoration: none;
  border: 1px solid transparent;
  background: transparent;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.aq-pager__btn { padding: 0 10px; }
.aq-pager__page:hover,
.aq-pager__btn:not(.is-disabled):hover {
  background: var(--c-bg-soft);
  color: var(--c-primary);
}
.aq-pager__page.is-active {
  background: var(--c-primary);
  color: #fff;
  cursor: default;
}
.aq-pager__btn.is-disabled {
  color: var(--c-text-subtle);
  cursor: not-allowed;
  opacity: 0.55;
}
.aq-pager__dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 40px;
  color: var(--c-text-subtle);
  user-select: none;
  font-weight: var(--fw-semibold);
}

/* ---------- Главная колонка с контентом раздела ---------- */
.catalog-grid__main {
  min-width: 0; /* fix for grid overflow */
}

.catalog-section {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.catalog-section__head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--s-3) var(--s-5);
  margin-bottom: var(--s-1);
}
.catalog-section__title {
  font-size: var(--fs-5xl);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  line-height: 1.1;
  margin: 0;
}
.catalog-section__found {
  font-size: var(--fs-base);
  color: var(--c-text-muted);
}
.catalog-section__found strong {
  color: var(--c-text);
  font-weight: var(--fw-semibold);
}

.catalog-section__toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--s-4);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--c-border-soft);
  margin-bottom: var(--s-4);
}

.catalog-sort {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--fs-sm);
}
.catalog-sort label {
  color: var(--c-text-muted);
  white-space: nowrap;
  font-weight: var(--fw-medium);
}
.catalog-sort select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  height: 38px;
  padding: 0 36px 0 14px;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
  background-color: #fff;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%232C5281' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='3,5 6,8 9,5'/></svg>");
  background-position: right 12px center;
  background-size: 12px 12px;
  background-repeat: no-repeat;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--c-text);
  cursor: pointer;
  min-width: 200px;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.catalog-sort select:hover {
  border-color: var(--c-primary);
}
.catalog-sort select:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(44, 82, 129, 0.12);
}
.catalog-sort select option {
  font-weight: var(--fw-medium);
  color: var(--c-text);
  background: #fff;
}

.catalog-empty {
  padding: var(--s-12) var(--s-5);
  text-align: center;
  color: var(--c-text-muted);
  background: var(--c-bg-soft);
  border-radius: var(--r-lg);
}

/* ---------- Фильтр: блок цены ---------- */
.filter__price {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--s-4);
}
.filter__price .input {
  height: 36px;
  font-size: var(--fs-sm);
  padding-inline: var(--s-3);
  width: 100%;
}
.filter__price-sep {
  color: var(--c-text-subtle);
  font-size: var(--fs-base);
}

/* ---------- Двойной ползунок цены ---------- */
.price-slider {
  position: relative;
  height: 24px;
  padding: 0 8px;
}
.price-slider__track {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  height: 4px;
  background: var(--c-border);
  border-radius: var(--r-pill);
  transform: translateY(-50%);
}
.price-slider__fill {
  position: absolute;
  top: 0; bottom: 0;
  background: var(--c-primary);
  border-radius: var(--r-pill);
}

.price-slider__input {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 24px;
  width: 100%;
  margin: 0;
  background: transparent;
  pointer-events: none;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  z-index: 2;
}
.price-slider__input::-webkit-slider-runnable-track {
  height: 4px;
  background: transparent;
  border: 0;
}
.price-slider__input::-moz-range-track {
  height: 4px;
  background: transparent;
  border: 0;
}
.price-slider__input::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  pointer-events: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--c-primary);
  cursor: grab;
  margin-top: -6px;
  box-shadow: 0 1px 3px rgba(10, 30, 91, 0.20);
  transition: transform var(--dur-fast) var(--ease);
}
.price-slider__input::-moz-range-thumb {
  pointer-events: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--c-primary);
  cursor: grab;
  box-shadow: 0 1px 3px rgba(10, 30, 91, 0.20);
}
.price-slider__input::-webkit-slider-thumb:hover,
.price-slider__input::-webkit-slider-thumb:active { transform: scale(1.15); }
.price-slider__input::-moz-range-thumb:hover { transform: scale(1.15); }

.catalog-empty--filter {
  margin-top: var(--s-4);
}

/* ---------- Блок "Похожие товары" на детальной странице ---------- */
.related-products {
  margin-top: var(--s-10);
}
.related-products__head {
  margin-bottom: var(--s-5);
}
.related-products__title {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  margin: 0;
}
.related-products .catalog-grid-products {
  grid-template-columns: repeat(4, 1fr);
}
@media (max-width: 991px) {
  .related-products .catalog-grid-products {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 767px) {
  .related-products .catalog-grid-products {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Состояние загрузки сетки при AJAX-фильтрации */
.catalog-grid-products.is-loading {
  position: relative;
  opacity: 0.5;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease);
}
.catalog-grid-products.is-loading::after {
  content: '';
  position: absolute;
  top: 20px; left: 50%;
  width: 32px; height: 32px;
  margin-left: -16px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: aq-spin 0.7s linear infinite;
}
@keyframes aq-spin { to { transform: rotate(360deg); } }

/* ---------- Чекбоксы в фильтре ---------- */
.filter__body .checkbox {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 5px 0;
  font-size: var(--fs-sm);
  cursor: pointer;
  position: relative;
}
.filter__body .checkbox.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.filter__body .checkbox input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.filter__body .checkbox .box {
  width: 18px; height: 18px;
  border-radius: var(--r-xs);
  border: 1.5px solid var(--c-border-strong);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.filter__body .checkbox .box::after {
  content: '';
  width: 10px; height: 10px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='2,7 6,11 12,3'/></svg>") center / contain no-repeat;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}
.filter__body .checkbox input:checked + .box {
  background: var(--c-primary);
  border-color: var(--c-primary);
}
.filter__body .checkbox input:checked + .box::after { opacity: 1; }
.filter__body .checkbox:hover .box { border-color: var(--c-primary); }
.filter__body .checkbox .lbl { flex: 1; color: var(--c-text); }
.filter__body .checkbox .count {
  color: var(--c-text-subtle);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1023px) {
  .catalog-grid { grid-template-columns: 220px 1fr; gap: var(--s-4); }
}
@media (max-width: 767px) {
  .catalog-grid { grid-template-columns: 1fr; }
  .filter {
    position: static;
    margin-bottom: var(--s-4);
  }
  .catalog-grid-products { grid-template-columns: repeat(2, 1fr); }
  .catalog-section__title { font-size: var(--fs-4xl); }
}
@media (max-width: 480px) {
  .catalog-grid-products { grid-template-columns: 1fr; }
}
