/* ============================================================
   EURO PLATE VALIDATOR – BASE STYLES
   ============================================================ */

/* --- Wrapper principale --- */
.plate-epv-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  /* assicura che eventuali overlay non vengano tagliati */
  overflow: visible;
}

/* --- Contenitore interno (flag + input + dropdown) --- */
.plate-epv {
  position: relative; /* 👈 dropdown assoluto ancorato qui */
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid #ccc;
  border-radius: 8px;
  padding: 10px 14px;
  transition:
    border-color 0.25s ease,
    box-shadow 0.25s ease;
  background-color: #fff;
}

/* --- Input targa --- */
.plate-input {
  flex: 1 1 auto;
  min-width: 0; /* 👈 importante in flex per evitare overflow */
  border: none;
  outline: none;
  font-size: 1rem;
  background: transparent;
  letter-spacing: 0.5px;
}

/* --- Bottone bandiera --- */
.flag-btn {
  display: flex;
  position: relative;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0;
}

/* --- Flag + label --- */
.epv__flag-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 20px;
  overflow: hidden;
  border-radius: 3px;
  background-color: #eee;
}

.epv__flag {
  width: 100%;
  height: 100%;
  zoom: 1.75;
}
/* Flag "Auto" = EU (SVG embedded, stessa size delle altre) */
.epv__auto-eu,
.epv__eu {
  width: 20px;
  height: 15px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  /* EU flag (blu + 12 stelle gialle semplificate) */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 3 2'><rect width='3' height='2' fill='%23005BBB'/><g fill='%23FFD500' transform='translate(1.5,1)'><g id='s'><circle r='.06' transform='rotate(0) translate(0.7,0)'/></g><use href='%23s' transform='rotate(30)'/><use href='%23s' transform='rotate(60)'/><use href='%23s' transform='rotate(90)'/><use href='%23s' transform='rotate(120)'/><use href='%23s' transform='rotate(150)'/><use href='%23s' transform='rotate(180)'/><use href='%23s' transform='rotate(210)'/><use href='%23s' transform='rotate(240)'/><use href='%23s' transform='rotate(270)'/><use href='%23s' transform='rotate(300)'/><use href='%23s' transform='rotate(330)'/></g></svg>") !important;
}
/* --- Dropdown elenco nazioni --- */

.dropdown {
  position: absolute;
  z-index: 9999;
  top: calc(100% + 6px); /* 👈 esci sotto al box */
  left: 0; /* 👈 allinea al bordo sinistro del container */
  min-width: max(280px, 100%); /* 👈 almeno 280px, ma non più stretto del box */
  max-height: 320px;
  right: auto;
  overflow: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  display: none;
}

.dropdown.open {
  display: block;
}

.country-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.country-item:hover {
  background-color: #f6f6f6;
}

/* --- Stato validazione testo --- */
.status {
  margin-top: 6px;
  font-size: 0.9rem;
  color: #555;
}

.status.ok {
  color: #198754;
}

.status.err {
  color: #dc3545;
}

/* ============================================================
   INTERAZIONI E STATI
   ============================================================ */

/* --- Focus visivo (neutro) --- */
.plate-epv:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

/* --- Stato valido (verde) --- */
.valid .plate-epv {
  border-color: #198754;
  box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.25);
}
.plate-input.valid {
  color: #16a34a;
}
/* --- Stato non valido (rosso) --- */

.plate-input.invalid {
  color: #dc2626;
}
.invalid .plate-epv {
  border-color: #dc3545;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25);
}

/* --- Transizione dolce per cambi di stato --- */
.plate-epv {
  transition:
    border-color 0.25s ease,
    box-shadow 0.25s ease;
}

/* ============================================================
   ACCESSIBILITÀ E RESPONSIVE
   ============================================================ */

.plate-epv button:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .plate-epv {
    flex-direction: column;
    align-items: stretch;
  }
  .flag-btn {
    justify-content: center;
  }
}


/* ============================================================
   VALIDATION UI _ @since 1.0.13 variant-4
   ============================================================ */

/* ---- Base ---- */
.plate-epv .epv__input-wrap {
  position: relative;
}

/* Variabili utili (tweak a piacere) */
.plate-epv {
  --epv-padL: 0.625rem; /* padding base lato sinistro  */
  --epv-padR: 0.625rem; /* padding base lato destro    */
  --epv-gap: 0.375rem; /* spazio icona↔testo          */
  --epv-icon: 14px; /* lato dell’icona semplice    */
  --epv-pill: 18px; /* diametro della pill         */
  --epv-textch: 12.5ch; /* spazio tipico per testo     */
}

/* Host inline */
.status-inline-host {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: var(--epv-padR);
  display: inline-flex;
  align-items: center;
  gap: var(--epv-gap);
  font-size: 0.75rem;
  line-height: 1;
  color: #64748b;
  pointer-events: none;
  white-space: nowrap;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 1;
}
.status-inline-host[data-pos="left"] {
  left: var(--epv-padL);
  right: auto;
}

/* Testo on/off */
.status-inline-host[data-text="false"] .s-text {
  display: none;
}

/* Slot icona */
.status-inline-host .s-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Icon mode (✓/!) */
.status-inline-host[data-icon="icon"] .s-icon {
  width: var(--epv-icon);
  height: var(--epv-icon);
  flex: 0 0 var(--epv-icon);
  font-weight: 700;
  line-height: 1;
}

/* Pill mode (tondo riempito con OK/ERR) */

.status-inline-host[data-icon="pill"] .s-icon {
  width: var(--epv-pill);
  height: var(--epv-pill);
  flex: 0 0 var(--epv-pill);
  border-radius: 999px;

  font-size: 10px;
  font-weight: 700;
  line-height: var(--epv-pill);
}
.status-inline-host[data-icon="none"] .s-icon {
  display: none;
}
/* Stato colore */
.status-inline-host[data-state="ok"] {
  color: #16a34a;
}
.status-inline-host[data-state="err"] {
  color: #dc2626;
}
.status-inline-host[data-state="ok"][data-icon="pill"] .ok {
  background-color: #16a34a;
  color: #fff;
}
.status-inline-host[data-state="err"][data-icon="pill"] .err {
  background-color: #dc2626;
  color: #fff;
  font-weight: bold;
}
/* to check */
.epv__input-wrap {
  min-width: 60%;
  display: flex;
  flex: 1;
}
/* to check */
.plate-input {
  width: inherit;
}
/* ---------------------------
      RISERVA SPAZIO NELL'INPUT
      (evita che il testo finisca sotto l’overlay)
      Richiede :has() — tutti i browser moderni ok.
      --------------------------- */

/* ---------- RIGHT side ---------- */
/* ICON (no text) */
.epv__input-wrap:has(.status-inline-host[data-state][data-pos="right"][data-icon="icon"][data-text="false"]) .plate-input {
  padding-right: calc(var(--epv-padR) + var(--epv-icon) + var(--epv-gap));
}
/* ICON + text */
.epv__input-wrap:has(.status-inline-host[data-state][data-pos="right"][data-icon="icon"][data-text="true"]) .plate-input {
  padding-right: calc(var(--epv-padR) + var(--epv-icon) + var(--epv-gap) + var(--epv-textch));
}

/* PILL (no text) */
.epv__input-wrap:has(.status-inline-host[data-state][data-pos="right"][data-icon="pill"][data-text="false"]) .plate-input {
  padding-right: calc(var(--epv-padR) + var(--epv-pill) + var(--epv-gap));
}
/* PILL + text */
.epv__input-wrap:has(.status-inline-host[data-state][data-pos="right"][data-icon="pill"][data-text="true"]) .plate-input {
  padding-right: calc(var(--epv-padR) + var(--epv-pill) + var(--epv-gap) + var(--epv-textch));
}

/* NONE + text (solo testo) */
.epv__input-wrap:has(.status-inline-host[data-state][data-pos="right"][data-icon="none"][data-text="true"]) .plate-input {
  padding-right: calc(var(--epv-padR) + var(--epv-textch));
}
/* NONE + no text → nessun padding extra (nessuna regola) */

/* ---------- LEFT side (mirror) ---------- */
/* ICON (no text) */
.epv__input-wrap:has(.status-inline-host[data-state][data-pos="left"][data-icon="icon"][data-text="false"]) .plate-input {
  padding-left: calc(var(--epv-padL) + var(--epv-icon) + var(--epv-gap));
}
/* ICON + text */
.epv__input-wrap:has(.status-inline-host[data-state][data-pos="left"][data-icon="icon"][data-text="true"]) .plate-input {
  padding-left: calc(var(--epv-padL) + var(--epv-icon) + var(--epv-gap) + var(--epv-textch));
}

/* PILL (no text) */
.epv__input-wrap:has(.status-inline-host[data-state][data-pos="left"][data-icon="pill"][data-text="false"]) .plate-input {
  padding-left: calc(var(--epv-padL) + var(--epv-pill) + var(--epv-gap));
}
/* PILL + text */
.epv__input-wrap:has(.status-inline-host[data-state][data-pos="left"][data-icon="pill"][data-text="true"]) .plate-input {
  padding-left: calc(var(--epv-padL) + var(--epv-pill) + var(--epv-gap) + var(--epv-textch));
}

/* NONE + text (solo testo) */
.epv__input-wrap:has(.status-inline-host[data-state][data-pos="left"][data-icon="none"][data-text="true"]) .plate-input {
  padding-left: calc(var(--epv-padL) + var(--epv-textch));
}
/* NONE + no text → nessun padding extra (nessuna regola) */

/* Retro-compat block */
.status {
  margin-top: 0.375rem;
  font-size: 0.875rem;
}
.status.ok {
  color: #16a34a;
}
.status.err {
  color: #dc2626;
}
