/* ============================================================
   FUEsion Voice — Voice Assistant UI Styles
   ============================================================ */

/* Floating Voice Button */
.fuesion-voice-btn {
  position: fixed;
  z-index: 100000;
}
.fuesion-voice-btn.bottom-right {
  bottom: 24px;
  right: 24px;
}
.fuesion-voice-btn.bottom-left {
  bottom: 24px;
  left: 24px;
}
.fgq-voice-header-mount {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}
.fuesion-voice-btn.top-right {
  top: 16px;
  right: 24px;
}
.fuesion-voice-btn.top-left {
  top: 16px;
  left: 24px;
}
.fuesion-voice-btn.inline {
  position: relative;
  display: inline-flex;
  bottom: auto;
  right: auto;
  left: auto;
  z-index: 1000;
}

/* Trigger Button */
.voice-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #c9a84c, #e6c55a);
  color: #1a1a2e;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(201, 168, 76, 0.4);
  transition: all 0.3s ease;
  white-space: nowrap;
}
.voice-trigger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(201, 168, 76, 0.5);
}
.voice-trigger.active {
  background: linear-gradient(135deg, #e74c3c, #ff6b6b);
  color: white;
  animation: voice-pulse 1.5s ease-in-out infinite;
}
.voice-trigger .mic-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.voice-trigger .voice-label {
  font-size: 13px;
}

/* Inline variant — golden mic-only icon button (label hidden, tooltip shows the wake phrase) */
.fuesion-voice-btn.inline .voice-trigger {
  padding: 0;
  width: 38px;
  height: 38px;
  justify-content: center;
  gap: 0;
  border-radius: 50%;
  box-shadow: 0 2px 12px rgba(201, 168, 76, 0.28);
}
.fuesion-voice-btn.inline .voice-trigger:hover {
  transform: translateY(-1px);
}
.fuesion-voice-btn.inline .voice-trigger .mic-icon {
  width: 18px;
  height: 18px;
}
.fuesion-voice-btn.inline .voice-label {
  display: none;
}

/* Voice Panel */
.voice-panel {
  position: absolute;
  bottom: 60px;
  right: 0;
  width: 360px;
  background: #1a1a2e;
  border: 1px solid rgba(201, 168, 76, 0.3);
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: voicePanelIn 0.3s ease;
}
.fuesion-voice-btn.inline .voice-panel {
  bottom: auto;
  top: calc(100% + 10px);
  right: 0;
  left: auto;
}
@media (max-width: 900px) {
  .fuesion-voice-btn.inline .voice-label { display: none; }
  .fuesion-voice-btn.inline .voice-trigger { padding: 0; }
  .fuesion-voice-btn.inline .voice-panel { right: -96px; width: min(340px, calc(100vw - 32px)); }
}
.fuesion-voice-btn.bottom-left .voice-panel {
  right: auto;
  left: 0;
}
/* Top positions: panel drops DOWN below the pill instead of upward */
.fuesion-voice-btn.top-right .voice-panel,
.fuesion-voice-btn.top-left .voice-panel {
  bottom: auto;
  top: 60px;
}
.fuesion-voice-btn.top-right .voice-panel {
  right: 0;
  left: auto;
}
.fuesion-voice-btn.top-left .voice-panel {
  right: auto;
  left: 0;
}

@keyframes voicePanelIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.voice-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: rgba(201, 168, 76, 0.1);
  border-bottom: 1px solid rgba(201, 168, 76, 0.15);
}

.voice-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.voice-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #666;
  transition: background 0.3s;
}
.voice-dot.connecting { background: #f39c12; animation: dot-blink 1s infinite; }
.voice-dot.listening { background: #2ecc71; animation: dot-blink 0.8s infinite; }
.voice-dot.speaking { background: #d4af37; animation: dot-blink 0.6s infinite; }
.voice-dot.error { background: #e74c3c; }

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

.voice-status {
  font-size: 13px;
  font-weight: 600;
  color: #c9a84c;
}
.voice-close {
  background: none;
  border: none;
  color: #888;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.voice-close:hover {
  color: #fff;
}

/* Waveform Animation */
.voice-waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 20px 18px;
  height: 60px;
}
.wave-bar {
  width: 4px;
  height: 8px;
  background: #444;
  border-radius: 4px;
  transition: all 0.15s ease;
}

/* Listening state — gold bouncing bars */
.voice-waveform.active .wave-bar {
  background: #c9a84c;
  animation: waveform 0.6s ease-in-out infinite;
}
.voice-waveform.active .wave-bar:nth-child(1) { animation-delay: 0s; }
.voice-waveform.active .wave-bar:nth-child(2) { animation-delay: 0.08s; }
.voice-waveform.active .wave-bar:nth-child(3) { animation-delay: 0.16s; }
.voice-waveform.active .wave-bar:nth-child(4) { animation-delay: 0.24s; }
.voice-waveform.active .wave-bar:nth-child(5) { animation-delay: 0.32s; }
.voice-waveform.active .wave-bar:nth-child(6) { animation-delay: 0.24s; }
.voice-waveform.active .wave-bar:nth-child(7) { animation-delay: 0.16s; }
.voice-waveform.active .wave-bar:nth-child(8) { animation-delay: 0.08s; }
.voice-waveform.active .wave-bar:nth-child(9) { animation-delay: 0s; }

/* AI speaking state — purple pulsing bars */
.voice-waveform.ai-speaking .wave-bar {
  background: #8b5cf6;
  animation: waveform 0.5s ease-in-out infinite;
}
.voice-waveform.ai-speaking .wave-bar:nth-child(1) { animation-delay: 0s; }
.voice-waveform.ai-speaking .wave-bar:nth-child(2) { animation-delay: 0.06s; }
.voice-waveform.ai-speaking .wave-bar:nth-child(3) { animation-delay: 0.12s; }
.voice-waveform.ai-speaking .wave-bar:nth-child(4) { animation-delay: 0.18s; }
.voice-waveform.ai-speaking .wave-bar:nth-child(5) { animation-delay: 0.24s; }
.voice-waveform.ai-speaking .wave-bar:nth-child(6) { animation-delay: 0.18s; }
.voice-waveform.ai-speaking .wave-bar:nth-child(7) { animation-delay: 0.12s; }
.voice-waveform.ai-speaking .wave-bar:nth-child(8) { animation-delay: 0.06s; }
.voice-waveform.ai-speaking .wave-bar:nth-child(9) { animation-delay: 0s; }

@keyframes waveform {
  0%, 100% { height: 8px; }
  50% { height: 32px; }
}

/* Transcript and AI Response */
.voice-transcript-area,
.voice-ai-area {
  margin: 4px 14px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.voice-transcript-area {
  background: rgba(46, 204, 113, 0.08);
  border-left: 3px solid #2ecc71;
}

.voice-ai-area {
  background: rgba(212, 175, 55, 0.08);
  border-left: 3px solid #d4af37;
}

.voice-transcript-label,
.voice-ai-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.voice-transcript-label { color: #2ecc71; }
.voice-ai-label { color: #d4af37; }

.voice-transcript,
.voice-ai-response {
  color: #ccc;
  word-wrap: break-word;
  min-height: 16px;
}
.voice-transcript.final { color: #fff; font-weight: 500; }
.voice-ai-response.final { color: #fff; }

/* Actions */
.voice-actions {
  padding: 6px 14px 12px;
  text-align: center;
}

.voice-use-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: linear-gradient(135deg, #c9a84c, #e6c55a);
  color: #1a1a2e;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}
.voice-use-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 12px rgba(201, 168, 76, 0.3);
}

/* Text Input Area */
.voice-text-input-area {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.voice-text-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(201, 168, 76, 0.25);
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.voice-text-input::placeholder {
  color: #666;
}
.voice-text-input:focus {
  border-color: #c9a84c;
  background: rgba(255, 255, 255, 0.08);
}
.voice-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #c9a84c, #e6c55a);
  color: #1a1a2e;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  padding: 0;
}
.voice-send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(201, 168, 76, 0.3);
}

.voice-hint {
  padding: 8px 14px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: #555;
  font-size: 11px;
  text-align: center;
  font-style: italic;
}

/* Pulse animation for active mic */
@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(231, 76, 60, 0.4); }
  50% { box-shadow: 0 4px 30px rgba(231, 76, 60, 0.7), 0 0 0 8px rgba(231, 76, 60, 0.15); }
}

/* ============================================================
   Inline Field Mic Button (FUEsionFieldMic)
   ============================================================ */
.field-mic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(201, 168, 76, 0.3);
  background: rgba(201, 168, 76, 0.12);
  color: #c9a84c;
  cursor: pointer;
  transition: all 0.2s;
  vertical-align: middle;
  margin-left: 6px;
  flex-shrink: 0;
  padding: 0;
}
.field-mic-btn:hover {
  background: rgba(201, 168, 76, 0.25);
  border-color: #c9a84c;
}
.field-mic-btn.recording {
  background: rgba(231, 76, 60, 0.2);
  border-color: #e74c3c;
  color: #e74c3c;
  animation: field-mic-pulse 1s ease-in-out infinite;
}

@keyframes field-mic-pulse {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 6px rgba(231, 76, 60, 0.15); }
}

/* Input + mic wrapper */
.input-with-mic {
  display: flex;
  align-items: center;
  gap: 6px;
}
.input-with-mic input,
.input-with-mic textarea,
.input-with-mic select {
  flex: 1;
}

/* Legacy inline mic button (from project-new.ejs) */
.input-voice-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-voice-wrap input,
.input-voice-wrap textarea {
  padding-right: 44px;
}
.input-mic-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(201, 168, 76, 0.15);
  color: #c9a84c;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
}
.input-mic-btn:hover {
  background: rgba(201, 168, 76, 0.25);
}
.input-mic-btn.recording {
  background: rgba(231, 76, 60, 0.2);
  color: #e74c3c;
  animation: voice-pulse-sm 1s ease-in-out infinite;
}
.input-mic-btn svg {
  width: 16px;
  height: 16px;
}

@keyframes voice-pulse-sm {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.15); }
}

/* Textarea voice button position */
.input-voice-wrap textarea ~ .input-mic-btn {
  top: 12px;
  transform: none;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 480px) {
  .voice-panel {
    width: calc(100vw - 48px);
    right: -12px;
  }
  .voice-trigger .voice-label {
    display: none;
  }
  .voice-trigger {
    padding: 12px;
    border-radius: 50%;
  }
}
