/**
 * Омни-кнопки: дуга каналов + модальные формы.
 */

:root {
	--omni-brand: #399ce3;
	--omni-brand-dark: #2b7fc4;
	--omni-toggle-open: #4a4f54;
	/* Компромисс: плотнее чем 236px, но без слипания; при обрезе справа см. --omni-arc-shift-x */
	--omni-radius-fan: 198px;
	/* Уже охват — крайние кнопки не упираются в край экрана */
	--omni-arc-span: 102deg;
	/* Сдвиг пивота дуги влево (половина кнопки не заходит за правый край) */
	--omni-arc-shift-x: -40px;
	--omni-channel-size: 48px;
	/* Выше большинства сторонних виджетов (Jivo и т.п.), чтобы FAB был кликабелен */
	--omni-z: 2147483646;
}

.omni-widget {
	position: fixed;
	right: max(20px, env(safe-area-inset-right, 0px));
	bottom: max(20px, env(safe-area-inset-bottom, 0px));
	top: auto;
	left: auto;
	transform: none;
	/* Выше нижнего sticky WooCommerce/Betheme (.mfn-footer-stickymenu z-index 9999) */
	z-index: var(--omni-z);
	width: 56px;
	height: 56px;
	font-family: inherit;
	box-sizing: border-box;
	isolation: isolate;
	overflow: visible;
}

/*
 * Betheme: при включённом нижнем меню (body.footer-menu-sticky) панель ~70px закрывает угол.
 * Меню показывается до max-width:767px — поднимаем FAB над ней.
 */
@media (max-width: 767px) {
	body.footer-menu-sticky .omni-widget {
		bottom: calc(78px + max(16px, env(safe-area-inset-bottom, 0px)));
	}
}

.omni-widget *,
.omni-widget *::before,
.omni-widget *::after {
	box-sizing: border-box;
}

/* Пивот дуги — центр круглой кнопки; translateX уводит дугу в область экрана */
.omni-widget__arc {
	position: absolute;
	right: 28px;
	bottom: 28px;
	width: 0;
	height: 0;
	pointer-events: none;
	z-index: 1;
	transform: translateX(var(--omni-arc-shift-x, -40px));
}

.omni-widget__arc > a,
.omni-widget__arc > button {
	position: absolute;
	left: 0;
	top: 0;
	width: var(--omni-channel-size);
	height: var(--omni-channel-size);
	margin: calc(var(--omni-channel-size) / -2) 0 0 calc(var(--omni-channel-size) / -2);
	border: 0;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	text-decoration: none;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
	transition:
		opacity 0.22s ease,
		transform 0.22s ease,
		visibility 0.22s ease;
	/* В закрытом состоянии не перехватывать клики (opacity:0 всё ещё может ловить hit-test) */
	pointer-events: none;
	opacity: 0;
	visibility: hidden;
	/* Дуга в сторону экрана (влево): +180deg; шаг угла = --omni-arc-span / --omni-arc-steps */
	transform: rotate(
			calc(
				195deg - var(--omni-i) * (var(--omni-arc-span, 102deg) / var(--omni-arc-steps, 7)) + 180deg
			)
		)
		translateY(calc(-1 * var(--omni-radius-fan)))
		rotate(
			calc(
				-195deg + var(--omni-i) * (var(--omni-arc-span, 102deg) / var(--omni-arc-steps, 7)) - 180deg
			)
		);
}

.omni-widget.is-open .omni-widget__arc > a,
.omni-widget.is-open .omni-widget__arc > button {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

/* Цвета каналов */
.omni-widget__channel--vk {
	background: #0077ff;
	color: #fff;
}
.omni-widget__channel--whatsapp {
	background: #25d366;
	color: #fff;
}
.omni-widget__channel--telegram {
	background: #229ed9;
	color: #fff;
}
.omni-widget__channel--viber {
	background: #7360f2;
	color: #fff;
}
.omni-widget__channel--contacts {
	background: #7360f2;
	color: #fff;
}
.omni-widget__channel--ok {
	background: #ee8208;
	color: #fff;
}
.omni-widget__arc > a.omni-widget__channel--avito {
	background: #fff;
	color: #333;
	border: 1px solid #e5e5e5;
	box-shadow:
		0 2px 10px rgba(0, 0, 0, 0.12),
		0 0 0 1px rgba(0, 0, 0, 0.04);
}

.omni-widget__arc > a.omni-widget__channel--avito .omni-icon--avito-mark {
	width: 22px;
	height: 22px;
}
.omni-widget__channel--email {
	background: #67b8f7;
	color: #fff;
}
.omni-widget__channel--callback {
	background: #399ce3;
	color: #fff;
}
.omni-widget__channel--request {
	background: #fff;
	color: #333;
	border: 1px solid #ddd;
}

.omni-widget__channel--request .omni-icon {
	width: 26px;
	height: 26px;
}

.omni-icon {
	width: 24px;
	height: 24px;
	display: block;
	flex-shrink: 0;
}

.omni-widget__toggle {
	position: absolute;
	right: 0;
	bottom: 0;
	width: 56px;
	height: 56px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	aspect-ratio: 1;
	cursor: pointer;
	z-index: 10;
	pointer-events: auto;
	color: #fff;
	background: linear-gradient(145deg, #58b6f6 0%, var(--omni-brand) 45%, var(--omni-brand-dark) 100%);
	box-shadow:
		0 4px 18px rgba(57, 156, 227, 0.48),
		0 0 0 0 rgba(57, 156, 227, 0.45);
	animation: omni-fab-pulse 2.4s ease-out infinite;
	transition:
		transform 0.2s ease,
		background 0.2s ease,
		box-shadow 0.2s ease;
}

.omni-widget.is-open .omni-widget__toggle {
	animation: none;
	background: linear-gradient(145deg, #5c6269 0%, #4a4f54 100%);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
}

.omni-widget__toggle:hover {
	transform: scale(1.06);
}

.omni-widget__toggle:active {
	transform: scale(0.98);
}

.omni-widget__toggle:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
}

.omni-widget__toggle-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	pointer-events: none;
}

.omni-widget__toggle-icon svg.omni-toggle__glyph {
	display: block;
	width: 28px;
	height: 28px;
	flex-shrink: 0;
}

.omni-widget__toggle-icon svg.omni-toggle__glyph--close {
	width: 26px;
	height: 26px;
}

@keyframes omni-fab-pulse {
	0% {
		box-shadow:
			0 4px 18px rgba(57, 156, 227, 0.48),
			0 0 0 0 rgba(57, 156, 227, 0.45);
	}
	55% {
		box-shadow:
			0 6px 22px rgba(57, 156, 227, 0.38),
			0 0 0 14px rgba(57, 156, 227, 0);
	}
	100% {
		box-shadow:
			0 4px 18px rgba(57, 156, 227, 0.48),
			0 0 0 0 rgba(57, 156, 227, 0);
	}
}

.omni-widget:not(.is-open) .omni-widget__toggle-icon--open {
	display: none;
}
.omni-widget.is-open .omni-widget__toggle-icon--closed {
	display: none;
}

/* Модальные окна */
.omni-modal[hidden] {
	display: none !important;
}

.omni-modal {
	position: fixed;
	inset: 0;
	z-index: calc(var(--omni-z) + 10);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
		max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
	overflow-x: hidden;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	box-sizing: border-box;
}

.omni-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
}

.omni-modal__dialog {
	position: relative;
	width: min(100%, 420px);
	max-width: calc(100vw - 24px);
	max-height: min(90vh, calc(100dvh - 24px));
	overflow-x: hidden;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
	padding: 0 0 clamp(14px, 3vw, 20px);
	box-sizing: border-box;
}

.omni-modal__head {
	background: linear-gradient(160deg, var(--omni-brand) 0%, var(--omni-brand-dark) 100%);
	color: #fff;
	padding: 16px 52px 16px 18px;
	border-radius: 12px 12px 0 0;
	box-sizing: border-box;
}

.omni-modal__head--row {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
}

.omni-modal__close {
	position: absolute;
	top: 50%;
	right: 10px;
	transform: translateY(-50%);
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.22);
	color: #fff;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	box-shadow: none;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.omni-modal__close:hover {
	background: rgba(255, 255, 255, 0.35);
}

.omni-modal__title {
	margin: 0;
	font-size: clamp(1rem, 3.5vw, 1.15rem);
	font-weight: 600;
	text-align: center;
	line-height: 1.3;
	padding: 0 4px;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.omni-modal__hint {
	margin: 14px clamp(14px, 4vw, 20px) 0;
	font-size: 0.9rem;
	color: #555;
	line-height: 1.5;
}

.omni-modal__hint--bubble {
	background: #e8f4fd;
	padding: 12px 14px;
	border-radius: 10px;
	border: 1px solid rgba(57, 156, 227, 0.15);
	margin-top: 14px;
}

.omni-modal__form {
	padding: 0 clamp(14px, 4vw, 20px);
	max-width: 100%;
	box-sizing: border-box;
}

.omni-field {
	display: block;
	margin-bottom: 14px;
	max-width: 100%;
	min-width: 0;
}

.omni-field__label {
	display: block;
	font-size: 0.8rem;
	font-weight: 500;
	color: #555;
	margin-bottom: 6px;
}

.omni-field input,
.omni-field textarea {
	width: 100%;
	max-width: 100%;
	min-width: 0;
	padding: 11px 13px;
	border: 1px solid #cfd6dc;
	border-radius: 8px;
	font: inherit;
	font-size: 16px;
	box-sizing: border-box;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.omni-field input:focus,
.omni-field textarea:focus {
	outline: none;
	border-color: var(--omni-brand);
	box-shadow: 0 0 0 3px rgba(57, 156, 227, 0.2);
}

.omni-field textarea {
	resize: vertical;
	min-height: 88px;
}

.omni-field-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
	max-width: 100%;
	min-width: 0;
}

.omni-field-row .omni-field {
	margin-bottom: 0;
}

.omni-field-row .omni-field input {
	min-width: 0;
}

/* Согласие с политикой */
.omni-consent {
	margin: 16px 0 4px;
	max-width: 100%;
}

.omni-consent__label {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	cursor: pointer;
	font-size: 0.88rem;
	line-height: 1.45;
	color: #444;
	max-width: 100%;
}

.omni-consent__input {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.omni-consent__box {
	flex-shrink: 0;
	width: 22px;
	height: 22px;
	margin-top: 2px;
	border: 2px solid #b8c2cc;
	border-radius: 6px;
	background: #fff;
	position: relative;
	transition: border-color 0.15s ease, background 0.15s ease;
}

.omni-consent__input:focus-visible + .omni-consent__box {
	box-shadow: 0 0 0 3px rgba(57, 156, 227, 0.35);
}

.omni-consent__input:checked + .omni-consent__box {
	background: var(--omni-brand);
	border-color: var(--omni-brand);
}

.omni-consent__input:checked + .omni-consent__box::after {
	content: "";
	position: absolute;
	left: 6px;
	top: 2px;
	width: 5px;
	height: 10px;
	border: solid #fff;
	border-width: 0 2.5px 2.5px 0;
	transform: rotate(45deg);
}

.omni-consent__text {
	flex: 1;
	min-width: 0;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.omni-consent__link {
	color: var(--omni-brand);
	font-weight: 500;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.omni-consent__link:hover {
	color: var(--omni-brand-dark);
}

.omni-consent__muted {
	color: #666;
}

.omni-modal__actions {
	display: flex;
	justify-content: stretch;
	margin-top: 18px;
}

.omni-modal__submit {
	width: 100%;
	background: var(--omni-brand);
	color: #fff;
	border: 0;
	padding: 14px 20px;
	border-radius: 10px;
	font-weight: 600;
	cursor: pointer;
	text-transform: uppercase;
	font-size: 0.82rem;
	letter-spacing: 0.06em;
	transition: background 0.15s ease, opacity 0.15s ease;
}

.omni-modal__submit:hover:not(:disabled) {
	background: var(--omni-brand-dark);
}

.omni-modal__submit:disabled {
	opacity: 0.45;
	cursor: not-allowed;
	background: var(--omni-brand);
}

.omni-modal__status {
	min-height: 1.25em;
	margin: 14px clamp(14px, 4vw, 20px) 0;
	font-size: 0.9rem;
	color: #0a7a32;
	max-width: 100%;
	word-wrap: break-word;
}

.omni-modal__status.is-error {
	color: #c00;
}

@media (min-width: 481px) {
	.omni-modal__actions {
		justify-content: flex-end;
	}

	.omni-modal__submit {
		width: auto;
		min-width: 160px;
		padding-inline: 32px;
	}
}

@media (max-width: 480px) {
	.omni-widget {
		right: max(12px, env(safe-area-inset-right, 0px));
		bottom: max(12px, env(safe-area-inset-bottom, 0px));
		top: auto;
		transform: none;
	}

	:root {
		--omni-radius-fan: 162px;
		--omni-arc-span: 96deg;
		--omni-arc-shift-x: -32px;
		--omni-channel-size: 44px;
	}

	.omni-field-row {
		grid-template-columns: 1fr;
		gap: 14px;
	}

	.omni-field-row .omni-field {
		margin-bottom: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.omni-widget__arc > a,
	.omni-widget__arc > button {
		transition: none;
	}

	.omni-widget__toggle {
		animation: none;
		box-shadow: 0 4px 18px rgba(57, 156, 227, 0.48);
	}

	.omni-widget.is-open .omni-widget__toggle {
		box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
	}
}
