/**
 * @file: catalog.css
 * @description: Стили каталога (сетка, сайдбар фильтров, кнопки Фильтры/Сортировка)
 * Подключать после base.css
 */

/* Описание категории: одна строка по умолчанию, градиент вниз, кнопка по центру */
.category-description {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.category-description__text {
  width: 100%;
  line-height: 1.5;
}
.category-description--collapsed .category-description__text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, black 0, black 1.2em, transparent 2.6em);
  mask-image: linear-gradient(to bottom, black 0, black 1.2em, transparent 2.6em);
  mask-size: 100% 100%;
  -webkit-mask-size: 100% 100%;
}
.category-description:not(.category-description--collapsed) .category-description__text {
  display: block;
  -webkit-mask-image: none;
  mask-image: none;
}
.category-description__toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: var(--flux-accent, #0d6efd);
  cursor: pointer;
  font-size: 0.85em;
  line-height: 1.2;
}
.category-description__toggle:hover {
  text-decoration: underline;
}
.category-description__toggle[aria-expanded="true"] .category-description__chevron {
  transform: rotate(180deg);
}
.category-description__toggle .category-description__toggle-label[hidden] {
  display: none;
}

/* Подвал категории: описание + SEO-блок из TV */
.flux-catalog-footer__description + .flux-catalog-footer__seo {
  margin-top: 1.5em;
}
.flux-catalog-footer p {
  margin: 0 0 0.75em;
}
.flux-catalog-footer p:last-child {
  margin-bottom: 0;
}

/* Catalog layout: двухколоночная сетка только с 1024px, чтобы не перебивать base.css на планшете/мобильном */
.flux-layout {
  display: grid;
  gap: 24px;
  align-items: start;
}
@media (min-width: 1024px) {
  .flux-layout {
    grid-template-columns: 280px 1fr;
  }
  /* 4 товара в ряд, пропорциональное сжатие при уменьшении экрана */
  .flux-layout > section {
    min-width: 0;
  }
  .flux-mfilter-results.flux-products__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .flux-mfilter-results {
    min-width: 0;
  }
  .flux-mfilter-results .flux-product {
    min-width: 0;
  }
}
/* Оверлей не участвует в сетке на ПК — скрыт по умолчанию; при <1024px показывается по кнопке «Фильтры» */
.flux-filters-overlay {
  display: none;
}
/* При ширине <1024px: блок фильтров скрыт, открывается по кнопке «Фильтры» (выдвижная панель + оверлей) */
@media (max-width: 1023px) {
  .flux-filters-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 199;
    opacity: 0;
    transition: opacity 0.25s ease;
  }
  .flux-filters-overlay.is-visible {
    display: block;
    opacity: 1;
  }
  .flux-sidebar--filters {
    display: block;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 85%;
    max-width: 320px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    padding-top: 56px;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
  }
  .flux-sidebar--filters.is-open {
    transform: translateX(0);
  }
  .flux-sidebar--filters .flux-sidebar__close-btn {
    display: flex;
    position: fixed;
    top: 12px;
    right: 12px;
    left: auto;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--flux-text);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: 1;
    border-radius: 12px;
  }
  .flux-sidebar--filters .flux-sidebar__close-btn:hover {
    background: #f0f0f0;
  }
  [data-catalog-filters-toggle] {
    display: inline-flex;
  }
  /* Пропорциональное сжатие сетки товаров (3 колонки на планшете) */
  .flux-layout > section {
    min-width: 0;
  }
  .flux-mfilter-results.flux-products__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-width: 0;
  }
  .flux-mfilter-results .flux-product {
    min-width: 0;
  }
}
.flux-catalog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.flux-catalog-title {
  margin: 0;
  font-size: var(--flux-h2);
  font-weight: 800;
  line-height: 1.2;
  min-width: 0;
}
.flux-catalog-subtitle {
  width: 100%;
  margin: 6px 0 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--flux-muted);
  order: 2;
}
@media (max-width: 767px) {
  .flux-catalog-head {
    flex-wrap: nowrap;
    gap: 12px;
  }
  .flux-catalog-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1.25rem;
  }
}
.flux-catalog-head__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  order: 3;
}
/* Кнопку «Фильтры» скрываем только на ПК (на мобильном/планшете показывается из base.css) */
@media (min-width: 1024px) {
  [data-catalog-filters-toggle] {
    display: none;
  }
}

/* Блок подкатегорий (плашки с иконками 32×32 из TV category_icon) */
.catalog-varieties {
  margin: 20px 0 24px;
}
.catalog-varieties__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}
.catalog-variety-plate {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--flux-text);
  text-decoration: none;
  background: var(--flux-bg-alt, #f5f5f5);
  border: 1px solid transparent;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.catalog-variety-plate:hover {
  background: #eee;
  border-color: var(--flux-border);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}
.catalog-variety-plate:focus-visible {
  outline: 2px solid var(--flux-accent, #2d7a3e);
  outline-offset: 2px;
}
.catalog-variety-plate__icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: transform 0.25s ease;
}
.catalog-variety-plate:hover .catalog-variety-plate__icon {
  transform: scale(1.08);
}
.catalog-variety-plate__icon--placeholder {
  background: linear-gradient(135deg, #e0e0e0 0%, #ececec 100%);
  background-size: auto;
}
.catalog-variety-plate--all .catalog-variety-plate__icon--placeholder {
  background: linear-gradient(135deg, #d4e5d9 0%, #e8f0ea 100%);
}
.catalog-variety-plate__label {
  white-space: nowrap;
}
.catalog-variety-plate--active {
  cursor: default;
  background: var(--flux-accent, #2d7a3e);
  color: #fff;
  border-color: var(--flux-accent, #2d7a3e);
}
.catalog-variety-plate--active:hover {
  transform: none;
  background: var(--flux-accent, #2d7a3e);
  border-color: var(--flux-accent, #2d7a3e);
  box-shadow: none;
}
.catalog-variety-plate--active .catalog-variety-plate__icon--placeholder {
  background: rgba(255, 255, 255, 0.35);
}

/* Sidebar filters — минимализм, без бордера */
.flux-sidebar {
  padding: 20px;
  background: #fff;
}
.flux-sidebar--filters {
  padding: 24px;
}

/* Сайдбар: пункт меню «Каталог» — по умолчанию свёрнут, раскрывается списком */
.flux-sidebar-menu {
  margin: 0 0 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--flux-border);
}
.flux-sidebar-menu__summary {
  list-style: none;
  font-weight: 700;
  font-size: 14px;
  color: var(--flux-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  user-select: none;
}
.flux-sidebar-menu__summary::-webkit-details-marker {
  display: none;
}
.flux-sidebar-menu__summary::after {
  content: "";
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat center;
  transition: transform 0.2s ease;
}
.flux-sidebar-menu[open] .flux-sidebar-menu__summary::after {
  transform: rotate(180deg);
}
.flux-sidebar-menu__list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.flux-sidebar-menu__list li {
  margin: 0;
}
.flux-sidebar-menu__list a {
  display: block;
  padding: 8px 0;
  font-size: 14px;
  color: var(--flux-text);
  text-decoration: none;
  transition: color 0.2s;
}
.flux-sidebar-menu__list a:hover {
  color: var(--flux-accent);
}
.flux-sidebar__title {
  margin: 0 0 20px;
  font-size: 16px;
  font-weight: 700;
  color: var(--flux-text);
}
.flux-sidebar__actions {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.flux-sidebar__apply {
  width: 100%;
}
.flux-sidebar__reset {
  width: 100%;
  background: #f5f5f5;
  color: var(--flux-text);
}
.flux-sidebar__reset:hover {
  background: #eee;
}
.flux-sidebar__close-btn {
  display: none;
}
@media (max-width: 767px) {
  .flux-sidebar.is-open .flux-sidebar__close-btn {
    display: block;
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
    padding: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--flux-text);
  }
}

/* Filter group — аккордеон */
.flux-filter-group {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--flux-border);
}
.flux-filter-group:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.flux-filter-group__summary {
  list-style: none;
  font-weight: 700;
  font-size: 14px;
  color: var(--flux-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  user-select: none;
}
.flux-filter-group__summary::-webkit-details-marker {
  display: none;
}
.flux-filter-group__summary::after {
  content: "";
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat center;
  transition: transform 0.2s ease;
}
.flux-filter-group[open] .flux-filter-group__summary::after {
  transform: rotate(180deg);
}
.flux-filter-group__label {
  font-weight: 700;
  font-size: 14px;
  color: var(--flux-text);
  margin-bottom: 12px;
}

/* Категории — чипы */
.flux-filter-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.flux-filter-category {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 13px;
  color: var(--flux-text);
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}
.flux-filter-category:hover {
  background: #f5f5f5;
  color: var(--flux-text);
}
.flux-filter-category--active {
  background: #f0f0f0;
  color: var(--flux-text);
  font-weight: 600;
  cursor: default;
}

/* Диапазон: поля + слайдер */
.flux-filter-range {
  margin-top: 12px;
}
.flux-filter-range__inputs {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.flux-filter-range__input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--flux-border);
  border-radius: 12px;
  font-size: 14px;
  color: var(--flux-text);
  background: #fff;
}
.flux-filter-range__input::placeholder {
  color: var(--flux-muted);
}
.flux-filter-range__input:focus {
  outline: none;
  border-color: var(--flux-accent);
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}
.flux-filter-range__slider {
  position: relative;
  height: 24px;
  padding: 0 6px;
}
.flux-filter-range__track {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 6px;
  margin-top: -3px;
  background: #e8e8e8;
  border-radius: 3px;
}
.flux-filter-range__fill {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--flux-accent);
  border-radius: 3px;
  pointer-events: none;
}
.flux-filter-range__handle {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  margin-top: -8px;
  background: #fff;
  border: 2px solid var(--flux-accent);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  cursor: grab;
  pointer-events: none;
}
.flux-filter-range__handle:active {
  cursor: grabbing;
}

/* noUiSlider в сайдбаре: чёрные ползунки, без цифр на ручках */
.flux-sidebar .noUi-handle {
  background: #000;
  border: 2px solid #000;
  border-radius: 50%;
}
.flux-sidebar .noUi-handle:hover {
  background: #333;
  border-color: #333;
}
.flux-sidebar .noUi-tooltip {
  display: none !important;
}

/* Чекбоксы с количеством */
.flux-filter-options {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.flux-filter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 14px;
  color: var(--flux-text);
  cursor: pointer;
}
.flux-filter-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin: 0;
  accent-color: var(--flux-accent);
  cursor: pointer;
}
.flux-filter-option__text {
  flex: 1;
  min-width: 0;
}
.flux-filter-option__count {
  flex-shrink: 0;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--flux-muted);
  background: #f0f0f0;
  border-radius: 10px;
}
/* Счётчики без скобок (mFilter по умолчанию добавляет ::before/::after) */
.flux-sidebar .mfilter-count::before,
.flux-sidebar .mfilter-count::after {
  content: none;
}

/* Legacy (если остались старые классы) */
.flux-filter {
  margin-top: 14px;
}
.flux-filter__title {
  font-weight: 700;
  margin: 0 0 8px;
}
.flux-filter__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  color: var(--flux-text);
}
.flux-pagination {
  display: flex;
  gap: 8px;
  margin-top: 24px;
}
.mfilter-slider .noUi-connect {
  background: var(--flux-accent);
}
/* --- Панель mFilter: сортировка, лимит, вид (единый полукруглый стиль) --- */
.flux-mfilter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 10px 20px;
  background: var(--flux-bg-alt, #f5f5f5);
  border: 1px solid var(--flux-border);
  border-radius: 999px;
}
.flux-mfilter-toolbar__count {
  font-size: 14px;
}
.flux-mfilter-toolbar__count .mfilter-total {
  font-weight: 700;
  color: var(--flux-text);
}
.flux-mfilter-toolbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.flux-mfilter-toolbar__desktop {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.flux-mfilter-toolbar__mobile {
  display: none;
}
/* Селекты и кнопки внутри панели — в одном полукруглом стиле */
.flux-mfilter-toolbar .flux-mfilter-select {
  padding: 8px 16px;
  min-height: 40px;
  width: auto;
  border-radius: 999px;
  border: 1px solid var(--flux-border);
  background: #fff;
  font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.flux-mfilter-toolbar .flux-mfilter-select:hover,
.flux-mfilter-toolbar .flux-mfilter-select:focus {
  border-color: var(--flux-accent, #2d7a3e);
  outline: none;
}
.flux-mfilter-toolbar .flux-btn {
  border-radius: 999px;
}
.flux-mfilter-toolbar__limit-label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.flux-mfilter-toolbar__limit-label span {
  white-space: nowrap;
}
.flux-mfilter-toolbar .mfilter-view-switcher {
  display: flex;
  gap: 6px;
}
.flux-mfilter-toolbar .flux-btn--icon {
  padding: 8px;
  min-width: 40px;
}
.flux-mfilter-toolbar .flux-btn--icon svg {
  display: block;
}

/* Мобильный: только кнопка «Сортировка» + переключатель вида */
@media (max-width: 767px) {
  .flux-mfilter-toolbar {
    gap: 12px;
    padding: 10px 14px;
  }
  .flux-mfilter-toolbar__actions {
    flex-wrap: nowrap;
    min-width: 0;
  }
  .flux-mfilter-toolbar__desktop {
    display: none;
  }
  .flux-mfilter-toolbar__mobile {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
    justify-content: flex-end;
  }
  .flux-mfilter-toolbar__count {
    flex: 1;
    min-width: 0;
  }
  .flux-mfilter-toolbar .flux-mfilter-dropdown__trigger {
    border-radius: 999px;
  }
}

/* Dropdown «Сортировка» (мобильный) */
.flux-mfilter-dropdown {
  position: relative;
}
.flux-mfilter-dropdown__trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.flux-mfilter-dropdown__label {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flux-mfilter-dropdown__chevron {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.flux-mfilter-dropdown[data-open="true"] .flux-mfilter-dropdown__chevron {
  transform: rotate(180deg);
}
.flux-mfilter-dropdown__panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  max-width: 90vw;
  background: #fff;
  border-radius: var(--flux-radius-md);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  border: 1px solid var(--flux-border);
  padding: 12px 0;
  z-index: 100;
  max-height: 70vh;
  overflow-y: auto;
}
.flux-mfilter-dropdown__panel[hidden] {
  display: none !important;
}
.flux-mfilter-dropdown__section {
  padding: 0 4px 8px;
}
.flux-mfilter-dropdown__section:last-child {
  padding-bottom: 0;
}
.flux-mfilter-dropdown__section-title {
  display: block;
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--flux-muted);
}
.flux-mfilter-dropdown__option {
  display: block;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  font-size: 14px;
  color: var(--flux-text);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.flux-mfilter-dropdown__option:hover {
  background: #f0f0f0;
}
.flux-mfilter-dropdown__option.active {
  background: rgba(0, 0, 0, 0.06);
  font-weight: 600;
}

/* Режим «список» mFilter — одна колонка */
.flux-products__grid--list {
  grid-template-columns: 1fr;
}

