/* ─────────────────────────────────────────────────────────────
   Reusable international phone input widget
   Progressive enhancement for any <input data-phone>.
   Design-agnostic: the country selector sits beside the existing
   input and inherits neutral styling that fits both the public
   site and the dashboard.
   ───────────────────────────────────────────────────────────── */

.phone-field {
  display: flex;
  align-items: stretch;
  gap: 8px;
  position: relative;
  width: 100%;
}

/* The original <input> keeps its own look; just let it flex-fill. */
.phone-field > input.phone-num {
  flex: 1 1 auto;
  min-width: 0;
}

/* Country selector button */
.phone-cc {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  min-height: 42px;
  border: 1.5px solid rgba(0, 0, 0, 0.14);
  border-radius: 10px;
  background: #fff;
  color: inherit;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .18s, box-shadow .18s;
}
.phone-cc:hover { border-color: rgba(0, 0, 0, 0.28); }
.phone-cc:focus-visible { outline: none; border-color: var(--accent, #56BD81); }
.phone-field.is-open .phone-cc { border-color: var(--accent, #56BD81); }

.phone-cc .phone-flag { font-size: 18px; line-height: 1; }
.phone-cc .phone-dial { font-variant-numeric: tabular-nums; }
.phone-cc .phone-caret {
  font-size: 10px;
  opacity: .55;
  transition: transform .18s;
}
.phone-field.is-open .phone-cc .phone-caret { transform: rotate(180deg); }

/* Invalid state */
.phone-field.is-invalid > input.phone-num { border-color: #ef4444 !important; }
.phone-field.is-invalid .phone-cc { border-color: #ef4444; }
.phone-error {
  display: none;
  width: 100%;
  margin-top: 4px;
  font-size: 12px;
  color: #b91c1c;
}
.phone-field.is-invalid + .phone-error { display: block; }

/* Dropdown panel */
.phone-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 1200;
  width: 300px;
  max-width: min(300px, calc(100vw - 32px));
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  display: none;
}
.phone-field.is-open .phone-dropdown { display: block; }

.phone-search-wrap { padding: 10px; border-bottom: 1px solid rgba(0, 0, 0, 0.08); }
.phone-search {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid rgba(0, 0, 0, 0.14);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  color: #16161D;
  background: #fff;
}
.phone-search:focus { border-color: var(--accent, #56BD81); }

.phone-list {
  list-style: none;
  margin: 0;
  padding: 4px;
  max-height: 240px;
  overflow-y: auto;
}
.phone-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #16161D;
}
.phone-list li .pl-flag { font-size: 18px; line-height: 1; flex: 0 0 auto; }
.phone-list li .pl-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phone-list li .pl-dial { color: #64748b; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.phone-list li:hover,
.phone-list li.active { background: rgba(86, 189, 129, 0.14); }
.phone-list li[aria-selected="true"] { font-weight: 600; }
.phone-list .pl-empty { padding: 16px 12px; text-align: center; color: #94a3b8; font-size: 13px; }

@media (max-width: 480px) {
  .phone-dropdown { width: calc(100vw - 32px); }
}
