/* =============================================================
   FB Phone Input — country flag picker + auto-formatted number.
   Used by every form across the site that captures a phone number.
   Markup contract: see assets/js/fb-phone-input.js docblock.

   v1.2.99: every `var()` carries a hardcoded fallback so the widget
   renders correctly in WP-admin context (where the theme's
   design-system.css tokens are NOT loaded). Without fallbacks the
   dropdown rendered transparent on admin pages.
   ============================================================= */

.fb-phone {
	position: relative;
	display: flex;
	align-items: stretch;
	width: 100%;
	min-height: 44px;
	border: 1px solid var(--slate-200, #e2e8f0);
	border-radius: var(--radius-md, 8px);
	background: var(--white, #ffffff);
	transition: border-color .15s var(--ease, cubic-bezier(.4,0,.2,1)), box-shadow .15s var(--ease, cubic-bezier(.4,0,.2,1));
}
.fb-phone:hover { border-color: var(--slate-300, #cbd5e1); }
.fb-phone:focus-within {
	border-color: var(--green, #38ad4e);
	box-shadow: 0 0 0 3px rgba( 56, 173, 78, .15 );
}
.fb-phone.is-error,
.fb-phone:has( .fb-phone-input.is-error ) {
	border-color: var(--red-500, #ef4444);
}
.fb-phone.is-error:focus-within,
.fb-phone:has( .fb-phone-input.is-error ):focus-within {
	box-shadow: 0 0 0 3px rgba( 239, 68, 68, .15 );
}

/* ───────── Country picker trigger (left side) ───────── */
.fb-phone-country {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 0 10px 0 12px;
	border: 0;
	border-right: 1px solid var(--slate-200, #e2e8f0);
	background: var(--slate-50, #f8fafc);
	cursor: pointer;
	border-radius: var(--radius-md, 8px) 0 0 var(--radius-md, 8px);
	font-family: inherit;
	font-size: var(--fs-md, 15px);
	color: var(--slate-700, #334155);
	transition: background .12s var(--ease, cubic-bezier(.4,0,.2,1));
	flex-shrink: 0;
}
.fb-phone-country:hover { background: var(--slate-100, #f1f5f9); }
.fb-phone-country:focus-visible {
	outline: 2px solid var(--green, #38ad4e);
	outline-offset: -2px;
}
.fb-phone-flag {
	display: block;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	object-fit: cover;
	background: var(--slate-100, #f1f5f9); /* placeholder while SVG loads */
	flex-shrink: 0;
}
.fb-phone-dial {
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	color: var(--slate-900, #0f172a);
	white-space: nowrap;
}
.fb-phone-chevron {
	width: 12px;
	height: 12px;
	stroke: var(--slate-400, #94a3b8);
	fill: none;
	stroke-width: 2.2;
	stroke-linecap: round;
	stroke-linejoin: round;
	flex-shrink: 0;
}

/* ───────── National-number input (right side) ───────── */
.fb-phone-input {
	flex: 1;
	min-width: 0;
	border: 0;
	background: transparent;
	padding: 0 14px;
	font-family: inherit;
	font-size: var(--fs-md, 15px);
	color: var(--slate-900, #0f172a);
	outline: none;
	border-radius: 0 var(--radius-md, 8px) var(--radius-md, 8px) 0;
	font-variant-numeric: tabular-nums;
}
.fb-phone-input::placeholder { color: var(--slate-400, #94a3b8); }

/* Hidden E.164 field carries the actual value to the server. */
input[data-fb-phone-e164] {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	border: 0;
}

/* ───────── Dropdown ───────── */
.fb-phone-dropdown {
	position: absolute;
	top: calc( 100% + 4px );
	left: 0;
	z-index: 50;
	width: 320px;
	max-width: calc( 100vw - 32px );
	background: var(--white, #ffffff);
	border: 1px solid var(--slate-200, #e2e8f0);
	border-radius: var(--radius-md, 8px);
	box-shadow: var(--shadow-lg, 0 12px 40px -8px rgba(15,23,42,.18), 0 0 0 1px rgba(15,23,42,.05));
	overflow: hidden;
	display: flex;
	flex-direction: column;
}
.fb-phone-dropdown[hidden] { display: none; }

.fb-phone-search {
	width: 100%;
	height: 40px;
	padding: 0 14px;
	border: 0;
	border-bottom: 1px solid var(--slate-100, #f1f5f9);
	background: var(--white, #ffffff);
	font-family: inherit;
	font-size: var(--fs-md, 15px);
	color: var(--slate-900, #0f172a);
	outline: none;
}
.fb-phone-search:focus {
	background: var(--slate-50, #f8fafc);
}

.fb-phone-list {
	list-style: none;
	margin: 0;
	padding: 4px 0;
	max-height: 300px;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	background: var(--white, #ffffff);
}
.fb-phone-option {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 14px;
	cursor: pointer;
	font-size: var(--fs-md, 15px);
	color: var(--slate-700, #334155);
	transition: background .1s var(--ease, cubic-bezier(.4,0,.2,1));
	background: var(--white, #ffffff);
}
.fb-phone-option:hover,
.fb-phone-option:focus-visible {
	background: var(--slate-50, #f8fafc);
	outline: none;
}
.fb-phone-option.is-selected {
	background: var(--green-50, #f4faf3);
	color: var(--green-dark, #237d38);
	font-weight: 600;
}
.fb-phone-option .fb-phone-flag {
	width: 22px;
	height: 22px;
}
.fb-phone-option-name { flex: 1; min-width: 0; }
.fb-phone-option-dial {
	color: var(--slate-400, #94a3b8);
	font-variant-numeric: tabular-nums;
	flex-shrink: 0;
}
.fb-phone-option.is-selected .fb-phone-option-dial { color: var(--green-dark, #237d38); }

.fb-phone-empty {
	padding: 16px;
	text-align: center;
	color: var(--slate-500, #64748b);
	font-size: var(--fs-sm, 13px);
}

/* ───────── Error message ───────── */
.fb-phone-error {
	position: absolute;
	top: calc( 100% + 4px );
	left: 0;
	right: 0;
	font-size: var(--fs-sm, 13px);
	color: var(--red-600, #dc2626);
	line-height: 1.4;
	padding: 2px 4px;
}

/* ───────── Mobile: full-screen dropdown for usability ───────── */
@media ( max-width: 640px ) {
	.fb-phone-dropdown {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		max-width: none;
		border-radius: 0;
		z-index: 9999;
	}
	.fb-phone-list { max-height: none; flex: 1; }
}

/* v1.2.96 (audit MED #2): inside admin modals the modal-body has its own
   overflow-y:auto + max-height — the dropdown's 300px list extends past
   the modal scroll boundary on shorter viewports and gets clipped.
   Shrink the list scroll cap inside `.fb-modal` so the whole dropdown
   fits within the modal viewport. */
.fb-modal .fb-phone-list { max-height: 200px; }
