/* Daytemis Voice Assistant Widget */

#daytemis-voice-btn {
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: white;
  cursor: pointer;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}

#daytemis-voice-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(124, 58, 237, 0.55);
}

#daytemis-voice-btn:active {
  transform: scale(0.95);
}

/* Mic icon */
#daytemis-voice-btn svg {
  width: 26px;
  height: 26px;
  fill: white;
}

/* Pulse ring animation (idle state, inviting) */
#daytemis-voice-btn.idle::before {
  content: '';
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid rgba(124, 58, 237, 0.5);
  animation: pulse-ring 2s ease-out infinite;
}

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

/* Connecting state - spinner */
#daytemis-voice-btn.connecting svg {
  animation: spin 1s linear infinite;
}

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

/* Listening state - strong red glow + double ring pulse */
#daytemis-voice-btn.listening {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  box-shadow: 0 0 20px rgba(220, 38, 38, 0.5);
  animation: glow-pulse 1.2s ease-in-out infinite;
}

#daytemis-voice-btn.listening::before {
  content: '';
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 3px solid rgba(239, 68, 68, 0.7);
  animation: listen-ring 1.5s ease-out infinite;
}

#daytemis-voice-btn.listening::after {
  content: '';
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid rgba(239, 68, 68, 0.4);
  animation: listen-ring 1.5s ease-out infinite 0.5s;
}

@keyframes listen-ring {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(2); opacity: 0; }
}

@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 15px rgba(220, 38, 38, 0.4); }
  50% { box-shadow: 0 0 30px rgba(220, 38, 38, 0.7); }
}

/* Speaking state - waveform bars */
#daytemis-voice-btn.speaking {
  background: linear-gradient(135deg, #059669, #10b981);
}

.voice-bars {
  display: none;
  gap: 3px;
  align-items: center;
  height: 24px;
}

#daytemis-voice-btn.speaking .voice-bars {
  display: flex;
}

#daytemis-voice-btn.speaking svg {
  display: none;
}

.voice-bars span {
  display: block;
  width: 4px;
  background: white;
  border-radius: 2px;
  animation: bar-bounce 0.8s ease-in-out infinite;
}

.voice-bars span:nth-child(1) { height: 8px; animation-delay: 0s; }
.voice-bars span:nth-child(2) { height: 16px; animation-delay: 0.15s; }
.voice-bars span:nth-child(3) { height: 12px; animation-delay: 0.3s; }
.voice-bars span:nth-child(4) { height: 20px; animation-delay: 0.45s; }
.voice-bars span:nth-child(5) { height: 10px; animation-delay: 0.6s; }

@keyframes bar-bounce {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}

/* Tooltip bubble */
#daytemis-voice-tooltip {
  position: fixed;
  bottom: 170px;
  right: 20px;
  background: white;
  color: #1f2937;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 99998;
  max-width: 220px;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

#daytemis-voice-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Small triangle pointing down to button */
#daytemis-voice-tooltip::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 24px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid white;
}

/* Error tooltip */
#daytemis-voice-tooltip.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

#daytemis-voice-tooltip.error::after {
  border-top-color: #fef2f2;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  #daytemis-voice-btn {
    bottom: 90px;
    right: 16px;
    width: 56px;
    height: 56px;
  }

  #daytemis-voice-btn.idle::before {
    width: 56px;
    height: 56px;
  }

  #daytemis-voice-tooltip {
    bottom: 156px;
    right: 16px;
    font-size: 13px;
    max-width: 200px;
  }
}
