/* ============================================================
   AUTO108 v4 · Catalog Section
   Страница раздела каталога /preview-v4/catalog/...
   - .v4-cat-layout         — обёртка (sidebar + content или только content).
                              Имя выбрано так, чтобы не пересекаться с .v4-section
                              из products_carousel.css (используется на главной).
   - .v4-section-filter     — sticky-сайдбар smart-фильтра
   - .v4-section-content    — главная колонка (H1 + подкатегории + товары)
   - .v4-cats / .v4-cat     — компактный список подкатегорий
   ============================================================ */

.v4-cat-layout {
	display: grid;
	grid-template-columns: 1fr;
	gap: 24px;
	max-width: var(--container-max);
	margin: 0 auto;
	padding: 24px;
}

.v4-cat-layout--with-filter {
	grid-template-columns: 260px 1fr;
}

.v4-section-filter {
	align-self: start;
	position: sticky;
	top: 156px;
	min-width: 0;
}

.v4-section-content {
	min-width: 0;
}

.v4-section-h1 {
	font-family: var(--font-display);
	font-weight: 800;
	font-size: 28px;
	letter-spacing: -0.02em;
	line-height: 1.15;
	color: var(--ink-900);
	margin: 0 0 18px;
}

/* ---------- Подкатегории — компактный список ---------- */

.v4-cats {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 10px;
	margin-bottom: 28px;
}

.v4-cat {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 14px;
	background: #fff;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	text-decoration: none;
	color: inherit;
	min-height: 76px;
	transition: border-color .15s, box-shadow .15s, transform .15s;
}

.v4-cat:hover {
	border-color: var(--accent);
	box-shadow: 0 4px 14px rgba(0, 0, 0, .05);
	transform: translateY(-1px);
}

.v4-cat-img {
	width: 56px;
	height: 56px;
	flex-shrink: 0;
	display: grid;
	place-items: center;
	background: #fff;
	border-radius: 8px;
	overflow: hidden;
}

.v4-cat-img img {
	display: block;
	width: 100%;
	height: 100%;
	/* contain + явный размер бокса — картинка целиком и по центру, без обрезки низа
	 * (max-* в grid-ячейке давал боксу авто-высоту больше ячейки → низ срезался). */
	object-fit: contain;
	object-position: center;
}

.v4-cat-img-svg {
	width: 100%;
	height: 100%;
	display: block;
}

.v4-cat-name {
	flex: 1;
	font-family: var(--font-display);
	font-weight: 600;
	font-size: 14px;
	line-height: 1.3;
	color: var(--ink-900);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	min-width: 0;
}

.v4-cat-count {
	flex-shrink: 0;
	font-family: var(--font-mono);
	font-size: 11px;
	font-weight: 600;
	color: var(--ink-500);
	background: var(--ink-100);
	padding: 3px 8px;
	border-radius: 6px;
	letter-spacing: 0.02em;
}

/* ---------- Список товаров (.v1-prods из v4_popular) ----------
   Перебиваем дефолтный grid 5-в-ряд из design.css на сетку, согласованную
   с layout-ом раздела: 4 колонки без фильтра, 3 — со sticky-сайдбаром.
   На уровне .v4-section-content — чтобы НЕ ломать главную /preview-v4/,
   где тот же шаблон v4_popular живёт в .v1-cats-like контекстах.        */

.v4-section-content .v1-prods {
	grid-template-columns: repeat(4, minmax(0, 1fr));
}

.v4-cat-layout--with-filter .v4-section-content .v1-prods {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* ---------- Пагинация ---------- */
/* Bitrix:main.pagenavigation в разных версиях ядра рендерит разные обёртки:
   - .bx-pagination (новый стиль)
   - .modern-page-navigation (классический D7)
   - .bx-pager (старый)
   Покрываем все три, чтобы скин был одинаковый независимо от ядра.        */

.v4-section-content .bx-pagination,
.v4-section-content .modern-page-navigation,
.v4-section-content .bx-pager {
	margin: 28px 0 0;
	display: flex;
	justify-content: center;
	flex-wrap: wrap;
	gap: 6px;
}

.v4-section-content .bx-pagination-container,
.v4-section-content .modern-page-navigation > div {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.v4-section-content .bx-pagination-container ul,
.v4-section-content .modern-page-navigation ul {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	list-style: none;
	margin: 0;
	padding: 0;
}

.v4-section-content .bx-pagination-container li,
.v4-section-content .modern-page-navigation li {
	margin: 0;
}

/* Стандартный «кнопочный» вид (≈v1-cat) для всех элементов пагинации */
.v4-section-content .bx-pagination a,
.v4-section-content .bx-pagination span,
.v4-section-content .modern-page-navigation a,
.v4-section-content .modern-page-navigation span,
.v4-section-content .bx-pager a,
.v4-section-content .bx-pager span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 38px;
	height: 38px;
	padding: 0 12px;
	background: #fff;
	border: 1px solid var(--line);
	border-radius: 8px;
	font-family: var(--font-display);
	font-weight: 600;
	font-size: 13px;
	color: var(--ink-800);
	text-decoration: none;
	transition: border-color .15s, background .15s, color .15s;
}

.v4-section-content .bx-pagination a:hover,
.v4-section-content .modern-page-navigation a:hover,
.v4-section-content .bx-pager a:hover {
	border-color: var(--accent);
	color: var(--accent);
}

/* Текущая страница — чёрная плашка */
.v4-section-content .bx-pagination .bx-active,
.v4-section-content .bx-pagination .bx-active span,
.v4-section-content .modern-page-navigation .modern-page-current,
.v4-section-content .bx-pager .bx-active span {
	background: var(--ink-900);
	border-color: var(--ink-900);
	color: #fff;
	cursor: default;
}

/* Prev/Next кнопки — моноширинный шрифт для стрелок/слов */
.v4-section-content .bx-pag-prev a,
.v4-section-content .bx-pag-next a,
.v4-section-content .modern-page-previous,
.v4-section-content .modern-page-next {
	font-family: var(--font-mono);
	font-size: 12px;
	letter-spacing: 0.04em;
}

/* ---------- catalog.smart.filter — стандартный шаблон в v4-обёртке ---------- */

/* Контейнер фильтра — белая карточка как другие v4-блоки */
.v4-section-filter .bx-filter,
.v4-section-filter > div {
	background: #fff;
	border: 1px solid var(--line);
	border-radius: 12px;
	padding: 16px;
}

.v4-section-filter .bx-filter-title {
	font-family: var(--font-display);
	font-weight: 700;
	font-size: 13px;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--ink-900);
	margin: 0 0 12px;
}

/* ---------- Mobile ---------- */

@media (max-width: 1100px) {
	.v4-section-content .v1-prods {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
	.v4-cat-layout--with-filter .v4-section-content .v1-prods {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 900px) {
	.v4-cat-layout--with-filter {
		grid-template-columns: 1fr;
	}
	.v4-section-filter {
		position: static;
		order: 2;
	}
	.v4-section-content {
		order: 1;
	}
	.v4-section-content .v1-prods,
	.v4-cat-layout--with-filter .v4-section-content .v1-prods {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (max-width: 720px) {
	/* Мобильная — 2 карточки товара в строку. */
	.v4-section-content .v1-prods,
	.v4-cat-layout--with-filter .v4-section-content .v1-prods {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 600px) {
	.v4-cat-layout {
		padding: 16px;
		gap: 16px;
	}
	.v4-section-h1 {
		font-size: 22px;
	}
	/* Подбор марки/модели — 2 карточки в строку, чтобы не листать длинный список. */
	.v4-cats {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 8px;
		margin-bottom: 20px;
	}
	.v4-cat {
		min-height: 64px;
		padding: 8px 12px;
		gap: 8px;
	}
	.v4-section-content .v1-prods,
	.v4-cat-layout--with-filter .v4-section-content .v1-prods {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
	.v4-cat-img {
		width: 48px;
		height: 48px;
	}
}

/* ---------- Пагинация (.v4-pager) ---------- */
/* Подключается шаблоном v4_pager (bitrix:main.pagenavigation) под списком
   товаров. Обёрнут в <nav class="v4-pager-wrap"> в шаблоне v4_popular,
   чтобы место в DOM было всегда (даже при пустой NAV_STRING). */

.v4-pager-wrap {
	margin: 28px 0 8px;
	min-height: 1px; /* якорь в DOM, даже если внутри пусто */
}

.v4-pager {
	display: flex;
	justify-content: center;
}

.v4-pager-list {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.v4-pager-item {
	display: inline-flex;
}

.v4-pager-link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	padding: 0 10px;
	border-radius: 10px;
	background: #fff;
	color: var(--ink-700, #334155);
	font-family: var(--font-display, inherit);
	font-weight: 600;
	font-size: 14px;
	line-height: 1;
	text-decoration: none;
	border: 1px solid var(--line, #E2E8F0);
	transition: background .15s ease, color .15s ease, border-color .15s ease;
}

a.v4-pager-link:hover {
	background: var(--accent-soft, #EDF2F8);
	color: var(--accent, #238EE3);
	border-color: var(--accent, #238EE3);
}

.v4-pager-link--active,
.v4-pager-item--active .v4-pager-link {
	background: var(--accent, #238EE3);
	color: #fff;
	border-color: var(--accent, #238EE3);
	cursor: default;
}

.v4-pager-link--disabled {
	opacity: .35;
	cursor: not-allowed;
}

.v4-pager-item--prev .v4-pager-link svg,
.v4-pager-item--next .v4-pager-link svg {
	width: 8px;
	height: 12px;
	fill: currentColor;
}
/* стрелка «Назад» — отзеркалена */
.v4-pager-item--prev .v4-pager-link svg {
	transform: rotate(180deg);
}

.v4-pager-item--ellipsis span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 24px;
	height: 40px;
	color: var(--ink-500, #64748B);
	font-weight: 600;
}

/* ---------- SEO-описание раздела (.v4-section-description) ---------- */
/* HTML из поля DESCRIPTION секции (контент-менеджер пишет в админке).
   Поэтому стили задаются вложенно — p, ul, h2/h3 — на случай произвольной
   разметки. Структура — типографика чтения, не «карточка». */

.v4-section-description {
	margin: 24px 0 8px;
	padding: 20px 24px;
	background: #fff;
	border: 1px solid var(--line, #E2E8F0);
	border-radius: 14px;
	color: var(--ink-700, #334155);
	font-size: 15px;
	line-height: 1.65;
}

.v4-section-description > *:first-child { margin-top: 0; }
.v4-section-description > *:last-child  { margin-bottom: 0; }

.v4-section-description h2,
.v4-section-description h3 {
	font-family: var(--font-display, inherit);
	font-weight: 700;
	color: var(--ink-900, #0F172A);
	letter-spacing: -0.01em;
	line-height: 1.25;
	margin: 18px 0 10px;
}
.v4-section-description h2 { font-size: 22px; }
.v4-section-description h3 { font-size: 18px; }

.v4-section-description p {
	margin: 0 0 12px;
}

.v4-section-description ul,
.v4-section-description ol {
	margin: 8px 0 12px;
	padding-left: 22px;
}
.v4-section-description li { margin: 4px 0; }

.v4-section-description a {
	color: var(--accent, #238EE3);
	text-decoration: underline;
	text-underline-offset: 2px;
}
.v4-section-description a:hover { text-decoration: none; }

.v4-section-description img {
	max-width: 100%;
	height: auto;
	border-radius: 8px;
	margin: 8px 0;
}

.v4-section-description table {
	width: 100%;
	border-collapse: collapse;
	margin: 12px 0;
	font-size: 14px;
}
.v4-section-description th,
.v4-section-description td {
	padding: 8px 12px;
	border: 1px solid var(--line, #E2E8F0);
	text-align: left;
}
.v4-section-description th {
	background: var(--accent-soft, #EDF2F8);
	font-weight: 600;
}

@media (max-width: 768px) {
	.v4-section-description {
		padding: 16px;
		font-size: 14px;
	}
	.v4-section-description h2 { font-size: 20px; }
	.v4-section-description h3 { font-size: 17px; }
}

