/* Libreria elementi grafici Beevo (18.11)
   Riferimento obbligatorio per ogni pagina nuova: catalogo dal vivo su #/ui, guida in docs/libreria-grafica.md,
   valori in docs/design/beevo-tokens.json (usati anche dalle app native).
   Si carica dopo styles.css: completa gli elementi che mancavano, non cambia quelli esistenti. */

:root {
  --r-card: 22px; --r-modal: 20px; --r-field: 12px; --r-menu: 14px; --r-item: 9px; --r-badge: 10px;
  --h-control: 38px; --h-control-sm: 30px;
  --shadow-menu: 0 12px 32px rgba(17,19,24,.14), 0 2px 6px rgba(17,19,24,.06);
  --t-ok: #e7f6ee; --t-warn: #fff1e6; --t-bad: #fdecec; --t-info: #e8edff; --t-ai: #f1eafd;
}

/* ---------- caselle e scelte: sempre nel blu Beevo, mai il blu del sistema */
:where(input[type=checkbox], input[type=radio]) { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; vertical-align: -3px; cursor: pointer; }
:where(input[type=checkbox], input[type=radio]):disabled { cursor: not-allowed; }

/* ---------- interruttore: <label class="switch"><input type="checkbox"><i></i>Testo</label> */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px !important; height: 1px; padding: 0 !important; border: 0 !important; pointer-events: none; }
.field label.switch, .field label.chk { display: inline-flex; font-size: 13.5px; color: var(--text); margin: 0; font-weight: 400; }
.field .chk input { width: 16px; padding: 0; }
.switch > i { position: relative; width: 36px; height: 22px; flex: none; border-radius: 999px; background: #d9dce3; transition: background .18s ease; }
.switch > i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(17,19,24,.25); transition: transform .18s ease; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(14px); }
.switch input:focus-visible + i { box-shadow: 0 0 0 4px var(--field-ring, rgba(61,99,221,.16)); }
.switch input:disabled + i { opacity: .5; } .switch:has(input:disabled) { cursor: not-allowed; color: var(--muted); }

/* ---------- pulsanti: varianti che mancavano */
.btn:has(> svg.lu, > .lu-pre, > .has-lu) { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn .lu, .btn .lu-pre .lu { width: 15px; height: 15px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--soft); color: var(--text); }
.btn.danger.fill { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.icon { width: var(--h-control); height: var(--h-control); padding: 0; border-radius: 50%; }
.btn.icon.sm { width: var(--h-control-sm); height: var(--h-control-sm); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--field-ring, rgba(61,99,221,.16)); }

/* ---------- avvisi in pagina */
.alert { display: flex; gap: 10px; align-items: flex-start; border-radius: 14px; padding: 11px 14px; font-size: 13.5px; line-height: 1.45; background: var(--soft); color: var(--text); }
.alert .lu { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.alert.info { background: var(--t-info); color: #23409b; } .alert.ok { background: var(--t-ok); color: #14532d; }
.alert.warn { background: var(--t-warn); color: #8a3d00; } .alert.bad { background: var(--t-bad); color: #9b1c20; }
.alert.ai { background: var(--t-ai); color: #5b2a9e; }

/* ---------- tendina Beevo (si apre al posto della lista del sistema, vedi static/ui.js) e menu azioni */
.pu-pop { position: fixed; z-index: 2000; min-width: 180px; max-width: min(420px, calc(100vw - 16px)); background: #fff; border: 1px solid var(--line); border-radius: var(--r-menu); box-shadow: var(--shadow-menu); padding: 6px; display: flex; flex-direction: column; animation: pu-in .12s ease-out; font-size: 13.5px; color: var(--text); }
@keyframes pu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.pu-pop .pu-q { margin: 0 0 6px; padding: 7px 10px 7px 32px; border: 1px solid var(--field-line, var(--line)); border-radius: var(--r-item); font: inherit; font-size: 13px; width: 100%; outline: none; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c818c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 10px center / 14px 14px; }
.pu-pop .pu-q:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--field-ring, rgba(61,99,221,.16)); }
.pu-list { overflow-y: auto; max-height: 300px; overscroll-behavior: contain; }
.pu-it { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: var(--r-item); font: inherit; color: inherit; text-align: left; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pu-it > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pu-it .lu { width: 15px; height: 15px; flex: none; color: var(--muted); }
.pu-it.hi { background: var(--soft); }
.pu-it.sel { font-weight: 600; } .pu-it.sel .pu-ck, .pu-it.sel .pu-ck .lu { color: var(--accent); }
.pu-it .pu-ck { width: 15px; height: 15px; flex: none; visibility: hidden; } .pu-it.sel .pu-ck { visibility: visible; }
.pu-it:disabled { color: var(--faint); cursor: not-allowed; }
.pu-it.danger { color: var(--bad); } .pu-it.danger .lu { color: var(--bad); }
.pu-it .pu-kbd { margin-left: auto; color: var(--faint); font-size: 11.5px; }
.pu-grp { padding: 8px 10px 4px; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.pu-sep { height: 1px; background: var(--line-2); margin: 5px 4px; }
.pu-none { padding: 10px; color: var(--muted); font-size: 13px; }
select.pu-open { border-color: var(--accent) !important; box-shadow: 0 0 0 4px var(--field-ring, rgba(61,99,221,.16)); }

/* ---------- catalogo #/ui */
.uil { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; align-items: start; }
.uil-toc { position: sticky; top: 0; display: flex; flex-direction: column; gap: 2px; }
.uil-toc a { padding: 7px 10px; border-radius: 10px; color: #3d424c; font-weight: 500; font-size: 13px; }
.uil-toc a:hover { background: #fff; color: var(--text); }
.uil > div { min-width: 0; }
.uil-sec { margin-bottom: 16px; scroll-margin-top: 12px; }
.uil-sec > header small { font-weight: 400; color: var(--muted); font-size: 12.5px; margin-left: 4px; }
.uil-demo { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 16px; background: var(--soft); border-radius: 14px; }
.uil-demo.col { flex-direction: column; align-items: stretch; }
.uil-code { display: block; margin-top: 10px; padding: 9px 12px; background: #f8f9fb; border: 1px solid var(--line-2); border-radius: 10px; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: #3d424c; white-space: pre-wrap; word-break: break-word; }
.uil-rule { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.5; margin: 8px 0 0; }
.uil-rule .lu { width: 15px; height: 15px; flex: none; margin-top: 2px; }
.uil-rule.ok .lu { color: var(--ok); } .uil-rule.no .lu { color: var(--bad); }
.uil-sw { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.uil-sw div { border-radius: 12px; border: 1px solid var(--line); overflow: hidden; background: #fff; font-size: 12px; }
.uil-sw i { display: block; height: 46px; }
.uil-sw span { display: block; padding: 6px 9px; } .uil-sw code { color: var(--muted); font-size: 11px; }
.uil-ic { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.uil-ic div { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; background: #fff; border-radius: 10px; border: 1px solid var(--line-2); font-size: 10.5px; color: var(--muted); text-align: center; word-break: break-all; }
.uil-ic .lu { width: 20px; height: 20px; color: var(--text); }
.uil-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; width: 100%; }
.uil-form .field { margin: 0; }
@media (max-width: 900px) { .uil { grid-template-columns: minmax(0, 1fr); } .uil-toc { position: static; flex-direction: row; overflow-x: auto; } .uil-toc a { white-space: nowrap; } }
