/**
 * Попап покупки в один клик (Buy It Now).
 *
 * Токены темы: --primary, --text, --text-2, --text-3.
 * Стили полей заданы и для разметки WooCommerce (.form-row), которую рисует
 * woocommerce_form_field(), — чтобы попап не зависел от стилей страницы чекаута.
 */

.onyx-bn-modal {
	--bn-radius: 16px;
	--bn-border: rgba(16, 16, 16, 0.08);
	--bn-danger: #d92d20;
	/* Высота нижней панели (Shop / Search / Cart / Menu) и запас над ней.
	   Панель править нельзя, поэтому её габарит учитывает сама форма: на
	   телефоне карточка попапа заканчивалась на y=639 при панели от y=594 —
	   кнопку «Submit order» перекрывало на 21 px (замер WebKit 390). */
	--bn-toolbar: 70px;
	--bn-toolbar-gap: 16px;
	--bn-toolbar-space: calc(var(--bn-toolbar) + env(safe-area-inset-bottom, 0px) + var(--bn-toolbar-gap));
}

.onyx-bn-modal .modal-dialog {
	max-width: 520px;
}

.onyx-bn-card {
	position: relative;
	max-height: calc(100vh - 40px);
	overflow-y: auto;
	padding: 32px;
	border: 0;
	border-radius: var(--bn-radius);
	background: #fff;
}

/*
 * Телефон: панель снизу перекрывала форму. Поднимаем карточку над панелью —
 * ограничиваем высоту видимой частью экрана и сдвигаем её вверх на половину
 * панели, чтобы центрирование считалось от свободной области. Внутренний
 * нижний отступ не даёт кнопке отправки прилипнуть к панели.
 */
@media (max-width: 1199.98px) {
	.onyx-bn-modal .modal-dialog {
		margin-top: 0;
		margin-bottom: var(--bn-toolbar-space);
	}

	.onyx-bn-card {
		max-height: calc(100vh - var(--bn-toolbar-space) - 20px);
		padding-bottom: 24px;
	}
}

.onyx-bn-card__close {
	position: absolute;
	top: 16px;
	right: 16px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--text-2);
	cursor: pointer;
	transition: color 0.2s ease, background-color 0.2s ease;
}

.onyx-bn-card__close:hover {
	background: rgba(16, 16, 16, 0.05);
	color: var(--text);
}

.onyx-bn-card__title {
	margin: 0 0 20px;
	padding-right: 44px;
	font-size: 24px;
	line-height: 1.2;
	color: var(--text);
}

/* Товар */

.onyx-bn-product {
	display: flex;
	gap: 16px;
	align-items: flex-start;
	padding-bottom: 20px;
	border-bottom: 1px solid var(--bn-border);
}

.onyx-bn-product__media {
	flex: 0 0 72px;
	width: 72px;
}

.onyx-bn-product__media img {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 12px;
}

.onyx-bn-product__body {
	min-width: 0;
}

.onyx-bn-product__name {
	margin: 0 0 6px;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.35;
	color: var(--text);
}

.onyx-bn-product__price {
	margin: 0;
	font-size: 16px;
	color: var(--text);
}

.onyx-bn-product__sku {
	margin: 4px 0 0;
	font-size: 13px;
}

/* Количество и итог */

.onyx-bn-qty {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-top: 20px;
}

.onyx-bn-qty__label {
	font-size: 15px;
	color: var(--text-2);
}

.onyx-bn-qty .wg-quantity {
	display: flex;
	align-items: center;
	gap: 4px;
}

.onyx-bn-qty .btn-quantity {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 1px solid var(--bn-border);
	border-radius: 50%;
	background: transparent;
	color: var(--text);
	cursor: pointer;
}

.onyx-bn-qty .quantity-product {
	width: 56px;
	height: 36px;
	padding: 0;
	border: 0;
	background: transparent;
	text-align: center;
	font-size: 16px;
	color: var(--text);
	-moz-appearance: textfield;
}

.onyx-bn-qty .quantity-product::-webkit-outer-spin-button,
.onyx-bn-qty .quantity-product::-webkit-inner-spin-button {
	margin: 0;
	-webkit-appearance: none;
}

.onyx-bn-total {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
	margin-top: 16px;
	padding: 16px 0;
	border-top: 1px solid var(--bn-border);
	border-bottom: 1px solid var(--bn-border);
}

.onyx-bn-total span {
	font-size: 15px;
	color: var(--text-2);
}

.onyx-bn-total strong {
	font-size: 20px;
	color: var(--text);
}

/* Поля покупателя — те же, что на чекауте */

.onyx-bn-fields {
	margin-top: 20px;
}

.onyx-bn-fields .form-row {
	margin: 0 0 14px;
	padding: 0;
}

.onyx-bn-fields label {
	display: block;
	margin-bottom: 6px;
	font-size: 14px;
	color: var(--text-2);
}

.onyx-bn-fields .required {
	color: var(--bn-danger);
}

.onyx-bn-fields .input-text,
.onyx-bn-fields select,
.onyx-bn-fields .select2-selection {
	width: 100%;
	min-height: 48px;
	padding: 0 14px;
	border: 1px solid var(--bn-border);
	border-radius: 10px;
	background: #fff;
	font-size: 15px;
	color: var(--text);
}

.onyx-bn-fields .input-text:focus,
.onyx-bn-fields select:focus {
	border-color: var(--primary);
	outline: none;
}

/*
 * Страна выбирается тем же selectWoo, что и на чекауте (подключает скрипт попапа),
 * поэтому выравниваем значение по центру 48-пиксельного поля, как в .input-text:
 * по умолчанию select2 держит строку 28px и прижимает её к верху.
 */
.onyx-bn-fields .select2-container {
	width: 100%;
}

.onyx-bn-fields .select2-selection--single {
	padding: 0;
	border-radius: 10px;
}

.onyx-bn-fields .select2-selection--single .select2-selection__rendered {
	padding-left: 14px;
	padding-right: 40px;
	line-height: 46px;
	font-size: 15px;
	color: var(--text);
}

.onyx-bn-fields .select2-selection--single .select2-selection__arrow {
	right: 8px;
	height: 46px;
}

/*
 * Плагин телефона сжимает поле по содержимому (inline-block) — на чекауте
 * и здесь оно должно занимать всю ширину строки.
 */
.onyx-bn-fields .woocommerce-input-wrapper {
	display: block;
}

.onyx-bn-fields .iti,
.onyx-bn-fields .iti__tel-input {
	display: block;
	width: 100%;
}

.onyx-bn-fields .form-row.onyx-bn-invalid .input-text,
.onyx-bn-fields .form-row.onyx-bn-invalid select {
	border-color: var(--bn-danger);
}

.onyx-bn-field-error {
	display: block;
	margin-top: 6px;
	font-size: 13px;
	color: var(--bn-danger);
}

.onyx-bn-field-error strong {
	font-weight: 600;
}

/* Отправка */

.onyx-bn-error {
	margin: 4px 0 14px;
	font-size: 14px;
	color: var(--bn-danger);
}

/*
 * Кнопка отправки всегда на виду: полей пять, и на невысоком экране форма
 * прокручивается внутри карточки — кнопка липнет к нижнему краю окна.
 * Тень-подложка закрывает поля, уезжающие под кнопку, до самых краёв карточки
 * (карточка обрезает её по своим скруглениям).
 */
.onyx-bn-submit {
	position: sticky;
	bottom: 0;
	z-index: 3;
	margin-top: 6px;
	box-shadow: 0 32px 0 0 #fff, 0 0 0 32px #fff;
}

.onyx-bn-submit[disabled] {
	opacity: 0.6;
	pointer-events: none;
}

/* Успех */

.onyx-bn-success {
	text-align: center;
}

.onyx-bn-success__tile {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 64px;
	height: 64px;
	margin: 0 auto 18px;
	border-radius: 50%;
	background: rgba(23, 178, 106, 0.12);
	color: #17b26a;
	font-size: 28px;
}

.onyx-bn-success__title {
	margin: 0 0 10px;
	font-size: 24px;
	color: var(--text);
}

.onyx-bn-success__text {
	margin: 0 0 16px;
	font-size: 15px;
	line-height: 1.5;
	color: var(--text-2);
}

.onyx-bn-success__meta {
	margin: 0 0 20px;
	font-size: 14px;
	color: var(--text-3);
}

.onyx-bn-success__total {
	margin-left: 8px;
}

.onyx-bn-success .tf-btn {
	display: block;
}

/* Телефон */

@media (max-width: 575px) {
	.onyx-bn-card {
		padding: 24px 18px;
		border-radius: 14px;
	}

	.onyx-bn-card__title {
		font-size: 20px;
	}

	.onyx-bn-product__media {
		flex-basis: 56px;
		width: 56px;
	}

	.onyx-bn-qty {
		margin-top: 16px;
	}
}
