/**
 * phone-input.css
 * Custom styles for intl-tel-input integration.
 * Included globally via layouts — do not duplicate in individual views.
 */

/* ── Input wrapper ────────────────────────────────────────────────────────── */
/* Target ONLY the wrapper around the <input>, NOT the body-level dropdown
   container that ITI appends to <body> (class="iti iti--container").
   :not(.iti--container) is the critical guard — without it our
   width:100%/position:relative overrides ITI's position:absolute on the
   container and the dropdown ends up in normal document flow off-screen.    */
.iti:not(.iti--container) {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    position: relative;
}

/* ── Body-level dropdown container ────────────────────────────────────────── */
/* ITI appends <div class="iti iti--container"> to <body> and positions it via
   inline top/left JS.  Force position:absolute so those coordinates work,
   and push z-index above every stacking context on the page.               */
.iti.iti--container {
    position: absolute !important;
    z-index: 99999 !important;
}

/* The generated <input> must stretch to fill the entire wrapper */
.iti__tel-input {
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

/* ── Flag / dial-code selector ────────────────────────────────────────────── */
/* Prevent the flag container from shrinking the remaining input space */
.iti__flag-container {
    z-index: 10;
    flex-shrink: 0;
}

/* Dial-code text never wraps or overflows its button */
.iti__selected-dial-code {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 3.5rem;
}

/* ── Dropdown ─────────────────────────────────────────────────────────────── */
/* dropdownContainer:document.body appends the list to <body>, so it must sit
   above all modals (z-index 999) and sticky headers.

   TWO rules are required:
   1) Default hidden state  (ITI adds .iti__hide when closed)
   2) Explicit visible state (override Tailwind's [hidden]{display:none})     */
.iti__country-list {
    z-index: 99999 !important;
    max-height: 220px !important;
    overflow-y: auto !important;
    /* Prevent the list from exceeding the viewport width on small screens */
    max-width: min(320px, 95vw) !important;
    box-sizing: border-box !important;
    border-radius: 0.75rem !important;
    border: 1px solid #e5e7eb !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15) !important;
    background-color: #fff !important;
}

/* When the dropdown is open ITI removes .iti__hide; force it visible so
   Tailwind's [hidden]{display:none} preflight cannot override this. */
.iti__country-list:not(.iti__hide) {
    display: block !important;
}

/* Individual country row — long country names truncate rather than wrap */
.iti__country {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Error state applied by phone-input.js on invalid submission */
.phone-input--error {
    border-color: #f87171 !important;
    background-color: #fef2f2 !important;
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.2) !important;
}

/* Error message paragraph — toggled visible/hidden by JS.
   When placed inside a phone input wrapper (overflow-hidden), the wrapper
   expands naturally to show the error below the input field. */
[data-phone-error] {
    display: none;
    font-size: 0.75rem;
    line-height: 1.4;
    color: #ef4444;
}

[data-phone-error].visible {
    display: block;
}
