/* Кошик shop (задача #533) — мінімальна функціональна верстка (без дизайну). Структурна стилізація
   по тегах/структурі, мінімум класів. Іконка кошика в хедері, сторінка /cart, кнопка «Додати в кошик»,
   тости повідомлень (adjusted/removed). */

/* ── Кнопка «Додати в кошик» на сторінці товару ── */
.product-buy .buy-btn {
	cursor: pointer;
}
.product-buy .buy-btn[disabled] {
	cursor: default;
	opacity: .5;
}

/* ── Іконка кошика в хедері ── */
header .container [data-cart-link] {
	position: relative;
	display: inline-flex;
	align-items: center;
	text-decoration: none;
}
header .container [data-cart-link] [data-cart-count] {
	min-width: 1.1em;
	padding: 0 .35em;
	margin-left: .2em;
	border-radius: 1em;
	background: #c0392b;
	color: #fff;
	font-size: .75em;
	line-height: 1.5;
	text-align: center;
}

/* ── Сторінка кошика ── */
.cart {
	max-width: 900px;
	margin: 0 auto;
	padding: 1rem;
}
.cart-empty {
	padding: 2rem 0;
}
.cart-list {
	list-style: none;
	margin: 0;
	padding: 0;
}
.cart-item {
	display: grid;
	grid-template-columns: 64px 1fr auto auto auto auto;
	gap: .75rem;
	align-items: center;
	padding: .75rem 0;
	border-bottom: 1px solid #e5e5e5;
}
.cart-item-media img {
	width: 64px;
	height: 64px;
	object-fit: contain;
}
.cart-item-info {
	min-width: 0;
}
.cart-item-name a {
	text-decoration: none;
}
.cart-item-code {
	font-size: .8em;
	color: #888;
}
.cart-item-qty input {
	width: 4rem;
	text-align: center;
}
.cart-item-total {
	font-weight: 600;
	white-space: nowrap;
}
.cart-item > [data-cart-remove] {
	border: 0;
	background: none;
	font-size: 1.4rem;
	line-height: 1;
	cursor: pointer;
	color: #888;
}
.cart-item > [data-cart-remove]:hover {
	color: #c0392b;
}
.cart-footer {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding-top: 1rem;
}
.cart-total {
	font-size: 1.2rem;
}
.cart-total span {
	font-weight: 700;
}
.cart-checkout {
	cursor: pointer;
}

@media (max-width: 640px) {
	.cart-item {
		grid-template-columns: 48px 1fr auto;
		grid-template-areas:
			"media info remove"
			"media price qty"
			"media total total";
	}
	.cart-item-media  { grid-area: media; }
	.cart-item-info   { grid-area: info; }
	.cart-item-price  { grid-area: price; }
	.cart-item-qty    { grid-area: qty; }
	.cart-item-total  { grid-area: total; }
	.cart-item > [data-cart-remove] { grid-area: remove; justify-self: end; }
	.cart-item-media img { width: 48px; height: 48px; }
}

/* ── Тости повідомлень (adjusted/removed/added) ── */
[data-toast-host] {
	position: fixed;
	right: 1rem;
	bottom: 1rem;
	z-index: 9999;
	display: flex;
	flex-direction: column;
	gap: .5rem;
	max-width: 320px;
}
[data-toast-host] .toast {
	padding: .6rem .9rem;
	border-radius: 4px;
	background: #333;
	color: #fff;
	font-size: .9rem;
	opacity: 0;
	transform: translateY(.5rem);
	transition: opacity .3s, transform .3s;
}
[data-toast-host] .toast.show {
	opacity: 1;
	transform: translateY(0);
}

/* Каталог товарів shop (контрольна точка 2, #497). Структурна стилізація, мінімум класів. */

.catalog {
	max-width: 1280px;
	margin: 0 auto;
	padding: 16px;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color: #1c1c1c;
}

.catalog-toolbar {
	display: flex;
	align-items: center;
	gap: 16px;
	flex-wrap: wrap;
	padding-bottom: 16px;
	border-bottom: 1px solid #ececec;
}

.catalog-count {
	font-size: 15px;
	color: #555;
}
.catalog-count span {
	font-weight: 700;
	color: #1c1c1c;
}

.catalog-sort {
	margin-left: auto;
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 14px;
	color: #555;
}
.catalog-sort select {
	padding: 7px 10px;
	border: 1px solid #d5d5d5;
	border-radius: 8px;
	background: #fff;
	font-size: 14px;
	cursor: pointer;
}

.filter-toggle {
	display: none;
	padding: 8px 14px;
	border: 1px solid #d5d5d5;
	border-radius: 8px;
	background: #fff;
	font-size: 14px;
	cursor: pointer;
}

.catalog-body {
	display: grid;
	grid-template-columns: 260px 1fr;
	gap: 24px;
	margin-top: 20px;
	align-items: start;
}

/* ── Сайдбар фільтрів ── */

.catalog-filters {
	display: flex;
	flex-direction: column;
	gap: 18px;
}

.filter-group h4 {
	margin: 0 0 8px;
	font-size: 14px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .3px;
	color: #333;
}

.filter-search {
	width: 100%;
	padding: 7px 10px;
	margin-bottom: 8px;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
	font-size: 13px;
	box-sizing: border-box;
}

.filter-group ul {
	list-style: none;
	margin: 0;
	padding: 0;
	max-height: 260px;
	overflow-y: auto;
}
.filter-group[data-group="category"] li a,
.filter-group[data-group="brand"] li label {
	display: block;
	padding: 5px 8px;
	font-size: 14px;
	color: #333;
	text-decoration: none;
	border-radius: 6px;
	cursor: pointer;
}
.filter-group[data-group="category"] li a:hover,
.filter-group[data-group="brand"] li label:hover {
	background: #f4f4f4;
}
.filter-group[data-group="category"] li.active a {
	background: #eaf3ff;
	color: #0a58ca;
	font-weight: 600;
}
.filter-group[data-group="brand"] li label {
	display: flex;
	align-items: center;
	gap: 8px;
}
.filter-group[data-group="brand"] input[type="checkbox"] {
	flex: none;
}
.filter-group li b {
	font-weight: 400;
	font-size: 12px;
	color: #999;
}

.price-range {
	display: flex;
	align-items: center;
	gap: 6px;
}
.price-range input {
	width: 100%;
	min-width: 0;
	padding: 7px 8px;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
	font-size: 13px;
	box-sizing: border-box;
}
.price-range button {
	flex: none;
	padding: 7px 12px;
	border: 1px solid #0a58ca;
	background: #0a58ca;
	color: #fff;
	border-radius: 8px;
	font-size: 13px;
	cursor: pointer;
}

.filter-instock {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 14px;
	color: #333;
	cursor: pointer;
}

/* ── Активні фільтри (чіпи) ── */

.catalog-selected {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}
.catalog-selected:empty {
	display: none;
}
.chip {
	display: inline-flex;
	align-items: center;
	padding: 4px 10px;
	background: #eef1f5;
	border-radius: 14px;
	font-size: 13px;
	color: #333;
	text-decoration: none;
}
.chip:hover {
	background: #e2e6ec;
}
.chip-reset {
	background: transparent;
	color: #c0392b;
	text-decoration: underline;
}

/* ── Список товарів ── */

/* Кількість колонок — з конфігу (catalog.php <style>: --cat-cols-m / --cat-cols-d, #498 п.2).
   Mobile-first: --cat-cols-m; desktop-брейкпоінт нижче перемикає на --cat-cols-d. */
.catalog-list {
	display: grid;
	grid-template-columns: repeat(var(--cat-cols-m, 2), 1fr);
	gap: 16px;
}
@media (min-width: 861px) {
	.catalog-list {
		grid-template-columns: repeat(var(--cat-cols-d, 4), 1fr);
	}
}
.catalog-list article {
	display: flex;
	flex-direction: column;
	border: 1px solid #ececec;
	border-radius: 12px;
	padding: 12px;
	background: #fff;
	transition: box-shadow .15s;
}
.catalog-list article:hover {
	box-shadow: 0 4px 16px rgba(0, 0, 0, .08);
}
.catalog-list article > a {
	text-decoration: none;
	color: inherit;
	display: flex;
	flex-direction: column;
	gap: 8px;
	flex: 1;
}
.catalog-list img {
	width: 100%;
	aspect-ratio: 1 / 1;
	object-fit: contain;
	background: #fafafa;
	border-radius: 8px;
}
.catalog-list h3 {
	margin: 0;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.35;
	color: #1c1c1c;
}
.catalog-list .price {
	margin-top: 8px;
	font-size: 17px;
	font-weight: 700;
	color: #1c1c1c;
}
.catalog-list .price small {
	font-size: 12px;
	font-weight: 400;
	color: #888;
}
.catalog-list .price s {
	font-size: 13px;
	font-weight: 400;
	color: #aaa;
	margin-left: 4px;
}

.catalog-empty {
	grid-column: 1 / -1;
	padding: 40px;
	text-align: center;
	color: #888;
	font-size: 16px;
}

/* ── Пагінація: "Показати ще" + панель номерів (#500) ── */

/* "Показати ще" — єдиний тригер довантаження (append), над панеллю номерів. */
.load-more {
	display: block;
	margin: 24px auto 0;
	padding: 12px 32px;
	border: 1px solid #0a58ca;
	border-radius: 8px;
	background: #fff;
	color: #0a58ca;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	transition: background .15s, color .15s;
}
.load-more:hover {
	background: #0a58ca;
	color: #fff;
}

/* Панель номерів: стрілки ← → по краях, номери по центру, на всю ширину блоку. */
.pagination {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 16px;
	font-size: 14px;
	color: #555;
}
.pagination .pg-nums {
	flex: 1;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 6px;
}
.pg-num,
.pg-arrow {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	padding: 0 10px;
	border: 1px solid #d5d5d5;
	border-radius: 8px;
	color: #0a58ca;
	text-decoration: none;
	box-sizing: border-box;
}
a.pg-num:hover,
a.pg-arrow:hover {
	background: #f4f4f4;
}
.pg-num.current {
	background: #0a58ca;
	border-color: #0a58ca;
	color: #fff;
	font-weight: 700;
	cursor: default;
}
.pg-gap {
	min-width: 24px;
	text-align: center;
	color: #999;
}
.pg-arrow.is-disabled {
	color: #ccc;
	border-color: #ececec;
	cursor: default;
}

@media (max-width: 480px) {
	.pg-num,
	.pg-arrow {
		min-width: 34px;
		height: 34px;
		padding: 0 6px;
	}
}

/* ── AJAX-лоадер (#502) ── */

@keyframes catalog-spin {
	to { transform: rotate(360deg); }
}

/* Replace-запит (фільтр/сортування/клік по номеру): оверлей зі спінером на область
   результатів; фільтри/тулбар блокуються на час запиту. */
.catalog-results {
	position: relative;
}
.catalog.is-loading .catalog-results::after {
	content: '';
	position: absolute;
	inset: 0;
	background: rgba(255, 255, 255, .6);
	z-index: 5;
}
.catalog.is-loading .catalog-results::before {
	content: '';
	position: absolute;
	top: 90px;
	left: 50%;
	width: 40px;
	height: 40px;
	margin-left: -20px;
	border: 3px solid #d5d5d5;
	border-top-color: #0a58ca;
	border-radius: 50%;
	z-index: 6;
	animation: catalog-spin .7s linear infinite;
}
.catalog.is-loading .catalog-filters,
.catalog.is-loading .catalog-toolbar {
	pointer-events: none;
	opacity: .6;
}

/* Append-запит ("Показати ще"): локальний спінер у кнопці (текст ховається, ширина стабільна),
   БЕЗ оверлею на список — накопичений список лишається видимим, скрол не рухається (#500). */
.load-more.is-loading {
	color: transparent;
	pointer-events: none;
	position: relative;
}
.load-more.is-loading::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 18px;
	height: 18px;
	margin: -9px 0 0 -9px;
	border: 2px solid rgba(10, 88, 202, .35);
	border-top-color: #0a58ca;
	border-radius: 50%;
	animation: catalog-spin .7s linear infinite;
}

/* ── Адаптив ── */

@media (max-width: 860px) {
	.catalog-body {
		grid-template-columns: 1fr;
	}
	.filter-toggle {
		display: inline-block;
	}
	.catalog-filters {
		display: none;
	}
	.catalog-filters.open {
		display: flex;
	}
	.catalog-sort {
		margin-left: 0;
	}
}

/* Сторінка товару shop (КРОК 1, #510). Структурна стилізація, мінімум класів. */

.product {
	display: grid;
	grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
	gap: 32px;
	max-width: 1100px;
	margin: 16px auto 0;
	padding: 0 16px;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color: #1c1c1c;
	align-items: start;
}

/* ── Галерея ── */

.product-gallery {
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.product-gallery-main {
	border: 1px solid #ececec;
	border-radius: 12px;
	background: #fff;
	padding: 12px;
}
.product-gallery-main img {
	width: 100%;
	aspect-ratio: 1 / 1;
	object-fit: contain;
	background: #fafafa;
	border-radius: 8px;
}
.product-gallery-thumbs {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}
.product-thumb {
	width: 72px;
	height: 72px;
	padding: 4px;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
	background: #fff;
	cursor: pointer;
}
.product-thumb img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}
.product-thumb.active {
	border-color: #0a58ca;
}
.product-thumb:hover {
	border-color: #b9cdf0;
}

/* ── Інфо ── */

.product-info h1 {
	margin: 0 0 12px;
	font-size: 24px;
	font-weight: 700;
	line-height: 1.25;
}
.product-code {
	font-size: 13px;
	color: #888;
	margin-bottom: 16px;
}
.product-code span {
	color: #555;
}

.product-price {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 20px;
}
.product-price small {
	font-size: 14px;
	color: #888;
}
.price-current {
	font-size: 28px;
	font-weight: 700;
	color: #1c1c1c;
}
.price-old {
	font-size: 16px;
	color: #aaa;
}
.price-discount {
	font-size: 14px;
	font-weight: 600;
	color: #c0392b;
}

.product-buy {
	display: flex;
	align-items: center;
	gap: 16px;
	flex-wrap: wrap;
}
.buy-btn {
	padding: 13px 36px;
	border: none;
	border-radius: 8px;
	background: #0a58ca;
	color: #fff;
	font-size: 16px;
	font-weight: 600;
	cursor: not-allowed;
	opacity: .55;
}
.product-stock {
	font-size: 14px;
}
.product-stock.in {
	color: #2e7d32;
}
.product-stock.out {
	color: #c0392b;
}

/* ── Опис ── */

.product-description {
	max-width: 1100px;
	margin: 32px auto 0;
	padding: 0 16px;
}
.product-description h2 {
	font-size: 18px;
	font-weight: 700;
	margin: 0 0 12px;
	padding-bottom: 8px;
	border-bottom: 1px solid #ececec;
}
.product-description-body {
	font-size: 15px;
	line-height: 1.6;
	color: #333;
}
.product-description-body img {
	max-width: 100%;
	height: auto;
}

.product-not-found {
	max-width: 1100px;
	margin: 40px auto;
	padding: 40px 16px;
	text-align: center;
	color: #888;
	font-size: 18px;
}

/* ── Варіант-селект (КРОК 2) ── */

.product-variants {
	margin: 18px 0;
}
.product-variants label {
	display: block;
	font-size: 13px;
	color: #888;
	margin-bottom: 6px;
}
.product-variants select {
	width: 100%;
	max-width: 360px;
	padding: 10px 12px;
	border: 1px solid #d5d5d5;
	border-radius: 8px;
	background: #fff;
	font-size: 15px;
	cursor: pointer;
}

/* ── Характеристики (КРОК 2) ── */

.product-characteristics {
	max-width: 1100px;
	margin: 32px auto 0;
	padding: 0 16px;
}
.product-characteristics h2 {
	font-size: 18px;
	font-weight: 700;
	margin: 0 0 12px;
	padding-bottom: 8px;
	border-bottom: 1px solid #ececec;
}
.product-characteristics dl {
	margin: 0;
	border: 1px solid #ececec;
	border-radius: 8px;
	overflow: hidden;
}
.product-characteristics dl > div {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
}
.product-characteristics dl > div:nth-child(odd) {
	background: #fafafa;
}
.product-characteristics dt {
	padding: 9px 14px;
	font-size: 14px;
	color: #666;
}
.product-characteristics dd {
	margin: 0;
	padding: 9px 14px;
	font-size: 14px;
	color: #1c1c1c;
}

/* ── Схожі товари (КРОК 3) ── */

.product-related {
	max-width: 1100px;
	margin: 40px auto 0;
	padding: 0 16px;
}
.product-related h2 {
	font-size: 18px;
	font-weight: 700;
	margin: 0 0 16px;
	padding-bottom: 8px;
	border-bottom: 1px solid #ececec;
}

/* ── Адаптив ── */

@media (max-width: 720px) {
	.product {
		grid-template-columns: 1fr;
		gap: 20px;
	}
	.product-info h1 {
		font-size: 20px;
	}
	.price-current {
		font-size: 24px;
	}
}

/* Пошук shop (задача #518): поле в header + liveSearch dropdown + сторінка /search.
   Сторінка /search переюзає каталожні класи (.catalog-body, .filter-group, .catalog-list,
   .pagination з !catalog.css), тут — лише специфіка пошуку. Mobile-first, брейкпоінт 861px. */

/* ── Header з полем пошуку ── */
header .container {
	display: flex;
	align-items: center;
	gap: 16px;
	flex-wrap: wrap;
	max-width: 1280px;
	margin: 0 auto;
	padding: 10px 16px;
}

header form[role="search"] {
	position: relative;
	display: flex;
	flex: 1 1 240px;
	min-width: 0;
	margin-left: auto;
}
header form[role="search"] input[type="search"] {
	flex: 1;
	min-width: 0;
	padding: 9px 12px;
	border: 1px solid #d5d5d5;
	border-radius: 8px 0 0 8px;
	font-size: 15px;
	box-sizing: border-box;
}
header form[role="search"] button {
	flex: none;
	padding: 9px 14px;
	border: 1px solid #0a58ca;
	background: #0a58ca;
	color: #fff;
	border-radius: 0 8px 8px 0;
	font-size: 15px;
	cursor: pointer;
}

/* ── liveSearch dropdown ── */
.search-results {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	z-index: 50;
	background: #fff;
	border: 1px solid #e0e0e0;
	border-radius: 10px;
	box-shadow: 0 8px 28px rgba(0, 0, 0, .12);
	padding: 14px;
	max-height: 78vh;
	overflow-y: auto;
}
.search-results .search-query {
	font-size: 15px;
	font-weight: 600;
	color: #1c1c1c;
	margin-bottom: 10px;
}
.search-cols {
	display: grid;
	grid-template-columns: 1fr;
	gap: 14px;
}
.search-facets {
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.search-facets h4 {
	margin: 0 0 6px;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: .3px;
	color: #888;
}
.search-facets a {
	display: flex;
	justify-content: space-between;
	gap: 8px;
	padding: 4px 6px;
	font-size: 14px;
	color: #333;
	text-decoration: none;
	border-radius: 6px;
}
.search-facets a:hover { background: #f4f4f4; }
.search-facets a b { font-weight: 400; color: #999; }

.search-groups {
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.search-groups h4 {
	margin: 0 0 6px;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: .3px;
	color: #888;
}
.search-groups a {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 6px;
	text-decoration: none;
	color: #1c1c1c;
	border-radius: 8px;
}
.search-groups a:hover { background: #f7f7f7; }
.search-groups img {
	width: 44px;
	height: 44px;
	object-fit: contain;
	background: #fafafa;
	border-radius: 6px;
	flex: none;
}
.search-groups span {
	flex: 1;
	font-size: 14px;
	line-height: 1.3;
}
.search-groups b {
	flex: none;
	font-size: 14px;
	font-weight: 700;
}

.search-all {
	display: block;
	margin-top: 12px;
	padding: 10px;
	text-align: center;
	background: #0a58ca;
	color: #fff;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
}
.search-all:hover { background: #0847a3; }

/* ── Сторінка /search ── */
.search {
	max-width: 1280px;
	margin: 0 auto;
	padding: 16px;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color: #1c1c1c;
}
.search > .search-query {
	font-size: 22px;
	font-weight: 700;
	margin: 4px 0 16px;
}
.search[data-searchbase].is-loading {
	opacity: .6;
	pointer-events: none;
}

/* Desktop: dropdown у дві колонки (фасети + товари). */
@media (min-width: 861px) {
	.search-results { padding: 18px; }
	.search-cols {
		grid-template-columns: 220px 1fr;
		gap: 22px;
	}
}


