/* ========== Voice Assistant - Floating Button & Panel ========== */

/* --- Floating Trigger Button --- */
.voice-assistant-fab {
  position: fixed;
  bottom: 70px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(30, 41, 59, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.7);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  z-index: 999998;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}

.voice-assistant-fab:hover {
  background: rgba(40, 51, 69, 0.96);
  color: #fff;
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.55);
}

.voice-assistant-fab.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 28px rgba(102, 126, 234, 0.45);
}

.voice-assistant-fab svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  transition: transform 0.2s ease;
}

.voice-assistant-fab.active svg {
  animation: va-pulse-icon 1.8s ease-in-out infinite;
}

@keyframes va-pulse-icon {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* Pulse ring when listening */
.voice-assistant-fab.listening::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(102, 126, 234, 0.6);
  animation: va-ring-pulse 1.5s ease-out infinite;
}

@keyframes va-ring-pulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* --- Panel Container --- */
.voice-assistant-panel {
  position: fixed;
  bottom: 130px;
  right: 20px;
  width: 340px;
  max-height: 480px;
  background: rgba(15, 20, 35, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  z-index: 999997;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

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

/* --- Panel Header --- */
.va-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  gap: 10px;
}

.va-header-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: #e2e8f0;
  letter-spacing: 0.3px;
}

.va-header-status {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  gap: 5px;
}

.va-header-status .va-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
}

.va-header-status.connected .va-dot {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.va-header-status.listening .va-dot {
  background: #667eea;
  animation: va-dot-blink 1s ease-in-out infinite;
}

.va-header-status.speaking .va-dot {
  background: #f59e0b;
  animation: va-dot-blink 0.6s ease-in-out infinite;
}

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

.va-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  font-size: 16px;
}

.va-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.8);
}

/* --- Transcript Area --- */
.va-transcript {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 120px;
  max-height: 300px;
}

.va-transcript::-webkit-scrollbar {
  width: 4px;
}

.va-transcript::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.va-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  word-wrap: break-word;
  animation: va-msg-in 0.2s ease-out;
}

@keyframes va-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.va-msg.user {
  align-self: flex-end;
  background: rgba(102, 126, 234, 0.2);
  color: #c7d2fe;
  border-bottom-right-radius: 4px;
}

.va-msg.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
}

.va-msg.system {
  align-self: center;
  background: transparent;
  color: rgba(255, 255, 255, 0.35);
  font-size: 11px;
  padding: 4px 0;
}

/* --- Visualizer --- */
.va-visualizer {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0 16px;
}

.va-viz-bar {
  width: 3px;
  height: 8px;
  border-radius: 2px;
  background: rgba(102, 126, 234, 0.5);
  transition: height 0.08s ease;
}

.va-visualizer.active .va-viz-bar {
  animation: va-bar-dance 0.8s ease-in-out infinite;
  background: linear-gradient(to top, #667eea, #764ba2);
}

.va-visualizer.active .va-viz-bar:nth-child(1) { animation-delay: 0s; }
.va-visualizer.active .va-viz-bar:nth-child(2) { animation-delay: 0.1s; }
.va-visualizer.active .va-viz-bar:nth-child(3) { animation-delay: 0.2s; }
.va-visualizer.active .va-viz-bar:nth-child(4) { animation-delay: 0.3s; }
.va-visualizer.active .va-viz-bar:nth-child(5) { animation-delay: 0.15s; }
.va-visualizer.active .va-viz-bar:nth-child(6) { animation-delay: 0.25s; }
.va-visualizer.active .va-viz-bar:nth-child(7) { animation-delay: 0.05s; }
.va-visualizer.active .va-viz-bar:nth-child(8) { animation-delay: 0.35s; }
.va-visualizer.active .va-viz-bar:nth-child(9) { animation-delay: 0.12s; }
.va-visualizer.active .va-viz-bar:nth-child(10) { animation-delay: 0.22s; }
.va-visualizer.active .va-viz-bar:nth-child(11) { animation-delay: 0.08s; }
.va-visualizer.active .va-viz-bar:nth-child(12) { animation-delay: 0.28s; }
.va-visualizer.active .va-viz-bar:nth-child(13) { animation-delay: 0.18s; }
.va-visualizer.active .va-viz-bar:nth-child(14) { animation-delay: 0.32s; }
.va-visualizer.active .va-viz-bar:nth-child(15) { animation-delay: 0.07s; }
.va-visualizer.active .va-viz-bar:nth-child(16) { animation-delay: 0.27s; }

@keyframes va-bar-dance {
  0%, 100% { height: 8px; }
  50% { height: 32px; }
}

/* --- Controls --- */
.va-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px 16px;
  gap: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.va-mic-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(102, 126, 234, 0.4);
  background: rgba(102, 126, 234, 0.12);
  color: #667eea;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.va-mic-btn:hover {
  background: rgba(102, 126, 234, 0.2);
  border-color: rgba(102, 126, 234, 0.6);
}

.va-mic-btn.recording {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 20px rgba(102, 126, 234, 0.4);
  animation: va-mic-glow 1.8s ease-in-out infinite;
}

@keyframes va-mic-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(102, 126, 234, 0.4); }
  50% { box-shadow: 0 0 30px rgba(102, 126, 234, 0.6); }
}

.va-mic-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.va-end-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  font-size: 14px;
}

.va-end-btn:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* --- Empty State --- */
.va-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  gap: 8px;
  color: rgba(255, 255, 255, 0.3);
}

.va-empty svg {
  width: 36px;
  height: 36px;
  fill: currentColor;
  opacity: 0.5;
  margin-bottom: 4px;
}

.va-empty-title {
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
}

.va-empty-subtitle {
  font-size: 12px;
}

/* --- Settings Dropdown --- */
.va-settings-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  font-size: 14px;
  position: relative;
}

.va-settings-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.8);
}

.va-settings-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  width: 200px;
  background: rgba(20, 25, 40, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 10;
  display: none;
}

.va-settings-dropdown.open {
  display: block;
  animation: va-msg-in 0.15s ease-out;
}

.va-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.va-setting-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.va-setting-row label {
  cursor: pointer;
}

.va-setting-row select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #e2e8f0;
  font-size: 11px;
  padding: 2px 4px;
  outline: none;
}

/* --- Mobile Adjustments --- */
@media (max-width: 768px) {
  .voice-assistant-fab {
    bottom: 80px;
    right: 14px;
    width: 44px;
    height: 44px;
  }

  .voice-assistant-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 70vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }

  .voice-assistant-panel.open {
    transform: translateY(0);
  }
}

/* Hidden state (when feature is disabled) */
.voice-assistant-fab.va-hidden,
.voice-assistant-panel.va-hidden {
  display: none !important;
}
