/* ClusterSEO — override sopra il tema Gentelella v4.
   Il look resta Gentelella (colore --primary teal); qui solo il brand ClusterSEO
   e i componenti auth aggiuntivi (banner errore, QR MFA, dashboard essenziale). */

/* Banner errore in cima ai form auth */
.auth-error {
  margin-bottom: 16px;
  padding: 10px 12px;
  background: var(--red-lt);
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.4;
}
.auth-error:empty { display: none; }

/* Testo di aiuto sotto i campi */
.auth-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 6px 0 0;
}

/* MFA: QR Code + segreto testuale */
.auth-qr {
  display: block;
  width: 190px; height: 190px;
  margin: 8px auto 14px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #fff;
}
.auth-secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  letter-spacing: 1px;
  word-break: break-all;
  text-align: center;
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  color: var(--text);
}

/* --- Dashboard utente (Tassello 1: barra in alto, senza barra laterale) --- */
.dash-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--body-bg); }

.dash-topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; height: 60px; padding: 0 20px;
  background: var(--bg-surface); border-bottom: 1px solid var(--border-color);
}
.dash-brand { font-weight: 600; font-size: 18px; color: var(--text); }
.dash-brand span { color: var(--primary); }
.dash-brand img, .auth-brand .brand-logo { display: block; height: auto; max-width: 100%; }

/* Marchio della sidebar senza ricompilare la shell: il markup compilato ha «C» + «ClusterSEO» testuali.
   Base chiara finché non c'è la versione del logo per sfondi scuri (la sidebar è sempre scura). */
.sidebar-brand .brand-icon {
  display: none;
  background: var(--sidebar-text-active) url(/public/images/favicon.png) center / 22px auto no-repeat;
  font-size: 0;
}
.sidebar-brand .brand-name {
  box-sizing: border-box; width: 164px; height: 36px; padding: 4px 8px; border-radius: 6px;
  background: var(--sidebar-text-active) url(/public/images/logo-cluster-seo.png) center / contain no-repeat;
  background-origin: content-box;
  font-size: 0;
}
.sidebar-brand .brand-name small { font-size: 0; }
@media (min-width: 769px) {
  body.sidebar-rail .sidebar-brand .brand-icon { display: flex; }
}
.dash-topbar-right { display: flex; align-items: center; gap: 14px; }
.dash-logout-form { margin: 0; }

.credits-chip {
  background: var(--primary-lt); color: var(--primary-dk);
  border: 1px solid var(--primary); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.credits-chip:empty { display: none; }
.dash-user { color: var(--text-muted); font-size: 13px; }

.dash-main { width: 100%; max-width: 820px; margin: 0 auto; padding: 26px 20px; }

/* ============================================================
   Shell del tool (Tassello 2 — sidebar + topbar, server-rendered)
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; background: var(--body-bg); }

/* Sidebar */
.side {
  width: 240px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--bg-surface); border-right: 1px solid var(--border-color);
}
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; padding: 0 18px; border-bottom: 1px solid var(--border-color);
}
.side-brand { font-weight: 600; font-size: 18px; color: var(--text); }
.side-brand span { color: var(--primary); }
.side-close { display: none; background: none; border: 0; font-size: 26px; line-height: 1; color: var(--text-muted); cursor: pointer; }
.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 14px 10px; }
.side-nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: 8px; color: var(--text-secondary); text-decoration: none;
  font-size: 14px; font-weight: 500; border-left: 3px solid transparent;
}
.side-nav-item:hover { background: var(--bg-surface-secondary); color: var(--text); }
.side-nav-item.active { background: var(--primary-lt); color: var(--primary-dk); border-left-color: var(--primary); }
.side-nav-icon { display: inline-flex; width: 18px; height: 18px; }
.side-nav-icon svg { width: 18px; height: 18px; }
.side-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }

/* Corpo + topbar */
.app-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 60px; padding: 0 20px; background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.side-toggle { display: none; background: none; border: 0; color: var(--text); cursor: pointer; padding: 4px; }
.side-toggle svg { width: 22px; height: 22px; }
.app-main { width: 100%; max-width: 960px; margin: 0 auto; padding: 26px 24px; }

/* Switcher progetti */
.proj-switcher { position: relative; }
.proj-switcher-empty { color: var(--text-muted); font-size: 13px; }
.proj-switcher-btn {
  display: inline-flex; align-items: center; gap: 8px; max-width: 260px;
  background: var(--bg-surface-secondary); border: 1px solid var(--border-color);
  border-radius: 8px; padding: 7px 12px; color: var(--text); font-size: 13.5px;
  font-weight: 500; cursor: pointer;
}
.proj-switcher-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-switcher-caret { color: var(--text-muted); font-size: 11px; }
.proj-switcher-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 50; min-width: 220px;
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; display: grid; gap: 2px;
}
.proj-switcher-menu[hidden] { display: none; }
.proj-switcher-item-form { margin: 0; }
.proj-switcher-item {
  width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  padding: 9px 11px; border-radius: 7px; color: var(--text-secondary); font-size: 13.5px;
}
.proj-switcher-item:hover { background: var(--bg-surface-secondary); color: var(--text); }
.proj-switcher-item.active { color: var(--primary-dk); font-weight: 600; background: var(--primary-lt); }

/* Stato vuoto progetti (nessun pulsante: il collegamento arriva al Pezzo 2) */
.projects-none {
  background: var(--bg-surface); border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg); padding: 34px 24px; text-align: center;
  color: var(--text-muted); font-size: 14px; line-height: 1.6;
}

/* Barra in cima al contenuto: switcher progetti + crediti + email (shell Gentelella) */
.cs-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 18px;
}
.cs-topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cs-topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user-email { color: var(--text-muted); font-size: 13px; }

/* Pagina "scegli proprietà" (Pezzo 2) */
.project-form { max-width: 640px; }
.site-list { display: grid; gap: 8px; margin: 6px 0 18px; }
.site-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 10px; cursor: pointer;
}
.site-item:hover { border-color: var(--primary); }
.site-item input { margin: 0; }
.site-url { font-weight: 500; color: var(--text); word-break: break-all; }
.site-perm { margin-left: auto; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-color);
  border-radius: 8px; background: var(--bg-surface); color: var(--text); font-size: 14px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); }
.field .field-hint { display: block; font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.cost-note { color: var(--text-secondary); font-size: 14px; margin: 0 0 14px; }

/* Mobile: sidebar a scomparsa */
@media (max-width: 768px) {
  .side {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .side.open { transform: translateX(0); }
  .side-close { display: inline-flex; }
  .side-toggle { display: inline-flex; }
  .app-main { padding: 20px 16px; }
}

.trial-box {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-lg); padding: 20px 22px; margin-bottom: 24px;
}
.trial-box h2 { margin: 0 0 8px; font-size: 16px; color: var(--text); font-weight: 600; }
.trial-credits { font-size: 26px; font-weight: 600; color: var(--text); line-height: 1.2; }
.trial-credits span { font-size: 14px; font-weight: 400; color: var(--text-muted); }
.trial-expiry { margin: 10px 0 0; color: var(--text-secondary); font-size: 14px; }
.trial-box.warn { border-left-color: var(--yellow); background: var(--yellow-lt); }

/* --- Box piano attivo (area pagante, §12.1) --- */
.plan-box {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-lg); padding: 20px 22px; margin-bottom: 24px;
}
.plan-box h2 { margin: 0 0 8px; font-size: 16px; color: var(--text); font-weight: 600; }
.plan-name { margin: 0 0 10px; color: var(--primary-dk); font-size: 15px; font-weight: 600; }
.plan-credits { font-size: 26px; font-weight: 600; color: var(--text); line-height: 1.2; }
.plan-credits span { font-size: 14px; font-weight: 400; color: var(--text-muted); }
.plan-expiry { margin: 10px 0 0; color: var(--text-secondary); font-size: 14px; }
.plan-warning { margin: 10px 0 0; color: var(--text); font-size: 14px; font-weight: 500; }
.plan-box.warn { border-left-color: var(--yellow); background: var(--yellow-lt); }

/* --- Storico pagamenti (§12.1) --- */
.pay-history {
  width: 100%; border-collapse: collapse; margin-bottom: 24px;
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); overflow: hidden; font-size: 14px;
}
.pay-history th, .pay-history td {
  padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border-color);
}
.pay-history thead th {
  color: var(--text-muted); font-weight: 600; font-size: 13px;
  background: var(--bg-muted, var(--primary-lt));
}
.pay-history tbody tr:last-child td { border-bottom: none; }
.pay-history .num { text-align: right; white-space: nowrap; }
.pay-history-empty {
  background: var(--bg-surface); border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg); padding: 24px 22px;
  text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 24px;
}

.dash-section-title { font-size: 15px; color: var(--text); font-weight: 600; margin: 0 0 12px; }
.projects-empty {
  background: var(--bg-surface); border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg); padding: 30px 22px;
  text-align: center; color: var(--text-muted); font-size: 14px;
}

/* --- Lista progetti (sezione Progetti) --- */
.proj-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.proj-head .dash-section-title { margin-bottom: 4px; }
.proj-count {
  display: inline-block; min-width: 20px; padding: 0 7px; margin-left: 8px;
  font-size: 12px; font-weight: 600; line-height: 20px; text-align: center;
  color: var(--primary-dk); background: var(--primary-lt); border-radius: 20px;
}
.proj-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.proj-table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted);
  padding: 8px 10px; border-bottom: 1px solid var(--border-color);
}
.proj-table td { padding: 12px 10px; border-bottom: 1px solid var(--border-color); color: var(--text); vertical-align: middle; }
.proj-table .num { text-align: right; color: var(--text-secondary); white-space: nowrap; }
.proj-table .act { text-align: right; white-space: nowrap; }
.proj-cell { display: flex; align-items: center; gap: 10px; }
.proj-badge {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px;
  background: var(--primary-lt); color: var(--primary-dk);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px;
}
.proj-name { font-weight: 600; color: var(--text); }
.proj-url { font-size: 12px; color: var(--text-muted); }
.import-badge {
  display: inline-block; margin-top: 4px; margin-right: 6px; padding: 1px 8px;
  font-size: 11px; font-weight: 600; line-height: 18px; border-radius: 20px;
}
.import-badge.working { color: #8a6d00; background: #fff4cc; }
.import-badge.done { color: var(--primary-dk); background: var(--primary-lt); }
.import-badge.error { color: #a12020; background: #fbe0e0; }

/* I .btn sono spesso <a href>: Gentelella non azzera la sottolineatura del link.
   La togliamo a livello brand → vale per TUTTI i pulsanti con testo (regola app-wide). */
.btn, .btn:hover, .btn:focus { text-decoration: none; }

/* Dettaglio URL (Pezzo 9): badge stato per fonte + barra filtri */
.src-badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; line-height: 1.6; }
.src-badge.ok { color: var(--primary-dk); background: var(--primary-lt); }
.src-badge.warn { color: #8a6d00; background: #fff4cc; }
.src-badge.off { color: var(--text-muted); background: rgba(128,128,128,.12); }
.dt-filterbar { margin-bottom: 12px; }
.field.inline { display: inline-flex; align-items: center; gap: 8px; }
.gsc-dt th.act { text-align: right; }
.gsc-dt td:last-child { text-align: right; white-space: nowrap; }
.url-detail-btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; }
.url-detail-btn svg { width: 15px; height: 15px; }
.data-note.url-note { margin-top: 18px; }
/* Dettaglio URL: sezioni-card impilate con stacco uniforme */
.url-detail > * { margin-bottom: 16px; }
.url-detail > *:last-child { margin-bottom: 0; }
.url-detail > .gsc-panel-wide { margin-top: 0; }

/* Dashboard dettaglio progetto (Pezzo 4) */
.period-bar { display: inline-flex; gap: 4px; margin: 4px 0 10px; padding: 4px;
  background: var(--bg-surface-alt, rgba(128,128,128,.08)); border-radius: 10px; }
.period-btn { padding: 6px 14px; font-size: 13px; font-weight: 600; border-radius: 7px;
  color: var(--text-secondary); text-decoration: none; }
.period-btn:hover { color: var(--text); }
.period-btn.active { color: #fff; background: var(--primary); }
.metric-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 12px 0 18px; }
@media (max-width: 720px) { .metric-cards { grid-template-columns: repeat(2, 1fr); } }
.metric-card { padding: 16px 18px; background: var(--bg-surface); border: 1px solid var(--border-color-light);
  border-radius: 12px; }
.metric-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.metric-val { font-size: 26px; font-weight: 700; color: var(--text); margin: 6px 0 4px; }
.metric-delta { font-size: 12px; font-weight: 600; }
.metric-delta.good { color: #1a9c5b; }
.metric-delta.bad { color: #c0392b; }
.metric-delta.flat, .metric-delta.none { color: var(--text-muted); }
.data-note { padding: 8px 12px; margin: 0 0 14px; font-size: 13px; color: #8a6d00;
  background: #fff4cc; border-radius: 8px; }
.gsc-chart-card { padding: 14px 16px; }
.gsc-chart { height: 340px; }
.gsc-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
@media (max-width: 720px) { .gsc-panels { grid-template-columns: 1fr; } }
/* Variante a 3 colonne (card GA4: Dispositivi/Paesi/Peso canali affiancate). */
.gsc-panels-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 980px) { .gsc-panels-3 { grid-template-columns: 1fr; } }
.gsc-panel { padding: 14px 16px; background: var(--bg-surface); border: 1px solid var(--border-color-light); border-radius: 12px; }
.gsc-panel-wide { margin-top: 18px; }
.gsc-panels-dt > .gsc-panel-wide { margin-top: 0; }
.gsc-panels-dt > .gsc-panel { min-width: 0; overflow-x: auto; }
.gsc-dt { width: 100%; }
.gsc-dt td:first-child { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gsc-panel-title { margin: 0 0 10px; font-size: 14px; font-weight: 700; color: var(--text); }
.gsc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.gsc-table th { text-align: left; padding: 6px 8px; font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--border-color-light); }
.gsc-table th.num, .gsc-table td.num { text-align: right; }
.gsc-table td { padding: 6px 8px; color: var(--text); border-bottom: 1px solid var(--border-color-light); }
.gsc-table tbody tr:last-child td { border-bottom: none; }
.gsc-key { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-head-actions { display: flex; align-items: center; gap: 10px; }
.refresh-form { margin: 0; }
.refresh-hint { font-size: 13px; color: var(--text-muted); }
.refresh-banner { padding: 10px 14px; margin: 0 0 14px; font-size: 14px; border-radius: 8px; }
.refresh-banner.ok { color: var(--primary-dk); background: var(--primary-lt); }
.refresh-banner.warn { color: #8a6d00; background: #fff4cc; }
.proj-type { color: var(--text-secondary); }
.proj-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; margin-left: 6px;
  border: 1px solid var(--border-color); border-radius: 8px;
  color: var(--text-secondary); background: var(--bg-surface); cursor: pointer;
}
.proj-ico:hover { background: var(--bg-surface-secondary); color: var(--text); }
.proj-ico.danger:hover { color: var(--red); border-color: var(--red); }
.proj-ico svg { width: 16px; height: 16px; }
.proj-del { display: inline; margin: 0; }
.proj-ok {
  display: inline-block; margin-left: 8px; padding: 2px 10px; font-size: 12px; font-weight: 600;
  color: var(--primary-dk); background: var(--primary-lt); border-radius: 20px;
}

/* --- Schermata di blocco (prova terminata) --- */
.blocco-card {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-left: 4px solid var(--red);
  border-radius: var(--radius-lg); padding: 28px 26px; margin-top: 10px;
}
.blocco-card h1 { margin: 0 0 12px; font-size: 20px; color: var(--text); font-weight: 600; }
.blocco-card p { margin: 0 0 12px; color: var(--text-secondary); font-size: 14px; line-height: 1.6; }
.blocco-note { color: var(--text-muted); }
.blocco-soon { margin-top: 4px; color: var(--text); font-weight: 500; }

/* --- Pagina piani --- */
.plans-title { font-size: 20px; font-weight: 600; color: var(--text); margin: 6px 0 4px; }
.plans-sub { color: var(--text-muted); font-size: 14px; margin: 0 0 20px; }
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.plan-card {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 22px 20px; text-align: center;
}
.plan-card h2 { margin: 0 0 10px; font-size: 16px; font-weight: 600; color: var(--text); }
.plan-price { font-size: 30px; font-weight: 700; color: var(--text); line-height: 1.1; }
.plan-credits { color: var(--text-secondary); font-size: 13px; margin: 6px 0 16px; }
.plan-card form { margin: 0; }
.plan-card .btn { width: 100%; justify-content: center; }

@media (max-width: 560px) {
  .dash-user { display: none; }
}

/* --- Pagina Profilo: usa le classi native Gentelella v4 (card/row/form/table),
   nessun CSS custom qui. Le piccole rifiniture sono inline nel markup. --- */

/* --- Panoramica: card progetto (template Gentelella projects.html) adattate ai dati SEO.
   La card nativa .project-card è un <button>; qui è un <a>, quindi togliamo decorazioni del link. --- */
a.project-card { text-decoration: none; color: inherit; }
.proj-ov-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin-top: 2px; }
.proj-ov-stats > div { display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11.5px; color: var(--text-muted); }

/* Avvisi informativi nel tema scuro: il blu del tema sul suo fondo traslucido ha un contrasto di circa 2,65:1.
   Testo e icona mescolano il blu con il testo del tema (≥ 4,5:1, WCAG AA). Tema chiaro invariato. */
[data-theme=dark] .alert-info { color: color-mix(in srgb, var(--blue) 50%, var(--text)); }
