/* =========================
   语音识别核心样式 - 按钮在输入框内
========================= */

/* 输入框包装器 */
.input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
}

/* 语音按钮在输入框内 */
#voice-btn.inside-input {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
  z-index: 10;
}

/* 录音状态下的输入框内按钮 */
#voice-btn.inside-input.listening {
  color: #ff4757 !important;
  animation: voice-pulse 1.5s infinite;
}

@keyframes voice-pulse {
  0%, 100% {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
  50% {
    opacity: 0.8;
    transform: translateY(-50%) scale(1.05);
  }
}

/* 录音状态下的输入框 - 减少红色边框效果 */
#chat-input.listening {
  border-color: #ff6b81 !important;
  padding-right: 50px; /* 给语音按钮留空间 */
  box-shadow: 0 0 0 1px rgba(255, 107, 129, 0.3) !important; /* 减少阴影强度 */
}

/* =========================
   深色模式
========================= */
.dark-mode #voice-btn.inside-input {
  color: rgba(230, 232, 240, 0.7);
}

.dark-mode #voice-btn.inside-input:hover {
  color: rgba(230, 232, 240, 0.9);
  background: rgba(255, 255, 255, 0.05);
}

.dark-mode #voice-btn.inside-input.listening {
  color: #ff6b81 !important;
  background: rgba(255, 107, 129, 0.1); /* 减少背景色强度 */
  box-shadow: 0 0 8px rgba(255, 107, 129, 0.2); /* 减少阴影 */
}

.dark-mode #chat-input.listening {
  border-color: #ff6b81 !important;
  background: rgba(255, 107, 129, 0.02) !important; /* 减少背景色 */
}

/* =========================
   浅色模式
========================= */
.light-mode #voice-btn.inside-input {
  color: rgba(30, 32, 40, 0.6);
}

.light-mode #voice-btn.inside-input:hover {
  color: rgba(30, 32, 40, 0.9);
  background: rgba(0, 0, 0, 0.04);
}

.light-mode #voice-btn.inside-input.listening {
  color: #ff4757 !important;
  background: rgba(255, 71, 87, 0.08);
  box-shadow: 0 0 8px rgba(255, 71, 87, 0.15);
}

/* 确保亮色模式下输入框在录音时是白色背景 */
.light-mode #chat-input.listening {
  border-color: #ff4757 !important;
  background: #ffffff !important; /* 强制白色背景 */
  box-shadow: 0 0 0 1px rgba(255, 71, 87, 0.2) !important; /* 更柔和的阴影 */
}

/* 临时结果标记 */
#chat-input[data-interim] {
  opacity: 0.9;
  font-style: italic;
}

/* 语言提示（可选） */
#voice-btn.inside-input[data-lang]::after {
  content: attr(data-lang);
  position: absolute;
  bottom: -20px;
  right: 0;
  font-size: 0.7rem;
  opacity: 0.6;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  display: none;
}

#voice-btn.inside-input:hover[data-lang]::after {
  display: block;
}

/* 移动端适配 */
@media (max-width: 768px) {
  #voice-btn.inside-input {
    width: 30px;
    height: 30px;
    font-size: 1.1rem;
  }
  
  #voice-btn.inside-input.listening {
    animation: voice-pulse-mobile 1.5s infinite;
  }
  
  @keyframes voice-pulse-mobile {
    0%, 100% {
      opacity: 1;
      transform: translateY(-50%) scale(1);
    }
    50% {
      opacity: 0.8;
      transform: translateY(-50%) scale(1.04);
    }
  }
  
  #chat-input.listening {
    padding-right: 45px;
  }
}

@media (max-width: 480px) {
  #voice-btn.inside-input {
    width: 28px;
    height: 28px;
    font-size: 1rem;
    right: 8px;
  }
  
  #chat-input.listening {
    padding-right: 40px;
  }
  
  #voice-btn.inside-input[data-lang]::after {
    display: none; /* 在小屏幕上隐藏语言提示 */
  }
}