/*
 * HMA Square — Phone field overrides para intl-tel-input v28.
 *
 * Adapta la UI de intl-tel-input al tema dark del form Subscription.
 *
 * Scope:
 *   - #gform_wrapper_4 ... para el input y el botón selector (dentro del form).
 *   - body .iti__dropdown-content ... para el popup (se inyecta al body).
 *
 * Specificity: muchos overrides usan `body` o `html` como prefix para vencer
 * al CSS del theme starter-theme y al CSS base de intl-tel-input.
 */

/* ─────────── Input + selected country (dentro del wrapper GF) ─────────── */

#gform_wrapper_4 .iti {
	width: 100%;
}

/* Specificity boost: el theme custom.css define padding con !important sobre
   `#gform_wrapper_4 input[type="tel"]` (specificity 1,1,1). Para ganar usamos
   el selector compuesto (1,2,1) que sigue siendo legible. */
#gform_wrapper_4 input[type="tel"].iti__tel-input {
	width: 100%;
	box-sizing: border-box;
	/* Reservar espacio para el selector de país (botón con bandera, ~49px de ancho)
	   que vive absolute-positioned al inicio del input. Sin este padding el texto
	   se monta encima de la bandera. */
	padding-left: 56px !important;
}

#gform_wrapper_4 .iti__country-container {
	background: transparent;
}

#gform_wrapper_4 .iti__selected-country,
#gform_wrapper_4 .iti__selected-country-primary {
	background: transparent;
}

#gform_wrapper_4 .iti__selected-country:hover .iti__selected-country-primary,
#gform_wrapper_4 .iti__selected-country:focus .iti__selected-country-primary,
#gform_wrapper_4 .iti__selected-country[aria-expanded="true"] .iti__selected-country-primary {
	background: rgba( 255, 255, 255, 0.06 );
}

#gform_wrapper_4 .iti__arrow {
	border-top-color: #94a3b8;
}

#gform_wrapper_4 .iti__arrow--up {
	border-bottom-color: #94a3b8;
}

/* ─────────── Dropdown popup (vive en body, fuera del wrapper) ─────────── */

body .iti__dropdown-content {
	background: #0f1c33 !important;
	color: #e5e7eb !important;
	border: 1px solid rgba( 255, 255, 255, 0.10 ) !important;
	border-radius: 10px !important;
	box-shadow: 0 16px 40px rgba( 0, 0, 0, 0.55 ) !important;
	overflow: hidden;
	padding: 0 !important;
}

/* El wrapper es position:relative; el icono va absolute con left fijo y el input
   reserva espacio con padding-left. Approach más confiable que flex+gap (que
   v28 desconfigura cuando el input tiene width:100%). */
body .iti__search-input-wrapper {
	background: rgba( 11, 20, 36, 0.6 );
	border-bottom: 1px solid rgba( 255, 255, 255, 0.08 );
	padding: 12px 14px;
	position: relative;
	display: block;
}

body .iti__search-icon {
	color: #94a3b8;
	position: absolute;
	left: 24px;
	top: 50%;
	transform: translateY( -50% );
	pointer-events: none;
	z-index: 1;
	display: inline-block;
	line-height: 0;
}

body .iti__search-icon-svg {
	stroke: #94a3b8;
	stroke-width: 2;
	stroke-linecap: round;
	fill: none;
	width: 16px;
	height: 16px;
}

/* Search input — específico para vencer al starter-theme que añade box-shadow azul.
   Padding-left grande (38px) reserva espacio para el icono absolute-positioned. */
body .iti__dropdown-content input.iti__search-input,
body .iti__search-input-wrapper input.iti__search-input {
	background: transparent !important;
	color: #e5e7eb !important;
	border: 1px solid rgba( 255, 255, 255, 0.10 ) !important;
	border-radius: 6px !important;
	box-shadow: none !important;
	outline: none !important;
	padding: 8px 10px 8px 38px !important;
	width: 100% !important;
	font-size: 14px !important;
	line-height: 1.4 !important;
	min-height: 0 !important;
	box-sizing: border-box !important;
}

body .iti__dropdown-content input.iti__search-input:focus,
body .iti__search-input-wrapper input.iti__search-input:focus {
	background: rgba( 0, 0, 0, 0.25 ) !important;
	border-color: rgba( 56, 189, 248, 0.45 ) !important;
	box-shadow: 0 0 0 3px rgba( 56, 189, 248, 0.12 ) !important;
}

body .iti__dropdown-content input.iti__search-input::placeholder {
	color: #64748b !important;
	opacity: 1;
}

body .iti__search-clear,
body .iti__search-clear-svg {
	color: #94a3b8;
	fill: currentColor;
}

body .iti__search-clear:hover {
	color: #e5e7eb;
}

body .iti__a11y-text {
	color: #94a3b8;
}

body .iti__no-results {
	background: transparent;
	color: #94a3b8;
	padding: 12px 14px;
}

body .iti__country-list {
	background: transparent !important;
	max-height: 260px;
	border: none !important;
	margin: 0;
	padding: 4px 0;
	overflow-y: auto;
	overscroll-behavior: contain;
}

body .iti__country {
	background: transparent;
	color: #e5e7eb;
	padding: 8px 12px;
}

body .iti__country:hover,
body .iti__country.iti__highlight {
	background: rgba( 56, 189, 248, 0.18 ) !important;
	color: #ffffff !important;
}

body .iti__country-name {
	color: inherit;
}

body .iti__dial-code {
	color: #94a3b8;
}

body .iti__country:hover .iti__dial-code,
body .iti__country.iti__highlight .iti__dial-code {
	color: #cbd5e1;
}

/* Separador visual entre preferred (US, CA, MX) y el resto.
   Como countryOrder pone 3 preferred al inicio, ponemos border-top al 4o item. */
body .iti__country-list > li:nth-child(4) {
	border-top: 1px solid rgba( 255, 255, 255, 0.08 );
	margin-top: 4px;
	padding-top: 12px;
}

/* Scrollbar de la lista (Chromium/Edge/Safari). */
body .iti__country-list::-webkit-scrollbar {
	width: 8px;
}
body .iti__country-list::-webkit-scrollbar-track {
	background: transparent;
}
body .iti__country-list::-webkit-scrollbar-thumb {
	background: rgba( 255, 255, 255, 0.14 );
	border-radius: 4px;
}
body .iti__country-list::-webkit-scrollbar-thumb:hover {
	background: rgba( 255, 255, 255, 0.22 );
}

/* Firefox. */
body .iti__country-list {
	scrollbar-width: thin;
	scrollbar-color: rgba( 255, 255, 255, 0.18 ) transparent;
}

/* ─────────── Mensaje de error custom (matchea validation_message nativo) ─────────── */

#gform_wrapper_4 .hma-phone-error {
	display: inline-block;
	margin-top: 8px;
	padding: 10px 14px;
	background: rgba( 239, 68, 68, 0.08 );
	border: 1px solid rgba( 239, 68, 68, 0.45 );
	border-radius: 6px;
	color: #fca5a5;
	font-size: 0.9em;
}

#gform_wrapper_4 .gfield_error .iti__tel-input {
	border-color: #ef4444 !important;
}
