/*
 * 智能体语音输入（agent-voice-input.js）：
 * 麦克风按钮、手机「按住说话」条、电脑录音条、提示行。
 * 显隐只认 .hidden / .is-voice-hidden，ID 选择器不写 display !important，避免盖住隐藏类。
 */

.agent-voice-btn {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  margin-left: 6px;
  margin-right: auto;
  padding: 0;
  border: 1px solid var(--agent-shell-line, rgba(0, 0, 0, 0.12));
  border-radius: 999px;
  background: #fff;
  color: #1d1d1f;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.agent-voice-btn svg {
  width: 20px;
  height: 20px;
}

.agent-voice-btn:hover {
  border-color: rgba(0, 0, 0, 0.24);
}

.agent-voice-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.agent-voice-btn.is-voice-mode {
  background: #1d1d1f;
  border-color: #1d1d1f;
  color: #fff;
}

.agent-voice-btn.is-recording {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  animation: agentVoicePulse 1.4s ease-in-out infinite;
}

@keyframes agentVoicePulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4);
  }

  50% {
    box-shadow: 0 0 0 7px rgba(37, 99, 235, 0);
  }
}

.is-voice-hidden {
  display: none !important;
}

/* ---------------- 语音条：手机「按住说话」 ---------------- */

.agent-voice-bar {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  margin: 2px 0 4px;
  padding: 10px 14px;
  box-sizing: border-box;
  border: 0;
  border-radius: 14px;
  background: #f4f4f5;
  color: #1d1d1f;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s ease, color 0.2s ease, min-height 0.2s ease;
}

.agent-voice-bar.hidden {
  display: none !important;
}

.agent-voice-bar-text {
  position: relative;
  z-index: 1;
}

.agent-voice-timer {
  display: none;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

.agent-voice-wave {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: 26px;
  overflow: hidden;
  filter: drop-shadow(0 6px 14px rgba(59, 130, 246, 0.35));
}

.agent-voice-wave i {
  display: block;
  flex: 0 0 auto;
  width: 5px;
  height: 8px;
  border-radius: 999px;
  background: #3b82f6;
  transform-origin: center;
}

.agent-voice-bar.is-starting,
.agent-voice-bar.is-stopping {
  color: #52525b;
}

.agent-voice-bar.is-recording,
.agent-voice-bar.is-cancel {
  min-height: 112px;
  background: transparent;
}

.agent-voice-bar.is-recording {
  color: #2563eb;
}

.agent-voice-bar.is-cancel {
  color: #dc2626;
}

.agent-voice-bar.is-recording .agent-voice-wave,
.agent-voice-bar.is-cancel .agent-voice-wave {
  display: flex;
}

.agent-voice-bar.is-recording .agent-voice-timer,
.agent-voice-bar.is-cancel .agent-voice-timer {
  display: block;
}

.agent-voice-bar.is-recording .agent-voice-wave i,
.agent-voice-bar.is-cancel .agent-voice-wave i {
  animation: agentVoiceBar 1s ease-in-out infinite;
}

.agent-voice-bar.is-cancel .agent-voice-wave {
  filter: drop-shadow(0 6px 14px rgba(239, 68, 68, 0.3));
}

.agent-voice-bar.is-cancel .agent-voice-wave i {
  background: #ef4444;
}

@keyframes agentVoiceBar {
  0%,
  100% {
    height: 7px;
    opacity: 0.7;
  }

  50% {
    height: 22px;
    opacity: 1;
  }
}

/* ---------------- 电脑录音条：一行 波形 + 文案 + 计时 + 完成/取消 ---------------- */

.agent-voice-actions {
  display: none;
  gap: 6px;
}

.agent-voice-bar.is-desktop {
  flex-direction: row;
  justify-content: flex-start;
  gap: 12px;
  min-height: 44px;
  padding: 6px 8px 6px 14px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 14px;
  letter-spacing: 0;
  cursor: default;
  touch-action: auto;
}

.agent-voice-bar.is-desktop.is-recording,
.agent-voice-bar.is-desktop.is-starting,
.agent-voice-bar.is-desktop.is-stopping {
  min-height: 44px;
  background: #eff6ff;
}

.agent-voice-bar.is-desktop .agent-voice-wave {
  flex: 0 0 auto;
  width: auto;
  height: 20px;
  gap: 3px;
  filter: none;
}

.agent-voice-bar.is-desktop.is-recording .agent-voice-wave {
  display: flex;
}

.agent-voice-bar.is-desktop .agent-voice-wave i {
  width: 3px;
}

.agent-voice-bar.is-desktop .agent-voice-timer {
  margin-left: auto;
}

.agent-voice-bar.is-desktop .agent-voice-actions {
  display: inline-flex;
}

.agent-voice-action {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(37, 99, 235, 0.3);
  border-radius: 999px;
  background: #fff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.agent-voice-action.is-primary {
  border-color: #2563eb;
  background: #2563eb;
  color: #fff;
}

.agent-voice-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------------- 提示行：权限、无麦克风、服务不可用、没听清 ---------------- */

.agent-voice-tip {
  margin: 0 2px 4px;
  color: #52525b;
  font-size: 13px;
  line-height: 1.4;
}

.agent-voice-tip.hidden {
  display: none;
}

.agent-voice-tip.is-error {
  color: #dc2626;
}

@media (max-width: 960px), (hover: none) and (pointer: coarse) {
  .agent-voice-btn {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }

  .agent-voice-btn svg {
    width: 22px;
    height: 22px;
  }

  .agent-voice-bar {
    min-height: 52px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .agent-voice-btn.is-recording,
  .agent-voice-bar .agent-voice-wave i {
    animation: none !important;
  }
}
