/* =====================================================================
 * Доработки по ТЗ 19.10.2026. Подключается последним (inc/catalog.php).
 * Мобильная версия — основная.
 * ===================================================================== */

:root {
	--tvb-accent: #e8336b;       /* ярко-розовый для «ТОП продаж недели» */
	--tvb-accent-dark: #c81f55;
	--tvb-text: #212121;
	--tvb-soft: #fff3f5;
}

/* ---------------------------------------------------------------------
 * Главная: сетки товаров
 * ПК и планшет (≥768px): «ТОП продаж недели» и «Хиты продаж» — 4 колонки.
 * Мобильный (≤767px): оба блока — 2 колонки.
 * Слайдеры («Выгодные предложения недели», «Online-витрина», Instagram) не трогаем.
 * ------------------------------------------------------------------- */
.product-card-item {
	min-width: 0;
}

.catalog-page-products .product-card-item {
	text-decoration: none;
	color: inherit;
}

/* «ТОП продаж недели» */
.tvb-top {
	background: var(--tvb-accent);
	padding: 60px 0 50px;
}

.tvb-top__header {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 30px;
}

.tvb-top__title {
	margin: 0;
	color: #fff;
	font-size: 40px;
	line-height: 1.15;
	font-weight: 500;
	text-transform: uppercase;
}

.tvb-top__more {
	color: #fff;
	font-weight: 500;
	white-space: nowrap;
}

/*
 * «ТОП» и «Хиты продаж»: всегда 4 колонки на ПК и планшете.
 * В теме у .hits__grid было auto-fit по 330px — из-за этого на 1440px
 * выходило 3 колонки, на 1024px — 2, а на широком экране — 4.
 */
.tvb-top__grid,
.hits__grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	grid-gap: 30px;
	justify-content: stretch;
}

.tvb-top__grid .product-card-image,
.hits__grid .product-card-image {
	height: auto;
	aspect-ratio: 3 / 4;
	overflow: hidden;
}

.tvb-top__grid .product-card-image > img,
.hits__grid .product-card-image > img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

@media (max-width: 1140px) {
	.tvb-top__grid,
	.hits__grid {
		grid-gap: 20px;
	}
}

/* Белый текст на розовом; иконка корзины остаётся тёмной на светлом круге темы */
.tvb-top__grid .product-card-name,
.tvb-top__grid .product-card-price,
.tvb-top__grid .product-card-price * {
	color: #fff;
}

/* Мобильный: «ТОП» и «Хиты продаж» — 2 колонки, одинаковые карточки */
@media (max-width: 767px) {
	.tvb-top {
		padding: 30px 0;
	}

	.tvb-top__title {
		font-size: 26px;
	}

	.tvb-top__grid,
	.hits__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		grid-gap: 16px 10px;
	}

	.tvb-top__grid .product-card-image,
	.hits__grid .product-card-image,
	.catalog-page-products .product-card-image {
		height: auto;
		aspect-ratio: 3 / 4;
		overflow: hidden;
	}

	.tvb-top__grid .product-card-image > img,
	.hits__grid .product-card-image > img,
	.catalog-page-products .product-card-image > img {
		width: 100%;
		height: 100%;
		object-fit: cover;
	}

	.tvb-top__grid .product-card-footer,
	.hits__grid .product-card-footer,
	.catalog-page-products .product-card-footer {
		align-items: flex-end;
	}

	.tvb-top__grid .product-card-footer-left,
	.hits__grid .product-card-footer-left,
	.catalog-page-products .product-card-footer-left {
		flex: 1 1 auto;
		min-width: 0;
	}

	.tvb-top__grid .product-card-footer-right,
	.hits__grid .product-card-footer-right,
	.catalog-page-products .product-card-footer-right {
		flex: 0 0 36px;
	}

	.tvb-top__grid .product-card-name,
	.hits__grid .product-card-name,
	.catalog-page-products .product-card-name {
		margin-top: 8px;
		font-size: 14px;
		line-height: 1.25;
		overflow-wrap: anywhere;
	}

	.tvb-top__grid .product-card-price,
	.hits__grid .product-card-price,
	.catalog-page-products .product-card-price {
		margin-top: 4px;
		font-size: 16px;
		line-height: 1.2;
	}

	.tvb-top__grid .add-to-cart svg,
	.hits__grid .add-to-cart svg,
	.catalog-page-products .add-to-cart svg {
		width: 26px;
		height: auto;
	}
}

/* ---------------------------------------------------------------------
 * Футер: подменю «Каталог» не показываем — только пункты 1-го уровня
 * ------------------------------------------------------------------- */
.footer-menu .sub-menu {
	display: none !important;
}

/* ---------------------------------------------------------------------
 * Каталог (категории)
 * Десктоп — как было. Мобильный/планшет (≤991px): боковой колонки нет,
 * фильтр открывается панелью по кнопке «Фильтр», товары 2 колонки,
 * без внутренних прокруток — листается только сама страница.
 * ------------------------------------------------------------------- */
.catalog-toolbar {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 12px;
	margin-bottom: 24px;
}

.catalog-toolbar .catalog-per-page {
	margin-bottom: 0;
}

.catalog-filters-toggle,
.catalog-filters-head,
.catalog-filters-backdrop {
	display: none;
}

@media (max-width: 991px) {
	.catalog-page {
		display: block;
		margin-left: 0;
		margin-right: 0;
	}

	.catalog-page-products {
		flex: none;
		width: 100%;
		padding-left: 0;
		padding-right: 0;
	}

	/* Панель фильтра (вместо боковой колонки) */
	.catalog-page-left-sidebar {
		position: fixed;
		top: 0;
		bottom: 0;
		left: 0;
		z-index: 1001;
		width: min(88vw, 360px);
		max-width: none;
		margin: 0;
		padding: 0 16px 24px;
		background: #fff;
		box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
		overflow-y: auto;
		overscroll-behavior: contain;
		transform: translateX(-105%);
		visibility: hidden;
		transition: transform 0.25s ease, visibility 0.25s;
		flex: none;
	}

	.catalog-page-left-sidebar.is-open {
		transform: translateX(0);
		visibility: visible;
	}

	.catalog-filters-head {
		position: sticky;
		top: 0;
		z-index: 2;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin: 0 -16px 12px;
		padding: 14px 16px;
		background: #fff;
		border-bottom: 1px solid #f0d5dc;
	}

	.catalog-filters-head__title {
		font-size: 20px;
		font-weight: 700;
	}

	.catalog-filters-close {
		width: 36px;
		height: 36px;
		padding: 0;
		border: 0;
		background: transparent;
		color: var(--tvb-text);
		font-size: 30px;
		line-height: 1;
		cursor: pointer;
	}

	.catalog-filters-backdrop {
		position: fixed;
		inset: 0;
		z-index: 1000;
		display: block;
		background: rgba(0, 0, 0, 0.4);
	}

	.catalog-filters-backdrop[hidden] {
		display: none;
	}

	html.tvb-filters-open,
	html.tvb-filters-open body {
		overflow: hidden;
	}

	/* Внутри панели — без вложенных прокруток, sticky и ограничений высоты */
	.catalog-page-left-sidebar__sticky,
	.catalog-page-left-sidebar__scroll {
		position: static !important;
		max-height: none !important;
		height: auto !important;
		overflow: visible !important;
		padding-right: 0 !important;
	}

	/* Кнопка «Фильтр» + «Показывать» в одну строку над товарами */
	.catalog-toolbar {
		justify-content: space-between;
		margin-bottom: 16px;
	}

	.catalog-filters-toggle {
		display: inline-flex;
		align-items: center;
		gap: 8px;
		padding: 10px 18px;
		border: 1px solid #f3c2cd;
		border-radius: 10px;
		background: var(--tvb-soft);
		color: var(--tvb-text);
		font: inherit;
		font-weight: 600;
		cursor: pointer;
	}

	.catalog-filters-toggle.has-active::after {
		content: "";
		width: 8px;
		height: 8px;
		border-radius: 50%;
		background: var(--tvb-accent);
	}

	/* Товары: 2 колонки, без внутреннего скролла */
	.catalog-page-products .product-card-list {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 16px 10px;
		max-height: none !important;
		overflow: visible !important;
		margin: 0;
		padding-right: 0;
	}

	.catalog-page-products .product-card-item {
		flex: none;
		width: auto;
		padding: 0;
		margin: 0;
	}

	.catalog-page-products .product-card-image {
		height: auto;
		aspect-ratio: 3 / 4;
		overflow: hidden;
	}

	.catalog-page-products .product-card-image > img {
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
}

/* ---------------------------------------------------------------------
 * Шапка: Telegram / WhatsApp
 * ------------------------------------------------------------------- */
.header-messengers {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	margin: 6px 0 2px;
}

.header-messenger {
	display: inline-flex;
	width: 26px;
	height: 26px;
}

.header-messenger svg {
	width: 100%;
	height: 100%;
}

/* Иконки телефона и мессенджеров в правой группе — только когда блок контактов скрыт (≤1440px) */
.header-icon--mobile {
	display: none;
}

@media (max-width: 1440px) {
	.header-icon.header-icon--mobile {
		display: flex;
	}
}

@media (max-width: 480px) {
	.header-icon {
		margin-right: 8px;
	}

	.header-icon svg {
		width: 22px;
		height: 22px;
	}

	.header-icon .cart_contents_count {
		font-size: 18px;
	}

	.header-item.mobile-menu-wrap {
		margin-left: 8px;
	}
}

/* ---------------------------------------------------------------------
 * Список магазинов
 * ------------------------------------------------------------------- */
.tvb-stores {
	margin: 0;
	padding: 0;
	list-style: none;
}

.tvb-stores__item {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin: 0 0 12px;
}

.tvb-stores__item:last-child {
	margin-bottom: 0;
}

.tvb-stores__address {
	font-weight: 600;
}

.tvb-stores__note {
	font-weight: 400;
	color: #666;
}

.tvb-stores__phone {
	text-decoration: none;
	color: inherit;
	white-space: nowrap;
}

.tvb-stores__hours {
	font-size: 14px;
	color: #666;
}

.tvb-stores__route {
	font-size: 14px;
	color: var(--tvb-accent-dark);
}

/* В выпадающем списке шапки */
.tvb-stores--header {
	min-width: 260px;
	text-align: left;
}

.tvb-stores--header .tvb-stores__item {
	margin-bottom: 8px;
}

/* Футер: на мобильном список магазинов теперь виден (раньше скрыт ≤1440px) */
@media (max-width: 1440px) {
	.footer-middle-shop-list {
		display: block;
		margin: 20px 0;
	}
}

/* Блок «Наши магазины» */
.tvb-shops {
	padding-top: 60px;
	padding-bottom: 60px;
}

.tvb-shops__body {
	display: grid;
	grid-template-columns: minmax(260px, 1fr) 2fr;
	gap: 30px;
	align-items: start;
}

.tvb-shops__body > .tvb-shops__list:only-child {
	grid-column: 1 / -1;
}

.tvb-shops .tvb-stores {
	display: grid;
	gap: 16px;
}

.tvb-shops .tvb-stores__item {
	margin: 0;
	padding: 16px 18px;
	border-radius: 12px;
	background: var(--tvb-soft);
}

.tvb-shops .tvb-stores__phone {
	font-size: 18px;
	font-weight: 700;
}

.tvb-shops__map {
	min-height: 320px;
	border-radius: 12px;
	overflow: hidden;
}

.tvb-shops__map iframe {
	display: block;
	width: 100%;
	height: 420px;
	border: 0;
}

@media (max-width: 991px) {
	.tvb-shops {
		padding-top: 40px;
		padding-bottom: 40px;
	}

	.tvb-shops__body {
		grid-template-columns: 1fr;
		gap: 20px;
	}

	.tvb-shops__map iframe {
		height: 340px;
	}
}

/* ---------------------------------------------------------------------
 * Выпадающее меню шапки (3 уровня: Каталог → категория → подкатегория)
 * ПК (≥1441px): по наведению / фокусу с клавиатуры, 3-й уровень — вбок.
 * Мобильный (≤1440px): аккордеон в выезжающей панели, стрелка рядом с пунктом.
 * ------------------------------------------------------------------- */
.header-menu .sub-menu {
	margin: 0;
	padding: 0;
	list-style: none;
}

.header-menu .sub-menu a {
	display: block;
	color: var(--tvb-text);
	text-decoration: none;
	line-height: 1.3;
}

.submenu-toggle {
	display: none;
}

@media (min-width: 1441px) {
	ul.header-menu > li {
		position: relative;
		display: flex;
		align-items: center;
		height: 100%;
	}

	/* Стрелка у пунктов с подменю */
	.header-menu .menu-item-has-children > a {
		display: inline-flex;
		align-items: center;
		gap: 6px;
	}

	ul.header-menu > .menu-item-has-children > a::after {
		content: "";
		width: 6px;
		height: 6px;
		margin-top: -3px;
		border-right: 1.5px solid currentColor;
		border-bottom: 1.5px solid currentColor;
		transform: rotate(45deg);
		transition: transform 0.2s ease;
	}

	ul.header-menu > .menu-item-has-children:hover > a::after,
	ul.header-menu > .menu-item-has-children:focus-within > a::after {
		transform: rotate(-135deg);
		margin-top: 3px;
	}

	/* Подменю 2-го уровня */
	.header-menu .sub-menu {
		position: absolute;
		top: 100%;
		left: -20px;
		z-index: 100;
		min-width: 270px;
		padding: 10px 0;
		background: #fff;
		border-radius: 12px;
		box-shadow: 0 12px 40px rgba(33, 33, 33, 0.14);
		opacity: 0;
		visibility: hidden;
		transform: translateY(8px);
		transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
	}

	.header-menu li:hover > .sub-menu,
	.header-menu li:focus-within > .sub-menu {
		opacity: 1;
		visibility: visible;
		transform: translateY(0);
	}

	.header-menu .sub-menu li {
		position: relative;
	}

	.header-menu .sub-menu a {
		padding: 9px 22px;
		font-size: 15px;
		font-weight: 500;
		white-space: nowrap;
		transition: background-color 0.15s ease, color 0.15s ease;
	}

	.header-menu .sub-menu a:hover,
	.header-menu .sub-menu a:focus-visible,
	.header-menu .sub-menu .current-menu-item > a {
		background: var(--tvb-soft);
		color: var(--tvb-accent-dark);
	}

	/* Стрелка вправо у пунктов 2-го уровня с подменю */
	.header-menu .sub-menu .menu-item-has-children > a {
		display: flex;
		justify-content: space-between;
		gap: 16px;
	}

	.header-menu .sub-menu .menu-item-has-children > a::after {
		content: "";
		flex: 0 0 auto;
		width: 6px;
		height: 6px;
		border-right: 1.5px solid currentColor;
		border-bottom: 1.5px solid currentColor;
		transform: rotate(-45deg);
		align-self: center;
	}

	/* Подменю 3-го уровня — справа от пункта */
	.header-menu .sub-menu .sub-menu {
		top: -10px;
		left: 100%;
		min-width: 240px;
		transform: translateX(8px);
	}

	.header-menu .sub-menu li:hover > .sub-menu,
	.header-menu .sub-menu li:focus-within > .sub-menu {
		transform: translateX(0);
	}

	/* «Мостик», чтобы подменю не закрывалось при переводе курсора */
	.header-menu .sub-menu .menu-item-has-children::after {
		content: "";
		position: absolute;
		top: 0;
		right: -12px;
		width: 12px;
		height: 100%;
	}
}

@media (max-width: 1440px) {
	/* Панель меню: шире и с прокруткой, если пунктов много */
	.header-bottom {
		width: min(86vw, 380px);
		overflow-y: auto;
		overscroll-behavior: contain;
		padding-bottom: 40px;
	}

	ul.header-menu {
		width: 100%;
		padding-left: 24px;
		padding-right: 16px;
	}

	ul.header-menu li {
		width: 100%;
		margin-bottom: 0;
		padding-top: 0;
		padding-bottom: 0;
	}

	ul.header-menu > li {
		border-bottom: 1px solid #f3d3db;
	}

	.header-menu li.menu-item-has-children {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
	}

	.header-menu li > a {
		flex: 1 1 auto;
		min-width: 0;
		display: block;
		padding: 12px 0;
	}

	ul.header-menu > li > a {
		font-size: 18px;
	}

	/* Кнопка-стрелка (добавляет tvb-fixes.js) */
	.submenu-toggle {
		display: flex;
		align-items: center;
		justify-content: center;
		flex: 0 0 44px;
		width: 44px;
		height: 44px;
		padding: 0;
		border: 0;
		background: transparent;
		color: var(--tvb-text);
		cursor: pointer;
	}

	.submenu-toggle::before {
		content: "";
		width: 9px;
		height: 9px;
		margin-top: -4px;
		border-right: 2px solid currentColor;
		border-bottom: 2px solid currentColor;
		transform: rotate(45deg);
		transition: transform 0.2s ease, margin 0.2s ease;
	}

	.menu-item-has-children.is-open > .submenu-toggle::before {
		transform: rotate(-135deg);
		margin-top: 4px;
	}

	/* Подменю: на всю ширину строки, с отступом */
	.header-menu .sub-menu {
		flex: 0 0 100%;
		padding-left: 14px;
		border-left: 2px solid #f3c2cd;
		margin-bottom: 10px;
	}

	.header-menu .sub-menu a {
		padding: 9px 0;
		font-size: 16px;
	}

	.header-menu .sub-menu .sub-menu {
		margin-bottom: 4px;
	}

	.header-menu .sub-menu .sub-menu a {
		font-size: 15px;
		color: #555;
	}

	/* Свёрнуто, пока не нажата стрелка (без JS — всё раскрыто) */
	.header-menu.has-submenu-toggle .menu-item-has-children > .sub-menu {
		display: none;
	}

	.header-menu.has-submenu-toggle .menu-item-has-children.is-open > .sub-menu {
		display: block;
	}
}
