/* ═══════════════════════════════════════════════════════════════════════════
   VOICE CHAT — Realtime Voice UI Components
   FinBridge Venture Studio
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Voice Button (Microphone) ── */
.workspace-chat__voice {
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm, 8px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary, #6B7280);
  transition: all 0.2s;
  flex-shrink: 0;
  position: relative;
}

.workspace-chat__voice:hover {
  background: var(--color-bg-alt, #F8F7FC);
  color: var(--color-primary, #6B21A8);
}

.workspace-chat__voice:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* State: Listening (recording user's voice) */
.workspace-chat__voice--listening {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  animation: voice-pulse 1.5s ease-in-out infinite;
}

.workspace-chat__voice--listening:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #dc2626;
}

/* State: Agent is speaking */
.workspace-chat__voice--speaking {
  background: rgba(107, 33, 168, 0.1);
  color: var(--color-primary, #6B21A8);
  animation: voice-speaking 0.8s ease-in-out infinite alternate;
}

/* State: Connecting to server */
.workspace-chat__voice--connecting {
  color: var(--color-text-muted, #6B7280);
  animation: voice-connecting 1s linear infinite;
}

@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

@keyframes voice-speaking {
  from { transform: scale(1); }
  to { transform: scale(1.12); }
}

@keyframes voice-connecting {
  from { opacity: 1; }
  to { opacity: 0.4; }
}

/* ── Voice Status Bar (shown below the input bar when voice is active) ── */
.voice-status-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--color-bg-alt, #F8F7FC);
  border-top: 1px solid var(--color-border, #E5E7EB);
  font-size: 13px;
  color: var(--color-text-secondary, #6B7280);
  flex-shrink: 0;
}

.voice-status-bar--active {
  display: flex;
}

/* Status indicator dot */
.voice-status-bar__indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-muted, #6B7280);
  flex-shrink: 0;
}

.voice-status-bar__indicator--listening {
  background: #ef4444;
  animation: voice-pulse-dot 1.5s ease-in-out infinite;
}

.voice-status-bar__indicator--thinking {
  background: #f59e0b;
  animation: voice-pulse-dot 0.8s ease-in-out infinite;
}

.voice-status-bar__indicator--speaking {
  background: var(--color-primary, #6B21A8);
  animation: voice-pulse-dot 0.6s ease-in-out infinite;
}

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

.voice-status-bar__text {
  flex: 1;
}

/* Animated waveform (shown when agent is speaking) */
.voice-status-bar__waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 20px;
}

.voice-status-bar__waveform-bar {
  width: 3px;
  background: var(--color-primary, #6B21A8);
  border-radius: 2px;
  animation: waveform-anim 0.8s ease-in-out infinite;
}

.voice-status-bar__waveform-bar:nth-child(1) { animation-delay: 0s; height: 6px; }
.voice-status-bar__waveform-bar:nth-child(2) { animation-delay: 0.1s; height: 12px; }
.voice-status-bar__waveform-bar:nth-child(3) { animation-delay: 0.2s; height: 18px; }
.voice-status-bar__waveform-bar:nth-child(4) { animation-delay: 0.3s; height: 12px; }
.voice-status-bar__waveform-bar:nth-child(5) { animation-delay: 0.4s; height: 6px; }

@keyframes waveform-anim {
  0%, 100% { transform: scaleY(0.4); opacity: 0.6; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* Stop voice button in status bar */
.voice-status-bar__stop {
  background: none;
  border: 1px solid var(--color-border, #E5E7EB);
  border-radius: 6px;
  padding: 2px 10px;
  font-size: 11px;
  color: var(--color-text-secondary, #6B7280);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.voice-status-bar__stop:hover {
  background: var(--color-bg, #fff);
  color: #dc2626;
  border-color: #dc2626;
}

/* ── Voice Message Bubbles (visual distinction for voice messages) ── */
.mentor-msg--voice .mentor-msg__bubble {
  border-left: 3px solid var(--color-primary, #6B21A8);
}

.mentor-msg--voice-user .mentor-msg__bubble {
  border-right: 3px solid #ef4444;
}

/* Voice icon badge on messages */
.mentor-msg__voice-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--color-text-muted, #6B7280);
  margin-top: 4px;
}

/* ── Voice Toggle Button (TTS on/off in status bar) ── */
.voice-status-bar__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--color-border, #E5E7EB);
  border-radius: 50%;
  background: none;
  color: var(--color-text-secondary, #6B7280);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}
.voice-status-bar__toggle:hover {
  background: var(--color-bg, #fff);
  color: var(--color-primary, #6B21A8);
  border-color: var(--color-primary, #6B21A8);
}

/* ── Agent voice select in admin form ── */
.agent-voice-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color, #e5e7eb);
}
.agent-voice-section label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, #6b7280);
  margin-bottom: 6px;
}
.agent-voice-section select {
  width: 100%;
}

/* ── PTT Button ──────────────────────────────────────────────────────────── */
.voice-ptt-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border: 2px solid var(--color-primary, #6B21A8);
  border-radius: 20px;
  background: transparent;
  color: var(--color-primary, #6B21A8);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  flex-shrink: 0;
}

.voice-ptt-btn:hover {
  background: rgba(107, 33, 168, 0.08);
}

.voice-ptt-btn--active,
.voice-ptt-btn:active {
  background: var(--color-primary, #6B21A8);
  color: #fff;
  transform: scale(0.97);
  box-shadow: 0 0 0 4px rgba(107, 33, 168, 0.2);
  animation: ptt-pulse 1s ease-in-out infinite;
}

@keyframes ptt-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(107, 33, 168, 0.2); }
  50%       { box-shadow: 0 0 0 8px rgba(107, 33, 168, 0.08); }
}

/* ── Level Meter ─────────────────────────────────────────────────────────── */
.voice-level-meter {
  width: 60px;
  height: 6px;
  background: rgba(107, 33, 168, 0.12);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

.voice-level-meter__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6B21A8, #a855f7);
  border-radius: 3px;
  transition: width 0.08s ease;
}
