/* Sophie pre-screening logic — v2 compact layout
   Inspired by appointment-confirmation reference: gradient bg,
   sidebar nav, center phone, flanking callouts. */

:root {
  --bg-grad-1: #fdf2f8;
  --bg-grad-2: #f5d0fe;
  --bg-grad-3: #ddd6fe;
  --sidebar-bg: rgba(255, 255, 255, 0.7);
  --card-bg: #ffffff;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --text-soft: #9ca3af;
  --border: rgba(0, 0, 0, 0.06);
  --accent: #7c3aed;
  --accent-strong: #6d28d9;
  --accent-soft: rgba(124, 58, 237, 0.1);
  --bg-phone: #efeae2;
  --bg-bubble-sophie: #ffffff;
  --bg-bubble-candidate: #d9fdd3;
  --whatsapp-header: #128c7e;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 24px 48px rgba(124, 58, 237, 0.15);
}

[data-theme='dark'] {
  --bg-grad-1: #0f0a1f;
  --bg-grad-2: #1e1033;
  --bg-grad-3: #1a0f2e;
  --sidebar-bg: rgba(20, 20, 30, 0.7);
  --card-bg: #15181d;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --text-soft: #6b7280;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #a78bfa;
  --accent-strong: #c4b5fd;
  --accent-soft: rgba(167, 139, 250, 0.15);
  --bg-phone: #0e1418;
  --bg-bubble-sophie: #1f2937;
  --bg-bubble-candidate: #054640;
  --whatsapp-header: #075e54;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 48px rgba(167, 139, 250, 0.2);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, var(--bg-grad-1) 0%, var(--bg-grad-2) 50%, var(--bg-grad-3) 100%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

[data-theme='light'] .theme-icon-dark { display: none; }
[data-theme='dark'] .theme-icon-light { display: none; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--sidebar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--border);
  padding: 28px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.sidebar-head { padding: 0 8px; }
.brand {
  display: block;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
}
.brand-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
}

.scene-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
}
.scene-list-item {
  background: none;
  border: none;
  text-align: left;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  font: inherit;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  transition: background 120ms, color 120ms;
}
.scene-list-item:hover { background: var(--accent-soft); color: var(--text); }
.scene-list-item.active {
  background: var(--accent);
  color: white;
  font-weight: 600;
}

.sidebar-ctas {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-cta {
  display: block;
  text-align: center;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 120ms, box-shadow 120ms, background 120ms;
}
.sidebar-cta.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.3);
}
.sidebar-cta.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(124, 58, 237, 0.4);
}
.sidebar-cta.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.35;
}
.sidebar-cta.secondary:hover {
  background: var(--accent-soft);
}

/* Stage */
.stage {
  display: flex;
  flex-direction: column;
  padding: 20px 32px 32px;
  min-width: 0;
}
.stage-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.stage-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.stage-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.theme-toggle {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}
.lang-switch {
  display: inline-flex;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  box-shadow: var(--shadow-sm);
}
.lang-pill {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.lang-pill:hover { color: var(--text); }
.lang-pill.active {
  background: var(--accent);
  color: white;
}

/* Floating arrows beside the phone */
.arrow {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 28px;
  font-weight: 600;
  cursor: pointer;
  align-self: center;
  margin-top: 80px;
  box-shadow: var(--shadow-md);
  transition: transform 120ms, background 120ms, box-shadow 120ms, color 120ms;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.arrow:hover {
  background: var(--accent);
  color: white;
  transform: scale(1.06);
  box-shadow: 0 14px 32px rgba(124, 58, 237, 0.3);
}
.arrow:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
  background: var(--card-bg);
  color: var(--text);
}

.stage-body {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto;
  gap: 20px;
  align-items: start;
  flex: 1;
  min-height: 0;
}

/* Callouts */
.callouts {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 60px;
}
.callout {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  animation: callout-in 350ms ease-out;
  max-width: 280px;
}
.callouts-left .callout { margin-left: auto; }
.callout-label {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.005em;
  color: var(--text);
  margin-bottom: 4px;
  display: block;
}
.callout-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}
.callout-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 120ms, box-shadow 120ms, background 120ms;
}
.callout-cta.whatsapp {
  background: rgba(37, 211, 102, 0.95);
  color: white;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}
.callout-cta.whatsapp::before {
  content: '💬';
  font-size: 13px;
}
.callout-cta.whatsapp:hover {
  transform: translateY(-1px);
  background: rgb(34, 197, 94);
  box-shadow: 0 8px 16px rgba(37, 211, 102, 0.4);
}
.callout::after {
  content: '';
  position: absolute;
  top: 22px;
  width: 24px;
  height: 1px;
  background: var(--text-soft);
  opacity: 0.5;
}
.callouts-left .callout::after { right: -24px; }
.callouts-right .callout::after { left: -24px; }

@keyframes callout-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Phone */
.phone-wrap { display: flex; justify-content: center; }
.phone {
  width: 360px;
  background: var(--bg-phone);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
}
.phone-bar {
  background: var(--whatsapp-header);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.phone-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.phone-name { font-weight: 600; font-size: 14px; }
.phone-status { font-size: 11px; opacity: 0.85; }
.chat {
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 360px;
  max-height: 480px;
  overflow-y: auto;
}
.bubble {
  max-width: 85%;
  padding: 7px 11px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: bubble-in 200ms ease-out;
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.bubble.sophie {
  align-self: flex-start;
  background: var(--bg-bubble-sophie);
  color: var(--text);
  border-top-left-radius: 2px;
}
.bubble.candidate {
  align-self: flex-end;
  background: var(--bg-bubble-candidate);
  color: var(--text);
  border-top-right-radius: 2px;
}
.bubble .meta {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
}

/* Voice & PDF bubbles (same as v1) */
.bubble.voice { padding: 10px 12px; min-width: 240px; }
.voice-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.voice-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--whatsapp-header);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}
.voice-wave {
  flex: 1;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-size: 11px;
  font-family: monospace;
}
.voice-duration { font-size: 11px; color: var(--text-muted); }
.voice-transcript {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  border-top: 1px dashed var(--border);
  padding-top: 6px;
}

.bubble.pdf { padding: 10px 12px; min-width: 220px; }
.pdf-head { display: flex; align-items: center; gap: 10px; }
.pdf-icon { font-size: 26px; flex-shrink: 0; }
.pdf-info { display: flex; flex-direction: column; }
.pdf-name { font-weight: 600; font-size: 13px; color: var(--text); }
.pdf-size { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.phone-input {
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-soft);
  background: var(--card-bg);
}

/* Final CTA scene — vertical center, hero-like presentation */
.chat.final-cta-mode {
  justify-content: center;
  align-items: center;
  gap: 24px;
  padding: 24px 16px;
}
.chat.final-cta-mode .bubble.sophie {
  align-self: center;
  text-align: center;
  max-width: 86%;
  font-size: 14px;
  background: transparent;
  box-shadow: none;
  border: none;
  color: var(--text-muted);
  font-style: italic;
}

/* Final CTA buttons — render inside chat area on the last scene */
.chat-cta-button {
  display: block;
  width: calc(100% - 16px);
  margin: 6px auto 0;
  padding: 14px 18px;
  border-radius: 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms, box-shadow 120ms, background 120ms;
  animation: bubble-in 240ms ease-out;
}
.chat.final-cta-mode .chat-cta-button {
  margin: 0 auto;
  width: calc(100% - 32px);
  padding: 18px 22px;
  font-size: 16px;
  border-radius: 14px;
}
.chat-cta-button.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.35);
}
.chat-cta-button.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(124, 58, 237, 0.45);
}
/* Subtle pulse on the primary CTA in the final scene — draws the eye without
   feeling like a spam banner. */
.chat.final-cta-mode .chat-cta-button.primary {
  animation: bubble-in 240ms ease-out, cta-pulse 2.2s ease-in-out 400ms infinite;
}
@keyframes cta-pulse {
  0%, 100% {
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.35);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 16px 40px rgba(124, 58, 237, 0.55), 0 0 0 6px rgba(124, 58, 237, 0.12);
    transform: scale(1.025);
  }
}
.chat.final-cta-mode .chat-cta-button.primary:hover {
  animation: none;
  transform: translateY(-2px) scale(1.025);
  box-shadow: 0 18px 44px rgba(124, 58, 237, 0.55);
}
.chat-cta-button.secondary {
  background: rgba(37, 211, 102, 0.95);
  color: white;
  box-shadow: 0 6px 18px rgba(37, 211, 102, 0.35);
}
.chat-cta-button.secondary:hover {
  transform: translateY(-1px);
  background: rgb(34, 197, 94);
  box-shadow: 0 10px 22px rgba(37, 211, 102, 0.45);
}
.chat-cta-button.secondary::before {
  content: '💬 ';
}

/* ===== Demo frames (scene 1: Hire Sophie animated setup) ===== */
.chat.demo-mode {
  background: linear-gradient(180deg, #fafaff 0%, #f3eefe 100%);
  padding: 20px 16px;
  justify-content: flex-start;
  min-height: 420px;
  position: relative;
  overflow: hidden;
}
[data-theme='dark'] .chat.demo-mode {
  background: linear-gradient(180deg, #15101f 0%, #1c1330 100%);
}

.demo-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: demo-in 400ms ease-out;
  width: 100%;
}
.demo-frame.exit { animation: demo-out 280ms ease-in forwards; }
@keyframes demo-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes demo-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-12px); }
}

.demo-step-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 4px;
}
.demo-step-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}
.demo-step-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.demo-success {
  font-size: 12px;
  color: #16a34a;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: demo-in 350ms ease-out 0.2s both;
}
[data-theme='dark'] .demo-success { color: #4ade80; }
.demo-success::before {
  content: '✓';
  display: inline-flex;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #16a34a;
  color: white;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}

/* QR frame */
.demo-qr {
  width: 160px;
  height: 160px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 1px;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.demo-qr-cell {
  background: #1a1d23;
}
.demo-qr-cell.empty { background: white; }
.demo-qr::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #16a34a, transparent);
  top: 12px;
  border-radius: 2px;
  animation: qr-scan 1.6s ease-in-out infinite;
  box-shadow: 0 0 12px rgba(22, 163, 74, 0.6);
}
@keyframes qr-scan {
  0%   { top: 12px; opacity: 0.9; }
  50%  { top: 142px; opacity: 1; }
  100% { top: 12px; opacity: 0.9; }
}

/* Sheet frame */
.demo-sheet {
  width: 100%;
  max-width: 290px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
[data-theme='dark'] .demo-sheet { background: #20242c; }
.demo-sheet-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 100, 50, 0.05);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
[data-theme='dark'] .demo-sheet-head { background: rgba(34, 197, 94, 0.08); }
.demo-sheet-head::before {
  content: '📊';
  font-size: 14px;
}
.demo-sheet-row {
  padding: 7px 12px;
  font-size: 11.5px;
  color: var(--text);
  border-bottom: 1px solid var(--border-soft, rgba(0,0,0,0.04));
  font-family: 'SF Mono', Menlo, monospace;
  animation: sheet-row-in 260ms ease-out both;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.demo-sheet-row:last-child { border-bottom: none; }
.demo-sheet-row.more {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  font-family: inherit;
}
@keyframes sheet-row-in {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Questions frame */
.demo-questions {
  width: 100%;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.demo-q-item {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--text);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
  animation: q-item-in 320ms ease-out both;
}
[data-theme='dark'] .demo-q-item { background: #20242c; }
.demo-q-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
@keyframes q-item-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Launch frame */
.demo-launch-summary {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
  box-shadow: var(--shadow-sm);
}
[data-theme='dark'] .demo-launch-summary { background: #20242c; }
.demo-launch-button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 14px 32px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.35);
  animation: launch-pulse 1.2s ease-in-out infinite;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.demo-launch-button.fired {
  animation: none;
  opacity: 0.6;
  cursor: default;
}
@keyframes launch-pulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(124, 58, 237, 0.35); transform: scale(1); }
  50%      { box-shadow: 0 12px 32px rgba(124, 58, 237, 0.55); transform: scale(1.04); }
}
.demo-launch-button::before { content: '🚀'; }

.demo-progress {
  width: 100%;
  max-width: 220px;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.demo-progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  width: 0;
  animation: progress 1.6s ease-out forwards;
}
@keyframes progress {
  from { width: 0; }
  to   { width: 100%; }
}

/* Step indicator dots */
.demo-dots {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
}
.demo-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-soft);
  opacity: 0.35;
  transition: opacity 200ms, background 200ms, transform 200ms;
}
.demo-dot.active {
  background: var(--accent);
  opacity: 1;
  transform: scale(1.3);
}

/* Tagline */
.tagline {
  margin: 24px auto 0;
  text-align: center;
  font-size: 15px;
  color: var(--text-muted);
  max-width: 600px;
  line-height: 1.5;
}
.scene-counter {
  margin: 8px auto 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 500;
}

/* Responsive */
@media (max-width: 1100px) {
  .stage-body { grid-template-columns: auto 1fr auto; }
  .callouts-left, .callouts-right { display: none; }
  .arrow { margin-top: 220px; }
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 220px 1fr; }
  .arrow { width: 44px; height: 44px; font-size: 22px; }
}
@media (max-width: 700px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 12px;
    gap: 8px;
  }
  .sidebar-head, .sidebar-ctas { display: none; }
  .scene-list { flex-direction: row; gap: 6px; }
  .scene-list-item { white-space: nowrap; }
  .stage { padding: 16px; }
  .arrow { margin-top: 180px; }
}
