/* voice-widget.css - Minimal styles for ElevenLabs voice agent POC */
/* ================================================================= */

/* Apple-Grade Icon System - Lucide-inspired with performance optimization */
/* ======================================================================== */
:root {
  /* Icon Design Tokens */
  --icon-size: 20px;
  --icon-passive: #c5d0e4;      /* soft neutral - matches avatar border */
  --icon-hover: #ff4f64;        /* brand coral - matches CTA buttons */
  --icon-active: #ff4f64;       /* consistent active state */
  --icon-muted: #5c6b73;        /* muted microphone state */
  
  /* Performance-optimized transitions - shadows/blur only on interaction */
  --icon-transition: color 0.15s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --icon-shadow-hover: 0 8px 25px rgba(59, 130, 246, 0.4);
}

/* Base Icon Button Component */
.icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;  /* Touch target compliance */
  min-height: 44px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  cursor: pointer;
  transition: var(--icon-transition);
  color: var(--icon-passive);
  /* Remove backdrop-filter for performance - only add on hover */
}

.icon-btn svg {
  width: var(--icon-size);
  height: var(--icon-size);
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none; /* Clicks go to button */
  transition: var(--icon-transition);
}

/* Interaction States - Performance optimized */
.icon-btn:hover {
  color: var(--icon-hover);
  transform: scale(1.1);
  backdrop-filter: blur(10px); /* Only on hover for performance */
  box-shadow: var(--icon-shadow-hover);
}

.icon-btn:active {
  color: var(--icon-active);
  transform: scale(0.95);
}

.icon-btn:focus-visible {
  outline: 2px solid var(--icon-hover);
  outline-offset: 2px;
}

/* Mute State Specific */
.icon-btn.muted {
  color: var(--icon-muted);
  border-color: rgba(239, 68, 68, 0.3);
}

.icon-btn.muted:hover {
  color: var(--icon-hover);
  background: rgba(239, 68, 68, 0.1);
}

/* Subtle breathing animation for passive state - performance optimized */
.icon-btn:not(:hover):not(:active):not(.muted) svg {
  animation: iconBreathe 3s ease-in-out infinite;
}

@keyframes iconBreathe {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

/* Icon visibility utilities */
.icon-hidden {
  display: none;
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Info icon styling */
.info-icon {
  width: var(--icon-size) !important;
  height: var(--icon-size) !important;
  max-width: var(--icon-size) !important;
  max-height: var(--icon-size) !important;
  margin-right: 0.5rem;
  display: inline-block;
  flex-shrink: 0;
}

/* Comprehensive SVG icon size constraints */
svg {
  max-width: var(--icon-size);
  max-height: var(--icon-size);
}

/* Specific overrides for button SVGs */
.call-button svg,
.voice-flip-trigger svg,
.welcome-icon svg {
  width: var(--icon-size) !important;
  height: var(--icon-size) !important;
  max-width: var(--icon-size) !important;
  max-height: var(--icon-size) !important;
  flex-shrink: 0;
}

/* Welcome icon should be larger but controlled */
.welcome-icon svg {
  width: 2rem !important;
  height: 2rem !important;
  max-width: 2rem !important;
  max-height: 2rem !important;
}


/* Flip Card Styles */
.voice-flip-card {
  perspective: 1000px;
  width: 450px;
  max-width: 100%;
  margin: 2rem auto;
  min-height: 480px;     /* Reduced for better mobile fit */
  max-height: 90vh;      /* Prevent exceeding viewport */
  height: auto;          /* allow growth */
  box-sizing: border-box;
  transition: min-height 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.voice-flip-card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.voice-flip-card-inner.flipped {
  transform: rotateY(180deg);
}

.voice-flip-card-front,
.voice-flip-card-back {
  width: 100%;
  height: 100%;
  position: absolute;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 20px;
  overflow: hidden;
  will-change: transform;
}

.voice-flip-card-front {
  background: linear-gradient(135deg, 
    rgba(30, 41, 59, 0.95) 0%, 
    rgba(15, 23, 42, 0.98) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 0 100px rgba(59, 130, 246, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-flip-card-back {
  transform: rotateY(180deg);
  background: transparent;
  display: flex;
  position: relative;
  width: 450px;
  max-width: 100%;
}

.voice-flip-card-back > #voice-conversation-container {
  flex: 1;
  display: flex;
  width: 100%;
}

.voice-flip-card-back .voice-chat-container {
  height: 100%;
  width: 100%;
  max-width: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 0 100px rgba(59, 130, 246, 0.1);
}

/* Agent Profile (Front Face) */
.agent-profile {
  text-align: center;
  padding: 3rem 2.5rem;
}

.agent-avatar-large {
  width: 150px;
  height: 150px;
  margin: 0 auto 2.5rem;
  position: relative;
}

.agent-avatar-large::before {
  content: '';
  position: absolute;
  inset: -4px;
  background: linear-gradient(45deg, #3b82f6, #8b5cf6, #ec4899, #3b82f6);
  border-radius: 50%;
  opacity: 0.3;
  animation: rotate 6s linear infinite;
  z-index: -1;
}

.agent-avatar-large img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid rgba(59, 130, 246, 0.3);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.9) 100%);
  box-shadow: 
    0 10px 30px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  position: relative;
  z-index: 2;
}

.agent-name {
  font-size: 1.875rem;
  font-weight: 700;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.agent-tagline {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  line-height: 1.4;
}


.voice-flip-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border: none;
  border-radius: 50px;
  color: white;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 4px 15px rgba(59, 130, 246, 0.3),
    0 1px 2px rgba(0, 0, 0, 0.2) inset;
}

.voice-flip-trigger:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 8px 25px rgba(59, 130, 246, 0.4),
    0 1px 2px rgba(0, 0, 0, 0.2) inset;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.voice-flip-trigger:active {
  transform: translateY(0);
}

.voice-flip-trigger i {
  font-size: 1.25rem;
}

/* Close Button */
.voice-flip-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  /* backdrop-filter removed for performance - only on hover */
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: white;
  font-size: 1.125rem;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 1000;
}

.voice-flip-close[hidden] {
  display: none !important;
}

.voice-flip-close:hover {
  background: rgba(239, 68, 68, 0.8);
  border-color: rgba(239, 68, 68, 0.3);
  transform: scale(1.1);
  backdrop-filter: blur(10px); /* Performance optimization - only on hover */
  -webkit-backdrop-filter: blur(10px);
}

/* Voice Chat Container */
.voice-chat-container {
  position: relative;
  max-width: 450px;
  margin: 2rem auto;
  padding: 0;
  background: linear-gradient(135deg, 
    rgba(30, 41, 59, 0.95) 0%, 
    rgba(15, 23, 42, 0.98) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 0 100px rgba(59, 130, 246, 0.1);
  overflow: visible;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  transform: scale(0.95);
  will-change: opacity, transform;
}

.voice-chat-container.initialized {
  opacity: 1;
  transform: scale(1);
}

/* Agent Section */
.agent-section {
  position: relative;
  padding: 2rem 1.5rem 1rem;  /* Increased top padding for expanded waveform area */
  background: 
    radial-gradient(circle at 50% 0%, rgba(59, 130, 246, 0.12) 0%, transparent 65%),
    linear-gradient(135deg, rgba(59, 130, 246, 0.06) 0%, rgba(139, 92, 246, 0.06) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
  overflow: visible; /* Explicitly allow waveform effects to extend beyond bounds */
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  min-height: 140px; /* Ensure sufficient space for expanded waveforms */
}

.agent-avatar {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 15px auto 1.5rem auto;  /* Increased top margin for waveform space */
  z-index: 2; /* Higher z-index to stay above waveform */
  width: 80px;
  height: 80px;
}

/* Waveform Container - Responsive area for agent waveform */
.agent-waveform-container {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(95vw, 480px);  /* Enhanced: 95% of viewport width, max 480px for better flow */
  height: min(95vw, 480px); /* Enhanced: 95% of viewport width, max 480px for better flow */
  min-width: 320px;         /* Increased minimum size for better waveform display */
  min-height: 320px;        /* Increased minimum size for better waveform display */
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 0; /* Behind avatar */
  opacity: 0;
  transition: opacity 0.3s ease;
  overflow: visible;        /* Explicitly allow waveform effects to extend gracefully */
}

.agent-waveform-container.active {
  opacity: 1;
}

.agent-avatar::before {
  content: '';
  position: absolute;
  inset: -6px;  /* Increased from -3px to -6px for better visual presence */
  background: linear-gradient(45deg, #3b82f6, #8b5cf6, #ec4899, #3b82f6);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.3s ease;
  animation: rotate 3s linear infinite;
  z-index: -1;
}

.agent-avatar.active::before {
  opacity: 1;
}

@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.agent-avatar img {
  width: 80px;  /* Refined size */
  height: 80px;
  max-width: 80px;
  max-height: 80px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid rgba(59, 130, 246, 0.25);  /* Subtler border */
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.9) 100%);
  box-shadow: 
    0 3px 16px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  position: relative;
  z-index: 2;
  will-change: transform, filter;
  transform: scale(1);
  animation: breathing 4s ease-in-out infinite;
}

/* Elegant breathing animation for idle state */
@keyframes breathing {
  0%, 100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.02);
    opacity: 1;
  }
}

/* Idle state breathing glow */
.agent-avatar.idle::after {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.2) 0%, transparent 70%);
  animation: idleGlow 3s ease-in-out infinite;
  z-index: -1;
  pointer-events: none;
}

@keyframes idleGlow {
  0%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.1);
  }
}

/* Agent speaking state - pause breathing, add active effects */
.agent-avatar.agent-speaking img {
  animation-play-state: paused;
  transform: scale(1.05);
}

.agent-avatar.agent-speaking::after {
  display: none; /* Hide idle glow when speaking */
}

/* User speaking state - subtle avatar dimming */
.agent-avatar.user-speaking img {
  opacity: 0.7;
  animation-play-state: paused;
}

.agent-avatar.user-speaking::after {
  display: none; /* Hide idle glow when user is speaking */
}

.agent-avatar img.active {
  border-color: transparent;
  transform: scale(1.05);
  box-shadow: 
    0 8px 30px rgba(59, 130, 246, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.2) inset,
    0 0 40px rgba(59, 130, 246, 0.3);
}

/* User Waveform - Card Border Pulse Effect */
.voice-chat-container {
  transition: box-shadow 0.3s ease, border 0.3s ease;
}

.voice-chat-container.user-speaking {
  border: 2px solid rgba(59, 130, 246, 0.6);
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 0 100px rgba(59, 130, 246, 0.1),
    /* User speaking pulse rings */
    0 0 0 4px rgba(59, 130, 246, 0.4),
    0 0 0 8px rgba(59, 130, 246, 0.2),
    0 0 0 12px rgba(59, 130, 246, 0.1),
    0 0 40px rgba(59, 130, 246, 0.3);
  animation: userSpeakingPulse 2s ease-in-out infinite;
}

@keyframes userSpeakingPulse {
  0%, 100% {
    box-shadow: 
      0 20px 50px rgba(0, 0, 0, 0.5),
      0 0 0 1px rgba(255, 255, 255, 0.05) inset,
      0 0 100px rgba(59, 130, 246, 0.1),
      0 0 0 4px rgba(59, 130, 246, 0.4),
      0 0 0 8px rgba(59, 130, 246, 0.2),
      0 0 0 12px rgba(59, 130, 246, 0.1),
      0 0 40px rgba(59, 130, 246, 0.3);
    transform: scale(1);
  }
  50% {
    box-shadow: 
      0 20px 50px rgba(0, 0, 0, 0.5),
      0 0 0 1px rgba(255, 255, 255, 0.05) inset,
      0 0 100px rgba(59, 130, 246, 0.1),
      0 0 0 8px rgba(59, 130, 246, 0.6),
      0 0 0 16px rgba(59, 130, 246, 0.3),
      0 0 0 24px rgba(59, 130, 246, 0.1),
      0 0 60px rgba(59, 130, 246, 0.5);
    transform: scale(1.01);
  }
}

/* Agent Waveform Canvas - Responsive size */
.agent-waveform-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;  /* Fill container responsively */
  height: 100%; /* Fill container responsively */
  max-width: 400px;  /* Maximum size limit */
  max-height: 400px; /* Maximum size limit */
  pointer-events: none;
  z-index: 1;
}

/* Chat Window */
.chat-window {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.chat-window:not(.in-call) {
  min-height: auto;        /* Let content determine height */
  max-height: none;        /* Remove height restriction for initial state */
  overflow-y: hidden;      /* Completely hide scroll when not in call */
  padding-bottom: 0;       /* Remove extra padding */
}

.chat-window.in-call,
.chat-window.post-call {
  min-height: 200px;       /* Minimum height during call */
  max-height: 500px;       /* Maximum before scroll */
  height: auto;            /* Dynamic height based on content */
  overflow-y: auto;        /* Enable scroll when content exceeds max-height */
  background: 
    linear-gradient(to bottom, 
      rgba(0, 0, 0, 0.3) 0%, 
      rgba(0, 0, 0, 0.2) 100%);
}

/* Smooth height transition when content changes */
.chat-window.in-call:has(.chat-message) {
  animation: expandHeight 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes expandHeight {
  from {
    max-height: 200px;
  }
  to {
    max-height: 600px;
  }
}

.chat-messages {
  padding: 0.75rem;  /* More refined padding */
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-welcome {
  text-align: center;
  padding: 1rem 1rem;  /* Tighter, more refined padding */
  color: var(--text-secondary);
  background: 
    radial-gradient(circle at 50% 25%, rgba(59, 130, 246, 0.08) 0%, transparent 65%),
    linear-gradient(135deg, 
      rgba(59, 130, 246, 0.04) 0%, 
      rgba(139, 92, 246, 0.04) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;  /* Slightly smaller radius for refinement */
  margin: 0.5rem 0.75rem 1rem;  /* Optimized margins */
  box-shadow: 
    0 2px 12px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.welcome-icon {
  font-size: 2rem;  /* More refined size */
  color: #3b82f6;
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.25));
}

.chat-welcome h3 {
  font-size: 1.125rem;  /* Slightly smaller for balance */
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.chat-welcome p {
  font-size: 0.875rem;  /* More refined typography */
  line-height: 1.4;
  margin: 0 0 0.5rem 0;
  opacity: 0.75;
}

.chat-welcome p:last-child {
  margin-bottom: 0;  /* Remove margin from last paragraph */
}

/* Chat Messages */
.chat-message {
  padding: 0.875rem 1.25rem;
  margin-bottom: 0.5rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  animation: slideIn 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform-origin: bottom;
  transition: all 0.2s ease;
}

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

.chat-message.user {
  background: linear-gradient(135deg, 
    rgba(59, 130, 246, 0.12) 0%, 
    rgba(59, 130, 246, 0.08) 100%);
  border-left: 3px solid #3b82f6;
  border-color: rgba(59, 130, 246, 0.5);
  margin-left: 2rem;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.1);
}

.chat-message.agent {
  background: linear-gradient(135deg, 
    rgba(139, 92, 246, 0.12) 0%, 
    rgba(139, 92, 246, 0.08) 100%);
  border-left: 3px solid #8b5cf6;
  border-color: rgba(139, 92, 246, 0.5);
  margin-right: 2rem;
  box-shadow: 0 2px 10px rgba(139, 92, 246, 0.1);
}

.chat-message.system {
  background: linear-gradient(135deg, 
    rgba(34, 197, 94, 0.1) 0%, 
    rgba(34, 197, 94, 0.05) 100%);
  border: 1px solid rgba(34, 197, 94, 0.3);
  text-align: center;
  font-size: 0.875rem;
  margin: 0.75rem 2rem;
  box-shadow: 0 2px 10px rgba(34, 197, 94, 0.1);
}

.message-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.message-header i {
  font-size: 0.875rem;
  padding: 0.25rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.message-label {
  font-weight: 600;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.message-time {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.message-text {
  color: var(--text-primary);
  line-height: 1.5;
}

.message-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  color: #22c55e;
}

.message-content i {
  font-size: 1rem;
}

/* Call Button */
.call-button {
  width: calc(100% - 1.5rem);  /* Refined width with margins */
  margin: 0 0.75rem 0.75rem;   /* Add side margins for better proportion */
  padding: 1rem 1.5rem;        /* More refined padding */
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border: none;
  border-radius: 12px;         /* Add border radius for refinement */
  font-size: 1rem;             /* Slightly smaller font */
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  position: relative;
  overflow: hidden;
  box-shadow: 
    0 3px 12px rgba(59, 130, 246, 0.25),
    0 1px 2px rgba(0, 0, 0, 0.15) inset,
    0 0 0 1px rgba(255, 255, 255, 0.05) inset;
}

.call-button:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  transform: translateY(-2px);
  box-shadow: 
    0 6px 20px rgba(59, 130, 246, 0.4),
    0 2px 4px rgba(0, 0, 0, 0.2) inset;
}

.call-button:active {
  transform: translateY(0);
  box-shadow: 
    0 2px 10px rgba(59, 130, 246, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.3) inset;
}

.call-button.active {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.call-button.active:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

.call-button i {
  font-size: 1.25rem;
  transition: all 0.3s ease;
}

/* Connection Status Indicator */
.connection-status {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.7rem;
  transition: all 0.3s ease;
  opacity: 0.8;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b7280;
  transition: all 0.3s ease;
  position: relative;
}

.status-dot.connected {
  background: #22c55e;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
}

.status-dot.connecting {
  background: #f59e0b;
  animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.status-dot.disconnected {
  background: #6b7280;
}

/* Mute Button */
.mute-button {
  position: absolute;
  top: 0.75rem;
  min-width: 44px;  /* WCAG compliance for touch targets */
  min-height: 44px;
  display: none;  /* hidden by default, shown on call start */
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  /* backdrop-filter removed for performance - only on hover */
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease, top 0.15s ease, right 0.15s ease;  /* Smooth position transitions */
  color: var(--icon-passive);
  z-index: 1001;  /* Higher than close button to prevent overlap */
}

.mute-button:hover {
  color: var(--icon-hover);
  transform: scale(1.1);
  backdrop-filter: blur(10px); /* Only on hover for performance */
  box-shadow: var(--icon-shadow-hover);
}

.mute-button:active {
  color: var(--icon-active);
  transform: scale(0.95);
}

.mute-button:focus-visible {
  outline: 2px solid var(--icon-hover);
  outline-offset: 2px;
}

.mute-button.muted {
  color: var(--icon-muted);
  border-color: rgba(239, 68, 68, 0.3);
}

.mute-button.muted:hover {
  color: var(--icon-hover);
  background: rgba(239, 68, 68, 0.1);
}

/* Mute Button Positioning Classes */
.mute-button.mute--offset {
  right: 3.5rem;  /* Non-overlapping position when close button is visible */
}

.mute-button.mute--overlap {
  right: 1rem;    /* Overlapping position when close button is hidden */
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: rgba(139, 92, 246, 0.1);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

/* Notification Styles */
.notification {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  padding: 0.75rem 1.5rem;
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: white;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
}

.notification.show {
  transform: translateX(-50%) translateY(0);
}

.notification-success {
  border-color: rgba(34, 197, 94, 0.3);
  background: linear-gradient(135deg, 
    rgba(34, 197, 94, 0.15) 0%, 
    rgba(30, 41, 59, 0.95) 100%);
}

.notification-error {
  border-color: rgba(239, 68, 68, 0.3);
  background: linear-gradient(135deg, 
    rgba(239, 68, 68, 0.15) 0%, 
    rgba(30, 41, 59, 0.95) 100%);
}

.notification i {
  font-size: 1.125rem;
}

/* Mobile safeguard for very small screens */
@media (max-width: 420px) {
  .voice-flip-card {
    width: 95%;
    min-height: 420px;    /* Further reduced height for small screens */
    max-height: 85vh;     /* Prevent overflow on small screens */
  }
  
  .chat-welcome {
    padding: 0.5rem 0.5rem; /* Ultra compact padding */
    margin: 0.25rem 0.5rem 0.25rem; /* Minimal margins */
  }
  
  .chat-welcome h3 {
    font-size: 0.875rem;  /* Much smaller heading */
    margin-bottom: 0.25rem;
  }
  
  .chat-welcome p {
    font-size: 0.7rem;    /* Ultra compact text */
    margin: 0 0 0.25rem 0; /* Minimal margins */
    line-height: 1.2;     /* Very tight line height */
  }
  
  .chat-welcome p:last-child {
    margin-bottom: 0;     /* Remove bottom margin from last paragraph */
  }
  
  .welcome-icon {
    font-size: 1.25rem;   /* Smaller icon */
    margin-bottom: 0.25rem; /* Minimal spacing */
  }
  
  .agent-section {
    padding: 1rem 1rem 0.75rem; /* More compact agent section */
  }
  
  .agent-avatar img {
    width: 70px;          /* Smaller avatar on tiny screens */
    height: 70px;
  }
  
  .chat-messages {
    padding: 0.5rem;      /* Reduced padding */
  }
  
  .chat-window:not(.in-call) {
    max-height: 180px;    /* Further reduced for better mobile fit */
  }
}

/* Responsive Design */
@media (max-width: 640px) {
  .voice-flip-card {
    min-height: 520px;
    height: auto;
    margin: 1rem auto;
    width: calc(100% - 2rem);
  }
  
  .agent-profile {
    padding: 2.5rem 2rem;
  }
  
  .agent-avatar-large {
    width: 120px;
    height: 120px;
    margin: 0 auto 2rem;
  }
  
  .agent-name {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
  }
  
  .agent-tagline {
    font-size: 1rem;
    margin-bottom: 1.5rem;
  }
  
  .voice-flip-trigger {
    padding: 0.875rem 2rem;
    font-size: 1rem;
  }
  
  .voice-chat-container {
    margin: 1rem;
    max-width: calc(100% - 2rem);
  }
  
  .agent-section {
    padding: 1.5rem;
  }
  
  .agent-avatar img {
    width: 80px;
    height: 80px;
  }
  
  .chat-window.in-call {
    height: 400px;  /* slightly smaller on mobile but still improved */
  }
  
  .chat-messages {
    padding: 0.75rem;
  }
  
  .call-button {
    padding: 1rem;
    font-size: 1rem;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .agent-avatar img {
    animation: none;
  }
  
  .agent-avatar.idle::after {
    animation: none;
    opacity: 0.4;
  }
  
  .chat-message {
    animation: none;
    opacity: 1;
    transform: none;
  }
  
  .voice-chat-container.user-speaking {
    animation: none;
    /* Keep static glow effect */
    box-shadow: 
      0 20px 50px rgba(0, 0, 0, 0.5),
      0 0 0 1px rgba(255, 255, 255, 0.05) inset,
      0 0 100px rgba(59, 130, 246, 0.1),
      0 0 0 4px rgba(59, 130, 246, 0.4),
      0 0 20px rgba(59, 130, 246, 0.3);
  }
}

/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Premium scrollbar styling - matches dark theme */
.chat-window::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.chat-window::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.3);
  border-radius: 10px;
  margin: 10px 0;
}

.chat-window::-webkit-scrollbar-thumb {
  background: linear-gradient(
    to bottom,
    rgba(59, 130, 246, 0.4),
    rgba(139, 92, 246, 0.4)
  );
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 
    0 0 6px rgba(59, 130, 246, 0.2),
    inset 0 0 6px rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.chat-window::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(
    to bottom,
    rgba(59, 130, 246, 0.6),
    rgba(139, 92, 246, 0.6)
  );
  box-shadow: 
    0 0 12px rgba(59, 130, 246, 0.4),
    inset 0 0 8px rgba(255, 255, 255, 0.2);
}

.chat-window::-webkit-scrollbar-thumb:active {
  background: linear-gradient(
    to bottom,
    rgba(59, 130, 246, 0.8),
    rgba(139, 92, 246, 0.8)
  );
}

/* Firefox scrollbar support */
.chat-window {
  scrollbar-width: thin;
  scrollbar-color: rgba(59, 130, 246, 0.4) rgba(15, 23, 42, 0.3);
}

/* Ripple effect for buttons */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: scale(0);
  animation: ripple-animation 0.6s ease-out;
  pointer-events: none;
}

@keyframes ripple-animation {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Loading dots animation */
.loading-dots {
  display: inline-flex;
  gap: 0.25rem;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.3;
  animation: loading-dot 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) {
  animation-delay: 0s;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes loading-dot {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  30% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* Enhanced Error Notification System */
.error-notification {
  position: fixed;
  top: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: linear-gradient(135deg, 
    rgba(239, 68, 68, 0.95) 0%, 
    rgba(185, 28, 28, 0.95) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 16px;
  box-shadow: 
    0 20px 50px rgba(239, 68, 68, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  z-index: 10000;
  max-width: 90vw;
  width: 500px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
}

.error-notification.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.error-notification.dismissing {
  transform: translateX(-50%) translateY(-100px);
  opacity: 0;
}

.notification-content {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.5rem;
  color: white;
}

.notification-content i:first-child {
  font-size: 1.25rem;
  margin-top: 0.125rem;
  flex-shrink: 0;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.3));
}

.notification-content span {
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.5;
  font-weight: 500;
}

.notification-close {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: white;
  flex-shrink: 0;
}

.notification-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.notification-close:active {
  transform: scale(0.95);
}

/* Loading State Enhancements */
.voice-flip-trigger.loading {
  position: relative;
  pointer-events: none;
  overflow: hidden;
}

.voice-flip-trigger.loading::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

.voice-flip-trigger.loading span {
  opacity: 0.7;
}

.voice-flip-trigger.loading i {
  animation: loading-pulse 1s ease-in-out infinite;
}

@keyframes loading-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.9);
  }
}

/* Enhanced Keyboard Focus States */
.voice-flip-trigger.keyboard-focused {
  outline: 2px solid #3b82f6;
  outline-offset: 4px;
  box-shadow: 
    0 4px 15px rgba(59, 130, 246, 0.3),
    0 1px 2px rgba(0, 0, 0, 0.2) inset,
    0 0 0 4px rgba(59, 130, 246, 0.1);
}

/* Close Button Disabled Feedback */
.voice-flip-close.disabled-feedback {
  animation: disabled-shake 0.4s ease-in-out;
  background: rgba(239, 68, 68, 0.3);
  border-color: rgba(239, 68, 68, 0.5);
}

@keyframes disabled-shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* Screen Reader Only Content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Enhanced Mobile Touch Targets */
@media (max-width: 640px) {
  .error-notification {
    top: 1rem;
    left: 1rem;
    right: 1rem;
    width: auto;
    max-width: none;
    transform: translateY(-200px);
  }
  
  .error-notification.show {
    transform: translateY(0);
  }
  
  .error-notification.dismissing {
    transform: translateY(-200px);
  }
  
  .notification-content {
    padding: 1.25rem;
  }
  
  /* Larger touch targets on mobile */
  .voice-flip-trigger {
    min-height: 48px;
    touch-action: manipulation;
  }
  
  .voice-flip-close {
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
  }
  
  .mute-button {
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .error-notification {
    background: #dc2626;
    border: 2px solid #ffffff;
  }
  
  .voice-flip-trigger {
    border: 2px solid var(--color-primary);
  }
  
  .voice-flip-close {
    border: 2px solid rgba(255, 255, 255, 0.5);
  }
}

/* Helper classes used in index.html */
.min-h-screen {
  min-height: 100vh;
}

.cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
  color: white;
  border: none;
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-xl);
  font-weight: 600;
  font-size: var(--text-base);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
  transition: all var(--transition-base);
  cursor: pointer;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.5);
  background: linear-gradient(135deg, var(--color-primary-hover) 0%, var(--color-primary) 100%);
}

.cta-btn:active {
  transform: translateY(0);
}

.cta-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}
