/* Presidio IA · accesso, organizzazioni, primi passi, spiegazioni e persone
   Indice: accesso · caricamento · cornice (organizzazione, utente, salvataggio) · spiegazioni · primi passi · benvenuto · persone e dati */

/* ============ Accesso ============ */
body.is-auth .sidebar, body.is-auth .topbar, body.is-auth .tabbar { display: none; }
body.is-auth .app { grid-template-columns: minmax(0, 1fr); }
body.is-auth .main { padding: 0; }

.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.auth-aside {
  display: flex; flex-direction: column; gap: 40px;
  padding: 40px 48px;
  background: var(--accent); color: var(--accent-ink);
  position: relative; overflow: hidden;
}
.auth-aside::after {
  content: ""; position: absolute; right: -140px; bottom: -140px; width: 420px; height: 420px; border-radius: 50%;
  border: 56px solid color-mix(in srgb, var(--accent-ink) 7%, transparent); pointer-events: none;
}
.auth-aside .brand { color: inherit; padding: 0; }
.auth-aside .brand-sub { color: color-mix(in srgb, var(--accent-ink) 75%, transparent); }
.auth-aside .brand-mark rect { fill: var(--accent-ink); }
.auth-aside .brand-mark path { stroke: var(--accent); }
.auth-aside .brand-mark circle { fill: var(--accent); }
.auth-pitch { display: flex; flex-direction: column; gap: 18px; margin: auto 0; max-width: 520px; position: relative; z-index: 1; }
.auth-headline { font-size: 34px; line-height: 1.15; letter-spacing: -0.02em; }
.auth-sub { font-size: 17px; opacity: 0.88; }
.auth-points { list-style: none; display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }
.auth-points li { display: flex; gap: 14px; align-items: flex-start; }
.auth-points li > span:last-child { display: flex; flex-direction: column; gap: 2px; font-size: 15px; line-height: 1.45; }
.auth-points li > span:last-child > span { opacity: 0.85; }
.auth-point-icon {
  flex: none; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent-ink) 14%, transparent);
}
.auth-foot { font-size: 12px; line-height: 1.5; opacity: 0.7; position: relative; z-index: 1; }

.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--ground); }
.auth-card {
  width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 14px;
  padding: 32px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-md);
  animation: rise-in 0.25s ease-out;
}
.auth-title { font-size: 26px; letter-spacing: -0.015em; }
.auth-title:focus { outline: none; }
.auth-lead { color: var(--ink-2); }
.auth-form { display: flex; flex-direction: column; gap: 16px; margin-top: 4px; }
.auth-form .btn-primary { min-height: 46px; font-size: 16px; margin-top: 4px; }
.auth-after { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; margin-top: 4px; border-top: 1px solid var(--line); font-size: 15px; color: var(--ink-2); }
.auth-after .link, .auth-card button.link { background: none; border: 0; padding: 0; font-size: inherit; }
.auth-demo { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.auth-demo .ico { color: var(--accent); }
.auth-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); }
.auth-icon.is-warn { background: var(--warn-soft); color: var(--warn); }
.auth-error { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); background: var(--critical-soft); color: var(--critical); font-weight: 600; font-size: 14.5px; }
.auth-error .ico { margin-top: 1px; }

.field-error { color: var(--critical); font-size: 14px; font-weight: 600; }
.field-aside { align-self: flex-end; font-size: 14px; margin-top: 2px; }
button.field-aside { background: none; border: 0; padding: 0; }
.check-row { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; color: var(--ink-2); line-height: 1.45; cursor: pointer; }
.check-row input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.input.is-readonly, .input[readonly] { background: var(--surface-2); color: var(--muted); }

.pw-wrap { position: relative; }
.pw-wrap .input { width: 100%; padding-right: 48px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 36px; border: 0; background: none; color: var(--muted); border-radius: 8px; display: grid; place-items: center; }
.pw-toggle:hover { color: var(--ink); background: var(--surface-3); }
.pw-meter { display: flex; flex-direction: column; gap: 6px; }
.pw-track { height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.pw-bar { display: block; height: 100%; width: 0; background: var(--critical); transition: width 0.2s, background 0.2s; }
.pw-meter[data-level="1"] .pw-bar { background: var(--warn); }
.pw-meter[data-level="2"] .pw-bar, .pw-meter[data-level="3"] .pw-bar { background: var(--ok); }
.pw-label { font-size: 13px; color: var(--muted); }

.btn.is-loading { position: relative; color: transparent !important; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--accent-ink); border-right-color: transparent; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.invite-box { display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: var(--r-md); background: var(--accent-soft); }
.invite-org { font-weight: 700; font-size: 17px; }

@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { padding: 24px 20px 28px; gap: 20px; }
  .auth-pitch { margin: 0; gap: 10px; }
  .auth-headline { font-size: 24px; }
  .auth-sub, .auth-points, .auth-foot { display: none; }
  .auth-main { padding: 20px 16px 40px; align-items: flex-start; }
  .auth-card { padding: 22px 18px; box-shadow: none; }
}

/* ============ Caricamento ============ */
.boot { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
.boot .brand-mark { width: 48px; height: 48px; animation: fade-in 0.6s ease-out; }

/* ============ Cornice ============ */
.org-avatar, .user-avatar {
  flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; letter-spacing: 0.02em;
}
.user-avatar { border-radius: 50%; background: var(--surface-3); color: var(--ink-2); }
.user-avatar.is-pending { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line-strong); }

.org-switch {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 10px 8px 8px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface-2);
}
.org-switch:hover { border-color: var(--line-strong); background: var(--surface); }
.org-switch > .ico { color: var(--muted); }
.org-switch-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.org-switch-name { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-switch-role { font-size: 12.5px; color: var(--muted); }
.org-switch-sm { width: auto; min-width: 0; max-width: 46vw; padding: 6px 10px; gap: 6px; background: transparent; }
.org-switch-sm .org-switch-name { font-size: 14px; }

.org-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.org-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface);
}
.org-item:hover { border-color: var(--accent); }
.org-item.is-current { border-color: var(--accent); background: var(--accent-soft); }
.org-item > .ico { color: var(--accent); }
.org-item-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.org-item-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-item-role { font-size: 13px; color: var(--muted); }

.user-chip {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px; border-radius: var(--r-md); border: 1px solid transparent; background: none;
}
button.user-chip:hover { background: var(--surface-2); border-color: var(--line); }
.user-chip.is-demo { flex-direction: column; align-items: stretch; background: var(--accent-soft); }
.user-chip-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; font-size: 14px; }
.user-chip-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-text > span { font-size: 12.5px; color: var(--muted); }

.save-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.save-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.save-status[data-kind="pending"] .save-dot, .save-status[data-kind="saving"] .save-dot { background: var(--info); animation: pulse 1s ease-in-out infinite alternate; }
.save-status[data-kind="offline"] .save-dot { background: var(--warn); }
.save-status[data-kind="offline"] { color: var(--warn); }
.save-status[data-kind="error"] .save-dot { background: var(--critical); }
.save-status[data-kind="error"] { color: var(--critical); }
.save-status[data-kind="demo"] .save-dot { background: var(--faint); }
.save-status-sm { padding: 0 8px; align-self: center; }
@keyframes pulse { from { opacity: 0.35; } to { opacity: 1; } }

.offline-bar {
  position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: 250;
  display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px);
  padding: 10px 14px; border-radius: var(--r-md); background: var(--warn-soft); color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); box-shadow: var(--shadow-md); font-size: 14px; font-weight: 600;
}
.offline-bar .link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; }

.readonly-note { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: var(--r-md); background: var(--surface-2); color: var(--muted); font-size: 14px; font-weight: 600; }
.nav-badge.is-soft { background: var(--accent-soft); color: var(--accent); font-size: 11px; }

/* ============ Spiegazioni ============ */
.explainer { border-radius: var(--r-lg); background: color-mix(in srgb, var(--info-soft) 60%, var(--surface)); border: 1px solid color-mix(in srgb, var(--info) 18%, var(--line)); }
.explainer > summary {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; list-style: none;
  font-weight: 700; font-size: 15px; color: var(--ink);
}
.explainer > summary::-webkit-details-marker { display: none; }
.explainer > summary > .ico:last-child { margin-left: auto; color: var(--muted); transition: transform 0.15s; }
.explainer[open] > summary > .ico:last-child { transform: rotate(180deg); }
.explainer-icon { color: var(--info); display: grid; }
.explainer-body { display: flex; flex-direction: column; gap: 8px; padding: 0 16px 14px 44px; font-size: 15px; color: var(--ink-2); max-width: 80ch; animation: reveal 0.18s ease-out; }
.explainer-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 2px; }
@media (max-width: 560px) { .explainer-body { padding-left: 16px; } }

.concept-body { display: flex; flex-direction: column; gap: 10px; color: var(--ink-2); }
.concept-body strong { color: var(--ink); }

/* ============ Primi passi ============ */
.start-summary { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.start-summary-text { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 4px; }

.start-steps { list-style: none; display: flex; flex-direction: column; gap: 10px; counter-reset: none; }
.start-step {
  display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 14px;
  padding: 16px 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line);
}
.start-step.is-next { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm); }
.start-step.is-done { background: var(--surface-2); }
.start-step.is-done .start-title { color: var(--ink-2); }
.start-marker {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--line-strong); color: var(--muted); font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums;
}
.start-step.is-next .start-marker { border-color: var(--accent); color: var(--accent); }
.start-step.is-done .start-marker { border-color: var(--ok); background: var(--ok); color: #fff; }
.start-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding-top: 4px; }
.start-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.start-title { font-size: 17px; }
.start-meta { display: inline-flex; align-items: center; gap: 4px; }
.start-meta .muted { display: inline-flex; align-items: center; gap: 4px; }
.start-text { color: var(--ink-2); max-width: 72ch; }
.start-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.start-concept { border-top: 1px dashed var(--line); padding-top: 8px; }
.start-concept > summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14.5px; list-style: none; }
.start-concept > summary::-webkit-details-marker { display: none; }
.start-concept[open] > summary { margin-bottom: 10px; }
.start-concept .concept-body { font-size: 15px; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.section-lead { margin-top: -14px; }
.concept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.concept-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
  padding: 16px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.concept-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.concept-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 4px; }
.concept-term { font-weight: 700; font-size: 16px; }
.concept-what { font-size: 14px; color: var(--muted); line-height: 1.45; }
.concept-more { margin-top: auto; padding-top: 6px; display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 600; font-size: 14px; }

.start-daily h2 { margin-bottom: 12px; }
.daily-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.daily-list li { display: flex; gap: 12px; align-items: flex-start; color: var(--ink-2); }
.daily-list .ico { color: var(--accent); margin-top: 3px; }

.start-card { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: linear-gradient(0deg, var(--surface), var(--surface)) padding-box; }
.start-card-main { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 6px; }
.start-card-title { font-weight: 700; font-size: 18px; }
.start-card-main .bar { margin-top: 4px; max-width: 360px; }
.start-card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ============ Benvenuto nel percorso di configurazione ============ */
.welcome-steps { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.welcome-steps li { display: flex; gap: 14px; align-items: flex-start; }
.welcome-steps p { color: var(--ink-2); font-size: 15px; margin-top: 2px; }
.welcome-n { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; }

/* ============ Persone e dati ============ */
.member-list { list-style: none; display: flex; flex-direction: column; }
.member { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.member:first-child { border-top: 0; }
.member-text { min-width: 0; }
.member-name { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.member-text .muted { overflow: hidden; text-overflow: ellipsis; }
.member .select { min-width: 150px; min-height: 36px; padding-top: 5px; padding-bottom: 5px; }
.sub-h { font-size: 14px; font-weight: 600; color: var(--muted); margin-top: 8px; }
@media (max-width: 560px) {
  .member { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .member > :nth-child(3) { grid-column: 2; justify-self: start; }
  .member > :nth-child(4) { grid-column: 3; grid-row: 1; }
}

.roles-help > summary, .history > summary { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--accent); font-weight: 600; list-style: none; }
.roles-help > summary::-webkit-details-marker, .history > summary::-webkit-details-marker { display: none; }
.roles-help[open] > summary, .history[open] > summary { margin-bottom: 12px; }
.history-list { list-style: none; display: flex; flex-direction: column; }
.history-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.history-list li:first-child { border-top: 0; }
.history-when { font-weight: 600; font-variant-numeric: tabular-nums; }

.copy-field { display: flex; gap: 8px; }
.copy-field .input { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 13px; }

.settings-section { scroll-margin-top: 24px; }
.settings-section.is-danger { border-color: color-mix(in srgb, var(--critical) 30%, var(--line)); }
.settings-section.is-danger h2 { color: var(--critical); }
.danger-list { display: flex; flex-direction: column; }
.danger-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.danger-row:first-child { border-top: 0; padding-top: 0; }
.danger-title { font-weight: 700; }
@media (max-width: 560px) { .danger-row { flex-direction: column; align-items: flex-start; gap: 8px; } }

@media print {
  .explainer, .start-card, .offline-bar { display: none !important; }
}
