/* ==========================================================================
   catalog_qty.css
   Вибір кількості «– N +» і позначка «У кошику» на картках товару в каталозі.
   Розмітка: app/views/parts/catalog_buy.php, catalog_in_cart_badge.php.
   ========================================================================== */

/* ---- блок покупки під ціною ---- */
.catalog-buy {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-top: 14px;
}

/* ---- «– N +» ---- */
.qty-stepper {
	display: inline-flex;
	align-items: center;
	flex: 0 0 auto;
	border: 1px solid #ddd;
	border-radius: 10px;
	overflow: hidden;
	background: #fff;
}

.qty-stepper .qty-btn {
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	background: #f4f4f4;
	color: #333;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	transition: background .15s ease;
	touch-action: manipulation;   /* без затримки й зуму від подвійного дотику */
}
.qty-stepper .qty-btn:hover:not(:disabled) { background: #e8e8e8; }
.qty-stepper .qty-btn:disabled { color: #bbb; cursor: not-allowed; }

/* у main.css є глобальне input { margin: .4rem } — тут воно не потрібне */
.qty-stepper .qty-input {
	width: 46px;
	height: 40px;
	margin: 0 !important;
	padding: 0;
	border: 0;
	text-align: center;
	font-weight: 600;
	font-size: 16px;            /* 16px: iOS не збільшує сторінку при фокусі */
	-moz-appearance: textfield;
	appearance: textfield;
	background: #fff;
}
.qty-stepper .qty-input::-webkit-outer-spin-button,
.qty-stepper .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-stepper .qty-input:focus { outline: 2px solid var(--accent-color, #7ca877); outline-offset: -2px; }

/* ---- кнопка ---- */
.catalog-buy .add-to-cart {
	flex: 1 1 auto;
	margin-left: 0 !important;  /* перекриваємо старе .product-links a { margin-left } */
	min-height: 40px;
	white-space: nowrap;
	border-radius: 10px;
	font-weight: 600;
	transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.catalog-buy .add-to-cart i { margin-right: 4px; }

/* товар уже в кошику: кнопка заповнена кольором сайту */
.is-in-cart .catalog-buy .add-to-cart:not([data-preorder="1"]) {
	background: var(--accent-color2, #2e7d32);
	border-color: var(--accent-color2, #2e7d32);
	color: #fff;
}
.is-in-cart .catalog-buy .add-to-cart:not([data-preorder="1"]):hover { filter: brightness(1.08); }

/* весь залишок уже в кошику */
.catalog-buy.is-exhausted .add-to-cart { opacity: .55; pointer-events: none; }

/* коротка анімація після додавання */
.catalog-buy .add-to-cart.just-added { animation: catalogBuyPulse .6s ease; }
@keyframes catalogBuyPulse {
	0%   { transform: scale(1); }
	40%  { transform: scale(1.05); }
	100% { transform: scale(1); }
}

/* ---- позначка «У кошику: N шт.» на фото ---- */
.product-card .product-thumb,
.mini-product-card .mini-thumb { position: relative; }

.in-cart-badge {
	position: absolute;
	left: 10px;
	bottom: 10px;
	z-index: 3;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 10px;
	border-radius: 999px;
	background: var(--accent-color2, #2e7d32);
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
	box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
	pointer-events: none;
}
.in-cart-badge[hidden] { display: none; }
.in-cart-badge.just-updated { animation: catalogBuyPulse .6s ease; }

/* ---- компактний варіант для бічної колонки ---- */
.catalog-buy--mini {
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 0;
}
.catalog-buy--mini .qty-stepper .qty-btn { width: 32px; height: 32px; font-size: 17px; }
.catalog-buy--mini .qty-stepper .qty-input { width: 36px; height: 32px; font-size: 15px; }
.catalog-buy--mini .add-to-cart { min-height: 32px; flex: 1 1 auto; }
.mini-product-card .in-cart-badge { left: 6px; bottom: 6px; padding: 3px 8px; font-size: 12px; gap: 4px; }
/* на маленькому фото лише значок і число */
.mini-product-card .in-cart-badge__label,
.mini-product-card .in-cart-badge__unit { display: none; }

/* ---- вузькі екрани ---- */
@media (max-width: 1199.98px) {
	/* у три колонки на планшеті кнопка з текстом не влазить поруч зі степером */
	.col-lg-4 .catalog-buy--card .catalog-buy__label { display: none; }
	.col-lg-4 .catalog-buy--card .add-to-cart i { margin-right: 0; font-size: 18px; }
}
@media (max-width: 991.98px) {
	.col-lg-4 .catalog-buy--card .catalog-buy__label { display: inline; }
	.col-lg-4 .catalog-buy--card .add-to-cart i { margin-right: 4px; font-size: inherit; }
}
@media (max-width: 575.98px) {
	/* телефон: більші кнопки під палець */
	.catalog-buy--card .qty-stepper .qty-btn { width: 44px; height: 44px; }
	.catalog-buy--card .qty-stepper .qty-input { height: 44px; }
	.catalog-buy--card .add-to-cart { min-height: 44px; }
}
