/**
 * Voice Interface Styles
 *
 * Styles for voice-first UI components including:
 * - Microphone controls
 * - Audio visualizer
 * - Voice interface container
 * - Animations and transitions
 */

/* ========================================
   Voice Interface Container
   ======================================== */

.voice-interface {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 2rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 1rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  min-height: 400px;
}

.voice-interface--listening {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.voice-interface--speaking {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  animation: pulse-glow 2s ease-in-out infinite;
}

.voice-interface--agent-speaking {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  animation: pulse-glow 2s ease-in-out infinite;
}

.voice-interface--thinking {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  }
  50% {
    box-shadow: 0 10px 60px rgba(0, 0, 0, 0.3), 0 0 30px rgba(255, 255, 255, 0.2);
  }
}

/* ========================================
   Microphone Controls
   ======================================== */

.microphone-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Permission Request State */
.microphone-controls--permission,
.microphone-controls--denied {
  align-items: center;
  text-align: center;
  padding: 2rem;
}

.microphone-controls__permission,
.microphone-controls__error {
  max-width: 400px;
}

.microphone-controls__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.microphone-controls__icon--inactive {
  background: rgba(255, 255, 255, 0.15);
}

.microphone-controls__icon--error {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.microphone-controls__title {
  font-size: 1.5rem;
  font-weight: 600;
  color: white;
  margin: 0 0 0.5rem;
}

.microphone-controls__description {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.9);
  margin: 0 0 1.5rem;
  line-height: 1.5;
}

.microphone-controls__actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.microphone-controls__button {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.microphone-controls__button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.microphone-controls__button--primary {
  background: white;
  color: #667eea;
}

.microphone-controls__button--primary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.95);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.microphone-controls__button--primary:active:not(:disabled) {
  transform: translateY(0);
}

.microphone-controls__button--secondary {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.microphone-controls__button--secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

/* Active Controls */
.microphone-controls--active {
  flex-direction: row;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.microphone-controls__toggle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.microphone-controls__toggle:focus {
  outline: 3px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.microphone-controls__toggle--active {
  background: rgba(34, 197, 94, 0.9);
  color: white;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.microphone-controls__toggle--active:hover:not(:disabled) {
  background: rgba(34, 197, 94, 1);
  transform: scale(1.05);
}

.microphone-controls__toggle--muted {
  background: rgba(239, 68, 68, 0.9);
  color: white;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.microphone-controls__toggle--muted:hover:not(:disabled) {
  background: rgba(239, 68, 68, 1);
  transform: scale(1.05);
}

.microphone-controls__toggle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.microphone-controls__level {
  flex: 1;
  min-width: 200px;
}

.microphone-controls__level-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 0.5rem;
}

.microphone-controls__level-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
}

.microphone-controls__level-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e 0%, #3b82f6 100%);
  transition: width 0.1s ease-out;
  border-radius: 4px;
}

.microphone-controls__devices {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.microphone-controls__devices-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
}

.microphone-controls__devices-select {
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 0.375rem;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  max-width: 250px;
}

.microphone-controls__devices-select:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.microphone-controls__devices-select option {
  background: #667eea;
  color: white;
}

.microphone-controls__error-message {
  width: 100%;
  padding: 0.75rem;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 0.375rem;
  color: #fca5a5;
  font-size: 0.875rem;
}

/* ========================================
   Audio Visualizer
   ======================================== */

.audio-visualizer {
  position: relative;
  width: 100%;
  height: 200px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0.5rem;
  overflow: hidden;
}

.audio-visualizer__canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.audio-visualizer__status {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 1rem;
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
  backdrop-filter: blur(8px);
}

.audio-visualizer__status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
}

.audio-visualizer__status-indicator--user {
  background: #3b82f6;
  animation: pulse-indicator 1.5s ease-in-out infinite;
}

.audio-visualizer__status-indicator--agent {
  background: #22c55e;
  animation: pulse-indicator 1.5s ease-in-out infinite;
}

.audio-visualizer__status-indicator--idle {
  background: #9ca3af;
}

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

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
  .voice-interface {
    padding: 1.5rem;
    min-height: 300px;
  }

  .microphone-controls--active {
    flex-direction: column;
    align-items: stretch;
  }

  .microphone-controls__toggle {
    width: 56px;
    height: 56px;
    align-self: center;
  }

  .microphone-controls__devices {
    flex-direction: column;
    align-items: stretch;
  }

  .microphone-controls__devices-select {
    max-width: none;
  }

  .audio-visualizer {
    height: 150px;
  }
}

@media (max-width: 480px) {
  .voice-interface {
    padding: 1rem;
  }

  .microphone-controls__title {
    font-size: 1.25rem;
  }

  .microphone-controls__description {
    font-size: 0.875rem;
  }

  .audio-visualizer {
    height: 120px;
  }
}

/* ========================================
   High Contrast Mode
   ======================================== */

@media (prefers-contrast: high) {
  .voice-interface {
    border: 2px solid white;
  }

  .microphone-controls__button--primary {
    border: 2px solid #667eea;
  }

  .microphone-controls__toggle:focus {
    outline-width: 4px;
  }

  .microphone-controls__devices-select:focus {
    outline-width: 3px;
  }
}

/* ========================================
   Reduced Motion
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  .voice-interface--speaking,
  .voice-interface--agent-speaking {
    animation: none;
  }

  .audio-visualizer__status-indicator--user,
  .audio-visualizer__status-indicator--agent {
    animation: none;
  }

  .microphone-controls__toggle:hover:not(:disabled) {
    transform: none;
  }

  .microphone-controls__button--primary:hover:not(:disabled) {
    transform: none;
  }
}
