/**
 * intl-tel-input widget — theming + layout for input[data-evd-phone].
 *
 * The vendored library (evd/assets/vendor/intl-tel-input/) exposes its own
 * `--iti-*` custom properties for colors and flag/globe sprite paths. We map
 * those onto this theme's existing `--lw-*` design tokens (defined in
 * lightweight.css :root — available site-wide, not just on lightweight
 * pages) instead of hardcoding any color, per project convention.
 *
 * No inline CSS anywhere; this file is enqueued as a stylesheet.
 *
 * @package EthicVillageDjerba
 */

/* --------------------------------------------------------------------------
   1. Vendored image paths
   -------------------------------------------------------------------------- */

/*
 * The shipped intlTelInput.min.css already resolves --iti-path-flags-1x etc.
 * to "../img/flags.webp" relative to its own css/ folder, which is exactly
 * where we vendored evd/assets/vendor/intl-tel-input/img/ — so no override
 * is needed for the default (light) globe icon. We only override the globe
 * icon for the site's dark navy theme (body.lw-page), matching the library's
 * documented dark-mode pattern of swapping in the light-colored globe.
 */
body.lw-page .iti {
	--iti-path-globe-1x: url( '../vendor/intl-tel-input/img/globe.webp' );
	--iti-path-globe-2x: url( '../vendor/intl-tel-input/img/globe@2x.webp' );
}

/* --------------------------------------------------------------------------
   2. Wrapper sizing — match this theme's text inputs
   -------------------------------------------------------------------------- */

.iti {
	display: block;
	width: 100%;
}

.iti input.iti__tel-input {
	width: 100%;
	padding: 10px 14px;
	border: 1px solid var(--lw-input-border);
	border-radius: var(--lw-radius-sm);
	background: var(--lw-white);
	color: var(--lw-text-dark);
	font-family: inherit;
	font-size: inherit;
	line-height: inherit;
	transition: border-color var(--lw-transition, 0.25s ease);
}

.iti input.iti__tel-input:focus {
	outline: none;
	border-color: var(--lw-gold);
}

/* --------------------------------------------------------------------------
   3. Palette — map iti tokens onto theme tokens (no hardcoded colors)
   -------------------------------------------------------------------------- */

/*
 * Site default is dark navy, so the dropdown/search/list are dark by
 * default here. Ahmed 2026-07-09: dropdown rendered white-on-white/washed
 * out against the dark navy UI because these tokens pointed at --lw-white
 * unconditionally.
 *
 * `--lw-navy-dark`, `--lw-white` and the `--lw-white-NN` opacity family are
 * NOT literal colors here — on `.mphb-gs-owner-portal` (which carries this
 * `.iti`) they are redefined by owner-portal.css's own
 * `[data-theme="light"]` block (surface `--lw-navy-dark` -> cream,
 * foreground `--lw-white*` -> dark navy), so reusing them makes this
 * dropdown flip automatically with the portal's light/dark toggle — no
 * separate light override block needed. `--lw-card-border` /
 * `--lw-card-bg-hover` / `--lw-input-border` / `--lw-text-muted` are NOT
 * redefined by that toggle, so they are intentionally avoided here.
 */
.iti {
	--iti-border-color: var(--lw-white-15);
	--iti-dropdown-bg: var(--lw-navy-dark);
	--iti-hover-color: var(--lw-white-10);
	--iti-dialcode-color: var(--lw-white-60);
	--iti-search-icon-color: var(--lw-white-60);
	--iti-arrow-color: var(--lw-white-80);
}

.iti__country.iti__highlight {
	color: var(--lw-white);
	background-color: var(--lw-white-10);
}

.iti__country-list {
	background: var(--lw-navy-dark);
	color: var(--lw-white);
}

.iti__country:hover {
	background-color: var(--lw-white-10);
}

.iti__search-input {
	background: var(--lw-navy-dark);
	color: var(--lw-white);
	border-color: var(--lw-white-15);
}

.iti__search-input::placeholder {
	color: var(--lw-white-60);
}

/* --------------------------------------------------------------------------
   4. Error message
   -------------------------------------------------------------------------- */

.evd-phone-error {
	margin-top: 6px;
	padding: 8px 12px;
	border-radius: var(--lw-radius-sm);
	background: var(--lw-error-soft);
	color: var(--lw-error);
	font-size: 13px;
	line-height: 1.4;
}

.evd-phone-error[hidden] {
	display: none;
}

/* --------------------------------------------------------------------------
   5. RTL (Arabic) — country dropdown + separate dial code
   -------------------------------------------------------------------------- */

/*
 * The library detects RTL itself via `.closest('[dir=rtl]')` (language_attributes()
 * emits dir="rtl" on <html> for is_rtl() locales) and swaps its own internal
 * padding/flag-container placement accordingly, so most layout logic needs no
 * override here. We only need to align the pieces this theme controls: overall
 * text direction inside the wrapper and the error message's reading direction.
 */
[dir="rtl"] .iti {
	direction: rtl;
}

[dir="rtl"] .iti__tel-input {
	direction: ltr;
	text-align: right;
}

[dir="rtl"] .evd-phone-error {
	text-align: right;
}
