/* Voice recording and playback styles */

/* Recording indicator */
#recording-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(220, 38, 38, 0.15);
  border-radius: 20px;
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

#recording-indicator.active {
  display: flex;
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #dc2626;
  animation: pulse-rec 1s ease-in-out infinite;
}

@keyframes pulse-rec {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

#recording-timer {
  font-size: 13px;
  color: #dc2626;
  font-variant-numeric: tabular-nums;
  font-family: monospace;
}

/* Mic button states */
.mic-btn {
  transition: all 0.2s ease;
}

.mic-btn.recording {
  background: rgba(220, 38, 38, 0.2) !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.3);
  animation: pulse-btn 1s ease-in-out infinite;
}

@keyframes pulse-btn {
  0%, 100% { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.1); }
}

.mic-btn.voice-processing {
  opacity: 0.5;
  pointer-events: none;
}

/* Voice processing spinner in chat */
.voice-processing-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #888;
  font-style: italic;
}

.voice-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #888;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Voice message styling */
.voice-message .model-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 8px;
  margin-left: 6px;
  opacity: 0.6;
}

/* Audio player in chat */
.voice-player {
  margin-top: 6px;
}

.voice-native-audio {
  width: 100%;
  max-width: 340px;
  height: 34px;
  display: block;
}

.voice-audio-hint {
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.7;
}

.voice-play-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: inherit;
  padding: 4px 12px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s;
}

.voice-play-btn:hover {
  background: rgba(255,255,255,0.2);
}

/* Playback indicator on body */
body.voice-playing .chat-header::after {
  content: '🔊';
  position: absolute;
  right: 50px;
  animation: fade-speaker 1.5s ease-in-out infinite;
}

@keyframes fade-speaker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Input bar relative positioning for recording indicator */
.input-bar {
  position: relative;
}

/* Voice toggle switch in settings */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.15);
  border-radius: 24px;
  transition: background 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: #22c55e;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* Voice mode select dropdown */
.setting-select {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: inherit;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}

.setting-select option {
  background: #1a1a1a;
  color: #fff;
}

/* VAD mode mic button */
.mic-btn.vad-active {
  background: rgba(34, 197, 94, 0.2) !important;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.3);
  animation: pulse-vad 1.5s ease-in-out infinite;
}

@keyframes pulse-vad {
  0%, 100% { box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.1); }
}

/* VAD silence countdown indicator */
#vad-silence-indicator {
  display: none;
  font-size: 11px;
  color: #f59e0b;
  margin-left: 8px;
  font-variant-numeric: tabular-nums;
}

#vad-silence-indicator.active {
  display: inline;
}
