@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-gradient: radial-gradient(circle at 50% 20%, #1e1b4b 0%, #0f172a 50%, #030712 100%);
  --surface: rgba(15, 23, 42, 0.75);
  --surface-border: rgba(255, 255, 255, 0.12);
  --surface-hover: rgba(255, 255, 255, 0.08);
  
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.4);
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.4);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-full: 9999px;
  
  --shadow-glow: 0 0 50px -10px var(--primary-glow);
  --glass-blur: blur(24px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
}

/* Ambient dynamic background lighting */
.ambient-glow {
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--primary-glow) 0%, rgba(6, 182, 212, 0.15) 50%, transparent 70%);
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
  animation: floatAmbient 12s ease-in-out infinite alternate;
}

@keyframes floatAmbient {
  0% { transform: translate(-20%, -20%) scale(1); }
  50% { transform: translate(20%, 20%) scale(1.15); }
  100% { transform: translate(-10%, 10%) scale(0.95); }
}

/* Main Call Screen Container */
.call-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 540px;
  height: 92vh;
  max-height: 880px;
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), var(--shadow-glow);
  overflow: hidden;
}

/* Header */
.call-header {
  padding: 24px 28px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.clinic-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.clinic-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.clinic-details h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.clinic-details p {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.call-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.07);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-subtle);
  transition: all 0.3s ease;
}

.status-dot.active {
  background: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
  animation: pulseDot 2s infinite;
}

.status-dot.connecting {
  background: #f59e0b;
  box-shadow: 0 0 10px #f59e0b;
  animation: pulseDot 1s infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Call Body (Orb + Transcription) */
.call-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  overflow: hidden;
  position: relative;
}

/* Visualizer Orb Area */
.visualizer-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  position: relative;
}

.orb-wrapper {
  position: relative;
  width: 60px;
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.orb-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(99, 102, 241, 0.25);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.orb-ring.r1 { width: 100%; height: 100%; animation: spinSlow 20s linear infinite; }
.orb-ring.r2 { width: 125%; height: 125%; border-color: rgba(6, 182, 212, 0.15); animation: spinReverse 25s linear infinite; }
.orb-ring.r3 { width: 150%; height: 150%; border-color: rgba(99, 102, 241, 0.08); }

@keyframes spinSlow { to { transform: rotate(360deg); } }
@keyframes spinReverse { to { transform: rotate(-360deg); } }

.voice-orb {
  width: 43px;
  height: 43px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #818cf8 0%, #4f46e5 50%, #06b6d4 100%);
  box-shadow: 0 0 40px var(--primary-glow), inset 0 0 20px rgba(255, 255, 255, 0.4);
  transition: transform 0.1s ease-out, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.voice-orb::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 60%);
  animation: orbShine 6s infinite linear;
}

@keyframes orbShine {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.voice-orb.thinking {
  animation: orbThinking 1.3s ease-in-out infinite;
}

@keyframes orbThinking {
  0%, 100% {
    box-shadow: 0 0 40px rgba(245, 158, 11, 0.5), inset 0 0 20px rgba(255, 255, 255, 0.4);
  }
  50% {
    box-shadow: 0 0 68px rgba(245, 158, 11, 0.9), inset 0 0 26px rgba(255, 255, 255, 0.6);
  }
}

/* "Acting" — a tool/function call is actively running (booking, checking slots, etc.) */
.voice-orb.acting {
  animation: orbActing 0.9s ease-in-out infinite;
}

@keyframes orbActing {
  0%, 100% {
    box-shadow: 0 0 42px rgba(34, 211, 238, 0.55), inset 0 0 20px rgba(255, 255, 255, 0.4);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 72px rgba(34, 211, 238, 0.95), inset 0 0 26px rgba(255, 255, 255, 0.6);
    transform: scale(1.04);
  }
}

@keyframes dotBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.status-banner {
  width: 100%;
  text-align: center;
  padding: 10px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.speaking-state-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  text-transform: uppercase;
  transition: color 0.3s;
}

/* Audio Waveform Bars */
.waveform-container {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  margin-top: 8px;
}

.waveform-bar {
  width: 5px;
  height: 5px;
  background: var(--text-subtle);
  border-radius: var(--radius-full);
  transition: height 0.08s ease, background 0.2s;
}

/* Live Transcription Stream */
.transcript-section {
  width: 100%;
  flex: 1;
  margin-top: 16px;
  background: none;
  border: none;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  gap: 18px;
  scroll-behavior: smooth;
}

.transcript-section::-webkit-scrollbar {
  width: 4px;
}
.transcript-section::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
}

.empty-transcript {
  margin: auto;
  text-align: center;
  color: var(--text-subtle);
  font-size: 13px;
  font-weight: 500;
}

.chat-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 94%;
  animation: slideUpFade 0.25s ease-out forwards;
}

.chat-row.assistant { align-self: flex-start; }
.chat-row.user { align-self: flex-end; flex-direction: row-reverse; }

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

.chat-avatar {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.chat-row.user .chat-avatar {
  background: rgba(6, 182, 212, 0.18);
  border-color: rgba(6, 182, 212, 0.35);
}

.chat-bubble-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-row.user .chat-bubble-col { align-items: flex-end; }

.chat-bubble {
  font-size: 16px;
  line-height: 1.6;
  padding: 12px 16px;
  border-radius: 16px;
}

.chat-bubble.assistant {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
}

.chat-bubble.user {
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.bubble-time {
  font-size: 11px;
  color: var(--text-subtle);
  margin-top: 4px;
  padding: 0 4px;
}

.chat-row.user .bubble-time { text-align: right; }

.bubble-text {
  word-break: break-word;
}

/* ChatGPT-style typing indicator bubble, shown in the transcript while thinking/acting */
.typing-bubble-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 18px;
  padding: 2px 0;
}

.typing-bubble-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a5b4fc;
  animation: dotBounce 1.2s infinite ease-in-out;
}

.typing-bubble-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-bubble-dots span:nth-child(3) { animation-delay: 0.3s; }

.email-badge {
  display: inline-block;
  background: rgba(99, 102, 241, 0.22);
  color: #a5b4fc;
  border: 1px solid rgba(165, 180, 252, 0.35);
  padding: 2px 8px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9em;
  font-weight: 600;
  margin: 0 2px;
  vertical-align: baseline;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Call Control Footer */
.call-footer {
  padding: 20px 28px 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(15, 23, 42, 0.5);
}

.control-btn {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font-size: 22px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.control-btn:active {
  transform: translateY(1px) scale(0.96);
}

.control-btn.active-off {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--danger);
}

.control-btn.btn-call {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: none;
  color: white;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
}

.control-btn.btn-call:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 6px 24px rgba(16, 185, 129, 0.6);
}

.control-btn.btn-end {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border: none;
  color: white;
  box-shadow: 0 4px 20px var(--danger-glow);
}

.control-btn.btn-end:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 6px 24px rgba(239, 68, 68, 0.6);
}

/* Pre-call Start Hero View */
.start-view {
  position: absolute;
  inset: 0;
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 36px 28px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.start-view.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.96);
}

.hero-content {
  text-align: center;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-avatar {
  width: 90px;
  height: 90px;
  border-radius: 28px;
  background: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 42px;
  margin-bottom: 20px;
  box-shadow: 0 12px 30px rgba(99, 102, 241, 0.4);
}

.hero-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.hero-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.5;
  margin-bottom: 24px;
}

.quick-prompts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.prompt-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: #cbd5e1;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
}

.prompt-chip span {
  font-size: 16px;
}

.start-btn {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: none;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.4);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(79, 70, 229, 0.6);
}

.start-btn:active {
  transform: translateY(1px);
}
