/* ========== Phone country dropdown theme ==========
   Matches the custom Service dropdown (custom-select.js, .field__listbox / .field__option in
   src/scss/pages/home/_contact.scss), so both lists in the form look the same.
   Colors, radii, the shadow and the z-index use the custom properties emitted in
   src/scss/base/_layout.scss ($theme-light and $css-tokens), so a token change reaches this file too.
   Loaded after intlTelInput.min.css so these rules win without touching the library file.
*/

/* On :root because on touch devices the list opens in a popup appended to <body>, outside the field */
:root {
    --iti-border-color: var(--color-border);
    --iti-country-selector-bg: var(--color-surface);
    --iti-icon-color: var(--color-text-muted);
    --iti-hover-color: var(--color-aqua-light);
    --iti-strict-reject-flash-color: var(--color-teal-alpha);
    --iti-spacer-horizontal: 12px;
    --iti-arrow-padding: 8px;
}

/* The library wraps the input in an inline-block ".iti", which would size the field to its content */
.field .iti {
    display: block;
    width: 100%;
}

/* The popup list is attached to <body>: lift it above the fixed header and the floating button */
.iti--detached-country-selector {
    z-index: var(--z-modal);
}

/* Selected-country button: rounded to sit inside the input's left corners */
.iti__selected-country-primary {
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.iti__selected-country:focus-visible {
    outline: 2px solid var(--color-teal-text);
    outline-offset: -2px;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

/* Dropdown panel */
.iti__country-selector {
    overflow: hidden;
}

/* No margin: contact-form.js sets the 4px gap on whichever side the list opens */
.iti--inline-country-selector .iti__country-selector {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-medium);
}

.iti--fullscreen-popup .iti__country-selector {
    border-radius: var(--radius-lg);
}

.iti--inline-country-selector .iti__country-list {
    max-height: 240px;
}

.iti__country-list {
    box-sizing: border-box;
    padding: 4px 4px 8px;
    color: var(--color-text);
}

.iti__country-list .iti__country:last-child {
    margin-bottom: 8px;
}

/* Search box: leaves room for the globe icon; the wrapper underline marks focus */
.iti .iti__search-input {
    padding-top: 12px;
    padding-bottom: 12px;
    padding-left: calc(var(--iti-spacer-horizontal) + var(--iti-globe-icon-size) + var(--iti-spacer-horizontal));
    border: 0;
    border-radius: 0;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 1rem;
    box-shadow: none;
}

.iti .iti__search-input::placeholder {
    color: var(--color-text-muted);
    opacity: 1;
}

.iti .iti__search-input:focus-visible {
    outline: none;
}

.iti__search-input-wrapper:focus-within {
    box-shadow: inset 0 -2px 0 var(--color-teal-text);
}

/* Options: same highlight and selected look as .field__option */
.iti__country {
    border-radius: var(--radius-md);
    font-size: 1rem;
    line-height: 1.5;
}

.iti__country.iti__highlight {
    color: var(--color-navy);
}

.iti__country[aria-selected="true"] {
    font-weight: 500;
    color: var(--color-teal-text);
}

.iti__country[aria-selected="true"] .iti__country-check {
    color: var(--color-teal-text);
}

/* Long names wrap before the code, so "(+387)" never splits across two lines */
.iti__dial-code {
    margin-left: 6px;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.iti__no-results {
    padding: 12px;
    color: var(--color-text-muted);
}

/* High contrast mode drops backgrounds and shadows: outlines keep the focus and the highlighted option visible */
@media (forced-colors: active) {
    .iti__search-input-wrapper:focus-within {
        outline: 2px solid;
        outline-offset: -2px;
    }

    .iti__country.iti__highlight {
        outline: 2px solid;
        outline-offset: -2px;
    }
}
