/**
 * Shared front styles for Hafez_User_Field_Engine controls.
 *
 * Loaded on حساب کاربری and KYC (handle `hafez-user-fields`) so engine
 * markup always looks the same. Field titles/labels are defined ONLY here —
 * do not restyle them in account.css / kyc.css.
 */

.hafez-user-fields-form {
	--hafez-uf-label-size: 13px;
	--hafez-uf-label-weight: 600;
	--hafez-uf-label-line: 1.4;
	--hafez-uf-label-gap: 6px;
}

body.hafez-kyc-page .hafez-user-fields-form .hafez-user-fields__row,
body.hafez-kyc-page .hafez_kyc .hafez-user-fields__row,
body.hafez-kyc-page .hafez_kyc__field {
	margin-bottom: var(--hafez-uf-row-gap, 14px);
}

/*
 * Canonical field titles (text / select / date / radio legend / contracts /
 * signature / avatar / map). !important beats later account/theme label rules.
 */
.hafez-user-fields-form .hafez-user-fields__row > label,
.hafez-user-fields-form .hafez-user-fields__radio-legend,
.hafez-user-fields-form .hafez-user-fields__contracts-label,
.hafez-user-fields-form .hafez-user-fields__contracts-upload-label,
.hafez-user-fields-form .hafez-user-fields__signature-label,
.hafez-user-fields-form .hafez-user-fields__avatar-label,
.hafez-user-fields-form .hafez-user-fields__map-label,
.hafez-user-fields-form .hafez-user-fields__passwords > legend,
body.hafez-account-page .woocommerce-MyAccount-content .hafez-user-fields-form .hafez-user-fields__row > label,
body.hafez-account-page .woocommerce-MyAccount-content .hafez-user-fields-form .hafez-user-fields__radio-legend,
body.hafez-account-page .woocommerce-MyAccount-content .hafez-user-fields-form .hafez-user-fields__contracts-label,
body.hafez-account-page .woocommerce-MyAccount-content .hafez-user-fields-form .hafez-user-fields__contracts-upload-label,
body.hafez-account-page .woocommerce-MyAccount-content .hafez-user-fields-form .hafez-user-fields__signature-label,
body.hafez-account-page .woocommerce-MyAccount-content .hafez-user-fields-form .hafez-user-fields__avatar-label,
body.hafez-account-page .woocommerce-MyAccount-content .hafez-user-fields-form .hafez-user-fields__map-label,
body.hafez-account-page .woocommerce-MyAccount-content .hafez-user-fields-form .hafez-user-fields__passwords > legend,
body.hafez-kyc-page .hafez-user-fields-form .hafez-user-fields__row > label,
body.hafez-kyc-page .hafez-user-fields-form .hafez-user-fields__radio-legend,
body.hafez-kyc-page .hafez-user-fields-form .hafez-user-fields__contracts-label,
body.hafez-kyc-page .hafez-user-fields-form .hafez-user-fields__contracts-upload-label,
body.hafez-kyc-page .hafez-user-fields-form .hafez-user-fields__signature-label,
body.hafez-kyc-page .hafez-user-fields-form .hafez-user-fields__avatar-label,
body.hafez-kyc-page .hafez-user-fields-form .hafez-user-fields__map-label {
	display: block;
	position: static;
	float: none !important;
	box-sizing: border-box;
	width: auto;
	max-width: 100%;
	margin: 0 0 var(--hafez-uf-label-gap, 6px);
	padding: 0;
	border: 0;
	color: var(--hafez-uf-label-color, var(--hafez-color-text, #2c2624));
	font-family: var(--hafez-font-sans, "IRANSans", Tahoma, Arial, sans-serif);
	font-size: var(--hafez-uf-label-size, 13px) !important;
	font-weight: var(--hafez-uf-label-weight, 600) !important;
	line-height: var(--hafez-uf-label-line, 1.4);
	letter-spacing: normal;
	text-transform: none;
}

.hafez-user-fields-form input[type="text"],
.hafez-user-fields-form input[type="password"],
.hafez-user-fields-form input[type="email"],
.hafez-user-fields-form input[type="tel"],
.hafez-user-fields-form input[type="number"],
.hafez-user-fields-form input[type="url"],
.hafez-user-fields-form select,
.hafez-user-fields-form textarea {
	box-sizing: border-box;
	display: block;
	width: 100%;
	max-width: 100%;
	min-height: var(--hafez-uf-input-height, 40px);
	height: var(--hafez-uf-input-height, 40px);
	margin: 0;
	padding: 0 12px;
	color: var(--hafez-uf-input-text, var(--hafez-color-text, #2c2624));
	font-family: var(--hafez-font-body, "IRANSans", Tahoma, Arial, sans-serif);
	font-size: 13px;
	line-height: var(--hafez-uf-input-height, 40px);
	vertical-align: middle;
	background: var(--hafez-uf-input-bg, var(--hafez-color-surface, #fff)) !important;
	border: 1px solid var(--hafez-uf-input-border, var(--hafez-color-border, #e6dfda));
	border-radius: var(--hafez-uf-input-radius, var(--hafez-radius-md, 8px));
	box-shadow: none !important;
	accent-color: var(--hafez-uf-radio-accent, var(--hafez-color-primary, #f15a24));
}

.hafez-user-fields-form input::placeholder,
.hafez-user-fields-form textarea::placeholder {
	color: var(--hafez-uf-placeholder, var(--hafez-color-text-muted, #6e6560));
	opacity: 1;
}

.hafez-user-fields-form input:focus,
.hafez-user-fields-form select:focus,
.hafez-user-fields-form textarea:focus {
	border-color: var(--hafez-uf-focus-border, var(--hafez-color-primary, #f15a24)) !important;
	outline: 2px solid color-mix(in srgb, var(--hafez-uf-focus-border, var(--hafez-color-primary, #f15a24)) 20%, transparent);
	outline-offset: 0;
}

.hafez-user-fields-form .hafez-user-fields__radio input,
.hafez-user-fields-form input[type="radio"],
.hafez-user-fields-form input[type="checkbox"] {
	accent-color: var(--hafez-uf-radio-accent, var(--hafez-color-primary, #f15a24));
}

.hafez-user-fields-form input[type="text"],
.hafez-user-fields-form input[type="password"],
.hafez-user-fields-form input[type="email"],
.hafez-user-fields-form input[type="tel"],
.hafez-user-fields-form input[type="number"],
.hafez-user-fields-form input[type="url"],
.hafez-user-fields-form select {
	padding-block: 0 !important;
}

.hafez-user-fields-form .hafez-user-fields__state,
.hafez-user-fields-form .hafez-user-fields__city,
.hafez-user-fields-form select[data-hafez-state],
.hafez-user-fields-form select[data-hafez-city],
.hafez-user-fields-form select.woocommerce-Input {
	box-sizing: border-box;
	width: 100%;
	min-height: var(--hafez-uf-input-height, 40px) !important;
	height: var(--hafez-uf-input-height, 40px) !important;
	padding: 0 12px !important;
	color: var(--hafez-uf-input-text, var(--hafez-color-text, #2c2624)) !important;
	-webkit-text-fill-color: var(--hafez-uf-input-text, var(--hafez-color-text, #2c2624)) !important;
	font-family: var(--hafez-font-body, "IRANSans", Tahoma, Arial, sans-serif) !important;
	font-size: 13px !important;
	line-height: var(--hafez-uf-input-height, 40px) !important;
	background: var(--hafez-uf-input-bg, var(--hafez-color-surface, #fff)) !important;
	border: 1px solid var(--hafez-uf-input-border, var(--hafez-color-border, #e6dfda)) !important;
	border-radius: var(--hafez-uf-input-radius, var(--hafez-radius-md, 8px)) !important;
}

/* Native <option> list (استان/شهر) must follow the same text/bg tokens. */
.hafez-user-fields-form select option,
.hafez-user-fields-form select.hafez-user-fields__state option,
.hafez-user-fields-form select.hafez-user-fields__city option,
.hafez-user-fields-form select[data-hafez-state] option,
.hafez-user-fields-form select[data-hafez-city] option {
	color: var(--hafez-uf-input-text, var(--hafez-color-text, #2c2624)) !important;
	background-color: var(--hafez-uf-input-bg, var(--hafez-color-surface, #fff)) !important;
}

.hafez-user-fields-form select option[value=""],
.hafez-user-fields-form select:has(> option[value=""]:checked) {
	color: var(--hafez-uf-placeholder, var(--hafez-color-text-muted, #6e6560)) !important;
	-webkit-text-fill-color: var(--hafez-uf-placeholder, var(--hafez-color-text-muted, #6e6560)) !important;
}

.hafez-user-fields-form select:has(> option[value=""]:checked) option:not([value=""]) {
	color: var(--hafez-uf-input-text, var(--hafez-color-text, #2c2624)) !important;
	-webkit-text-fill-color: var(--hafez-uf-input-text, var(--hafez-color-text, #2c2624)) !important;
}

/* Select2 (استان) must match native select (شهر) height exactly. */
.hafez-user-fields-form .select2-container {
	width: 100% !important;
}

.hafez-user-fields-form .select2-container .select2-selection--single {
	box-sizing: border-box;
	display: flex;
	align-items: center;
	min-height: var(--hafez-uf-input-height, 40px) !important;
	height: var(--hafez-uf-input-height, 40px) !important;
	padding: 0 12px !important;
	font-family: var(--hafez-font-body, "IRANSans", Tahoma, Arial, sans-serif) !important;
	font-size: 13px !important;
	color: var(--hafez-uf-input-text, var(--hafez-color-text, #2c2624)) !important;
	background: var(--hafez-uf-input-bg, var(--hafez-color-surface, #fff)) !important;
	border: 1px solid var(--hafez-uf-input-border, var(--hafez-color-border, #e6dfda)) !important;
	border-radius: var(--hafez-uf-input-radius, var(--hafez-radius-md, 8px)) !important;
}

.hafez-user-fields-form .select2-container--default .select2-selection--single .select2-selection__rendered {
	padding: 0 !important;
	color: var(--hafez-uf-input-text, var(--hafez-color-text, #2c2624)) !important;
	font-size: 13px !important;
	line-height: calc(var(--hafez-uf-input-height, 40px) - 2px) !important;
}

.hafez-user-fields-form .select2-container--default .select2-selection--single .select2-selection__placeholder {
	color: var(--hafez-uf-placeholder, var(--hafez-color-text-muted, #57534e)) !important;
	line-height: calc(var(--hafez-uf-input-height, 40px) - 2px) !important;
}

.hafez-user-fields-form .select2-container--default .select2-selection--single .select2-selection__arrow {
	top: 0 !important;
	height: var(--hafez-uf-input-height, 40px) !important;
}

.hafez-user-fields-form .select2-container--default.select2-container--focus .select2-selection--single,
.hafez-user-fields-form .select2-container--default.select2-container--open .select2-selection--single {
	border-color: var(--hafez-uf-focus-border, var(--hafez-color-primary, #f15a24)) !important;
}

/*
 * Select2 dropdown is portaled to <body> — keep text/bg tokens via page scopes.
 */
body.hafez-account-page .select2-dropdown,
body.hafez-kyc-page .select2-dropdown {
	background: var(--hafez-uf-input-bg, var(--hafez-color-surface, #fff)) !important;
	border-color: var(--hafez-uf-input-border, var(--hafez-color-border, #e6dfda)) !important;
	font-family: var(--hafez-font-body, "IRANSans", Tahoma, Arial, sans-serif) !important;
	font-size: 13px !important;
}

body.hafez-account-page .select2-results__option,
body.hafez-kyc-page .select2-results__option {
	color: var(--hafez-uf-input-text, var(--hafez-color-text, #2c2624)) !important;
	font-family: var(--hafez-font-body, "IRANSans", Tahoma, Arial, sans-serif) !important;
	font-size: 13px !important;
}

body.hafez-account-page .select2-container--default .select2-results__option--highlighted[aria-selected],
body.hafez-kyc-page .select2-container--default .select2-results__option--highlighted[aria-selected] {
	background: var(--hafez-uf-focus-border, var(--hafez-color-primary, #f15a24)) !important;
	color: var(--hafez-color-on-primary, #fff) !important;
}

.hafez-user-fields-form textarea {
	height: auto !important;
	min-height: max(88px, calc(var(--hafez-uf-input-height, 40px) * 2)) !important;
	padding: 10px 12px !important;
	line-height: 1.5 !important;
}
