/* Écran : champ téléphone commun (assets/js/phone.js) — bouton « pays » dans le champ (drapeau et chevron, comme dans
   Contacts d'iOS) et feuille « Pays ou région » (recherche, suggestions, liste alphabétique). Chargée par les trois
   gabarits (gestion, site, plein écran). Réutilise les tokens et composants de app.css (dialog.sheet, .sheet__bar,
   .group, .item, .item__value, .item.is-checked, .section__title) ; aucun token redéfini ; clair et sombre ; cibles
   de 44 px au toucher. */

/* ---------- Champ : pays puis numéro ---------- */

.phone-field { display: flex; align-items: center; gap: 2px; min-width: 0; }
.phone-field > .input { min-width: 0; }

.phone-cc {
    position: relative; flex: none; display: inline-flex; align-items: center; gap: 4px;
    min-height: 34px; padding: 0 9px 0 2px; margin: 0; border: 0; border-radius: var(--radius-xs);
    background: none; color: var(--label-2); cursor: pointer; font: var(--t-body);
    -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
    transition: background-color var(--t-press) var(--ease-std);
}
/* Cible de 44 px (le bouton garde la hauteur de la rangée) */
.phone-cc::after { content: ""; position: absolute; inset: -5px -2px; }
/* Séparateur fin entre le pays et le numéro */
.phone-cc::before {
    content: ""; position: absolute; right: 0; top: 8px; bottom: 8px;
    border-right: var(--hairline) solid var(--separator); pointer-events: none;
}
.phone-cc:active { background: var(--pressed); }
.phone-cc:focus-visible { outline: 2px solid var(--brand); outline-offset: 0; }
.phone-cc[disabled] { cursor: default; opacity: .5; }
.phone-cc__flag {
    display: inline-block; min-width: 24px; text-align: center;
    font: 400 22px/1 "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", var(--font);
}
.phone-cc__chev { flex: none; color: var(--label-2); }

/* Rangée « libellé à gauche, valeur à droite » : drapeau collé au numéro, le tout aligné à droite (largeur du texte
   mesurée par phone.js) */
.frow > .phone-field { flex: 1 1 50%; max-width: 66%; margin-left: auto; }
.phone-field--fit { justify-content: flex-end; }
.frow .phone-field > .input { flex: 0 1 auto; max-width: 100%; }
.phone-field--fit > .input { padding-left: 6px; }
/* Libellé au-dessus (réservation, /pro) : pleine largeur, numéro aligné à gauche après le pays */
.frow--stack > .phone-field { max-width: none; width: 100%; margin-left: 0; }
/* Rangée en grille (réservation : libellé et erreur sur la 1re ligne) : le champ occupe la 2e ligne, comme .input */
.frow--stack > .phone-field { grid-column: 1 / -1; grid-row: 2; }
.frow--stack .phone-field > .input { flex: 1 1 auto; width: auto; text-align: left; padding-left: 8px; }
/* Champ rempli (.field : installation, connexion) : le fond gris entoure le pays et le numéro */
.field .phone-field { background: var(--fill); border-radius: var(--radius-sm); padding-left: 8px; }
.field .phone-field > .input { flex: 1 1 auto; background: transparent; padding-left: 8px; }
.field .phone-field > .input:focus { box-shadow: none; }
.field .phone-field:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 40%, transparent); }

/* Gestion sur ordinateur (rampe macOS : valeurs dans une boîte grise de largeur commune, texte à gauche) : le pays et
   le numéro partagent la boîte, comme les autres champs de la liste */
@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
    .admin .frow > .phone-field {
        flex: 1 1 50%; width: 240px; max-width: 55%; margin-left: auto; justify-content: flex-start; gap: 0;
        background-color: var(--fill); border-radius: var(--radius-xs);
    }
    .admin .client-form .frow > .phone-field { flex: 0 0 320px; width: 320px; max-width: 65%; }
    .admin .frow > .phone-field > .input { flex: 1 1 auto; width: auto !important; max-width: none; min-width: 0; background: transparent; padding-left: 8px; }
    .admin .frow > .phone-field > .input:focus { box-shadow: none; }
    .admin .frow > .phone-field:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 40%, transparent); }
    .admin .phone-cc { min-height: 26px; padding: 0 7px 0 6px; }
    .admin .phone-cc::before { top: 5px; bottom: 5px; }
    .admin .phone-cc__flag { font-size: 17px; }
}

/* ---------- Feuille « Pays ou région » ---------- */

/* Grande feuille de hauteur fixe (la liste ne saute pas pendant la recherche) */
dialog.phone-sheet { height: calc(100dvh - 44px - env(safe-area-inset-top)); }
.phone-sheet__head { position: sticky; top: 0; z-index: 3; background: inherit; padding-bottom: 10px; }
.phone-sheet__head .sheet__bar { position: static; background: inherit; }
.phone-sheet .sheet__title:focus { outline: none; }
.phone-sheet__search { padding: 0 var(--gutter); }
.phone-sheet__q {
    width: 100%; min-height: 36px; padding: 0 12px 0 34px; border: 0; border-radius: var(--radius-sm);
    font: var(--t-body); color: var(--label); appearance: none; -webkit-appearance: none;
    background: var(--fill) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E") no-repeat 10px center;
}
.phone-sheet__q::placeholder { color: var(--label-2); opacity: 1; }
.phone-sheet__q:focus { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 40%, transparent); }
.phone-sheet__q::-webkit-search-decoration { -webkit-appearance: none; }
.phone-sheet__list { padding: 6px var(--gutter) calc(24px + env(safe-area-inset-bottom)); }
.phone-sheet__sec { margin: 0 0 22px; }
.phone-sheet__sec .section__title { margin: 0 16px var(--header-gap); }
/* Séparateurs alignés sur le nom du pays (après le drapeau), comme les listes d'iOS */
.phone-sheet .group { --sep-inset: 56px; background: var(--elevated-surface); }
.phone-sheet__row { gap: 12px; }
.phone-sheet__row .item__title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phone-sheet__row .item__value { flex: none; max-width: none; }
.phone-sheet__row:focus-visible { outline-offset: -2px; }
.phone-sheet__flag {
    flex: none; width: 28px; text-align: center;
    font: 400 24px/1 "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", var(--font);
}
/* Appareil sans drapeaux en couleur (Windows) : code du pays dans une pastille */
.phone-cc__flag.phone-cc__flag--iso, .phone-sheet__flag.phone-sheet__flag--iso {
    font: 600 12px/16px var(--font); letter-spacing: .02em; padding: 2px 4px; border-radius: 5px;
    background: var(--fill-2); color: var(--label); white-space: nowrap;
}
.phone-sheet__flag.phone-sheet__flag--iso { width: 30px; padding: 3px 0; }
.phone-sheet__empty { margin: 24px 16px; text-align: center; font: var(--t-sub); color: var(--label-2); }
@media (hover: hover) and (pointer: fine) {
    .phone-cc:hover { background: var(--pressed); }
    .phone-sheet__row:hover { background: var(--pressed); }
}
@media (min-width: 700px) {
    dialog.phone-sheet { height: min(720px, 100dvh - 80px); }
}
/* Sombre : feuille surélevée (gris foncé), rangées un ton au-dessus, comme les feuilles d'iOS */
@media (prefers-color-scheme: dark) {
    dialog.phone-sheet { background: var(--elevated); }
}
