/* Anagrafica unica: pagine Clienti e gruppi (elenco, scheda cliente, scheda gruppo) e dati aggiuntivi. Usa solo i token di app.css (temi chiaro e scuro). */

/* Gli elementi con display esplicito ignorerebbero l'attributo hidden. */
.reg [hidden], .reg-dialog [hidden] { display: none !important; }

.reg { min-width: 0; }
.reg .page-header h1 { overflow-wrap: anywhere; }
.reg .page-header h1 .badge { vertical-align: middle; font-size: 12px; }
.reg .card { min-width: 0; }
.reg-tab { min-width: 0; }

/* ---- Percorso e schede ---- */
.reg-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.reg-crumbs [aria-current="page"] { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.reg-tabs { flex-wrap: nowrap; }

/* ---- Intestazione di una scheda a blocchi ---- */
.reg-cards { display: flex; flex-direction: column; gap: 0; }
.reg-card-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 12px; }
.reg-card-head h2 { margin: 0; }
.reg-card-head > div:first-child { min-width: 0; flex: 1 1 260px; }
.reg-hint { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.reg-kv { grid-template-columns: minmax(8em, max-content) minmax(0, 1fr); gap: 8px 18px; margin: 0; }
.reg-kv dd { min-width: 0; }
.reg-form-actions { margin-top: 14px; }

/* ---- Elenchi ---- */
.reg-filters { margin-bottom: 12px; align-items: center; }
.reg-filters input[type="search"] { flex: 1 1 280px; min-width: 0; }
.reg-filters select { flex: 0 1 200px; max-width: 100%; }
.reg-summary { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.reg-results { min-width: 0; }
.reg-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-top: 12px; font-size: 13px; }
.reg-pager .actions { align-items: center; }
tr.reg-archived td { color: var(--muted); }
.reg-desc { min-width: 160px; color: var(--muted); }

.reg-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.reg-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.reg-key { color: var(--faint); font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.reg-codes { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.reg-code { display: inline-flex; align-items: center; gap: 5px; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); }
.reg-code code { font-size: 12px; }
.reg-code.provisional { background: var(--warn-soft); color: var(--warn); }
.reg-code-tag { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.reg-stack { display: flex; flex-direction: column; gap: 2px; }
.reg-actions-col { width: 1%; white-space: nowrap; }
.reg-row-actions { display: flex; flex-wrap: nowrap; justify-content: flex-end; gap: 6px; }

/* ---- Moduli ---- */
.reg-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px; align-items: start; }
.reg-fields .wide { grid-column: 1 / -1; }
.reg-fields .field input:not([type="checkbox"]), .reg-fields .field select, .reg-fields .field textarea { width: 100%; }
.reg-fields input[readonly], .reg-fields textarea[readonly] { background: var(--surface-2); }
.reg-check { display: flex; flex-direction: column; gap: 2px; align-self: center; }
.reg-dialog { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.reg-stack-gap { display: flex; flex-direction: column; gap: 12px; }
.reg-head-pick { margin-top: 12px; max-width: 420px; }

/* Campi con ricerca dentro un dialogo: la tendina spinge il contenuto invece di essere tagliata dal dialogo. */
.reg-dialog .reg-picker .combo-list, .reg-dialog .combobox .combo-list { position: static; width: auto; max-width: none; max-height: 220px; margin-top: 4px; box-shadow: none; }
.reg-codefield { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.reg-codefield-label { font-size: 12.5px; font-weight: 550; color: var(--muted); }
.reg-manual { display: flex; flex-direction: column; gap: 4px; }
.reg-manual .form-row { align-items: center; }
.reg-manual input { flex: 1 1 160px; }
.reg-chosen { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 28px; }
.reg-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.reg-chip code { color: inherit; }
.reg-chip-x { padding: 0 6px; border: none; border-radius: 999px; background: none; color: inherit; font-size: 16px; line-height: 1.3; }
.reg-chip-x:hover:not(:disabled) { background: var(--surface); color: var(--danger); }

/* ---- Conferma dell'impatto sui contratti ---- */
.reg-impact { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.reg-impact h3 { margin: 0 0 6px; }
.reg-impact ul { margin: 0; padding-left: 18px; }
.reg-impact li + li { margin-top: 6px; }
.reg-impact-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.reg-impact-group.danger h3 { color: var(--danger); }
.reg-impact-reasons { margin-top: 4px; color: var(--muted); font-size: 12.5px; }

/* ---- Utilizzi ---- */
.reg-usage + .reg-usage { margin-top: 16px; }
.reg-usage h3 { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.reg-usage-list { margin: 0; padding: 0; list-style: none; }
.reg-usage-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.reg-usage-list li:last-child { border-bottom: none; }

/* ---- Dati aggiuntivi: referenti, contatti, indirizzi, note ---- */
.reg-extras { display: flex; flex-direction: column; }
.reg-notes { display: flex; flex-direction: column; gap: 10px; }
.reg-note { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.reg-note.pinned { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); background: var(--warn-soft); }
.reg-note-body { margin: 0 0 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.reg-note-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }

@media (max-width: 760px) {
  .reg-row-actions { flex-wrap: wrap; }
  .reg-filters input[type="search"], .reg-filters select { flex-basis: 100%; }
  .reg-pager { flex-direction: column; align-items: flex-start; }
  .reg-kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .reg-kv dd { margin-bottom: 8px; }
}
