/*
 * Общие дополнения к элементам форм из kit.css.
 * Подключать после kit.css и перед стилями страницы.
 * Новые формы: обёртка .form-controls, поля .field.form-field.
 * Классы .auth-* сохранены для существующей разметки и JS авторизации.
 */

/* Общая утилита для подписей и уведомлений, доступных только экранному диктору. */
.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.form-controls,
.auth-body {
	/* Переменные, которых пока нет в kit.css. */
	--color-primary: #4C60F4;
	--color-primary-hover: #344AF4;
	--space-2: 8px;
	--text-xs: 12px;
	--color-error: #CD5153;
	--color-error-light: #FD9B9D;
	--color-success: #51CD78;
	--color-surface-muted: #F0F0F0;
	/* Hover из UI-кита: фон #F0F0F0 с чёрной заливкой 5%. */
	--color-surface-hover: #E4E4E4;
	--color-text-muted: #909090;
	--color-focus: #9BA7FD;
}

.form-controls .button,
.auth-body .button {
	padding-top: 14px;
	padding-bottom: 14px;
	line-height: 24px;
}

.form-controls .button:focus-visible,
.form-controls .field input:focus-visible,
.auth-body .field input:focus-visible {
	outline: 2px solid var(--color-focus);
	outline-offset: 0;
}

/* Компактное поле с плавающей подписью; базовые стили остаются в kit.css. */
.form-field,
.form-field input,
.auth-field,
.auth-field input {
	height: 52px;
}

.form-field input,
.auth-field input {
	padding: 24px 16px 8px;
}

.form-field label,
.auth-field label {
	top: 26px;
}

.form-field.active label,
.form-field.filled label,
.form-field input:focus + label,
.form-field input:not(:placeholder-shown) + label,
.form-field input:-webkit-autofill + label,
.auth-field.active label,
.auth-field.filled label,
.auth-field input:focus + label,
.auth-field input:not(:placeholder-shown) + label,
.auth-field input:-webkit-autofill + label {
	top: 8px;
	transform: none;
	font-size: 12px;
	line-height: 16px;
}

.form-field:focus-within input,
.auth-field:focus-within input {
	background: #FFFFFF;
	outline: 2px solid var(--color-focus);
}

.form-field--password input,
.auth-field--password input {
	padding-right: 56px;
}

.form-field.form-field--has-message,
.auth-field.auth-field--has-message {
	height: auto;
}

/* Ошибка сохраняет свой цвет даже при фокусе на поле. */
.form-controls .form-field.error input,
.auth-body .auth-field.error input,
.auth-body .auth-listbox.error .auth-listbox__trigger {
	background: #FFFFFF;
	outline: 2px solid var(--color-error-light);
}

.form-controls .field.error input:focus-visible,
.auth-body .field.error input:focus-visible {
	outline-color: var(--color-error-light);
}

.form-field .field-hint,
.form-error,
.auth-field .field-hint,
.auth-listbox .field-hint,
.auth-form-error {
	font-family: 'Inter';
	font-size: var(--text-xs);
	font-weight: 400;
	line-height: 16px;
	letter-spacing: -0.02em;
	color: var(--color-error);
	text-align: left;
}

.form-field .field-hint,
.auth-field .field-hint,
.auth-listbox .field-hint {
	margin: var(--space-2) 0 0;
}

.form-field--password .field-hint,
.auth-field--password .field-hint {
	margin-top: 4px;
	line-height: 18px;
	letter-spacing: -0.03em;
}

.form-field.form-field--has-message > .field-hint,
.auth-field.auth-field--has-message > .field-hint {
	display: block;
}

.form-field .field-hint:empty,
.form-error[hidden],
.auth-field .field-hint:empty,
.auth-listbox .field-hint:empty,
.auth-form-error[hidden] {
	display: none;
}

.form-error,
.auth-form-error {
	margin: 0;
}

/* Обе иконки берём из общего спрайта. JS меняет только data-password-visible. */
.form-password-toggle,
.auth-password-toggle {
	position: absolute;
	top: 14px;
	right: 16px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	padding: 0;
	color: #000000;
	background: transparent;
	border: 0;
	border-radius: 4px;
	cursor: pointer;
}

.form-password-toggle:focus-visible,
.auth-password-toggle:focus-visible {
	outline: 2px solid var(--color-primary);
	outline-offset: 0;
}

.form-password-toggle .form-password-toggle__visible,
.auth-password-toggle .form-password-toggle__visible {
	display: none;
}

.form-password-toggle[data-password-visible="true"] .form-password-toggle__hidden,
.auth-password-toggle[data-password-visible="true"] .form-password-toggle__hidden {
	display: none;
}

.form-password-toggle[data-password-visible="true"] .form-password-toggle__visible,
.auth-password-toggle[data-password-visible="true"] .form-password-toggle__visible {
	display: block;
}

.form-password-toggle:disabled,
.auth-password-toggle:disabled {
	cursor: default;
}

.form-password-strength,
.auth-password-strength {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin: 0;
	font-family: 'Inter';
	font-size: 14px;
	font-weight: 400;
	line-height: 24px;
	letter-spacing: -0.02em;
}

.form-password-strength[hidden],
.auth-password-strength[hidden] {
	display: none;
}

.form-password-strength__value--simple,
.auth-password-strength__value--simple {
	color: var(--color-error);
}

.form-password-strength__value--complex,
.auth-password-strength__value--complex {
	color: var(--color-success);
}

/* Наведение только для немобильной вёрстки и точного указателя. */
@media (min-width: 769px) and (hover: hover) and (pointer: fine) {
	.form-field:not(.active):not(.error):not(:focus-within) input:not(:disabled):not([readonly]):hover,
	.auth-field:not(.active):not(.error):not(:focus-within) input:not(:disabled):not([readonly]):hover {
		background: var(--color-surface-hover);
	}
}
