/**
 * Ambix Forms — frontend styles.
 */

:root {
	--ambix-border: #d5d9dd;
	--ambix-border-focus: #2271b1;
	--ambix-text: #1f2328;
	--ambix-muted: #6b7280;
	--ambix-radius: 6px;
	--ambix-gap: 18px;
	--ambix-choice-size: 14px;
	--ambix-choice-weight: 400;
	--ambix-choice-color: #1f2328;
	--ambix-choice-accent: #2271b1;
	--ambix-choice-btn-bg: #ffffff;
	--ambix-choice-btn-bg-hover: #f0f6fc;
	--ambix-choice-btn-bg-active: #2271b1;
	--ambix-choice-btn-color: #1f2328;
	--ambix-choice-btn-color-hover: #1f2328;
	--ambix-choice-btn-color-active: #ffffff;
	--ambix-choice-btn-border: #2271b1;
	--ambix-choice-btn-radius: 6px;
	--ambix-choice-btn-padding: 10px 20px;
	--ambix-choice-box-size: 18px;
	--ambix-choice-box-border-width: 2px;
	--ambix-choice-box-border-color: #9aa0a6;
	--ambix-choice-box-radius: 4px;
	--ambix-choice-box-bg: #ffffff;
	--ambix-choice-box-bg-checked: #2271b1;
	--ambix-choice-check-color: #ffffff;
	--ambix-choice-switch-off: #c9ced3;
	--ambix-choice-switch-on: #2271b1;
	--ambix-choice-switch-knob: #ffffff;
}

.ambix-form {
	width: 100%;
}

/* ---------------------------------------------------------------- Поля */
.ambix-form-fields {
	display: grid;
	grid-template-columns: repeat(12, 1fr);
	column-gap: var(--ambix-gap);
	row-gap: var(--ambix-gap);
}

.ambix-form-field {
	grid-column: span 12;
	min-width: 0;
}

.ambix-field-width-100 { grid-column: span 12; }
.ambix-field-width-75  { grid-column: span 9; }
.ambix-field-width-66  { grid-column: span 8; }
.ambix-field-width-50  { grid-column: span 6; }
.ambix-field-width-33  { grid-column: span 4; }
.ambix-field-width-25  { grid-column: span 3; }

.ambix-form-layout-inline .ambix-form-fields {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: var(--ambix-gap);
}

.ambix-form-layout-inline .ambix-form-field {
	flex: 1 1 200px;
	grid-column: auto;
}

/* --------------------------------------------------------------- Лейблы */
.ambix-field-label {
	display: block;
	margin-bottom: 6px;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.4;
	color: var(--ambix-text);
}

.ambix-required-mark {
	color: #ff3b30;
	margin-left: 2px;
}

.ambix-field-description {
	margin-top: 6px;
	font-size: 12px;
	line-height: 1.5;
	color: var(--ambix-muted);
}

.ambix-field-error {
	margin-top: 6px;
	font-size: 13px;
	line-height: 1.4;
	color: #c0392b;
}

.ambix-field-has-error .ambix-input {
	border-color: #c0392b;
}

/* --------------------------------------------------------------- Вводы */
.ambix-input {
	display: block;
	width: 100%;
	box-sizing: border-box;
	margin: 0;
	padding: 10px 12px;
	font-size: 15px;
	line-height: 1.4;
	font-family: inherit;
	color: var(--ambix-text);
	background-color: #fff;
	border: 1px solid var(--ambix-border);
	border-radius: var(--ambix-radius);
	transition: border-color 0.15s ease;
	-webkit-appearance: none;
	appearance: none;
}

.ambix-input::placeholder {
	color: #9ca3af;
	opacity: 1;
}

.ambix-input[readonly] {
	background-color: #f6f7f7;
}

.ambix-textarea {
	resize: vertical;
}

.ambix-select {
	cursor: pointer;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	padding-right: 32px;
}

.ambix-input[type="color"] {
	height: 44px;
	padding: 4px;
	cursor: pointer;
}

.ambix-input[type="file"] {
	padding: 8px;
	font-size: 14px;
	cursor: pointer;
}

.ambix-file-hint {
	margin-top: 6px;
	font-size: 12px;
	color: var(--ambix-muted);
}

.ambix-file-list {
	margin-top: 8px;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.ambix-file-item {
	font-size: 13px;
	color: var(--ambix-muted);
	padding: 6px 10px;
	background: #f6f7f7;
	border-radius: 4px;
}

/* ------------------------------------------------------- Группы опций */
.ambix-options-group {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.ambix-options-inline {
	flex-direction: row;
	flex-wrap: wrap;
	gap: 8px 20px;
}

.ambix-option {
	display: flex;
	align-items: center;
	gap: 8px;
}

.ambix-option input[type="checkbox"],
.ambix-option input[type="radio"] {
	width: 16px;
	height: 16px;
	margin: 0;
	flex: 0 0 auto;
	accent-color: var(--ambix-choice-accent);
	cursor: pointer;
}

.ambix-option label {
	font-size: var(--ambix-choice-size);
	font-weight: var(--ambix-choice-weight);
	line-height: 1.4;
	color: var(--ambix-choice-color);
	cursor: pointer;
}

.ambix-option-consent label {
	color: var(--ambix-choice-color);
}

/* --------------------------------------- Выравнивание текста и подпись */
.ambix-options-group.ambix-valign-top .ambix-option {
	align-items: flex-start;
}

.ambix-options-group.ambix-valign-bottom .ambix-option {
	align-items: flex-end;
}

.ambix-options-group.ambix-label-left .ambix-option {
	flex-direction: row-reverse;
	justify-content: flex-end;
}

/* ------------------------------------------------- Кнопочный режим опций */
.ambix-options-buttons {
	gap: 8px;
}

.ambix-options-buttons.ambix-options-inline {
	gap: 8px;
}

.ambix-options-buttons .ambix-option {
	gap: 0;
}

.ambix-options-buttons .ambix-option input[type="radio"],
.ambix-options-buttons .ambix-option input[type="checkbox"] {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	border: 0;
	white-space: nowrap;
}

.ambix-options-buttons .ambix-option label {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	padding: var(--ambix-choice-btn-padding);
	font-size: var(--ambix-choice-size);
	font-weight: var(--ambix-choice-weight);
	line-height: 1.3;
	text-align: center;
	color: var(--ambix-choice-btn-color);
	background-color: var(--ambix-choice-btn-bg);
	border: 1px solid var(--ambix-choice-btn-border);
	border-radius: var(--ambix-choice-btn-radius);
	user-select: none;
	transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.ambix-options-buttons .ambix-option label:hover {
	color: var(--ambix-choice-btn-color-hover);
	background-color: var(--ambix-choice-btn-bg-hover);
}

.ambix-options-buttons .ambix-option input:checked + label {
	color: var(--ambix-choice-btn-color-active);
	background-color: var(--ambix-choice-btn-bg-active);
	border-color: var(--ambix-choice-btn-bg-active);
}

.ambix-options-buttons .ambix-option input:focus-visible + label {
	outline: 2px solid var(--ambix-choice-accent);
	outline-offset: 2px;
}

/* ------------------------------------------------- Кастомный вид опций */
.ambix-options-custom .ambix-option {
	gap: 0;
}

.ambix-options-custom .ambix-option input[type="radio"],
.ambix-options-custom .ambix-option input[type="checkbox"] {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	border: 0;
	white-space: nowrap;
}

.ambix-options-custom .ambix-option label {
	position: relative;
	display: inline-flex;
	align-items: center;
	cursor: pointer;
}

.ambix-options-group.ambix-valign-top.ambix-options-custom .ambix-option label {
	align-items: flex-start;
}

.ambix-options-group.ambix-valign-bottom.ambix-options-custom .ambix-option label {
	align-items: flex-end;
}

.ambix-options-custom .ambix-option label::before {
	content: "";
	flex: none;
	box-sizing: border-box;
	width: var(--ambix-choice-box-size);
	height: var(--ambix-choice-box-size);
	margin-inline-end: 10px;
	border: var(--ambix-choice-box-border-width) solid var(--ambix-choice-box-border-color);
	border-radius: var(--ambix-choice-box-radius);
	background-color: var(--ambix-choice-box-bg);
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.ambix-options-custom .ambix-option-radio label::before {
	border-radius: 50%;
}

.ambix-options-custom .ambix-option input:checked + label::before {
	background-color: var(--ambix-choice-box-bg-checked);
	border-color: var(--ambix-choice-box-bg-checked);
}

.ambix-options-custom .ambix-option input:focus-visible + label::before {
	outline: 2px solid var(--ambix-choice-accent);
	outline-offset: 2px;
}

.ambix-options-custom .ambix-option label::after {
	content: "";
	position: absolute;
	left: 0;
	top: 50%;
	transform: translateY(-50%);
	width: var(--ambix-choice-box-size);
	height: var(--ambix-choice-box-size);
	background-color: var(--ambix-choice-check-color);
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 13l4 4L19 7' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 58% no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 13l4 4L19 7' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 58% no-repeat;
	opacity: 0;
	transition: opacity 0.15s ease;
	pointer-events: none;
}

.ambix-options-custom .ambix-option-radio label::after {
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='7' fill='white'/%3E%3C/svg%3E") center / 52% no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='7' fill='white'/%3E%3C/svg%3E") center / 52% no-repeat;
}

.ambix-options-custom .ambix-option input:checked + label::after {
	opacity: 1;
}

.ambix-options-group.ambix-valign-top.ambix-options-custom .ambix-option label::after {
	top: 0;
	transform: none;
}

.ambix-options-group.ambix-valign-bottom.ambix-options-custom .ambix-option label::after {
	top: auto;
	bottom: 0;
	transform: none;
}

/* ------------------------------------------------------- Переключатель */
.ambix-options-switch .ambix-option {
	gap: 0;
}

.ambix-options-switch .ambix-option input[type="radio"],
.ambix-options-switch .ambix-option input[type="checkbox"] {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	border: 0;
	white-space: nowrap;
}

.ambix-options-switch .ambix-option label {
	position: relative;
	display: inline-flex;
	align-items: center;
	min-height: 22px;
	padding-left: 48px;
	cursor: pointer;
}

.ambix-options-switch .ambix-option label::before {
	content: "";
	position: absolute;
	left: 0;
	top: 50%;
	transform: translateY(-50%);
	width: 38px;
	height: 22px;
	border-radius: 999px;
	background-color: var(--ambix-choice-switch-off);
	transition: background-color 0.2s ease;
}

.ambix-options-switch .ambix-option input:checked + label::before {
	background-color: var(--ambix-choice-switch-on);
}

.ambix-options-switch .ambix-option input:focus-visible + label::before {
	outline: 2px solid var(--ambix-choice-accent);
	outline-offset: 2px;
}

.ambix-options-switch .ambix-option label::after {
	content: "";
	position: absolute;
	left: 3px;
	top: 50%;
	transform: translateY(-50%);
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background-color: var(--ambix-choice-switch-knob);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
	transition: left 0.2s ease;
	pointer-events: none;
}

.ambix-options-switch .ambix-option input:checked + label::after {
	left: 19px;
}

.ambix-options-group.ambix-valign-top.ambix-options-switch .ambix-option label::before,
.ambix-options-group.ambix-valign-top.ambix-options-switch .ambix-option label::after {
	top: 0;
	transform: none;
}

.ambix-options-group.ambix-valign-bottom.ambix-options-switch .ambix-option label::before,
.ambix-options-group.ambix-valign-bottom.ambix-options-switch .ambix-option label::after {
	top: auto;
	bottom: 0;
	transform: none;
}

/* ------------------------------------------- Подпись слева от элемента */
.ambix-options-group.ambix-label-left.ambix-options-custom .ambix-option label,
.ambix-options-group.ambix-label-left.ambix-options-switch .ambix-option label {
	flex-direction: row-reverse;
	padding-left: 0;
}

.ambix-options-group.ambix-label-left.ambix-options-custom .ambix-option label {
	padding-right: calc(var(--ambix-choice-box-size) + 10px);
}

.ambix-options-group.ambix-label-left.ambix-options-switch .ambix-option label {
	padding-right: 48px;
}

.ambix-options-group.ambix-label-left.ambix-options-custom .ambix-option label::after {
	left: auto;
	right: 0;
}

.ambix-options-group.ambix-label-left.ambix-options-switch .ambix-option label::before {
	left: auto;
	right: 0;
}

.ambix-options-group.ambix-label-left.ambix-options-switch .ambix-option label::after {
	left: auto;
	right: 3px;
}

.ambix-options-group.ambix-label-left.ambix-options-switch .ambix-option input:checked + label::after {
	left: auto;
	right: 19px;
}

/* ------------------------------------------------------------- Рейтинг */
.ambix-rating {
	display: flex;
	align-items: center;
	gap: 4px;
}

.ambix-star {
	padding: 2px;
	border: none;
	background: none;
	cursor: pointer;
	line-height: 0;
	color: #d5d9dd;
	transition: color 0.15s ease, transform 0.1s ease;
}

.ambix-star svg {
	fill: currentColor;
}

.ambix-star:hover,
.ambix-star.is-hover {
	transform: scale(1.1);
}

.ambix-star.is-active,
.ambix-star.is-hover {
	color: #f5b301;
}

/* ------------------------------------------------------------ Количество */
.ambix-quantity {
	display: inline-flex;
	align-items: stretch;
}

.ambix-qty-btn {
	width: 40px;
	border: 1px solid var(--ambix-border);
	background: #f6f7f7;
	color: var(--ambix-text);
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.ambix-qty-btn:hover {
	background: #eceef0;
}

.ambix-qty-minus {
	border-radius: var(--ambix-radius) 0 0 var(--ambix-radius);
	border-right: none;
}

.ambix-qty-plus {
	border-radius: 0 var(--ambix-radius) var(--ambix-radius) 0;
	border-left: none;
}

.ambix-quantity .ambix-quantity-input {
	width: 72px;
	text-align: center;
	border-radius: 0;
}

/* --------------------------------------------------------------- Слайдер */
.ambix-range-wrapper {
	display: flex;
	align-items: center;
	gap: 12px;
}

.ambix-range {
	flex: 1;
	padding: 0;
	border: none;
	background: none;
	accent-color: var(--ambix-border-focus);
	cursor: pointer;
}

.ambix-range:focus {
	box-shadow: none;
}

.ambix-range-output {
	min-width: 48px;
	text-align: right;
	font-size: 14px;
	font-variant-numeric: tabular-nums;
	color: var(--ambix-text);
}

/* --------------------------------------------------------------- Подпись */
.ambix-signature-wrapper {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.ambix-signature-canvas {
	width: 100%;
	height: 180px;
	border: 1px solid var(--ambix-border);
	border-radius: var(--ambix-radius);
	background: #fff;
	touch-action: none;
	cursor: crosshair;
}

.ambix-signature-actions {
	display: flex;
	gap: 8px;
}

/* ----------------------------------------------------- Контентные поля */
.ambix-field-html {
	font-size: 15px;
	line-height: 1.6;
	color: var(--ambix-text);
}

.ambix-field-heading {
	margin: 0;
	font-size: 20px;
	font-weight: 600;
	line-height: 1.3;
	color: var(--ambix-text);
}

/* ---------------------------------------------------------- Honeypot */
.ambix-honeypot {
	position: absolute !important;
	left: -9999px !important;
	width: 1px !important;
	height: 1px !important;
	overflow: hidden !important;
}

/* ------------------------------------------------------------- Капча */
.ambix-captcha {
	margin-top: 12px;
	min-height: 1px;
}

/* -------------------------------------------------------------- Кнопка */
.ambix-submit-wrapper {
	margin-top: 20px;
	display: flex;
}

.ambix-align-left { justify-content: flex-start; }
.ambix-align-center { justify-content: center; }
.ambix-align-right { justify-content: flex-end; }
.ambix-align-justify { justify-content: stretch; }

.ambix-button {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	box-sizing: border-box;
	padding: 12px 24px;
	font-size: 15px;
	font-weight: 500;
	font-family: inherit;
	line-height: 1.2;
	text-align: center;
	color: #fff;
	background-color: #2271b1;
	border: none;
	border-radius: var(--ambix-radius);
	cursor: pointer;
	transition: background-color 0.15s ease, opacity 0.15s ease;
}

.ambix-button:hover {
	background-color: #135e96;
	color: #fff;
}

.ambix-button:disabled {
	opacity: 0.7;
	cursor: not-allowed;
}

.ambix-btn-secondary {
	color: var(--ambix-text);
	background-color: #f6f7f7;
	border: 1px solid var(--ambix-border);
}

.ambix-btn-secondary:hover {
	background-color: #eceef0;
	color: var(--ambix-text);
}

.ambix-btn-sm { padding: 8px 16px; font-size: 14px; }
.ambix-btn-md { padding: 12px 24px; font-size: 15px; }
.ambix-btn-lg { padding: 16px 32px; font-size: 17px; }

.ambix-btn-block { width: 100%; }

.ambix-submit-spinner {
	display: none;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: #fff;
	border-radius: 50%;
	animation: ambix-spin 0.7s linear infinite;
}

.is-submitting .ambix-submit-spinner {
	display: inline-block;
}

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

/* ------------------------------------------------------------ Сообщения */
.ambix-form-messages {
	margin-top: 16px;
}

.ambix-form-message {
	padding: 12px 16px;
	border-radius: var(--ambix-radius);
	font-size: 15px;
	line-height: 1.5;
}

.ambix-form-success {
	color: #0a7d33;
	background-color: #e8f7ee;
	border: 1px solid #b7e4c7;
}

.ambix-form-error {
	color: #c0392b;
	background-color: #fdecea;
	border: 1px solid #f5c6c2;
}

/* --------------------------------------- Отдельная кнопка (без отступов) */
.ambix-standalone-submit .ambix-submit-wrapper {
	margin-top: 0;
}

.ambix-standalone-submit .ambix-form-messages {
	margin-top: 0;
}

.ambix-standalone-submit .ambix-form-message {
	margin-top: 16px;
}

/* ----------------------------------------------------------------- Шаги */
.ambix-form-step {
	display: flex;
	flex-direction: column;
	gap: var(--ambix-gap);
	grid-column: span 12;
}

.ambix-form-step > .ambix-form-fields,
.ambix-form-step > .ambix-step-header {
	grid-column: span 12;
}

.ambix-step-title {
	font-size: 17px;
	font-weight: 600;
	color: var(--ambix-text);
}

.ambix-step-description {
	font-size: 14px;
	color: var(--ambix-muted);
}

.ambix-step-nav {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	margin-top: 4px;
}

.ambix-form-progress {
	margin-bottom: 20px;
	display: flex;
	align-items: center;
	gap: 12px;
}

.ambix-progress-bar {
	flex: 1;
	height: 6px;
	background-color: #eceef0;
	border-radius: 3px;
	overflow: hidden;
}

.ambix-progress-fill {
	height: 100%;
	background-color: #2271b1;
	border-radius: 3px;
	transition: width 0.3s ease;
}

.ambix-progress-text {
	font-size: 13px;
	color: var(--ambix-muted);
	font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------- Адаптивность */
@media (max-width: 767px) {
	.ambix-field-width-75,
	.ambix-field-width-66,
	.ambix-field-width-50,
	.ambix-field-width-33,
	.ambix-field-width-25 {
		grid-column: span 12;
	}
}
