/* ── Reset & Variables ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-dark: #0a0a0f;
  --bg-modal: #0d0d14;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.4);
  --accent-soft: rgba(99, 102, 241, 0.15);
  --green: #22c55e;
  --green-glow: rgba(34, 197, 94, 0.3);
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.4);
  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --text-muted: #55556a;
  --glass: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
}

/* ── Demo Page ── */
.demo-page {
  text-align: center;
  padding: 2rem;
}

.demo-page h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #fff 0%, #8888a0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.demo-page p {
  color: var(--text-secondary);
  font-size: 1rem;
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ── Floating Call Button ── */
.call-trigger {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 4px 24px var(--accent-glow),
    0 0 0 0 var(--accent-glow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 900;
  animation: trigger-pulse 3s ease-in-out infinite;
}

.call-trigger:hover {
  transform: scale(1.1);
  box-shadow:
    0 8px 32px var(--accent-glow),
    0 0 0 8px rgba(99, 102, 241, 0.1);
}

.call-trigger:active {
  transform: scale(0.95);
}

.call-trigger svg {
  width: 26px;
  height: 26px;
}

@keyframes trigger-pulse {
  0%, 100% { box-shadow: 0 4px 24px var(--accent-glow), 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 4px 24px var(--accent-glow), 0 0 0 12px rgba(99, 102, 241, 0); }
}

/* ── Modal Overlay ── */
.call-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 10, 0.92);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.call-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ── Modal Content ── */
.call-modal {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
  max-width: 400px;
  padding: 2rem;
}

.call-modal-overlay.active .call-modal {
  transform: scale(1) translateY(0);
}

/* ── Agent Info ── */
.agent-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.agent-name {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.agent-role {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ── Mic Orb Container ── */
.mic-orb-container {
  position: relative;
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Pulse Rings ── */
.pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--accent-soft);
  opacity: 0;
}

.call-modal-overlay.active.state-connecting .pulse-ring,
.call-modal-overlay.active.state-active .pulse-ring {
  animation: pulse-expand 2.5s ease-out infinite;
}

.pulse-ring:nth-child(1) { animation-delay: 0s; }
.pulse-ring:nth-child(2) { animation-delay: 0.6s; }
.pulse-ring:nth-child(3) { animation-delay: 1.2s; }

@keyframes pulse-expand {
  0% { transform: scale(0.8); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ── Glow Background ── */
.orb-glow {
  position: absolute;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  filter: blur(30px);
  opacity: 0;
  transition: opacity 0.6s ease;
}

.state-connecting .orb-glow {
  opacity: 0.4;
  animation: glow-breathe 2s ease-in-out infinite;
}

.state-active .orb-glow {
  opacity: 0.7;
  animation: glow-breathe-active 1.2s ease-in-out infinite;
}

@keyframes glow-breathe {
  0%, 100% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.15); opacity: 0.5; }
}

@keyframes glow-breathe-active {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.25); opacity: 0.8; }
}

/* ── Main Orb ── */
.mic-orb {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(145deg, #1a1a2e 0%, #0d0d14 100%);
  border: 1.5px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.state-idle .mic-orb {
  border-color: var(--glass-border);
}

.state-connecting .mic-orb {
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 0 40px var(--accent-glow), 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: orb-spin-border 3s linear infinite;
}

.state-active .mic-orb {
  border-color: rgba(34, 197, 94, 0.4);
  box-shadow: 0 0 50px var(--green-glow), 0 8px 32px rgba(0, 0, 0, 0.4);
}

.state-active .mic-orb .mic-icon {
  color: var(--green);
}

@keyframes orb-spin-border {
  0% { border-color: rgba(99, 102, 241, 0.15); }
  50% { border-color: rgba(99, 102, 241, 0.5); }
  100% { border-color: rgba(99, 102, 241, 0.15); }
}

/* ── Mic Icon ── */
.mic-icon {
  color: var(--accent);
  transition: color 0.4s ease;
  z-index: 3;
}

.mic-icon svg {
  width: 40px;
  height: 40px;
}

/* ── Sound Wave Bars ── */
.sound-waves {
  position: absolute;
  bottom: -40px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  height: 28px;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.state-active .sound-waves {
  opacity: 1;
}

.wave-bar {
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(to top, var(--accent), var(--green));
  animation: wave-dance 0.8s ease-in-out infinite alternate;
}

.wave-bar:nth-child(1) { height: 8px; animation-delay: 0.0s; }
.wave-bar:nth-child(2) { height: 16px; animation-delay: 0.1s; }
.wave-bar:nth-child(3) { height: 24px; animation-delay: 0.2s; }
.wave-bar:nth-child(4) { height: 12px; animation-delay: 0.3s; }
.wave-bar:nth-child(5) { height: 20px; animation-delay: 0.15s; }
.wave-bar:nth-child(6) { height: 10px; animation-delay: 0.25s; }
.wave-bar:nth-child(7) { height: 18px; animation-delay: 0.05s; }

@keyframes wave-dance {
  0% { transform: scaleY(0.3); }
  100% { transform: scaleY(1); }
}

/* ── Status Area ── */
.call-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  min-height: 50px;
}

.status-label {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  transition: color 0.3s ease;
}

.state-connecting .status-label { color: var(--accent); }
.state-active .status-label { color: var(--green); }

.call-timer {
  font-family: 'Outfit', sans-serif;
  font-size: 1.8rem;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.state-active .call-timer {
  opacity: 1;
  color: var(--text-primary);
}

/* ── Transcript ── */
.transcript-box {
  width: 100%;
  max-height: 80px;
  overflow: hidden;
  text-align: center;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.state-active .transcript-box {
  opacity: 1;
}

.transcript-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  font-style: italic;
}

/* ── Hang Up Button ── */
.hangup-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--red), #dc2626);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px var(--red-glow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  transform: translateY(10px);
}

.state-connecting .hangup-btn,
.state-active .hangup-btn {
  opacity: 1;
  transform: translateY(0);
}

.hangup-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 32px var(--red-glow);
}

.hangup-btn:active {
  transform: scale(0.95);
}

.hangup-btn svg {
  width: 26px;
  height: 26px;
}

/* ── Connecting Dots ── */
.connecting-dots span {
  animation: dot-blink 1.4s infinite;
  opacity: 0;
}

.connecting-dots span:nth-child(1) { animation-delay: 0s; }
.connecting-dots span:nth-child(2) { animation-delay: 0.2s; }
.connecting-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-blink {
  0%, 60%, 100% { opacity: 0; }
  30% { opacity: 1; }
}

/* ── Background Ambient ── */
.ambient-bg {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.06) 0%, transparent 70%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.state-active .ambient-bg {
  opacity: 1;
  animation: ambient-drift 8s ease-in-out infinite alternate;
}

@keyframes ambient-drift {
  0% { transform: translate(-30px, -20px) scale(1); }
  100% { transform: translate(30px, 20px) scale(1.1); }
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .mic-orb-container {
    width: 160px;
    height: 160px;
  }

  .mic-orb {
    width: 100px;
    height: 100px;
  }

  .mic-icon svg {
    width: 32px;
    height: 32px;
  }

  .call-timer {
    font-size: 1.5rem;
  }

  .agent-name {
    font-size: 1.2rem;
  }
}
