/* ─────────────────────────────────────────────────────────────────────────
   Agent edit — "Identità" section.
   Dark-theme reconstruction of the agent edit form (tab Generale > Identità),
   re-thought with form best practices: live avatar, inline validation,
   description counter, richer "tipo agente" picker. Reuses Veriax tokens.
   All classes prefixed `ae-` / `idn-` to avoid global collisions.
   ───────────────────────────────────────────────────────────────────────── */

.ae-page {
  max-width: 1480px; padding: 24px 36px 60px;
  /* Il reticolato "tech" di sfondo ora vive su .main (styles.css), così è
     uniforme su tutte le pagine — qui non va più ridichiarato (evita doppioni). */
  /* Colonna flessibile a piena altezza dello scroll-container (.main): così il
     footer (.ae-formfoot, margin-top:auto) resta ANCORATO in basso anche con
     contenuto corto, e sticky lo tiene visibile in scroll. Stesso meccanismo di
     .main-inner/.proto-hint — template unico per tutte le pagine edit. */
  display: flex; flex-direction: column;
}
/* min-height:100% riempie lo scroll-container → footer in fondo. Escluso .chat-page,
   che ha un suo modello di scroll interno (min-height:0 + .chat-scroll flex:1). */
.ae-page:not(.chat-page) { min-height: 100%; }

/* ── Edit header ── */
.ae-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; margin-bottom: 18px;
}
.ae-head-l { display: flex; align-items: center; gap: 14px; min-width: 0; }
.ae-head-thumb {
  width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 17px; letter-spacing: -0.02em;
  overflow: hidden;
}
.ae-head-thumb img { width: 100%; height: 100%; object-fit: cover; }
/* Logo a tutta altezza: con la riga meta (creato/modificato) il blocco testo
   cresce → il thumb si allunga per riempire l'altezza dell'header. Larghezza
   fissa (uguale al thumb editabile) e icona quadrata centrata, niente deformazioni. */
.ae-head-l > .ae-head-thumb:not(.editable) {
  align-self: stretch; height: auto; min-height: 56px;
  border-radius: 16px; /* width = height impostata via JS (quadrato a tutta altezza) */
}
.ae-head-l > .ae-head-thumb:not(.editable) > svg { width: 40px; height: 40px; }

/* Editable variant (Generale + Scheduled): bigger, fills the header height,
   click / drag-drop to upload. Base .ae-head-thumb (other agent tabs) stays small. */
.ae-head-thumb.editable {
  width: 88px; height: 88px;
  border-radius: 16px;
  position: relative; cursor: pointer; font-size: 26px;
  transition: box-shadow .15s ease, transform .05s ease;
}
/* Anche il thumb editabile riempie l'altezza dell'header (titolo + sotto + meta
   + stato): larghezza fissa 88, altezza a tutta l'altezza del blocco testo. */
.ae-head-l > .ae-head-thumb.editable {
  align-self: stretch; height: auto; min-height: 88px;
}
.ae-head-thumb.editable:hover { box-shadow: 0 0 0 2px var(--accent-ring); }
.ae-head-thumb.editable:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent); }
.ae-head-thumb.editable.drag { box-shadow: 0 0 0 2px var(--accent); }
.ae-head-thumb.editable:active { transform: scale(.97); }
.ae-thumb-overlay {
  position: absolute; inset: 0; border-radius: inherit;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .45); color: #fff;
  opacity: 0; transition: opacity .15s ease; pointer-events: none;
}
.ae-head-thumb.editable:hover .ae-thumb-overlay,
.ae-head-thumb.editable:focus-visible .ae-thumb-overlay,
.ae-head-thumb.editable.drag .ae-thumb-overlay { opacity: 1; }
.ae-thumb-clear {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; z-index: 2;
  border-radius: 50%; border: 1px solid var(--border); background: var(--bg-elev);
  color: var(--text-muted); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.ae-thumb-clear:hover { color: var(--text-strong); border-color: var(--border-strong); }
.ae-head-title { margin: 0; font-size: 21px; font-weight: 500; color: var(--text-strong); letter-spacing: -0.01em; }
.ae-head-sub { margin: 2px 0 0; font-size: 13px; color: var(--text-muted); }
/* Riga meta header: creato/modificato da chi e quando (sotto il sub, sopra lo status). */
.ae-head-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 12px; margin: 8px 0 9px; font-size: 12px; color: var(--text-muted); }
.ae-head-meta .ahm-i { display: inline-flex; align-items: center; gap: 5px; }
.ae-head-meta .ahm-p { display: inline-flex; align-items: center; gap: 5px; color: var(--text); font-weight: 500; }
.ae-head-meta .ahm-ava { width: 17px; height: 17px; border-radius: 5px; display: grid; place-items: center; color: #fff; font-size: 9px; font-weight: 700; flex-shrink: 0; }
.ae-head-meta .ahm-d { color: var(--text); }
.ae-head-meta .ahm-sep { width: 1px; height: 12px; background: var(--border); flex-shrink: 0; }
/* Azioni header (collapse + ⋮): allineate in BASSO a destra, come la riga tab
   di Generale (.ae-tabs-actions). Uniforme su tutte le pagine senza tab. */
.ae-head-actions { display: flex; gap: 8px; align-self: flex-end; }
/* Azioni (pulsanti sezioni + ⋮) sulla riga dei TAB, a destra, allineate
   verticalmente col testo dei tab (Generale, Prompt, …). */
/* Centrate verticalmente sul TESTO dei tab (i tab hanno padding-bottom 13 per
   l'underline → il testo sta in alto; compensiamo con padding-bottom qui). */
.ae-tabs-actions { margin-left: auto; align-self: flex-end; display: flex; align-items: center; gap: 8px; flex-shrink: 0; padding: 0 0 11px 12px; }

/* Riga tab: i tab scrollano orizzontalmente, le azioni (collapse + "...") stanno
   FUORI dallo scroll così il loro menu a tendina non viene tagliato da
   overflow-x:auto di .ae-tabs. */
.ae-tabsrow { display: flex; align-items: flex-end; }
.ae-tabsrow > .ae-tabs { flex: 1 1 auto; min-width: 0; }

/* ── Tabs ── */
.ae-tabs {
  display: flex; align-items: stretch; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 26px;
  overflow-x: auto;
  scrollbar-width: none;
}
.ae-tabs::-webkit-scrollbar { display: none; }
.ae-tab {
  position: relative;
  background: transparent; border: 0;
  padding: 0 14px 13px; margin-top: 2px;
  color: var(--text-muted); font-size: 14px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
}
.ae-tab:hover { color: var(--text); }
.ae-tab.on { color: var(--text-strong); }
.ae-tab.on::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px 2px 0 0;
}
/* Collapse / expand all sections — icon button at the right end of the tab row */
/* Pulsanti sezioni (apri/fisarmonica/comprimi) — STESSO stile del bottone ⋮
   (.head-icon-btn): bordati, 34×34, radius 9. Raggruppati in .ae-sections-ctl. */
.ae-sections-ctl { display: flex; align-items: center; gap: 4px; }
.ae-sections-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex-shrink: 0;
  background: transparent; border: 1px solid var(--border); border-radius: 9px;
  color: var(--text-muted); cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.ae-sections-toggle:hover { background: var(--bg-card); color: var(--text); border-color: var(--border-faint); }
.ae-sections-toggle svg { transition: transform .16s; }

/* ── Section anchor heading ── */
.ae-sec-anchor {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 16px;
}
.ae-sec-anchor h2 { margin: 0; font-size: 17px; font-weight: 600; color: var(--text-strong); }
.ae-sec-anchor .hash {
  color: var(--text-faint); font-size: 15px; opacity: 0; transition: opacity .12s;
  text-decoration: none;
}
.ae-sec-anchor:hover .hash { opacity: 1; }

/* Placeholder for non-Generale tabs (scope is Identità only) */
.ae-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center;
  border: 1px dashed var(--border); border-radius: var(--r-lg);
  padding: 64px 24px; color: var(--text-faint);
}
.ae-placeholder .ico { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--bg-card); border: 1px solid var(--border-faint); color: var(--text-muted); }
.ae-placeholder p { margin: 0; font-size: 13.5px; }

/* ─────────────────────────────  Identità card  ───────────────────────────── */
.idn-card {
  background: var(--bg-card);
  border: 1px solid var(--border-faint);
  border-radius: var(--r-xl);
  overflow: hidden;
}
.idn-card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-faint);
  background: linear-gradient(180deg, rgba(255,255,255,.015), transparent);
}
.idn-card-head h3 {
  display: flex; align-items: center; gap: 9px;
  margin: 0; font-size: 15px; font-weight: 600; color: var(--text-strong);
}
.idn-card-head h3 .badge-ico {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.idn-card-head .sub { margin: 4px 0 0 35px; font-size: 12.5px; color: var(--text-muted); }
.idn-req-legend { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-faint); white-space: nowrap; padding-top: 4px; }
.idn-req-legend .star { color: var(--accent); font-weight: 700; }
.ae-formfoot .idn-req-legend { padding-top: 0; padding-right: 14px; margin-right: 4px; border-right: 1px solid var(--border); }

.idn-card-body { padding: 22px; display: flex; flex-direction: column; gap: 22px; }
.idn-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 720px) { .idn-grid2 { grid-template-columns: 1fr; } }
.idn-grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 22px; }
@media (max-width: 900px) { .idn-grid3 { grid-template-columns: 1fr; } }

/* Number stepper (Priorità) — IDENTICO a MCP. Reso disponibile su tutte le
   pagine che caricano agent-edit.css (anche quelle senza agent-skill.css). */
.sk-stepper { display: inline-flex; align-items: center; gap: 6px; }
.sk-step-btn {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  background: var(--bg-app); border: 1px solid var(--border); border-radius: 9px;
  color: var(--text); font-size: 18px; line-height: 1; cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
}
.sk-step-btn:hover:not(:disabled) { border-color: var(--border-strong); background: var(--bg-card); }
.sk-step-btn:disabled { opacity: .4; cursor: default; }
.sk-step-val {
  flex: 1; height: 38px; min-width: 56px; padding: 0 12px;
  display: grid; place-items: center; text-align: center;
  background: var(--bg-content); border: 1px solid var(--border); border-radius: 9px;
  color: var(--text-strong); font-size: 15px; font-weight: 600; font-family: var(--mono);
  cursor: text; transition: border-color .12s, box-shadow .12s;
}
.sk-step-val:hover { border-color: var(--border-strong); }
.sk-step-val.edit, .sk-step-val:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.sk-step-val { width: 100%; }
input.sk-step-val::-webkit-outer-spin-button,
input.sk-step-val::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ── Field scaffolding ── */
.idn-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.idn-label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; }
.idn-label .star { color: var(--accent); font-weight: 700; }
.idn-label .opt { color: var(--text-faint); font-weight: 400; font-size: 12px; }
.idn-help { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-faint); line-height: 1.45; }
.idn-help svg { flex-shrink: 0; opacity: .8; }
.idn-err {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--danger); line-height: 1.45;
}
.idn-err svg { flex-shrink: 0; }

/* ── Text input ── */
.idn-inputwrap { position: relative; display: flex; align-items: center; }
.idn-input {
  width: 100%; height: 42px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 38px 0 13px;
  color: var(--text); font-size: 14px; outline: 0;
  transition: border-color .12s, box-shadow .12s;
}
.idn-input::placeholder { color: var(--text-faint); }
.idn-input:hover { border-color: var(--border-strong); }
.idn-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.idn-input.error { border-color: var(--danger); }
.idn-input.error:focus { box-shadow: 0 0 0 3px rgba(231,96,96,.16); }
.idn-input-clear {
  position: absolute; right: 8px;
  width: 24px; height: 24px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; color: var(--text-faint); cursor: pointer;
}
.idn-input-clear:hover { background: var(--bg-elev); color: var(--text); }
.idn-counter-inline { position: absolute; right: 12px; font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; pointer-events: none; }

/* ── Tipo agente — single-select cards (linguaggio dei connettori/Retriever) ── */
.ty-cardgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(232px, 1fr));
  gap: 10px;
}
.ty-card {
  position: relative;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 14px; text-align: left;
  background: var(--bg-app);
  border: 1px solid var(--border-faint);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.ty-card:hover { border-color: var(--border); background: var(--bg-card-hover); }
.ty-card.on { border-color: var(--accent); background: var(--bg-app); box-shadow: 0 0 0 1px var(--accent-ring); }
.ty-cardgrid.error .ty-card:not(.on) { border-color: rgba(231,96,96,.4); }
.ty-card-thumb {
  width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.ty-card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ty-card-name { font-size: 13.5px; font-weight: 500; color: var(--text-strong); }
.ty-card-desc { font-size: 12px; color: var(--text-faint); line-height: 1.45; }

/* ── Rich text editor ── */
.idn-rte {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-app);
  overflow: hidden;
  transition: border-color .12s, box-shadow .12s;
}
.idn-rte.focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.idn-rte.error { border-color: var(--danger); }
.idn-rte-toolbar {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-faint);
  background: var(--bg-card);
}
.idn-tb-btn {
  width: 30px; height: 30px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; color: var(--text-muted); cursor: pointer;
}
.idn-tb-btn:hover { background: var(--bg-elev); color: var(--text); }
.idn-tb-btn.on { background: var(--accent-soft); color: var(--accent); }
.idn-tb-btn:disabled { opacity: .35; cursor: default; }
.idn-tb-btn b { font-size: 14px; font-weight: 700; }
.idn-tb-btn i { font-size: 14px; font-weight: 600; }
.idn-tb-btn s { font-size: 14px; }
.idn-tb-sep { width: 1px; height: 18px; background: var(--border); margin: 0 5px; }
.idn-tb-sp { flex: 1; }

.idn-rte-area {
  min-height: 96px; max-height: 280px; overflow-y: auto;
  padding: 12px 14px;
  color: var(--text); font-size: 14px; line-height: 1.6; outline: 0;
}
.idn-rte-area:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
}
.idn-rte-area p { margin: 0 0 8px; }
.idn-rte-area p:last-child { margin-bottom: 0; }
.idn-rte-area ul, .idn-rte-area ol { margin: 0 0 8px; padding-left: 22px; }
.idn-rte-area h3 { font-size: 16px; margin: 2px 0 8px; color: var(--text-strong); }
.idn-rte-area a { color: var(--text-link); text-decoration: underline; }
.idn-rte-area code {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--bg-elev); border: 1px solid var(--border-faint);
  padding: 1px 5px; border-radius: 5px;
}
.idn-rte-area blockquote {
  margin: 0 0 8px; padding: 2px 0 2px 12px;
  border-left: 2px solid var(--border-strong); color: var(--text-muted);
}
.idn-rte-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 12px; border-top: 1px solid var(--border-faint);
  background: var(--bg-card);
}
.idn-rte-foot .hint { font-size: 11.5px; color: var(--text-faint); }
.idn-counter { font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.idn-counter.warn { color: var(--warn); }
.idn-counter.over { color: var(--danger); font-weight: 600; }

/* Simple textarea fallback (tweak) */
.idn-textarea {
  width: 100%; min-height: 110px; resize: vertical;
  background: var(--bg-app); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 13px;
  color: var(--text); font-size: 14px; line-height: 1.6; outline: 0;
  font-family: inherit;
}
.idn-textarea::placeholder { color: var(--text-faint); }
.idn-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.idn-textarea.error { border-color: var(--danger); }

/* ── Logo field ── */
.idn-logo-row { display: flex; align-items: stretch; gap: 16px; }
.idn-logo-preview {
  width: 132px; height: 132px; border-radius: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 34px; letter-spacing: -0.02em;
  position: relative; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.idn-logo-preview img { width: 100%; height: 100%; object-fit: cover; }
.idn-logo-badge {
  position: absolute; bottom: 5px; right: 5px;
  background: rgba(10,10,15,.7); backdrop-filter: blur(4px);
  border-radius: 6px; padding: 2px 6px; font-size: 9.5px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; color: #fff;
}
.idn-drop {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center;
  border: 1.5px dashed var(--border); border-radius: 16px;
  padding: 18px; cursor: pointer;
  background: var(--bg-app);
  transition: border-color .12s, background .12s;
}
.idn-drop:hover { border-color: var(--border-strong); background: var(--bg-card-hover); }
.idn-drop.drag { border-color: var(--accent); background: var(--accent-soft); }
.idn-drop .up-ico { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--bg-card); border: 1px solid var(--border-faint); color: var(--text-muted); }
.idn-drop .up-main { font-size: 13.5px; color: var(--text); }
.idn-drop .up-main .lnk { color: var(--text-link); font-weight: 500; }
.idn-drop .up-sub { font-size: 11.5px; color: var(--text-faint); }
.idn-logo-actions { display: flex; gap: 8px; margin-top: 10px; }

/* Footer action bar inside the form context — sticky to the bottom of the scroll area */
.ae-formfoot {
  position: sticky; bottom: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  /* top:auto → spinto in basso su contenuto corto (in .ae-page flex column);
     -36px/-60px → full-bleed sui padding di .ae-page; sticky → visibile in scroll. */
  margin: auto -36px -60px; padding: 11px 36px;
  background: var(--bg-app); border-top: 1px solid var(--border);
}
/* riga principale: hint + stato + azioni */
.ae-formfoot-main { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
/* riga sotto: "powered by THUX CODE" allineato a destra */
.ae-formfoot-powered { display: flex; align-items: center; justify-content: flex-end; padding-top: 6px; border-top: 1px solid var(--border-faint); }
.ae-powered.foot-row { border-left: 0; padding-left: 0; margin-left: 0; }
.ae-powered.foot-row .ae-powered-mark svg { height: 12px; }
/* Sticky top chrome (breadcrumb + edit header + tab bar) */
.ae-chrome {
  position: sticky; top: 0; z-index: 30;
  background: var(--bg-app);
  margin: -24px -36px 22px; padding: 18px 36px 0;
  border-bottom: 1px solid var(--border);
}
.ae-chrome .ae-tabs { margin-bottom: 0; border-bottom: 0; }

/* ── Header collassabile allo scroll ─────────────────────────────────────────
   Su scroll il chrome si compatta: via sottotitolo + riga meta (creato/modificato),
   breadcrumb e thumb ridotti → più spazio al contenuto (notebook/schermi bassi). */
.ae-chrome { transition: margin-bottom .18s ease, padding-top .18s ease; }
.ae-chrome .breadcrumbs { transition: max-height .18s ease, opacity .14s ease, margin .18s ease; overflow: hidden; }
.ae-chrome .ae-head { transition: margin-bottom .18s ease; }
.ae-chrome .ae-head-title { transition: font-size .18s ease; }
.ae-chrome .ae-head-thumb { transition: width .18s ease, height .18s ease, min-height .18s ease; }

.ae-chrome.shrink { margin-bottom: 10px; padding-top: 10px; }
.ae-chrome.shrink .breadcrumbs { max-height: 0; opacity: 0; margin-top: 0; margin-bottom: 0; }
.ae-chrome.shrink .ae-head { margin-bottom: 10px; }
.ae-chrome.shrink .ae-head-sub,
.ae-chrome.shrink .ae-head-meta { display: none; }
.ae-chrome.shrink .ae-head-title { font-size: 17px; }
.ae-chrome.shrink .ae-head-l > .ae-head-thumb:not(.editable) {
  align-self: center; width: 40px; height: 40px; min-height: 0; border-radius: 9px;
}
.ae-chrome.shrink .ae-head-l > .ae-head-thumb:not(.editable) > svg { width: 22px; height: 22px; }
.ae-chrome.shrink .ae-head-l > .ae-head-thumb.editable { align-self: center; width: 44px; height: 44px; min-height: 0; border-radius: 9px; }
.ae-dirty { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-muted); }
.ae-dirty .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px rgba(217,161,58,.18); }
.ae-dirty.saved .dot { background: var(--success); box-shadow: 0 0 0 3px rgba(47,179,122,.18); }
.ae-foot-actions { display: flex; gap: 10px; }

/* Firma "powered by THUX CODE" — a destra del footer, prima delle azioni */
.ae-powered {
  display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0;
  padding-left: 14px; margin-left: 2px; border-left: 1px solid var(--border);
  color: var(--text-faint); font-size: 11.5px; text-decoration: none;
  transition: color .14s;
}
.ae-powered:hover { color: var(--text-muted); }
.ae-powered .ae-powered-mark { display: inline-flex; }
.ae-powered .ae-powered-mark svg { height: 13px; width: auto; display: block; opacity: .9; }
.ae-powered:hover .ae-powered-mark svg { opacity: 1; }

/* Shared interaction hint — inline on the LEFT of the sticky footer */
.cap-foot-hint {
  flex: 1; min-width: 0;
  color: var(--text-faint); font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cap-foot-hint .kbd {
  font-family: var(--mono); background: var(--bg-elev);
  padding: 2px 6px; border-radius: 4px; color: var(--text-muted);
  font-size: 11px; border: 1px solid var(--border-faint);
}

/* ─────────────  Dropdown menus (.idn-menu) — shared across agent pages  ─────
   Used by the header overflow menu (HeaderTools) AND the Capacità MiniSelect.
   Previously had NO styling, so menus rendered as bare stacked buttons. */
.idn-menu {
  position: absolute; z-index: 240;
  min-width: 220px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 1px;
}
.idn-menu-sep { height: 1px; background: var(--border); margin: 5px 6px; opacity: .8; }
.idn-opt {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 7px 8px;
  background: transparent; border: 0; border-radius: 7px;
  font: inherit; color: var(--text); text-align: left;
  cursor: pointer; white-space: nowrap;
  transition: background .1s;
}
.idn-opt:hover { background: var(--bg-card-hover); }
.idn-opt.danger { color: var(--danger); }
.idn-opt .ty-ico {
  width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.idn-opt.danger .ty-ico { background: rgba(231,96,96,.14); color: var(--danger); }
.idn-opt .ty-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.idn-opt .ty-body b { font-weight: 500; font-size: 13.5px; color: inherit; }
.idn-opt .ty-sub { font-size: 11.5px; color: var(--text-faint); }
.idn-opt .ty-check { margin-left: auto; color: var(--accent); opacity: 0; flex-shrink: 0; }
.idn-opt.sel { color: var(--text-strong); }
.idn-opt.sel .ty-check { opacity: 1; }

/* ─────────────  Header tools: active switch + overflow «…» menu  ─────────────
   Shared cluster for every agent-detail header (replaces per-page copies). */
.head-tools { display: flex; align-items: center; gap: 12px; align-self: center; }
.head-menu-wrap { position: relative; }
.head-icon-btn {
  width: 34px; height: 34px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border);
  border-radius: 9px; color: var(--text-muted); cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.head-icon-btn:hover { background: var(--bg-card); color: var(--text); border-color: var(--border-faint); }
.head-icon-btn[aria-expanded="true"] { background: var(--bg-card); color: var(--text); border-color: var(--border-strong); }
/* The overflow actions menu — same vocabulary as the object context menu
   (.ctx-item / .ctx-divider in styles.css), anchored under the «…» button. */
.head-menu {
  position: absolute; z-index: 240;
  top: calc(100% + 6px); right: 0;
  min-width: 230px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px;
  box-shadow: var(--shadow-lg);
}

/* Submenu (e.g. Git ▸ Pull / Push) — flyout to the left of the header menu. */
.ctx-sub-wrap { position: relative; }
.ctx-item.has-sub .ctx-sub-caret { margin-left: auto; display: inline-flex; color: var(--text-faint); }
.ctx-item.has-sub.open { background: var(--bg-card-hover); }
.head-submenu {
  position: absolute; z-index: 241;
  top: -5px; right: calc(100% + 6px);
  min-width: 248px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px;
  box-shadow: var(--shadow-lg);
}
.head-submenu .ctx-item { align-items: flex-start; }
.head-submenu .ctx-item > svg { margin-top: 1px; }
.ctx-sub-text { display: flex; flex-direction: column; gap: 2px; white-space: normal; }
.ctx-sub-label { line-height: 1.2; }
.ctx-sub-hint { font-size: 11px; color: var(--text-faint); line-height: 1.3; }

/* ─────────────  Header status strip — visible state counterparts  ─────────────
   Shows the agent state the «…» menu can change (active, visibility, favorite,
   tags, hidden) so the user can always SEE the current state. */
.head-status { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.hs-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 25px; padding: 0 10px; border-radius: 8px;
  font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
  background: var(--bg-card); border: 1px solid var(--border-faint); color: var(--text-muted);
}
button.hs-pill { cursor: pointer; transition: border-color .12s, background .12s, color .12s; }
button.hs-pill:hover { border-color: var(--border-strong); color: var(--text); }
.hs-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.hs-state.on { color: var(--success); border-color: rgba(47,179,122,.32); background: rgba(47,179,122,.10); }
.hs-state.on .hs-dot { background: var(--success); box-shadow: 0 0 0 3px rgba(47,179,122,.18); }
.hs-state.off { color: var(--danger); border-color: rgba(231,96,96,.32); background: rgba(231,96,96,.10); }
.hs-state.off .hs-dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(231,96,96,.18); }
.hs-vis svg { opacity: .85; }
.hs-hidden { border-style: dashed; color: var(--text-faint); }
.hs-star {
  display: inline-flex; align-items: center; justify-content: center;
  width: 27px; height: 25px; border-radius: 7px; flex-shrink: 0;
  background: transparent; border: 1px solid transparent; cursor: pointer;
  color: var(--text-faint); transition: color .12s, background .12s;
}
.hs-star:hover { background: var(--bg-card); color: var(--text-muted); }
.hs-star.on { color: #e8b54a; }
.hs-sep { width: 1px; height: 16px; background: var(--border); margin: 0; }
.hs-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hs-tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 25px; padding: 0 9px; border-radius: 6px;
  font-size: 12px; font-family: var(--mono); font-weight: 500; white-space: nowrap;
  background: var(--bg-elev); border: 1px solid var(--border-faint); color: var(--text-muted);
  cursor: pointer; transition: border-color .12s, color .12s;
}
.hs-tag:hover { border-color: var(--border-strong); color: var(--text); }
.hs-tag.more { font-family: inherit; color: var(--text-faint); }
.hs-tag.add { color: var(--text-faint); border-style: dashed; font-family: inherit; }
.hs-tagcount {
  display: inline-flex; align-items: center; gap: 5px;
  height: 25px; padding: 0 9px; border-radius: 7px;
  font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
  background: var(--bg-card); border: 1px solid var(--border-faint); color: var(--text-muted);
}
.hs-tagcount.empty { border-style: dashed; color: var(--text-faint); font-weight: 500; }

/* ─────────────  Header modals: visibility picker + tag editor  ────────────── */
.vis-opts { display: flex; flex-direction: column; gap: 8px; padding: 6px 0 4px; }
.vis-opt {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border-radius: 10px; cursor: pointer; text-align: left;
  background: var(--bg-app); border: 1px solid var(--border); color: var(--text);
  transition: border-color .12s, background .12s;
}
.vis-opt:hover { border-color: var(--border-strong); }
.vis-opt.on { border-color: var(--accent); background: var(--accent-soft); }
.vis-opt-ico {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elev); border: 1px solid var(--border-faint); color: var(--text-muted);
}
.vis-opt.on .vis-opt-ico { background: var(--bg-card); color: var(--accent); border-color: var(--accent-ring); }
.vis-opt-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.vis-opt-body b { font-weight: 500; font-size: 14px; color: var(--text-strong); }
.vis-opt-body span { font-size: 12px; color: var(--text-faint); }
.vis-opt > svg { color: var(--accent); flex-shrink: 0; }

.tag-edit-box {
  display: flex; flex-wrap: wrap; align-items: flex-start; align-content: flex-start; gap: 7px;
  padding: 10px; min-height: 92px;
  background: var(--bg-app); border: 1px solid var(--border); border-radius: 10px;
}
.tag-edit-chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 5px 0 10px; border-radius: 7px;
  font-size: 12.5px; font-family: var(--mono);
  background: var(--bg-elev); border: 1px solid var(--border-faint); color: var(--text);
}
.tag-edit-chip button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 5px;
  background: transparent; border: 0; color: var(--text-faint); cursor: pointer;
}
.tag-edit-chip button:hover { background: var(--bg-card-hover); color: var(--text); }
.tag-edit-input {
  flex: 1; min-width: 120px; height: 26px;
  background: transparent; border: 0; outline: 0;
  color: var(--text); font-size: 13px; font-family: inherit;
}
.tag-edit-input::placeholder { color: var(--text-faint); }
.tag-edit-hint { margin: 10px 2px 2px; font-size: 12px; color: var(--text-faint); }
.tag-edit-hint .kbd {
  font-family: var(--mono); background: var(--bg-elev);
  padding: 1px 6px; border-radius: 4px; color: var(--text-muted);
  font-size: 11px; border: 1px solid var(--border-faint);
}

/* ─────────────  Toast (lightweight feedback on the agent pages)  ────────────── */
.ae-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 400; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 16px; font-size: 13px; color: var(--text);
  box-shadow: var(--shadow-lg); animation: slidein .15s ease;
}

/* ─────────────  Compact logo field (sits beside the Nome field)  ────────────── */
.idn-logo-compact { display: flex; align-items: stretch; gap: 12px; }
.idn-logo-preview.sm {
  width: 52px; height: 52px; border-radius: 11px; font-size: 15px; flex-shrink: 0;
}
.idn-logo-mini-drop {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 11px;
  padding: 0 13px; border-radius: 10px;
  background: var(--bg-app); border: 1px dashed var(--border); cursor: pointer;
  transition: border-color .12s, background .12s;
}
.idn-logo-mini-drop:hover, .idn-logo-mini-drop.drag { border-color: var(--accent); background: var(--accent-soft); }
.idn-logo-mini-drop .up-ico { color: var(--text-muted); display: flex; flex-shrink: 0; }
.idn-logo-mini-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.idn-logo-mini-txt b { font-size: 12.5px; font-weight: 500; color: var(--text); }
.idn-logo-mini-txt b .lnk { color: var(--text-link); }
.idn-logo-mini-txt span { font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── FolderNavBar — navigazione cartelle orizzontale (condivisa nei cataloghi) ──
   (duplica le regole di agent-model.css per le pagine che non lo caricano) */
/* Crumbs (cartelle selezionate) + child (da selezionare) = chip uniformi come i
   TAG. Cartella corrente = chip accent (come tag selezionato). Nessun separatore. */
.mdl-fnav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 2px; margin: 2px 0 16px; color: var(--text-muted); }
.mdl-fnav-crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mdl-fnav-sep { display: inline-flex; color: var(--text-faint); margin: 0 -1px; }
.mdl-fnav-crumb, .mdl-fnav-child {
  display: inline-flex; align-items: center; height: 30px; padding: 0 12px;
  background: var(--bg-card); border: 1px solid var(--border-faint); border-radius: 8px;
  color: var(--text-muted); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.mdl-fnav-crumb:hover, .mdl-fnav-child:hover { border-color: var(--border); color: var(--text); }
.mdl-fnav-crumb.cur { border-color: var(--accent); background: var(--accent-soft); color: var(--text-strong); }
.mdl-fnav-children { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ── Sola lettura (pagine /settings/<tool>/detail/<slug>) ──────────────────── */
.ae-ro-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 0 14px; padding: 9px 10px 9px 14px; border-radius: 10px;
  background: color-mix(in oklab, var(--warn) 14%, var(--bg-content));
  border: 1px solid color-mix(in oklab, var(--warn) 45%, var(--border));
  color: var(--warn); font-size: 13px; font-weight: 500;
}
/* In sola lettura: niente Salva/Annulla; tutta la form è non interattiva */
.ae-readonly .ae-foot-actions { display: none; }
/* Header: le pillole stato/visibilità/preferito/tag NON sono modificabili
   (restano visibili come stato). Il bottone azioni RESTA (le voci modificanti
   sono filtrate via readonly in HeaderTools). L'upload logo è disattivato.
   La navigazione (breadcrumb, tab, apri/chiudi sezioni) resta attiva. */
.ae-readonly .head-status { pointer-events: none; }
.ae-readonly .ae-head-thumb.editable { pointer-events: none; }
.ae-readonly .ae-head-thumb.editable .ae-thumb-edit,
.ae-readonly .ae-head-thumb .thumb-pick,
.ae-readonly .ae-head-thumb input[type="file"] { display: none; }
/* Bottoni "+ Aggiungi" delle sezioni catalogo: via in sola lettura */
.ae-readonly .idn-addbtn,
.ae-readonly .cap-add,
.ae-readonly .cx-tool-add,
.ae-readonly .conn-add,
.ae-readonly .cap-toolbar > .btn,
.ae-readonly .ty-cardgrid .pick-add { display: none !important; }
/* TOGLIE QUALSIASI BOTTONE CHE MODIFICA IL RECORD: ogni elemento interattivo
   DENTRO il corpo delle sezioni (cap-panel-body) è non cliccabile. La chrome
   (header, tab, comprimi sezioni col .cap-panel-head) resta navigabile. */
.ae-readonly .cap-panel-body button,
.ae-readonly .cap-panel-body input,
.ae-readonly .cap-panel-body textarea,
.ae-readonly .cap-panel-body select,
.ae-readonly .cap-panel-body a.btn,
.ae-readonly .cap-panel-body [role="button"],
.ae-readonly .cap-panel-body [contenteditable] { pointer-events: none !important; }
/* ECCEZIONE: i FILTRI di vista NON modificano il record → restano cliccabili
   (Tutti/Attivi · ricerca · segmentati · chip categorie). */
.ae-readonly .cap-panel-body .view-switch,
.ae-readonly .cap-panel-body .view-switch button,
.ae-readonly .cap-panel-body .seg,
.ae-readonly .cap-panel-body .seg button,
.ae-readonly .cap-panel-body .search,
.ae-readonly .cap-panel-body .search input,
.ae-readonly .cap-panel-body .search button,
.ae-readonly .cap-panel-body .conn-chips,
.ae-readonly .cap-panel-body .conn-chips button,
.ae-readonly .cap-panel-body .cap-chips,
.ae-readonly .cap-panel-body .cap-chips button { pointer-events: auto !important; }
.ae-readonly input, .ae-readonly textarea, .ae-readonly select, .ae-readonly .idn-input,
.ae-readonly .ty-card, .ae-readonly .conn-card, .ae-readonly .cap-card,
.ae-readonly .sk-stepper, .ae-readonly .seg, .ae-readonly .at-togglecard,
.ae-readonly .idn-inputwrap > button, .ae-readonly .pick-card,
.ae-readonly .cap-minicard, .ae-readonly .kb-pick, .ae-readonly .ty-card-thumb,
.ae-readonly .mdl-switch, .ae-readonly .gr-parentbtn, .ae-readonly .mini-select {
  pointer-events: none;
}
/* I CAMPI non sembrano più input: niente box (bordo/sfondo), solo testo */
.ae-readonly input:not([type="range"]),
.ae-readonly textarea,
.ae-readonly .idn-input {
  border-color: transparent !important;
  background: transparent !important;
  box-shadow: none !important;
  padding-left: 2px !important;
  opacity: 1;
  color: var(--text);
  resize: none;
}
/* Via gli affordance di editing (X pulisci, stepper +/-, toggle markdown…) */
.ae-readonly .idn-input-clear,
.ae-readonly .idn-inputwrap > button,
.ae-readonly .sk-step-btn,
.ae-readonly .pr-toolbar { display: none !important; }
.ae-readonly .sk-stepper { border-color: transparent; background: transparent; }
/* Le card non selezionate spariscono: in sola lettura si mostra solo la scelta */
.ae-readonly .ty-card:not(.on),
.ae-readonly .conn-card:not(.active):not(.selected),
.ae-readonly .cap-card:not(.active):not(.selected) { opacity: .4; }

/* ── Campi di RICERCA / filtro: NON modificano il record, quindi restano
   pienamente utilizzabili anche in sola lettura (detail). Copre `.search` e tutte
   le varianti `*-search` (cap-add-search, sch-cat-search, us-search, …), sia
   dentro i pannelli sia fuori. Le selettività battono sia
   `.ae-readonly .cap-panel-body input` sia `.ae-readonly input`. ── */
.ae-readonly .cap-panel-body [class*="search"] input,
.ae-readonly .cap-panel-body input[class*="search"],
.ae-readonly [class*="search"] input,
.ae-readonly input[class*="search"] {
  pointer-events: auto !important;
  -webkit-user-select: text;
  user-select: text;
}
