/* ============================================================
   VOICE WIDGET — Styles
   Floating button + panel + animations
   ============================================================ */

/* ── Floating Action Button ────────────────────────────────── */
.voice-fab {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--gradient-violet);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-voice);
  cursor: pointer;
  border: none;
  box-shadow: 0 6px 24px var(--accent-violet-glow), 0 0 0 0 rgba(124, 58, 237, 0.4);
  transition: all var(--transition-base);
  outline: none;
}

.voice-fab svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--transition-base);
}

.voice-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 32px var(--accent-violet-glow);
}

.voice-fab:active {
  transform: scale(0.95);
}

/* Tooltip */
.voice-fab-tooltip {
  position: absolute;
  right: 72px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.voice-fab-tooltip::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  border-top: 1px solid var(--border);
}

.voice-fab:hover .voice-fab-tooltip {
  opacity: 1;
}

/* Keyboard shortcut badge */
.voice-fab-shortcut {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  font-size: 0.55rem;
  font-family: var(--font-mono);
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.voice-fab:hover .voice-fab-shortcut {
  opacity: 1;
}


/* ── Listening State — Pulse Ripple ────────────────────────── */
.voice-fab.listening {
  background: var(--gradient-green);
  box-shadow: 0 6px 24px var(--accent-green-glow);
  animation: pulseGlow 1.5s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow:
      0 6px 24px var(--accent-green-glow),
      0 0 0 0 rgba(16, 185, 129, 0.4);
  }
  50% {
    box-shadow:
      0 6px 24px var(--accent-green-glow),
      0 0 0 16px rgba(16, 185, 129, 0);
  }
}

/* Ripple rings */
.voice-fab.listening::before,
.voice-fab.listening::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--accent-green);
  animation: rippleExpand 2s ease-out infinite;
}

.voice-fab.listening::after {
  animation-delay: 0.6s;
}

@keyframes rippleExpand {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}


/* ── Processing State ──────────────────────────────────────── */
.voice-fab.processing {
  background: var(--gradient-violet-cyan);
}

.voice-fab.processing svg {
  animation: spin 1s linear infinite;
}

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


/* ── Error State ───────────────────────────────────────────── */
.voice-fab.error {
  background: var(--gradient-red);
  box-shadow: 0 6px 24px var(--accent-red-glow);
  animation: shake 0.5s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-4px); }
  40%      { transform: translateX(4px); }
  60%      { transform: translateX(-3px); }
  80%      { transform: translateX(3px); }
}


/* ── Success State ─────────────────────────────────────────── */
.voice-fab.success {
  background: var(--gradient-green);
  box-shadow: 0 6px 24px var(--accent-green-glow);
}


/* ── Voice Panel (Slides up from bottom-right) ─────────────── */
.voice-panel {
  position: fixed;
  bottom: 104px;
  right: 32px;
  width: 360px;
  max-height: 480px;
  background: rgba(15, 15, 42, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  z-index: var(--z-voice);
  overflow: hidden;
  transform: translateY(16px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
}

.voice-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

.voice-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.voice-panel-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 600;
  font-size: 0.95rem;
}

.voice-panel-title .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: dotPulse 1.5s ease-in-out infinite;
}

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

.voice-panel-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  transition: all var(--transition-fast);
}

.voice-panel-close:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.voice-panel-close svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* Panel body */
.voice-panel-body {
  padding: var(--space-lg);
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* Audio Wave Visualizer */
.voice-waves {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 48px;
  padding: var(--space-md) 0;
}

.voice-wave-bar {
  width: 4px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--accent-violet);
  transition: height 0.15s ease;
}

.voice-waves.active .voice-wave-bar {
  animation: waveAnim 0.8s ease-in-out infinite;
}

.voice-waves.active .voice-wave-bar:nth-child(1) {
  animation-delay: 0s;
  background: var(--accent-violet);
}

.voice-waves.active .voice-wave-bar:nth-child(2) {
  animation-delay: 0.1s;
  background: linear-gradient(to top, var(--accent-violet), var(--accent-cyan));
}

.voice-waves.active .voice-wave-bar:nth-child(3) {
  animation-delay: 0.2s;
  background: var(--accent-cyan);
}

.voice-waves.active .voice-wave-bar:nth-child(4) {
  animation-delay: 0.3s;
  background: linear-gradient(to top, var(--accent-cyan), var(--accent-violet));
}

.voice-waves.active .voice-wave-bar:nth-child(5) {
  animation-delay: 0.4s;
  background: var(--accent-violet);
}

@keyframes waveAnim {
  0%, 100% { height: 6px; }
  50%      { height: 36px; }
}

/* Status text */
.voice-status {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.voice-status.listening {
  color: var(--accent-green);
}

.voice-status.processing {
  color: var(--accent-cyan);
}

.voice-status.error {
  color: var(--accent-red);
}

/* Transcript display */
.voice-transcript {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  min-height: 48px;
}

.voice-transcript-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-sm);
}

.voice-transcript-text {
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.voice-transcript-text.interim {
  color: var(--text-tertiary);
  font-style: italic;
}

/* Typing cursor effect */
.voice-transcript-text .cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent-violet);
  margin-left: 2px;
  animation: blink 0.8s step-end infinite;
  vertical-align: text-bottom;
}

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

/* Response area */
.voice-response {
  background: rgba(124, 58, 237, 0.06);
  border: 1px solid rgba(124, 58, 237, 0.15);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  animation: slideUp 0.3s ease;
}

.voice-response-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-violet);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.voice-response-text {
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.5;
}

/* Fallback text input */
.voice-fallback {
  display: flex;
  gap: var(--space-sm);
}

.voice-fallback-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: all var(--transition-base);
}

.voice-fallback-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-violet-glow);
}

.voice-fallback-input::placeholder {
  color: var(--text-tertiary);
}

.voice-fallback-send {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--gradient-violet);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-base);
}

.voice-fallback-send:hover {
  box-shadow: 0 4px 16px var(--accent-violet-glow);
}

.voice-fallback-send svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}


/* ── Responsive Voice Widget ───────────────────────────────── */
@media (max-width: 767px) {
  .voice-fab {
    bottom: 20px;
    right: 20px;
    width: 54px;
    height: 54px;
  }

  .voice-panel {
    bottom: 84px;
    right: 16px;
    left: 16px;
    width: auto;
    max-height: 60vh;
  }

  .voice-fab-tooltip,
  .voice-fab-shortcut {
    display: none;
  }
}
