/* =============================================================================
 * style.css — Studio Condominio AI · Future Is Now
 * Tema chiaro per app (CLAUDE.md). Palette brand teal #3AA6B9.
 * ========================================================================== */

:root {
  --teal: #3AA6B9;
  --teal-dark: #2E8597;
  --teal-soft: #E6F4F7;
  --ink: #2C3E50;
  --ink-soft: #51606E;
  --bg: #F9FAFB;
  --surface: #FFFFFF;
  --border: #E3E8EC;
  --muted: #8A97A3;
  --danger: #D9534F;
  --danger-soft: #FBECEB;
  --success: #2EA66B;
  --warn: #E0A100;
  --warn-soft: #FCF4DC;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 3px rgba(44,62,80,.07);
  --shadow: 0 6px 22px rgba(44,62,80,.10);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --serif: Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; margin: 0 0 .5em; }

/* ----------------------------- Boot splash ----------------------------- */
.boot-splash {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1rem;
}
.boot-logo { font-weight: 800; color: var(--teal); font-size: 1.5rem; letter-spacing: -.5px; }
.boot-text { color: var(--muted); font-size: .9rem; }
.boot-spinner, .spinner, .boot-spinner {
  width: 30px; height: 30px; border: 3px solid var(--teal-soft);
  border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------ Buttons -------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: inherit; font-size: .92rem; font-weight: 600; cursor: pointer;
  padding: .6rem 1.1rem; border-radius: var(--radius); border: 1px solid transparent;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
  background: #EEF2F4; color: var(--ink);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--ink-soft); }
.btn-ghost:hover { background: #F2F5F7; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-outline { background: transparent; border-color: var(--teal); color: var(--teal-dark); }
.btn-block { width: 100%; }
.btn-sm { padding: .4rem .75rem; font-size: .82rem; }

/* ------------------------------ Fields --------------------------------- */
.field, textarea.field, select.field {
  width: 100%; font-family: inherit; font-size: .95rem; color: var(--ink);
  padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.field:focus, textarea.field:focus, select.field:focus {
  outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft);
}
textarea.field { resize: vertical; min-height: 90px; line-height: 1.5; }
label.lbl { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-soft); margin: 0 0 .35rem; }
.form-row { margin-bottom: 1rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.hint { font-size: .78rem; color: var(--muted); margin-top: .3rem; }

/* ------------------------- Auth / blocco ------------------------------- */
.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 1.5rem; background: linear-gradient(135deg, #F4F8F9, #E6F0F2);
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow); padding: 2.2rem 2rem; text-align: center;
}
.auth-brand { display: flex; flex-direction: column; gap: 2px; margin-bottom: 1.4rem; }
.auth-logo { font-weight: 800; color: var(--teal); font-size: 1.05rem; }
.auth-product { font-size: .8rem; color: var(--muted); }
.auth-card h1 { font-size: 1.35rem; }
.auth-sub { color: var(--ink-soft); font-size: .92rem; margin: 0 0 1.3rem; }
.auth-card .field { text-align: center; letter-spacing: 1px; margin-bottom: .5rem; }
.auth-msg { min-height: 1.1rem; color: var(--danger); font-size: .85rem; margin-bottom: .6rem; }
.auth-foot { font-size: .8rem; color: var(--muted); margin-top: 1.2rem; }
.auth-actions { display: flex; gap: .6rem; justify-content: center; margin: 1rem 0; }
.blocked-icon { font-size: 2.6rem; margin-bottom: .4rem; }

/* ----------------------------- Layout ---------------------------------- */
.app-layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.main-col { display: flex; flex-direction: column; min-width: 0; }

.sidebar {
  background: var(--ink); color: #cdd6df; display: flex; flex-direction: column;
  padding: 1.2rem .9rem; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { padding: .3rem .6rem 1.3rem; display: flex; flex-direction: column; gap: 2px; }
.sb-logo { font-weight: 800; color: #fff; font-size: 1.05rem; letter-spacing: -.3px; }
.sb-product { font-size: .76rem; color: var(--teal); }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem; border-radius: 8px;
  color: #cdd6df; font-size: .92rem; font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav-item.active { background: var(--teal); color: #fff; }
.nav-icon { width: 20px; text-align: center; }
.sidebar-foot { padding: .8rem .6rem 0; border-top: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: .6rem; }
.plan-badge {
  display: inline-block; align-self: flex-start; font-size: .72rem; font-weight: 700;
  background: rgba(58,166,185,.2); color: var(--teal); padding: .2rem .55rem; border-radius: 20px; text-transform: capitalize;
}
.sb-link { color: #9fb0bd; font-size: .82rem; }
.sb-link:hover { color: #fff; }
.sb-credit { display: flex; flex-direction: column; gap: 1px; margin-top: .6rem; font-size: .7rem; color: #7d8c98; }
.sb-credit .sb-link { font-size: .72rem; }
.auth-brand-foot { font-size: .72rem; color: var(--muted); margin-top: .9rem; }
.auth-brand-foot a { color: var(--teal-dark); font-weight: 600; }
.policy-links { display: flex; flex-wrap: wrap; gap: .55rem; justify-content: center; margin-top: .45rem; font-size: .7rem; }
.policy-links a { color: var(--teal-dark); cursor: pointer; }
.sidebar .policy-links { justify-content: flex-start; }
.sidebar .policy-links a { color: #7d8c98; }
.sidebar .policy-links a:hover { color: #fff; }

/* --------------------------- Privacy / banner -------------------------- */
.privacy-bar {
  display: flex; align-items: center; gap: .6rem; background: var(--teal-soft);
  color: #1f5e6b; padding: .55rem 1.5rem; font-size: .82rem; border-bottom: 1px solid #d3e9ee;
}
.pb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(46,166,107,.2); flex: none; }
.key-banner {
  display: flex; align-items: center; gap: .5rem; background: var(--warn-soft);
  color: #7a5d00; padding: .5rem 1.5rem; font-size: .85rem; border-bottom: 1px solid #f0e2b6;
}
.kb-link { font-weight: 700; }

/* ----------------------------- Content --------------------------------- */
.content { padding: 1.8rem 1.8rem 3rem; flex: 1; min-width: 0; }
.page-head { margin-bottom: 1.4rem; }
.page-head h1 { font-size: 1.5rem; margin: 0; }
.page-head .sub { color: var(--muted); font-size: .9rem; margin-top: .25rem; }
.loading, .empty { text-align: center; color: var(--muted); padding: 3rem 1rem; }
.empty-icon { font-size: 2.4rem; margin-bottom: .5rem; }
.empty h2 { font-size: 1.1rem; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-sm); padding: 1.3rem;
}
.card + .card { margin-top: 1.2rem; }
.card h3 { font-size: 1.02rem; margin-bottom: .9rem; }
.split { display: grid; grid-template-columns: 420px 1fr; gap: 1.4rem; align-items: start; }

/* ------------------------------ KPI ------------------------------------ */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.4rem; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow-sm);
}
.kpi .num { font-size: 1.7rem; font-weight: 800; color: var(--teal-dark); letter-spacing: -1px; }
.kpi .label { font-size: .8rem; color: var(--muted); margin-top: .2rem; }

/* ----------------------------- Tabelle --------------------------------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .5px; padding: .55rem .6rem; border-bottom: 2px solid var(--border); }
.tbl td { padding: .65rem .6rem; border-bottom: 1px solid var(--border); }
.tbl tr:hover td { background: #FAFCFD; }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: .15rem .55rem; border-radius: 20px; }
.tag-ok { background: #E4F6ED; color: var(--success); }
.tag-warn { background: var(--warn-soft); color: #9a7300; }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
.tag-info { background: var(--teal-soft); color: var(--teal-dark); }

/* ------------------------- Document output ----------------------------- */
.doc-output {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 1.6rem 1.8rem; font-family: var(--serif); font-size: .96rem; line-height: 1.65;
  color: #222; white-space: pre-wrap; max-height: 65vh; overflow: auto;
}
.doc-toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.doc-placeholder { color: var(--muted); font-family: var(--font); text-align: center; padding: 3rem 1rem; }
.ai-foot-note {
  font-size: .76rem; color: var(--muted); font-style: italic; margin-top: .8rem;
  padding-top: .7rem; border-top: 1px dashed var(--border);
}

/* AI thinking steps */
.ai-steps { list-style: none; padding: 0; margin: 1rem 0; }
.ai-steps li { display: flex; align-items: center; gap: .6rem; padding: .35rem 0; color: var(--muted); font-family: var(--font); font-size: .88rem; }
.ai-steps li.done { color: var(--ink); }
.ai-steps li.done::before { content: '✓'; color: var(--success); font-weight: 800; }
.ai-steps li.run::before { content: '◐'; color: var(--teal); animation: spin 1s linear infinite; display: inline-block; }
.ai-steps li.wait::before { content: '○'; color: var(--border); }

/* --------------------------- Lista condomìni --------------------------- */
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem 1rem; border: 1px solid var(--border); border-radius: 10px; margin-bottom: .6rem; background: var(--surface);
}
.list-row:hover { border-color: var(--teal); }
.list-row .meta { color: var(--muted); font-size: .82rem; }
.row-actions { display: flex; gap: .4rem; }

/* ------------------------------ Toast ---------------------------------- */
.toast-host { position: fixed; bottom: 1.2rem; right: 1.2rem; display: flex; flex-direction: column; gap: .5rem; z-index: 9999; }
.toast {
  background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: 9px; font-size: .88rem;
  box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; max-width: 340px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warn { background: var(--warn); color: #3a2c00; }

/* ------------------------------ Modale --------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(28,40,52,.5); display: flex; align-items: center;
  justify-content: center; padding: 1.5rem; z-index: 9000;
}
.modal-box { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); width: 100%; max-width: 520px; max-height: 88vh; display: flex; flex-direction: column; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.3rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 1.05rem; }
.modal-x { background: none; border: none; font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-body { padding: 1.3rem; overflow: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: .6rem; padding: 1rem 1.3rem; border-top: 1px solid var(--border); }

/* ------------------------------ Spinner -------------------------------- */
.spinner-wrap { display: flex; align-items: center; gap: .7rem; color: var(--muted); padding: 1rem 0; }
.spinner-label { font-size: .9rem; }

/* -------------------------- Impostazioni ------------------------------- */
.setting-block { padding: 1.1rem 0; border-bottom: 1px solid var(--border); }
.setting-block:last-child { border-bottom: none; }
.setting-block h4 { font-size: .98rem; margin-bottom: .3rem; }
.setting-block p.desc { color: var(--muted); font-size: .85rem; margin: 0 0 .8rem; }
.status-pill { display: inline-flex; align-items: center; gap: .4rem; font-size: .82rem; font-weight: 700; padding: .25rem .6rem; border-radius: 20px; }
.status-on { background: #E4F6ED; color: var(--success); }
.status-off { background: var(--danger-soft); color: var(--danger); }
.inline-actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* ------------------------------ Guida ---------------------------------- */
.guide-hero { background: linear-gradient(135deg, var(--teal-soft), #ffffff); border: 1px solid #d3e9ee; border-radius: 14px; padding: 1.6rem 1.8rem; margin-bottom: 1.4rem; }
.guide-hero h2 { font-size: 1.3rem; margin: 0 0 .4rem; }
.guide-hero p { color: var(--ink-soft); margin: 0; max-width: 60ch; }
.guide-section-title { font-size: 1.05rem; margin: 1.6rem 0 .8rem; }
.guide-steps { display: grid; gap: .9rem; margin-bottom: 1rem; }
.guide-step { display: flex; gap: 1rem; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.1rem 1.2rem; }
.gs-num { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--teal); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.guide-step h4 { margin: .15rem 0 .35rem; font-size: 1rem; }
.guide-step p { margin: 0 0 .6rem; color: var(--ink-soft); font-size: .9rem; }
.guide-step ol, .guide-step ul { margin: .3rem 0 .6rem 1.1rem; padding: 0; font-size: .88rem; color: var(--ink-soft); }
.guide-step li { margin: .2rem 0; }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 1rem; }
.guide-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.1rem; display: flex; flex-direction: column; transition: border-color .15s, box-shadow .15s; }
.guide-tile:hover { border-color: var(--teal); box-shadow: var(--shadow-sm); }
.gt-icon { font-size: 1.6rem; }
.guide-tile h4 { margin: .4rem 0 .3rem; font-size: 1rem; }
.gt-what { color: var(--ink-soft); font-size: .85rem; margin: 0 0 .5rem; flex: 1; }
.gt-how { font-size: .8rem; color: var(--muted); margin: 0 0 .8rem; line-height: 1.5; }
.guide-callout { background: var(--teal-soft); border: 1px solid #d3e9ee; border-radius: 12px; padding: 1.2rem 1.4rem; margin: 1.4rem 0; color: #1f5e6b; font-size: .9rem; }
.guide-callout strong { color: #134e5a; }

/* ------------------------------ Tour guidato --------------------------- */
.tour-overlay { position: fixed; inset: 0; z-index: 9998; background: transparent; }
.tour-spot { position: fixed; z-index: 9999; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(20, 30, 40, .62); pointer-events: none; transition: all .22s ease; }
.tour-tip { position: fixed; z-index: 10000; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: 1.1rem 1.2rem; max-width: 360px; transition: left .2s, top .2s; }
.tour-count { font-size: .72rem; font-weight: 700; color: var(--teal); text-transform: uppercase; letter-spacing: .5px; margin-bottom: .3rem; }
.tour-tip h4 { margin: 0 0 .4rem; font-size: 1.02rem; }
.tour-tip p { margin: 0 0 1rem; color: var(--ink-soft); font-size: .9rem; line-height: 1.5; }
.tour-actions { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.tour-nav { display: flex; gap: .4rem; }
.tour-skip { background: none; border: none; color: var(--muted); font-size: .8rem; cursor: pointer; text-decoration: underline; padding: 0; }
.tour-skip:hover { color: var(--ink); }

/* ------------------------------ Footer brand --------------------------- */
.app-footer { text-align: center; color: var(--muted); font-size: .76rem; padding: 1.5rem; border-top: 1px solid var(--border); margin-top: 1rem; }
.app-footer a { color: var(--teal-dark); }

/* ------------------------------ Responsive ----------------------------- */
@media (max-width: 880px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .3rem; padding: .7rem 1rem; }
  .sidebar-brand { padding: 0; flex: 1; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; flex: none; gap: .25rem; }
  .nav-item span:not(.nav-icon) { display: none; }
  .nav-item { padding: .5rem .6rem; }
  .sidebar-foot { display: none; }
  .split { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 1.2rem; }
}
