/* Voice Search Modal Styles */
.voice-search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease-in-out;
  /* Ensure it's completely hidden during page load */
  transform: translateZ(0);
  will-change: opacity, visibility;
  /* Prevent any flash during page load */
  pointer-events: none;
}

.voice-search-overlay.active {
  display: flex;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.voice-search-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: white;
}

/* Microphone Button with Glowing Effect */
.voice-mic-button {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2d1b69 0%, #1a0d3a 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(0, 212, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: translateZ(0);
}

.voice-mic-button:hover {
  transform: scale(1.08) translateZ(0);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), 0 0 0 0 rgba(0, 212, 255, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.voice-mic-button:active {
  transform: scale(0.98) translateZ(0);
}

.voice-mic-button.listening {
  animation: pulse-glow 1.5s infinite, mic-bounce 0.6s ease-in-out;
}

/* Glowing Ring Animation */
.voice-mic-button::before {
  content: "";
  position: absolute;
  top: -25px;
  left: -25px;
  right: -25px;
  bottom: -25px;
  border-radius: 50%;
  background: linear-gradient(
    45deg,
    #00d4ff 0%,
    #5b21b6 25%,
    #ec4899 50%,
    #f59e0b 75%,
    #00d4ff 100%
  );
  background-size: 400% 400%;
  animation: gradient-rotate 4s ease infinite;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: -1;
  filter: blur(2px);
}

.voice-mic-button.listening::before {
  opacity: 0.9;
  animation: gradient-rotate 1.5s ease infinite, pulse-ring 2s ease infinite;
  filter: blur(1px);
}

/* Microphone Icon */
.voice-mic-icon {
  width: 40px;
  height: 40px;
  color: white;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.voice-mic-button.listening .voice-mic-icon {
  color: #00d4ff;
  animation: icon-pulse 1.2s ease infinite, icon-glow 2s ease infinite;
  filter: drop-shadow(0 0 10px rgba(0, 212, 255, 0.6));
}

/* Status Text */
.voice-status-text {
  margin-top: 30px;
  font-size: 18px;
  font-weight: 500;
  color: #e2e8f0;
  transition: all 0.3s ease;
}

.voice-status-text.listening {
  color: #00d4ff;
  animation: text-glow 2s ease infinite;
}

/* Close Button */
.voice-close-btn {
  position: absolute;
  top: 30px;
  right: 30px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.voice-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

/* Wave Animation */
.voice-wave {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 3px solid rgba(0, 212, 255, 0.4);
  opacity: 0;
  pointer-events: none;
  /* Only animate when overlay is active and listening */
  animation: none;
  /* Completely hidden when overlay is not active */
  display: none;
}

/* Show waves only when overlay is active */
.voice-search-overlay.active .voice-wave {
  display: block;
}

.voice-wave:nth-child(2) {
  border-color: rgba(236, 72, 153, 0.3);
}

.voice-wave:nth-child(3) {
  border-color: rgba(245, 158, 11, 0.3);
}

/* Only show wave animations when overlay is active and listening */
.voice-search-overlay.active.listening .voice-wave {
  animation: wave-expand 2.5s ease infinite;
}

.voice-search-overlay.active.listening .voice-wave:nth-child(2) {
  animation-delay: 0.3s;
}

.voice-search-overlay.active.listening .voice-wave:nth-child(3) {
  animation-delay: 0.6s;
}

/* Animations */
@keyframes pulse-glow {
  0% {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(0, 212, 255, 0.4),
      inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }
  50% {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), 0 0 0 15px rgba(0, 212, 255, 0.2),
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
  100% {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(0, 212, 255, 0.4),
      inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }
}

@keyframes mic-bounce {
  0%,
  100% {
    transform: scale(1) translateZ(0);
  }
  50% {
    transform: scale(1.05) translateZ(0);
  }
}

@keyframes icon-glow {
  0%,
  100% {
    filter: drop-shadow(0 0 10px rgba(0, 212, 255, 0.6));
  }
  50% {
    filter: drop-shadow(0 0 20px rgba(0, 212, 255, 0.9));
  }
}

@keyframes gradient-rotate {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes pulse-ring {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.4;
  }
  100% {
    transform: scale(1.2);
    opacity: 0;
  }
}

@keyframes icon-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

@keyframes text-glow {
  0%,
  100% {
    text-shadow: 0 0 5px rgba(0, 212, 255, 0.5);
  }
  50% {
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.8);
  }
}

@keyframes wave-expand {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0.8;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.2);
    opacity: 0.4;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.5);
    opacity: 0;
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .voice-mic-button {
    width: 100px;
    height: 100px;
  }

  .voice-mic-icon {
    width: 35px;
    height: 35px;
  }

  .voice-status-text {
    font-size: 16px;
    margin-top: 25px;
  }

  .voice-close-btn {
    top: 20px;
    right: 20px;
    width: 35px;
    height: 35px;
  }
}

/* Loading Spinner */
.voice-loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #00d4ff;
  animation: spin 1s ease-in-out infinite;
  margin-left: 10px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Error State */
.voice-error {
  color: #ef4444;
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}
