/**
 * Каталог товаров [custom_products] — в стиле корзины 2026
 */

.custom-products {
	--cc-radius: 14px;
	--cc-radius-sm: 10px;
	--cc-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
	--cc-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.08);
	--cc-border: 1px solid rgba(0, 0, 0, 0.06);
	--cc-accent: #44241c;
	--cc-accent-hover: #331a14;
	--cc-text-muted: #64748b;
	--cc-bg: #fff;
	--cc-bg-soft: #f8fafc;
	margin: 0;
	font-family: inherit;
	position: relative;
}

.custom-products__section-title {
	margin: 0 0 1rem;
	font-size: 1.25rem;
	font-weight: 700;
	color: #0f172a;
}

.custom-products__loader {
	position: absolute;
	inset: 0;
	background: rgba(255, 255, 255, 0.85);
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s ease;
	z-index: 10;
	border-radius: var(--cc-radius);
	pointer-events: none;
}

.custom-products__loader--active {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.custom-products__loader-spinner {
	width: 40px;
	height: 40px;
	border: 3px solid var(--cc-bg-soft);
	border-top-color: var(--cc-accent);
	border-radius: 50%;
	animation: custom-products-spin 0.7s linear infinite;
}

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

.custom-products__grid {
	display: grid;
	gap: 1.25rem;
	overflow: visible;
}

.custom-products--cols-2 .custom-products__grid { grid-template-columns: repeat(2, 1fr); }
.custom-products--cols-3 .custom-products__grid { grid-template-columns: repeat(3, 1fr); }
.custom-products--cols-4 .custom-products__grid { grid-template-columns: repeat(4, 1fr); }
.custom-products--cols-5 .custom-products__grid { grid-template-columns: repeat(5, 1fr); }
.custom-products--cols-6 .custom-products__grid { grid-template-columns: repeat(6, 1fr); }

.custom-products__item {
	min-width: 0;
	position: relative;
}

/* Панель количества открывается вверх — карточки ряда ниже иначе перекрывают её */
.custom-products__item:has(.custom-products__qty-trigger--open),
.custom-products__item--qty-open {
	z-index: 40;
}

.custom-products__inner {
	display: flex;
	flex-direction: column;
	height: 100%;
	padding: 1rem;
	background: var(--cc-bg);
	border: var(--cc-border);
	border-radius: var(--cc-radius);
	box-shadow: var(--cc-shadow);
	transition: box-shadow 0.2s ease;
	overflow: visible;
}

.custom-products__inner:hover {
	box-shadow: var(--cc-shadow-hover);
}

.custom-products__thumb {
	border-radius: var(--cc-radius-sm);
	overflow: hidden;
	margin-bottom: 0.75rem;
	aspect-ratio: 1;
	background: var(--cc-bg-soft);
}

.custom-products__thumb a {
	display: block;
	width: 100%;
	height: 100%;
}

.custom-products__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.custom-products__cat {
	margin-bottom: 0.35rem;
	font-size: 0.8rem;
}

.custom-products__cat a {
	color: var(--cc-text-muted);
	text-decoration: none;
}

.custom-products__cat a:hover {
	color: var(--cc-accent);
}

.custom-products__stock {
	font-size: 0.8rem;
	margin-bottom: 0.5rem;
}

.custom-products__stock--instock {
	color: #0d9488;
}

.custom-products__stock--outofstock {
	color: var(--cc-text-muted);
}

.custom-products__stock--onbackorder {
	color: #d97706;
}

.custom-products__title {
	margin: 0 0 0.5rem;
	font-size: 0.95rem;
	font-weight: 600;
	line-height: 1.35;
	flex: 1;
}

.custom-products__title a {
	color: inherit;
	text-decoration: none;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.custom-products__title a:hover {
	color: var(--cc-accent);
}

.custom-products__price {
	margin-bottom: 0.75rem;
	font-weight: 600;
}

.custom-products__price .woocommerce-Price-amount.amount,
.custom-products__price .woocommerce-Price-amount.amount bdi {
	color: #282626;
	font-size: 21px;
	white-space: nowrap;
}

/* Строка цены: селектор количества слева, итог справа */
.custom-products__price--with-qty {
	margin-bottom: 0.75rem;
}

.custom-products__price-row {
	display: flex;
	flex-direction: row;
	align-items: flex-end;
	justify-content: space-between;
	gap: 0.75rem;
	width: 100%;
	min-width: 0;
	position: relative;
	z-index: 1;
}

.custom-products__qty-wrap {
	flex: 1;
	min-width: 0;
}

.custom-products__qty-trigger {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	width: 100%;
	padding: 0;
	margin: 0;
	border: none;
	background: transparent;
	font: inherit;
	text-align: left;
	cursor: pointer;
	color: inherit;
	border-radius: var(--cc-radius-sm);
	transition: background 0.15s ease;
}

.custom-products__qty-trigger:hover {
	background: rgba(0, 0, 0, 0.03);
}

.custom-products__qty-trigger-main {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: .35rem;
    width: 100%;
}

.custom-products__qty-trigger-line {
	font-size: 0.95rem;
	line-height: 1.2;
	color: #0f172a;
}

@media (min-width: 768px) {
	.custom-products__qty-trigger-line {
		font-size: 1rem;
	}
}

.custom-products__qty-value {
	font-weight: 700;
}

.custom-products__qty-chevron {
	display: inline-flex;
	flex-shrink: 0;
	width: 0.75rem;
	color: var(--cc-text-muted);
	transition: transform 0.2s ease;
}

.custom-products__qty-trigger--open .custom-products__qty-chevron {
	transform: rotate(180deg);
}

.custom-products__qty-per {
	display: block;
	margin-top: 0.2rem;
	font-size: 0.75rem;
	line-height: 1.2;
	color: var(--cc-accent);
	opacity: 0.9;
}

@media (min-width: 768px) {
	.custom-products__qty-per {
		font-size: 0.8125rem;
	}
}

.custom-products__qty-panel {
	position: absolute;
	left: 0;
	right: 0;
	width: 100%;
	bottom: 100%;
	margin-bottom: 0.5rem;
	z-index: 5;
	background: var(--cc-bg);
	border: 1px solid rgba(0, 0, 0, 0.1);
	border-radius: var(--cc-radius-sm);
	box-shadow: var(--cc-shadow-hover);
	max-height: 220px;
	overflow-y: auto;
	
	box-sizing: border-box;
	scrollbar-width: thin;
	scrollbar-color: rgba(0, 0, 0, 0.2) var(--cc-bg-soft);
}

.custom-products__qty-panel::-webkit-scrollbar {
	width: 6px;
}

.custom-products__qty-panel::-webkit-scrollbar-track {
	background: var(--cc-bg-soft);
	border-radius: 3px;
}

.custom-products__qty-panel::-webkit-scrollbar-thumb {
	background: rgba(0, 0, 0, 0.2);
	border-radius: 3px;
}

.custom-products__qty-option {
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	width: 100%;
	padding: 0.65rem 0.5rem;
	margin: 0;
	border: none;
	border-bottom: 1px solid rgba(0, 0, 0, 0.06);
	background: var(--cc-bg-soft);
	cursor: pointer;
	font: inherit;
	text-align: left;
	transition: background 0.15s ease;
	box-sizing: border-box;
}

.custom-products__qty-option:last-child {
	border-bottom: none;
}

.custom-products__qty-option:hover,
.custom-products__qty-option:focus-within {
	background: rgba(0, 0, 0, 0.04);
}

.custom-products__qty-option--current {
	background: rgba(68, 36, 28, 0.06);
}

.custom-products__qty-radio {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	pointer-events: none;
}

.custom-products__qty-opt-left {
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
	min-width: 0;
	flex: 1;
}

.custom-products__qty-opt-qty {
	font-size: 0.8125rem;
	color: #0f172a;
}

.custom-products__qty-opt-unit {
	font-size: 0.7rem;
	color: var(--cc-text-muted);
}

.custom-products__qty-opt-line {
	flex-shrink: 0;
	font-size: 0.875rem;
	font-weight: 600;
	color: #282626;
}

.custom-products__qty-opt-line .woocommerce-Price-amount.amount,
.custom-products__qty-opt-line .woocommerce-Price-amount.amount bdi {
	color: #282626;
	font-size: inherit;
	white-space: nowrap;
}

.custom-products__price-total {
	flex-shrink: 0;
	text-align: right;
	align-self: flex-end;
}

.custom-products__price-total .woocommerce-Price-amount.amount,
.custom-products__price-total .woocommerce-Price-amount.amount bdi {
	color: #282626;
	font-size: 21px;
	font-weight: 700;
	white-space: nowrap;
}

.custom-products__button {
	margin-top: auto;
}

.custom-products__button .button,
.custom-products__button .add_to_cart_button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	padding: 0.6rem 1rem;
	border-radius: var(--cc-radius-sm);
	font-size: 0.9rem;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
	transition: background 0.2s, color 0.2s;
	background: var(--cc-accent);
	color: #fff;
	border: none;
}

.custom-products__button .button:hover,
.custom-products__button .add_to_cart_button:hover {
	background: var(--cc-accent-hover);
	color: #fff;
}

/* Пока идёт добавление в корзину — остальные кнопки не кликабельны */
.custom-products.add-to-cart-pending .add_to_cart_button {
	pointer-events: none;
}
.custom-products.add-to-cart-pending .add_to_cart_button:not(.loading) {
	opacity: 0.6;
	cursor: wait;
}

.custom-products__button .button:disabled,
.custom-products__button .added {
	opacity: 0.8;
	cursor: default;
}

/* Виджет в карточке товара (шорткод [minimum_order_info]) */
.custom-products--embed {
	max-width: 100%;
	width: 100%;
}

.custom-products--embed .custom-products__item,
.custom-products--embed .custom-products__inner {
	width: 100%;
}

.custom-products--embed .custom-products__inner {
	padding: 0;
	border: 0;
	box-shadow: none;
	background: transparent;
}

.custom-products--embed .custom-products__embed-widget {
	gap: 1rem;
}

.custom-products--embed .custom-products__qty-wrap--embed {
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	overflow: hidden;
}

.custom-products--embed .custom-products__qty-option {
	padding: 0.95rem 1rem;
	background: #fff;
}

.custom-products--embed .custom-products__qty-option--current {
	background: #f5f5f5;
}

.custom-products--embed .custom-products__qty-opt-qty,
.custom-products--embed .custom-products__qty-opt-qty strong {
	font-size: 1.35rem;
	line-height: 1.1;
	font-weight: 700;
}

.custom-products--embed .custom-products__qty-opt-unit {
	font-size: 0.95rem;
	line-height: 1.2;
	color: #1f2937;
}

.custom-products--embed .custom-products__qty-opt-line,
.custom-products--embed .custom-products__qty-opt-line .woocommerce-Price-amount.amount,
.custom-products--embed .custom-products__qty-opt-line .woocommerce-Price-amount.amount bdi {
	font-size: 1.45rem;
	font-weight: 700;
	line-height: 1.1;
}

.custom-products--embed .custom-products__embed-actions {
	margin-top: 0.85rem;
}

.custom-products--embed .custom-products__button .add_to_cart_button {
	min-height: 64px;
	font-size: 1.15rem;
	font-weight: 700;
	border-radius: 10px;
	background: #d32f2f;
	color: #fff;
}

.custom-products--embed .custom-products__button .add_to_cart_button:hover {
	background: #b71c1c;
	color: #fff;
}

.custom-products--embed .custom-products__button .cpw-add-label {
	letter-spacing: 0;
}

@media (max-width: 992px) {
	.custom-products--embed .custom-products__qty-opt-qty,
	.custom-products--embed .custom-products__qty-opt-qty strong {
		font-size: 1.15rem;
	}
	.custom-products--embed .custom-products__qty-opt-unit {
		font-size: 0.85rem;
	}
	.custom-products--embed .custom-products__qty-opt-line,
	.custom-products--embed .custom-products__qty-opt-line .woocommerce-Price-amount.amount,
	.custom-products--embed .custom-products__qty-opt-line .woocommerce-Price-amount.amount bdi {
		font-size: 1.15rem;
	}
	.custom-products--embed .custom-products__button .add_to_cart_button {
		min-height: 54px;
		font-size: 1rem;
	}
}

/* Elementor wrapper: шорткод должен занимать всю ширину контейнера */
.elementor-shortcode .custom-products--embed,
.elementor-shortcode .custom-products--embed .custom-products__item,
.elementor-shortcode .custom-products--embed .custom-products__inner,
.elementor-shortcode .custom-products--embed .custom-products__embed-widget {
	display: block;
	width: 100% !important;
	max-width: 100% !important;
}

/* Жестко фиксируем стиль кнопки в embed-виджете (поверх инлайн/утилити-классов) */
.elementor-shortcode .custom-products--embed .custom-products__button .add_to_cart_button,
.custom-products--embed .custom-products__button .add_to_cart_button {
	background-color: #dd1010 !important;
	color: #fff !important;
	border: none !important;
	border-radius: 20px !important;
	width: 100% !important;
	text-align: center !important;
	font-size: 20px !important;
	line-height: 1.2 !important;
}

.elementor-shortcode .custom-products--embed .custom-products__button .add_to_cart_button:hover,
.custom-products--embed .custom-products__button .add_to_cart_button:hover {
	background-color: #b80d0d !important;
	color: #fff !important;
}

.custom-products__empty {
	grid-column: 1 / -1;
	text-align: center;
	padding: 2rem;
	color: var(--cc-text-muted);
}

.custom-products__load-wrap {
	grid-column: 1 / -1;
	text-align: center;
	margin-top: 1.5rem;
}

.custom-products__load-more {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.75rem 2rem;
	border-radius: var(--cc-radius-sm);
	font-size: 0.95rem;
	font-weight: 600;
	cursor: pointer;
	background: transparent;
	color: #0f172a;
	border: 2px solid rgba(0, 0, 0, 0.12);
	transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.custom-products__load-more:hover:not(:disabled) {
	background: var(--cc-bg-soft);
	border-color: rgba(0, 0, 0, 0.2);
}

.custom-products__load-more:disabled {
	opacity: 0.7;
	cursor: not-allowed;
}

/* Планшет: не больше 3 колонок */
@media (max-width: 1024px) {
	.custom-products--cols-4 .custom-products__grid,
	.custom-products--cols-5 .custom-products__grid,
	.custom-products--cols-6 .custom-products__grid {
		grid-template-columns: repeat(3, 1fr);
	}
}

/* Мобильные и узкий планшет: всегда 2 карточки в ряд */
@media (max-width: 768px) {
	.custom-products__grid {
		grid-template-columns: repeat(2, 1fr) !important;
		gap: 0.75rem;
	}
}

@media (max-width: 640px) {
	.custom-products__inner {
		padding: 0.75rem;
	}

	.custom-products__title {
		font-size: 0.85rem;
	}

	.custom-products__price {
		font-size: 0.9rem;
	}

	.custom-products__button .button,
	.custom-products__button .add_to_cart_button {
		padding: 0.5rem 0.75rem;
		font-size: 0.85rem;
	}
}

/* Отключаем старые псевдо-элементы скидки/текста для qty=10 */
.custom-products a.ajax_add_to_cart[data-quantity="10"]::before,
.custom-products a.ajax_add_to_cart[data-quantity="10"]::after,
a.cpw-embed-add-btn.ajax_add_to_cart[data-quantity="10"]::before,
a.cpw-embed-add-btn.ajax_add_to_cart[data-quantity="10"]::after {
	content: none !important;
	display: none !important;
}
