/* =========================================================================
   SOFIA — Demo interattiva / Tour guidato
   Stili custom (il resto della UI usa Tailwind via CDN).
   Nessun dato reale: tutto fittizio e anonimizzato.
   ========================================================================= */

:root {
  --tour-dim: rgba(15, 23, 42, 0.60);
  --brand: #2563eb;
  --brand-ring: rgba(37, 99, 235, 0.55);
}

html, body { height: 100%; }
body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  overflow-x: hidden;
}

/* Fa in modo che i "click" del tour non selezionino testo */
body.tour-running { user-select: none; }

/* ---------------------------------------------------------------- Screens */
.screen { display: none; }
.screen.active { display: block; animation: screen-in 0.35s ease; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* Tab del dettaglio */
.tabpane { display: none; }
.tabpane.active { display: block; animation: screen-in 0.3s ease; }

/* Card categoria email espandibile */
.email-cat-body { display: none; }
.email-cat.open .email-cat-body { display: block; }
.email-cat.open .chevron { transform: rotate(180deg); }
.chevron { transition: transform 0.25s ease; }

/* Pane impostazioni */
.spane { display: none; }
.spane.active { display: block; animation: screen-in 0.3s ease; }

/* Sezioni Knowledge Base espandibili */
.kb-body { display: none; }
.kb-sec.open .kb-body { display: block; }
.kb-sec.open .chevron { transform: rotate(180deg); }

/* Pulsante call-to-action dentro il callout (es. avvia 2ª parte) */
.tour-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(90deg, #2563eb, #4f46e5);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 18px -6px rgba(37, 99, 235, 0.5);
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}
.tour-cta:hover { transform: translateY(-1px); box-shadow: 0 10px 22px -6px rgba(37, 99, 235, 0.6); }
.tour-cta:active { transform: scale(0.97); }
.tour-cta.secondary {
  background: #f1f5f9;
  color: #334155;
  box-shadow: none;
}
.tour-cta.secondary:hover { background: #e2e8f0; }

/* Modali / dialog */
.overlay-modal { display: none; }
.overlay-modal.open { display: flex; }

/* =============================================================== Fake cursor */
#tour-cursor {
  position: fixed;
  left: 0; top: 0;
  width: 30px; height: 30px;
  z-index: 10005;
  pointer-events: none;
  opacity: 0;
  transform: translate(-100px, -100px);
  transition: transform 0.85s cubic-bezier(0.45, 0.05, 0.2, 1), opacity 0.3s ease;
  will-change: transform;
  filter: drop-shadow(0 3px 4px rgba(2, 6, 23, 0.45));
}
#tour-cursor.visible { opacity: 1; }

#tour-cursor .ripple {
  position: absolute;
  left: 2px; top: 2px;
  width: 20px; height: 20px;
  border-radius: 9999px;
  background: var(--brand-ring);
  opacity: 0;
  transform: scale(0.2);
}
#tour-cursor.clicking .ripple { animation: cursor-ripple 0.6s ease-out; }
@keyframes cursor-ripple {
  0%   { opacity: 0.6; transform: scale(0.2); }
  100% { opacity: 0;   transform: scale(3.2); }
}

/* ============================================================== Spotlight */
#tour-highlight {
  position: fixed;
  z-index: 10001;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px var(--tour-dim);
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  pointer-events: none;
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.45, 0.05, 0.2, 1), opacity 0.35s ease;
}
#tour-highlight.visible { opacity: 1; }

/* Quando non c'è un target: dim pieno schermo centrato (intro/outro) */
#tour-highlight.center {
  left: 50%; top: 50%;
  width: 0; height: 0;
  outline-color: transparent;
}

/* ================================================================ Callout */
#tour-callout {
  position: fixed;
  z-index: 10004;
  width: 340px;
  max-width: calc(100vw - 32px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 24px 50px -12px rgba(2, 6, 23, 0.5);
  padding: 18px 20px 20px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease, left 0.4s ease, top 0.4s ease;
  border: 1px solid #e2e8f0;
}
#tour-callout.visible { opacity: 1; transform: none; }

#tour-callout .chapter-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #2563eb;
  background: #eff6ff;
  padding: 4px 10px;
  border-radius: 9999px;
  margin-bottom: 10px;
}
#tour-callout h4 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}
#tour-callout p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: #475569;
}
#tour-callout .callout-step {
  margin-top: 12px;
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
}

/* ============================================================ Control bar */
#tour-controls {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(120%);
  z-index: 10006;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.96);
  color: #e2e8f0;
  border-radius: 9999px;
  box-shadow: 0 16px 40px -8px rgba(2, 6, 23, 0.6);
  backdrop-filter: blur(6px);
  transition: transform 0.4s cubic-bezier(0.3, 0.7, 0.2, 1);
  max-width: calc(100vw - 24px);
}
#tour-controls.visible { transform: translateX(-50%) translateY(0); }

.tc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 9999px;
  border: none;
  background: transparent;
  color: #cbd5e1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.tc-btn:hover { background: rgba(148, 163, 184, 0.18); color: #fff; }
.tc-btn:active { transform: scale(0.92); }
.tc-btn.primary {
  background: #2563eb;
  color: #fff;
  width: 46px; height: 46px;
}
.tc-btn.primary:hover { background: #1d4ed8; }
.tc-btn:disabled { opacity: 0.35; cursor: default; }
.tc-btn:disabled:hover { background: transparent; color: #cbd5e1; }

#tc-label {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  padding: 0 6px;
  min-width: 148px;
  text-align: center;
}
#tc-label .tc-chapter { display: block; color: #fff; }
#tc-label .tc-count { display: block; color: #94a3b8; font-weight: 500; font-size: 11px; }

#tc-progress {
  width: 160px;
  height: 6px;
  background: rgba(148, 163, 184, 0.25);
  border-radius: 9999px;
  overflow: hidden;
  flex-shrink: 0;
}
#tc-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #6366f1);
  border-radius: 9999px;
  transition: width 0.4s ease;
}

/* Divider verticale nella barra */
.tc-sep { width: 1px; height: 26px; background: rgba(148, 163, 184, 0.25); flex-shrink: 0; }

/* ============================================================ Chapter menu */
#tour-chapters {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%) translateY(10px);
  z-index: 10006;
  width: 340px;
  max-width: calc(100vw - 24px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 24px 50px -12px rgba(2, 6, 23, 0.5);
  border: 1px solid #e2e8f0;
  padding: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#tour-chapters.open { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
#tour-chapters .ch-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: #94a3b8; padding: 8px 12px 4px;
}
.ch-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none; background: transparent;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-size: 13.5px; color: #334155; font-weight: 500;
  transition: background 0.15s ease;
}
.ch-item:hover { background: #f1f5f9; }
.ch-item.active { background: #eff6ff; color: #1d4ed8; font-weight: 600; }
.ch-item .ch-num {
  width: 22px; height: 22px; flex-shrink: 0;
  border-radius: 9999px;
  background: #e2e8f0; color: #475569;
  font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.ch-item.active .ch-num { background: #2563eb; color: #fff; }

/* ============================================================ Start screen */
#tour-intro {
  position: fixed;
  inset: 0;
  z-index: 10010;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(4px);
  transition: opacity 0.4s ease;
}
#tour-intro.hidden { opacity: 0; pointer-events: none; }
#tour-intro .intro-card {
  background: #fff;
  border-radius: 22px;
  padding: 40px 44px;
  max-width: 460px;
  text-align: center;
  box-shadow: 0 30px 70px -20px rgba(2, 6, 23, 0.7);
}

/* Piccole animazioni riutilizzate */
.pulse-ring { animation: pulse-soft 1.8s ease-in-out infinite; }
@keyframes pulse-soft {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4); }
  50%      { box-shadow: 0 0 0 12px rgba(37, 99, 235, 0); }
}

/* Barra di avanzamento generica (upload / processing) */
.progress-anim { transition: width 0.6s ease; }

/* Scrollbar discreta nelle aree scrollabili */
.thin-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.thin-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 9999px; }
.thin-scroll::-webkit-scrollbar-track { background: transparent; }

/* Badge "REC" lampeggiante */
.rec-dot { animation: blink 1.1s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

/* Nascondi la barra di scroll durante il tour per screenshot puliti (opzionale) */
@media (max-width: 900px) {
  #tour-callout { width: 300px; }
}
