/* ============================================================
   SaaS Subscription Platform Demo — Design System
   Stile: AI Company · Enterprise · Minimal · Dark premium
   ============================================================ */
:root {
  --bg: #05060a;
  --bg-alt: #090b12;
  --surface: #0d1019;
  --surface-2: #12161f;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f2f4f8;
  --text-dim: #9aa3b2;
  --violet: #7c5cff;
  --cyan: #33e0ff;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --grad: linear-gradient(120deg, var(--violet), var(--cyan));
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --radius: 16px;
  --gutter: clamp(1.25rem, 4vw, 3rem);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--violet); color: #fff; }

.container { max-width: 1180px; margin-inline: auto; padding-inline: var(--gutter); }

/* ---------- Tipografia ---------- */
h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -0.02em; line-height: 1.15; }
.eyebrow {
  font-family: var(--font-display); font-size: 0.78rem; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase;
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; margin-bottom: 0.9rem;
}
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.muted { color: var(--text-dim); }

/* ---------- Bottoni ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-family: var(--font-display); font-weight: 600; font-size: 0.95rem;
  padding: 0.75rem 1.5rem; border-radius: 999px; border: none; cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.22,1,0.36,1), box-shadow 0.25s, opacity 0.25s, border-color 0.25s;
  position: relative;
}
.btn--primary { background: var(--grad); color: #fff; box-shadow: 0 4px 20px rgba(124,92,255,0.35); }
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(124,92,255,0.5); }
.btn--ghost { background: rgba(255,255,255,0.03); border: 1px solid var(--line); color: var(--text); }
.btn--ghost:hover { transform: translateY(-2px); border-color: rgba(124,92,255,0.5); }
.btn--danger { background: rgba(248,113,113,0.12); border: 1px solid rgba(248,113,113,0.4); color: var(--err); }
.btn--danger:hover { background: rgba(248,113,113,0.2); }
.btn--sm { padding: 0.45rem 1rem; font-size: 0.83rem; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn.is-loading { color: transparent; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Card / superfici ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.6rem;
}
.card--hover { transition: transform 0.3s cubic-bezier(0.22,1,0.36,1), border-color 0.3s, box-shadow 0.3s; }
.card--hover:hover { transform: translateY(-4px); border-color: rgba(124,92,255,0.4); box-shadow: 0 16px 48px rgba(0,0,0,0.45); }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em;
  padding: 0.22rem 0.7rem; border-radius: 999px;
}
.badge--ok { background: rgba(52,211,153,0.12); color: var(--ok); border: 1px solid rgba(52,211,153,0.3); }
.badge--warn { background: rgba(251,191,36,0.12); color: var(--warn); border: 1px solid rgba(251,191,36,0.3); }
.badge--err { background: rgba(248,113,113,0.12); color: var(--err); border: 1px solid rgba(248,113,113,0.3); }
.badge--info { background: rgba(51,224,255,0.1); color: var(--cyan); border: 1px solid rgba(51,224,255,0.3); }

/* ---------- Form ---------- */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.4rem; }
.field input, .field select, .field textarea {
  width: 100%; padding: 0.75rem 1rem;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font-family: var(--font-body); font-size: 0.95rem;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(124,92,255,0.18);
}
.field .error-msg { display: none; font-size: 0.78rem; color: var(--err); margin-top: 0.3rem; }
.field.has-error input, .field.has-error select { border-color: var(--err); }
.field.has-error .error-msg { display: block; }
.check { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 0.8rem; cursor: pointer; }
.check input { width: 16px; height: 16px; margin-top: 0.2rem; accent-color: var(--violet); flex-shrink: 0; }

/* ---------- Tabelle ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 560px; }
th, td { text-align: left; padding: 0.85rem 1.1rem; border-bottom: 1px solid var(--line); }
th { font-family: var(--font-display); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.2s; }
tbody tr:hover { background: rgba(124,92,255,0.04); }

/* ---------- Toast ---------- */
#toast-zone { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 999; display: flex; flex-direction: column; gap: 0.6rem; }
.toast {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 0.85rem 1.2rem; font-size: 0.9rem; min-width: 260px; max-width: 360px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  animation: toastIn 0.35s cubic-bezier(0.22,1,0.36,1);
}
.toast--ok { border-left: 3px solid var(--ok); }
.toast--err { border-left: 3px solid var(--err); }
.toast--info { border-left: 3px solid var(--cyan); }
.toast.is-leaving { animation: toastOut 0.3s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(5,6,10,0.8); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center; padding: 1.5rem;
}
.modal-backdrop.is-open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 2rem; max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto;
  animation: toastIn 0.3s cubic-bezier(0.22,1,0.36,1);
}
.modal h3 { margin-bottom: 1rem; }

/* ---------- Nav pubblica ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(5,6,10,0.8); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.nav__inner { display: flex; align-items: center; justify-content: space-between; height: 66px; }
.nav__brand { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 0.5rem; }
.nav__brand .dot-logo { width: 26px; height: 26px; border-radius: 8px; background: var(--grad); display: inline-block; }
.nav__links { display: flex; gap: 1.6rem; align-items: center; font-size: 0.9rem; }
.nav__links a:not(.btn) { color: var(--text-dim); transition: color 0.25s; }
.nav__links a:not(.btn):hover { color: var(--text); }
.demo-banner {
  background: rgba(251,191,36,0.1); border-bottom: 1px solid rgba(251,191,36,0.25);
  color: var(--warn); text-align: center; font-size: 0.78rem; padding: 0.45rem 1rem; font-weight: 600;
}

/* ---------- Layout app (sidebar) ---------- */
.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 32px); }
.sidebar {
  background: var(--bg-alt); border-right: 1px solid var(--line);
  padding: 1.4rem 1rem; display: flex; flex-direction: column; gap: 0.25rem;
}
.sidebar .nav__brand { padding: 0 0.6rem 1.2rem; }
.sidebar a.side-link {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.65rem 0.9rem; border-radius: 10px;
  color: var(--text-dim); font-size: 0.9rem; font-weight: 500;
  transition: background 0.2s, color 0.2s;
}
.sidebar a.side-link:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.sidebar a.side-link.is-active { background: rgba(124,92,255,0.14); color: var(--text); }
.sidebar .side-spacer { flex: 1; }
.main-area { padding: clamp(1.4rem, 3vw, 2.5rem); min-width: 0; }
.main-area > section { display: none; }
.main-area > section.is-visible { display: block; animation: fadeUp 0.35s cubic-bezier(0.22,1,0.36,1); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.6rem; }
.page-head h1 { font-size: 1.5rem; }

/* ---------- Stat tiles ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.stat-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem; }
.stat-tile .label { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.stat-tile .value { font-family: var(--font-display); font-size: 1.65rem; font-weight: 700; margin-top: 0.25rem; }
.stat-tile .delta { font-size: 0.75rem; margin-top: 0.2rem; }

/* ---------- Pricing ---------- */
.pricing-toggle { display: inline-flex; align-items: center; gap: 0.8rem; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0.35rem; }
.pricing-toggle button {
  border: none; background: none; color: var(--text-dim); font-family: var(--font-display);
  font-weight: 600; font-size: 0.88rem; padding: 0.5rem 1.2rem; border-radius: 999px; cursor: pointer;
  transition: background 0.25s, color 0.25s;
}
.pricing-toggle button.is-active { background: var(--grad); color: #fff; }
.plans-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.3rem; margin-top: 2rem; }
.plan-card { position: relative; display: flex; flex-direction: column; }
.plan-card.is-featured { border-color: rgba(124,92,255,0.55); box-shadow: 0 0 50px rgba(124,92,255,0.15); }
.plan-card .flag {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--grad); color: #fff; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; padding: 0.25rem 0.9rem; border-radius: 999px;
}
.plan-card .price { font-family: var(--font-display); font-size: 2.4rem; font-weight: 700; margin: 0.7rem 0 0.1rem; }
.plan-card .price small { font-size: 0.9rem; color: var(--text-dim); font-weight: 500; }
.plan-card ul { list-style: none; margin: 1.2rem 0 1.6rem; flex: 1; }
.plan-card li { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.9rem; color: var(--text-dim); padding: 0.35rem 0; }
.plan-card li::before { content: "✓"; color: var(--cyan); font-weight: 700; }

/* ---------- FAQ ---------- */
.faq-item { border: 1px solid var(--line); border-radius: 14px; margin-bottom: 0.8rem; overflow: hidden; background: var(--surface); }
.faq-item summary {
  padding: 1.1rem 1.4rem; cursor: pointer; font-family: var(--font-display); font-weight: 600;
  list-style: none; display: flex; justify-content: space-between; align-items: center;
}
.faq-item summary::after { content: "+"; font-size: 1.3rem; color: var(--cyan); transition: transform 0.3s; }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p { padding: 0 1.4rem 1.2rem; color: var(--text-dim); font-size: 0.92rem; }

/* ---------- Skeleton loading ---------- */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, rgba(255,255,255,0.06) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; min-height: 1em; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Sezioni landing ---------- */
.section { padding-block: clamp(3.5rem, 8vw, 6.5rem); }
.section--alt { background: linear-gradient(180deg, transparent, rgba(124,92,255,0.04), transparent); }
.section__head { max-width: 640px; margin-bottom: 2.5rem; }
.section__head h2 { font-size: clamp(1.7rem, 3.6vw, 2.6rem); margin-bottom: 0.8rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.3rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.3rem; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding-block: 2.5rem; margin-top: 2rem; }
.footer__inner { display: flex; flex-wrap: wrap; gap: 2rem; justify-content: space-between; align-items: center; font-size: 0.85rem; color: var(--text-dim); }
.footer__links { display: flex; gap: 1.4rem; flex-wrap: wrap; }
.footer__links a:hover { color: var(--text); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .plans-grid, .grid-3 { grid-template-columns: 1fr; max-width: 480px; margin-inline: auto; }
  .grid-2 { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line);
    padding: 0.7rem; gap: 0.4rem; align-items: center; position: sticky; top: 0; z-index: 40;
    background: rgba(9,11,18,0.92); backdrop-filter: blur(12px);
  }
  .sidebar .nav__brand { padding: 0 0.6rem; white-space: nowrap; }
  .sidebar a.side-link { white-space: nowrap; padding: 0.5rem 0.8rem; font-size: 0.82rem; }
  .sidebar .side-spacer { display: none; }
}
@media (max-width: 640px) {
  .nav__links { gap: 0.9rem; font-size: 0.82rem; }
  .nav__links a.hide-mobile { display: none; }
  .page-head h1 { font-size: 1.25rem; }
  #toast-zone { left: 1rem; right: 1rem; }
  .toast { min-width: 0; max-width: none; }
}
