/* =============================================================================
   LIS Refertazione — em-forms.css
   Stile campi form ispirato a EndlessMed (rif. Team EM, 2026-06-24).
   ── SCOPED: tutte le regole sono sotto `.em-forms` → INERTE finché un contenitore
      non ha quella classe. NON tocca i form del resto del LIS.
   ── Il colore primario EREDITA dal LIS (`--color-primary`, teal) con fallback al
      blu EM (#2f80ed): così il focus resta coerente con il LIS. Per forzare il blu
      EM esatto, sostituire i fallback con #2f80ed fisso.
   ── NOTA: nella pagina Impostazioni i campi sono in `.settings-row` (stilati da
      settings.css con specificità (0,2,1)). Per usare queste classi lì serve o
      togliere `.settings-row` dai campi convertiti, o alzare la specificità.
   ============================================================================= */

.em-forms {
  /* Design token EM */
  --em-input-h: 34px;
  --em-input-py: 8px;
  --em-input-px: 12px;
  --em-input-fs: 0.88rem;
  --em-input-lh: 1.4;
  --em-input-bg: var(--color-surface, #fff);
  --em-input-color: var(--color-text, #1f2a44);
  --em-input-border: 1px solid var(--color-border, #bfc7d2);
  --em-input-radius: 8px;
  --em-focus-border: var(--color-primary, #2f80ed);
  --em-focus-ring: 0 0 0 3px rgba(47, 128, 237, 0.10);
  --em-placeholder: #6f7b92;
  --em-disabled-bg: var(--color-bg, #f8fbff);
  --em-disabled-opacity: 0.6;
  --em-label-fs: 0.76rem;
  --em-label-fw: 600;
  --em-label-color: var(--color-text-muted, #6f7b92);
  --em-label-ls: 0.04em;
  --em-label-mb: 5px;
}

/* ── Griglia campi (§1) ───────────────────────────────────────────────── */
.em-forms .field-row { margin-bottom: 12px; }
.em-forms .field-row:last-child { margin-bottom: 0; }
.em-forms .field-group { margin-bottom: 0; display: flex; flex-direction: column; }
.em-forms .field-group--chip { display: flex; align-items: flex-end; }
.em-forms .field-hint,
.em-forms .em-hint { font-size: 0.68rem; color: var(--color-text-muted, #6f7b92); margin-top: 4px; }

/* ── Label (§3) ───────────────────────────────────────────────────────── */
.em-forms .em-label,
.em-forms .field-group > label {
  display: block;
  font-size: var(--em-label-fs);
  font-weight: var(--em-label-fw);
  color: var(--em-label-color);
  letter-spacing: var(--em-label-ls);
  text-transform: uppercase;
  margin-bottom: var(--em-label-mb);
}
.em-forms .em-label-plain { text-transform: none; font-size: 0.92rem; font-weight: 700; letter-spacing: 0; }

/* ── Input / Select / Textarea (§2) ───────────────────────────────────── */
.em-forms .em-input,
.em-forms .em-select,
.em-forms .em-textarea {
  width: 100%;
  min-height: var(--em-input-h);
  padding: var(--em-input-py) var(--em-input-px);
  font-size: var(--em-input-fs);
  line-height: var(--em-input-lh);
  color: var(--em-input-color);
  background: var(--em-input-bg);
  border: var(--em-input-border);
  border-radius: var(--em-input-radius);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  box-sizing: border-box;
}
.em-forms .em-textarea { min-height: 80px; resize: vertical; }
.em-forms .em-input-sm { min-height: 28px; padding: 4px 8px; font-size: 0.82rem; }

/* Select nativo: chevron SVG custom (§7.1) */
.em-forms .em-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image: 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='%236f7b92' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.em-forms .em-select option { color: #1a1a2e; background: #fff; }

/* Stati */
.em-forms .em-input:focus,
.em-forms .em-select:focus,
.em-forms .em-textarea:focus {
  border-color: var(--em-focus-border);
  box-shadow: var(--em-focus-ring);
}
.em-forms .em-input::placeholder,
.em-forms .em-textarea::placeholder { color: var(--em-placeholder); }
.em-forms .em-input:disabled, .em-forms .em-input[readonly],
.em-forms .em-select:disabled,
.em-forms .em-textarea:disabled, .em-forms .em-textarea[readonly] {
  background: var(--em-disabled-bg);
  opacity: var(--em-disabled-opacity);
  cursor: not-allowed;
}
.em-forms .em-field-readonly {
  font-weight: 600;
  background: var(--em-disabled-bg);
}
.em-forms .text-upper { text-transform: uppercase; }

/* ── Checkbox / Radio (§3) ────────────────────────────────────────────── */
.em-forms input[type="checkbox"],
.em-forms input[type="radio"] { width: 16px; height: 16px; accent-color: var(--color-primary, #2f80ed); }
.em-forms .em-check,
.em-forms .checkbox-inline { display: inline-flex; align-items: center; gap: 6px; }
.em-forms .checkbox-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }

/* ── Chip toggle (§4) ─────────────────────────────────────────────────── */
.em-forms .stp-chip {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: var(--em-input-h);
  padding: 0 12px;
  border: var(--em-input-border);
  border-radius: var(--em-input-radius);
  background: var(--em-input-bg);
  color: var(--em-input-color);
  font-size: var(--em-input-fs);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.em-forms .stp-chip.is-active { background: #eef4ff; border-color: var(--em-focus-border); }
.em-forms .stp-check {
  width: 16px; height: 16px; border-radius: 4px;
  border: 1px solid #bfc7d2; display: inline-flex; align-items: center; justify-content: center;
  background: #fff;
}
.em-forms .stp-chip.is-active .stp-check { background: var(--em-focus-border); border-color: var(--em-focus-border); }

/* ── Avvisi / Note (§6) ───────────────────────────────────────────────── */
.em-forms .em-notice {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 0.82rem; line-height: 1.45;
  border-radius: 8px; padding: 8px 12px;
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
}
.em-forms .em-notice i, .em-forms .em-notice svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.em-forms .em-notice--danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.em-forms .em-notice--info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.em-forms .em-notice--inset-top { margin-top: -10px; }

/* ── Estensione legacy: campi .settings-row / .lis-input sotto .em-forms ───────
   Specificità superiore a settings.css (.settings-row input[type=text] = 0,2,1)
   così lo stile EM vince SENZA riscrivere il markup dei campi. Caricato dopo settings.css. */
.em-forms .settings-row input[type="text"],
.em-forms .settings-row input[type="url"],
.em-forms .settings-row input[type="email"],
.em-forms .settings-row input[type="password"],
.em-forms .settings-row input[type="number"],
.em-forms .settings-row select,
.em-forms .settings-row textarea,
.em-forms .lis-input {
  min-height: var(--em-input-h);
  height: auto;
  padding: var(--em-input-py) var(--em-input-px);
  font-size: var(--em-input-fs);
  line-height: var(--em-input-lh);
  color: var(--em-input-color);
  background: var(--em-input-bg);
  border: var(--em-input-border);
  border-radius: var(--em-input-radius);
  box-sizing: border-box;
}
.em-forms .settings-row textarea,
.em-forms textarea.lis-input { min-height: 80px; resize: vertical; }
.em-forms .settings-row select,
.em-forms select.lis-input {
  appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: 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='%236f7b92' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.em-forms .settings-row input:focus,
.em-forms .settings-row select:focus,
.em-forms .settings-row textarea:focus,
.em-forms .lis-input:focus {
  border-color: var(--em-focus-border);
  box-shadow: var(--em-focus-ring);
  outline: none;
}
.em-forms .settings-row input::placeholder,
.em-forms .settings-row textarea::placeholder,
.em-forms .lis-input::placeholder { color: var(--em-placeholder); }
/* Label dei campi (esclusi i toggle switch, che sono <label class="toggle-switch">) */
.em-forms .settings-row > label:not(.toggle-switch),
.em-forms .lis-label {
  display: block;
  font-size: var(--em-label-fs);
  font-weight: var(--em-label-fw);
  color: var(--em-label-color);
  letter-spacing: var(--em-label-ls);
  text-transform: uppercase;
  margin-bottom: var(--em-label-mb);
}
/* Titoli sezione: icona Lucide allineata al testo */
.em-forms h3 > i[data-lucide],
.em-forms h4 > i[data-lucide] { vertical-align: -2px; margin-right: 4px; }

/* Icona "info" nei titoli (sotto)sezione: l'hint descrittivo diventa un tooltip
   (Tippy) → recupera spazio verticale. Posizionata a sinistra, stile discreto. */
.em-forms .settings-info-ico {
  display: inline-flex;
  align-items: center;
  color: var(--color-text-muted, #6f7b92);
  cursor: help;
  flex-shrink: 0;
  transition: color .15s ease;
}
.em-forms .settings-info-ico > svg,
.em-forms .settings-info-ico > i { width: 15px; height: 15px; }
.em-forms .settings-info-ico:hover { color: var(--color-primary, #0f766e); }

/* Blocchi sezione (pagina PDF): background a contrasto + accento a sinistra per
   "tagliare" visivamente l'area di ogni (sotto)sezione. Theme-aware (light/dark)
   via --color-surface-hover. Scoped alla pagina PDF (pilota). */
.em-forms .settings-section {
  background: rgba(15, 118, 110, 0.05);            /* teal tenue, stesso hue dell'accento */
  border: 1px solid var(--color-border, #e2e8f0);
  border-left: 3px solid var(--color-primary, #0f766e);
  border-radius: 10px;
  overflow: hidden;                                /* clippa l'header agli angoli arrotondati */
  padding: 0 18px 16px;
  margin-bottom: 16px;
}
.em-forms .settings-section:last-child { margin-bottom: 0; }
/* Header sezione (h3): fascia full-bleed col COLORE DELL'ACCENTO, testo bianco */
.em-forms .settings-section > h3 {
  display: flex;
  align-items: center;
  background: var(--color-primary, #0f766e);
  color: #fff;
  margin: 0 -18px 14px;
  padding: 10px 16px;
}
.em-forms .settings-section > h3 .settings-info-ico { color: rgba(255,255,255,0.85); }
.em-forms .settings-section > h3 .settings-info-ico:hover { color: #fff; }
/* Sotto-titoli (h4) come riga flex */
.em-forms .settings-section h4 { display: flex; align-items: center; }
/* Icona info: spinta all'estrema destra del titolo */
.em-forms .settings-section .settings-info-ico { margin-left: auto; }
