/* exoCortex — componenti APP (densità portali operativi). Sprint 1 (2026-11-01).
   Estratto da components.css per avere UNA sola fonte editoriale condivisa col sito
   ufficiale. NON ancora caricato da nessuna pagina: il wiring (e la definizione dei
   token app qui sotto) avviene nello Sprint 3.
   Ogni valore viene dai token: nessun colore/misura scritto a mano.

   ⚠️ Token APP richiesti da questo foglio, DA DEFINIRE nello Sprint 3 (non esistono
   ancora in theme-vars.css): --nav-bg --nav-ink --nav-active-bg --nav-ink-active
   --surface-raised --table-row-height --row-hover --row-selected --overlay
   --modal-sm --modal-md --modal-lg. (--sidebar-width --topbar-height --control-height-sm
   sono già definiti in theme-vars.css dallo Sprint 1.) */

/* =====================================================================
   PORTALI OPERATIVI — stessa identità, densità più alta (desktop-first)
   ===================================================================== */
.xc-app {
  display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh; background: var(--surface-alt);
  font-size: 14px; line-height: 20px;
}
@media (max-width: 959px) { .xc-app { grid-template-columns: minmax(0, 1fr); } .xc-sidebar { display: none; } }

/* Barra laterale */
.xc-sidebar { background: var(--nav-bg); color: var(--nav-ink); display: flex; flex-direction: column; gap: var(--space-5); padding: var(--space-4) var(--space-3); }
.xc-sidebar__brand { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-2); min-height: 40px; }
.xc-sidebar__brand img { height: 28px; width: auto; }
.xc-nav { display: flex; flex-direction: column; gap: 2px; }
.xc-nav__section { padding: var(--space-3) var(--space-3) var(--space-1); font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; color: var(--nav-ink); opacity: 0.8; }
.xc-nav__item {
  display: flex; align-items: center; gap: var(--space-3); min-height: 40px; padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md); color: var(--nav-ink); text-decoration: none; font-weight: 500;
}
.xc-nav__item svg { width: 20px; height: 20px; flex: none; }
.xc-nav__item:hover { background: var(--nav-active-bg); color: var(--nav-ink-active); }
.xc-nav__item[aria-current="page"] { background: var(--nav-active-bg); color: var(--nav-ink-active); }
.xc-nav__item[aria-current="page"]::after { content: ""; width: 6px; height: 6px; margin-inline-start: auto; border-radius: var(--radius-pill); background: var(--human); }
.xc-nav__count { margin-inline-start: auto; font-size: 12px; line-height: 16px; font-weight: 600; padding: 2px var(--space-2); border-radius: var(--radius-pill); background: var(--nav-active-bg); color: var(--nav-ink-active); }
.xc-sidebar :focus-visible { outline-color: var(--nav-ink-active); }

/* Barra superiore */
.xc-main { display: flex; flex-direction: column; min-width: 0; }
.xc-topbar {
  display: flex; align-items: center; gap: var(--space-4); min-height: var(--topbar-height);
  padding-inline: var(--space-5); background: var(--surface-raised); border-bottom: 1px solid var(--border);
}
.xc-search { position: relative; flex: 1 1 auto; max-width: 480px; }
.xc-search svg { position: absolute; inset-inline-start: var(--space-3); top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--ink-subtle); }
.xc-search .xc-input { padding-inline-start: 40px; }
.xc-iconbtn {
  display: inline-grid; place-content: center; width: var(--control-height-sm); height: var(--control-height-sm);
  border-radius: var(--radius-md); border: 0; background: none; color: var(--ink-muted); cursor: pointer; position: relative;
}
.xc-iconbtn:hover { background: var(--surface-alt); color: var(--ink); }
.xc-iconbtn svg { width: 20px; height: 20px; }
.xc-iconbtn__dot { position: absolute; top: 7px; inset-inline-end: 7px; width: 8px; height: 8px; border-radius: var(--radius-pill); background: var(--human); border: 2px solid var(--surface-raised); }
.xc-avatar {
  display: inline-grid; place-content: center; width: 32px; height: 32px; flex: none; border-radius: var(--radius-pill);
  background: var(--brand-tint); color: var(--brand); font-size: 12px; font-weight: 600;
}

/* Densità: controlli compatti dentro l'app (o in qualsiasi contenitore .xc-compact, es. modali) */
.xc-app .xc-input, .xc-app .xc-select, .xc-compact .xc-input, .xc-compact .xc-select { min-height: var(--control-height-sm); padding: 6px var(--space-3); font-size: 14px; line-height: 20px; }
.xc-app .xc-select, .xc-compact .xc-select { padding-inline-end: 36px; background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%; }
.xc-app .xc-btn, .xc-compact .xc-btn { min-height: var(--control-height-sm); padding: 6px var(--space-4); font-size: 14px; }
.xc-app .xc-label, .xc-compact .xc-label { font-size: 13px; line-height: 18px; }
.xc-app .xc-help, .xc-app .xc-error-msg, .xc-compact .xc-help, .xc-compact .xc-error-msg { font-size: 13px; line-height: 18px; }

/* Pagina */
.xc-page { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-5); }
@media (min-width: 1200px) { .xc-page { padding: var(--space-6); } }
.xc-page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-4); }
.xc-page-header h1 { font-family: var(--font-display); font-size: 22px; line-height: 28px; font-weight: 600; }
.xc-page-header p { color: var(--ink-muted); margin-top: var(--space-1); }
.xc-page-header__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.xc-breadcrumb { display: flex; gap: var(--space-2); font-size: 13px; line-height: 18px; color: var(--ink-subtle); margin-bottom: var(--space-1); }
.xc-breadcrumb a { color: var(--ink-muted); text-decoration: none; }
.xc-breadcrumb a:hover { color: var(--brand); text-decoration: underline; }

/* Indicatori */
.xc-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
@media (max-width: 1100px) { .xc-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.xc-kpi { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5); display: flex; flex-direction: column; gap: var(--space-1); }
.xc-kpi__label { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-muted); }
.xc-kpi__value { font-family: var(--font-display); font-size: 28px; line-height: 36px; font-weight: 600; color: var(--ink); }
.xc-kpi__delta { font-size: 13px; line-height: 18px; color: var(--ink-subtle); }
.xc-kpi__delta--good { color: var(--success); }
.xc-kpi__delta--bad { color: var(--danger); }

/* Schede */
.xc-tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); overflow-x: auto; }
.xc-tab {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: 40px; padding: var(--space-2) var(--space-3);
  border: 0; background: none; font: inherit; font-weight: 500; color: var(--ink-muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.xc-tab:hover { color: var(--ink); }
.xc-tab[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.xc-tab__count { font-size: 12px; line-height: 16px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--surface-sunken); color: var(--ink-muted); }
.xc-tab[aria-selected="true"] .xc-tab__count { background: var(--brand-tint); color: var(--brand); }

/* Barra filtri */
.xc-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.xc-toolbar__spacer { flex: 1 1 auto; }
.xc-chip {
  display: inline-flex; align-items: center; gap: var(--space-1); min-height: 32px; padding: 4px var(--space-3);
  border-radius: var(--radius-pill); border: 1px solid var(--border-control); background: var(--surface-raised);
  font: inherit; font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer;
}
.xc-chip[aria-pressed="true"] { background: var(--brand-tint); border-color: var(--brand); color: var(--brand); }
.xc-chip svg { width: 14px; height: 14px; }
.xc-bulkbar { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-4); background: var(--brand-tint); color: var(--ink); font-weight: 500; }

/* Tabella */
.xc-table-card { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.xc-table-wrap { overflow-x: auto; }
.xc-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; }
.xc-table th {
  text-align: start; padding: var(--space-2) var(--space-4); height: 40px; background: var(--surface-alt);
  font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; color: var(--ink-muted);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.xc-table td { padding: var(--space-3) var(--space-4); height: var(--table-row-height); border-bottom: 1px solid var(--border); vertical-align: middle; }
.xc-table tbody tr:hover { background: var(--row-hover); }
.xc-table tbody tr[aria-selected="true"] { background: var(--row-selected); }
.xc-table tbody tr:last-child td { border-bottom: 0; }
.xc-table__check { width: 44px; padding-inline-end: 0; }
.xc-table__id { font-family: var(--font-mono); font-size: 13px; color: var(--ink-muted); white-space: nowrap; }
.xc-table__title { font-weight: 500; color: var(--ink); text-decoration: none; }
.xc-table__title:hover { color: var(--brand); text-decoration: underline; }
.xc-table__sub { display: block; font-size: 13px; line-height: 18px; color: var(--ink-subtle); }
.xc-table__num { text-align: end; font-variant-numeric: tabular-nums; }
.xc-table th[aria-sort] button { all: unset; cursor: pointer; display: inline-flex; gap: var(--space-1); align-items: center; }
.xc-table th[aria-sort] button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.xc-table .xc-choice input { margin: 0; }
.xc-table-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); color: var(--ink-muted); font-size: 13px; }
.xc-pagination { display: flex; gap: var(--space-1); }

/* Stato e priorità: sempre punto/icona + testo */
.xc-status { display: inline-flex; align-items: center; gap: 6px; padding: 2px var(--space-2); border-radius: var(--radius-pill); font-size: 13px; line-height: 18px; font-weight: 500; white-space: nowrap; }
.xc-status::before { content: ""; width: 8px; height: 8px; border-radius: var(--radius-pill); background: currentColor; }
.xc-status--new { background: var(--brand-tint); color: var(--brand); }
.xc-status--progress { background: var(--warning-tint); color: var(--warning); }
.xc-status--waiting { background: var(--surface-sunken); color: var(--ink-muted); }
.xc-status--resolved { background: var(--success-tint); color: var(--success); }
.xc-status--breach { background: var(--danger-tint); color: var(--danger); }
.xc-priority { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; line-height: 18px; font-weight: 600; white-space: nowrap; }
.xc-priority::before { content: ""; width: 10px; height: 10px; border-radius: 2px; background: currentColor; }
.xc-priority--1 { color: var(--danger); }
.xc-priority--2 { color: var(--warning); }
.xc-priority--3 { color: var(--brand); }
.xc-priority--4 { color: var(--ink-subtle); }
.xc-sla { font-variant-numeric: tabular-nums; white-space: nowrap; }
.xc-sla--risk { color: var(--danger); font-weight: 600; }

/* Suggerimento IA: blu = IA, sempre spiegabile e mai applicato da solo */
.xc-ai {
  display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4);
  background: var(--brand-tint); border-radius: var(--radius-md); color: var(--ink);
}
.xc-ai__mark { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--brand); }
.xc-ai__title { display: block; font-size: 13px; line-height: 18px; font-weight: 600; color: var(--brand); }
.xc-ai__body { font-size: 14px; line-height: 20px; }
.xc-ai__why { display: block; margin-top: var(--space-1); font-size: 13px; line-height: 18px; color: var(--ink-muted); }

/* =====================================================================
   MODALI
   ===================================================================== */
.xc-modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: var(--space-5);
  background: var(--overlay);
}
.xc-modal {
  width: 100%; max-width: var(--modal-md); max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  background: var(--surface-raised); color: var(--ink); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  font-size: 14px; line-height: 20px;
}
dialog.xc-modal { padding: 0; border: 0; }
dialog.xc-modal::backdrop { background: var(--overlay); }
.xc-modal--sm { max-width: var(--modal-sm); }
.xc-modal--lg { max-width: var(--modal-lg); }
.xc-modal__header { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-5) var(--space-5) var(--space-3); }
.xc-modal__title { font-family: var(--font-display); font-size: 20px; line-height: 28px; font-weight: 600; margin: 0; }
.xc-modal__subtitle { display: block; margin-top: 2px; font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.xc-modal__close { margin-inline-start: auto; margin-top: -4px; margin-inline-end: -8px; }
.xc-modal__body { padding: var(--space-2) var(--space-5) var(--space-5); overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-4); }
.xc-modal__footer {
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2);
  padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border); background: var(--surface-alt);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.xc-modal__footer-note { margin-inline-end: auto; align-self: center; font-size: 13px; color: var(--ink-subtle); }
.xc-modal__icon { width: 40px; height: 40px; flex: none; display: grid; place-content: center; border-radius: var(--radius-pill); }
.xc-modal__icon svg { width: 20px; height: 20px; }
.xc-modal__icon--danger { background: var(--danger-tint); color: var(--danger); }
.xc-modal__icon--brand { background: var(--brand-tint); color: var(--brand); }
.xc-btn--danger { background: var(--danger); color: var(--on-brand); }
.xc-btn--danger:hover { filter: brightness(0.92); }
@media (max-width: 639px) {
  .xc-modal-backdrop { place-items: end stretch; padding: 0; }
  .xc-modal { max-width: none; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92vh; }
  .xc-modal__footer { border-radius: 0; }
  .xc-modal__footer .xc-btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: no-preference) {
  .xc-modal { animation: xc-modal-in var(--duration-base) ease-out; }
}
@keyframes xc-modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
