/* ========================================================
 * 语音通话 UI - 白底蓝紫高雅简洁风
 * 主色：#A78BFA → #6366F1（蓝紫渐变）
 * ======================================================== */

:root {
  --vc-grad: linear-gradient(135deg, #A78BFA 0%, #6366F1 100%);
  --vc-grad-soft: linear-gradient(135deg, #DDD6FE 0%, #C4B5FD 100%);
  --vc-grad-bg: linear-gradient(135deg, #FFFFFF 0%, #F5F3FF 50%, #EEF2FF 100%);
  --vc-text: #2D2A5F;
  --vc-text-soft: #8B85B8;
  --vc-bg: #FFFFFF;
  --vc-bg-soft: #F5F3FF;
  --vc-border: rgba(167, 139, 250, 0.18);
  --vc-shadow: 0 20px 60px rgba(99, 102, 241, 0.15);
  --vc-shadow-sm: 0 4px 14px rgba(99, 102, 241, 0.10);
  --vc-danger: #F87171;
  --vc-danger-deep: #EF4444;
}

/* ============ 全屏遮罩 ============ */
.voice-call-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  align-items: stretch;
  justify-content: center;
  background: rgba(245, 243, 255, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: vcOverlayFadeIn 0.3s ease;
}
.voice-call-overlay.show { display: flex; }
@keyframes vcOverlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============ 通话窗口主体 ============ */
.voice-call-window {
  position: relative;
  width: 100%;
  max-width: 460px;
  margin: auto;
  background: #FFFFFF;
  border-radius: 28px;
  box-shadow: var(--vc-shadow);
  border: 1px solid rgba(167, 139, 250, 0.10);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: min(92vh, 720px);
  animation: vcWinIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 0 18px 0;
  gap: 0;
}
@keyframes vcWinIn {
  from { transform: translateY(20px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* 背景柔光层（极淡蓝紫光晕，几乎不可见，仅做点缀） */
.voice-call-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 15% 8%, rgba(167, 139, 250, 0.06), transparent 45%),
    radial-gradient(circle at 90% 95%, rgba(99, 102, 241, 0.05), transparent 45%);
  pointer-events: none;
  /* 即使联系人有头像，也不再用作背景图（JS 端已不再设置 backgroundImage） */
  background-size: cover;
  background-position: center;
}

/* ============ 顶部栏 ============ */
.voice-call-topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
}
.voice-call-back-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  color: var(--vc-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  box-shadow: var(--vc-shadow-sm);
}
.voice-call-back-btn:hover { background: #fff; }
.voice-call-back-btn:active { transform: scale(0.92); }
.voice-call-back-btn svg { width: 18px; height: 18px; fill: var(--vc-text); }

.voice-call-mode-tag {
  font-size: 12px;
  color: var(--vc-text-soft);
  font-weight: 500;
  letter-spacing: 1px;
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  border: 1px solid var(--vc-border);
}

/* ============ 头像信息小卡（参考图：白底悬浮卡片） ============ */
.voice-call-header {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 8px 4px 12px;
}
.voice-call-header-card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 28px 16px;
  background: #FFFFFF;
  border-radius: 22px;
  box-shadow: 0 8px 28px rgba(99, 102, 241, 0.10);
  border: 1px solid rgba(167, 139, 250, 0.14);
  min-width: 200px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.voice-call-header-card.thinking,
.voice-call-header-card.speaking {
  animation: vcCardBreath 2.2s ease-in-out infinite;
}
@keyframes vcCardBreath {
  0%, 100% { transform: translateY(0); box-shadow: 0 8px 28px rgba(99, 102, 241, 0.10); }
  50% { transform: translateY(-3px); box-shadow: 0 14px 36px rgba(99, 102, 241, 0.18); }
}

.voice-call-avatar-wrap {
  position: relative;
  display: inline-block;
}
.voice-call-avatar-wrap::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: var(--vc-grad-soft);
  opacity: 0;
  z-index: -1;
  transition: opacity 0.3s;
}
.voice-call-avatar-wrap.thinking::before,
.voice-call-avatar-wrap.speaking::before {
  opacity: 0.45;
  animation: vcAvatarPulse 1.6s ease-in-out infinite;
}
@keyframes vcAvatarPulse {
  0%, 100% { transform: scale(1); opacity: 0.35; }
  50% { transform: scale(1.12); opacity: 0.65; }
}
.voice-call-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.18);
  display: block;
}

.voice-call-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--vc-text);
  letter-spacing: 0.3px;
  margin: 0;
}
.voice-call-status {
  font-size: 12px;
  color: var(--vc-text-soft);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.vc-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--vc-grad);
  display: inline-block;
}
.vc-dot.connecting {
  animation: vcDotBlink 1.2s ease-in-out infinite;
}
.vc-dot.ended { background: #C7D2FE; }
@keyframes vcDotBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ============ 字幕区（独立卡片，实线极淡边框） ============ */
.voice-call-transcript {
  position: relative;
  z-index: 2;
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px;
  margin: 6px 2px 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #FAFBFF;
  border: 1px solid rgba(167, 139, 250, 0.18);
  border-radius: 18px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6);
  scrollbar-width: thin;
  scrollbar-color: rgba(167, 139, 250, 0.3) transparent;
}
.voice-call-transcript::-webkit-scrollbar { width: 4px; }
.voice-call-transcript::-webkit-scrollbar-thumb {
  background: rgba(167, 139, 250, 0.3);
  border-radius: 2px;
}
.voice-call-transcript:empty::before {
  content: '通话字幕将显示在这里';
  display: block;
  text-align: center;
  font-size: 12px;
  color: var(--vc-text-soft);
  padding: 20px 0;
  opacity: 0.7;
}

.vc-trans-line {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  animation: vcLineIn 0.3s ease;
}
@keyframes vcLineIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.vc-trans-line.ai {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.9);
  color: var(--vc-text);
  border: 1px solid var(--vc-border);
  border-bottom-left-radius: 4px;
}
.vc-trans-line.me {
  align-self: flex-end;
  background: var(--vc-grad);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}
.vc-speaker {
  display: block;
  font-size: 11px;
  font-weight: 500;
  margin-bottom: 2px;
  opacity: 0.7;
}
.vc-trans-line.ai .vc-speaker { color: #6366F1; }
.vc-trans-line.me .vc-speaker { color: rgba(255, 255, 255, 0.85); }

/* ============ 输入条 ============ */
.voice-call-input-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 8px;
  transition: opacity 0.2s ease;
}
.voice-call-input-bar.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* 模式切换按钮 */
.vc-input-mode-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  color: var(--vc-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--vc-shadow-sm);
  border: 1px solid var(--vc-border);
}
.vc-input-mode-btn:hover { background: #fff; }
.vc-input-mode-btn:active { transform: scale(0.92); }
.vc-input-mode-btn:disabled { cursor: not-allowed; }
.vc-input-mode-btn .vc-mode-icon {
  width: 20px;
  height: 20px;
  fill: #6366F1;
}
/* voice 模式：显示键盘图标（点击切到打字） */
.voice-call-input-bar.mode-voice .vc-mode-icon.vc-mode-voice { display: none; }
.voice-call-input-bar.mode-voice .vc-mode-icon.vc-mode-keyboard { display: block; }
.voice-call-input-bar.mode-text .vc-mode-icon.vc-mode-voice { display: block; }
.voice-call-input-bar.mode-text .vc-mode-icon.vc-mode-keyboard { display: none; }
.voice-call-input-bar:not(.mode-text):not(.mode-voice) .vc-mode-icon.vc-mode-keyboard { display: block; }
.voice-call-input-bar:not(.mode-text):not(.mode-voice) .vc-mode-icon.vc-mode-voice { display: none; }

/* 打字模式输入框 */
.vc-input-text-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border-radius: 22px;
  padding: 4px 4px 4px 16px;
  box-shadow: var(--vc-shadow-sm);
  border: 1px solid var(--vc-border);
}
.vc-input-text {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  color: var(--vc-text);
  height: 36px;
  padding: 0;
  font-family: inherit;
}
.vc-input-text::placeholder { color: var(--vc-text-soft); }
.vc-input-send-btn {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--vc-grad);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}
.vc-input-send-btn svg { width: 16px; height: 16px; fill: #fff; }
.vc-input-send-btn:active { transform: scale(0.92); }
.vc-input-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* 长按说话按钮 */
.vc-hold-talk-btn {
  flex: 1;
  position: relative;
  height: 44px;
  border: 1.5px solid #C4B5FD;
  border-radius: 22px;
  background: #fff;
  color: var(--vc-text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--vc-shadow-sm);
  transition: background 0.25s, color 0.25s, transform 0.05s, border-color 0.25s;
  overflow: hidden;
}
.vc-hold-talk-btn:active { transform: scale(0.98); }
.vc-hold-talk-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.vc-hold-talk-label {
  position: relative;
  z-index: 2;
  padding: 0 10px;
}
/* 录音中：蓝紫渐变 + 蓝紫光波纹（不再红色） */
.vc-hold-talk-btn.recording {
  background: var(--vc-grad);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 22px rgba(99, 102, 241, 0.40);
}
.vc-hold-talk-btn.recording .vc-hold-talk-label {
  font-weight: 600;
}
.vc-hold-talk-ripple {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
  z-index: 1;
}
.vc-hold-talk-btn.recording .vc-hold-talk-ripple {
  animation: vcRippleAnim 1.4s ease-out infinite;
}
@keyframes vcRippleAnim {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0.55; }
  100% { transform: translate(-50%, -50%) scale(20); opacity: 0; }
}

/* ============ 控制按钮区 ============ */
.voice-call-controls {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 28px;
  padding: 14px 24px 24px;
}
.voice-call-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.voice-call-btn-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--vc-border);
  box-shadow: var(--vc-shadow-sm);
  transition: transform 0.15s, box-shadow 0.2s;
}
.voice-call-btn:hover .voice-call-btn-icon {
  background: #fff;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.18);
}
.voice-call-btn:active .voice-call-btn-icon { transform: scale(0.92); }
.voice-call-btn-icon svg {
  width: 24px;
  height: 24px;
  fill: #6366F1;
}
.voice-call-btn-label {
  font-size: 12px;
  color: var(--vc-text-soft);
  font-weight: 500;
}
/* 挂断按钮：保留红色（柔和） */
.voice-call-btn.hangup .voice-call-btn-icon {
  background: linear-gradient(135deg, #FCA5A5 0%, #EF4444 100%);
  border-color: transparent;
  box-shadow: 0 8px 22px rgba(239, 68, 68, 0.32);
}
.voice-call-btn.hangup .voice-call-btn-icon svg {
  fill: #fff;
  transform: rotate(135deg);
}
.voice-call-btn.hangup:hover .voice-call-btn-icon {
  box-shadow: 0 10px 28px rgba(239, 68, 68, 0.45);
}
.voice-call-btn.hangup .voice-call-btn-label {
  color: #EF4444;
}

/* ============ 通话回看弹窗 ============ */
.voice-call-replay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(45, 42, 95, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  animation: vcOverlayFadeIn 0.25s ease;
}
.voice-call-replay.show { display: flex; }
.voice-call-replay-content {
  width: min(92vw, 460px);
  max-height: 80vh;
  background: var(--vc-grad-bg);
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--vc-shadow);
  border: 1px solid rgba(255, 255, 255, 0.6);
}
.voice-call-replay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--vc-border);
}
.voice-call-replay-header h3 {
  margin: 0;
  font-size: 16px;
  color: var(--vc-text);
  font-weight: 600;
}
.voice-call-replay-close {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  color: var(--vc-text-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.voice-call-replay-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.voice-call-replay-body .vc-trans-line {
  animation: none;
}

/* ============ 浮球（最小化常驻） ============ */
.voice-call-bubble {
  position: fixed;
  z-index: 99998;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--vc-grad);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4),
              0 0 0 1px rgba(255, 255, 255, 0.4) inset;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  transition: transform 0.15s, box-shadow 0.2s;
  animation: vcBubbleIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.voice-call-bubble.show { display: flex; }
@keyframes vcBubbleIn {
  from { opacity: 0; transform: scale(0.4); }
  to { opacity: 1; transform: scale(1); }
}
.voice-call-bubble:hover {
  box-shadow: 0 12px 32px rgba(99, 102, 241, 0.55);
}
.voice-call-bubble.dragging { transition: none; cursor: grabbing; }

/* 线性 📞 图标（白色描边，无填充） */
.voice-call-bubble svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: #fff;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  position: relative;
  z-index: 2;
}

/* 持续呼吸光圈 */
.voice-call-bubble::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: var(--vc-grad);
  opacity: 0.35;
  z-index: -1;
  animation: vcBubbleBreath 2.4s ease-in-out infinite;
}
@keyframes vcBubbleBreath {
  0%, 100% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.18); opacity: 0; }
}

/* AI 说话中：水波扩散 */
.voice-call-bubble.speaking::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #A78BFA;
  opacity: 0;
  animation: vcBubbleWave 1.4s ease-out infinite;
}
@keyframes vcBubbleWave {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* 浮球右上角小关闭按钮（长按浮球时显示） */
.voice-call-bubble-close {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--vc-border);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  color: #EF4444;
  font-weight: bold;
  box-shadow: var(--vc-shadow-sm);
  z-index: 3;
  line-height: 1;
}
.voice-call-bubble.show-close .voice-call-bubble-close {
  display: flex;
}

/* ============ 移动端适配 ============ */
@media (max-width: 480px) {
  .voice-call-window {
    max-width: 100%;
    height: 100vh;
    border-radius: 0;
  }
  .voice-call-avatar {
    width: 78px;
    height: 78px;
  }
  .voice-call-name { font-size: 16px; }
  .voice-call-header-card { padding: 16px 24px 14px; }
  .voice-call-controls {
    padding: 12px 20px 28px;
    gap: 22px;
  }
  .voice-call-btn-icon { width: 52px; height: 52px; }
}

/* ============ 暗色主题适配 ============ */
.theme-dark .voice-call-window {
  background: linear-gradient(135deg, #1F1B3A 0%, #2A2348 50%, #2D2A5F 100%);
  border-color: rgba(167, 139, 250, 0.18);
}
.theme-dark .voice-call-name,
.theme-dark .voice-call-replay-header h3 {
  color: #E0DAFF;
}
.theme-dark .voice-call-status,
.theme-dark .voice-call-mode-tag,
.theme-dark .voice-call-btn-label {
  color: #B5ADDB;
}
.theme-dark .voice-call-back-btn,
.theme-dark .vc-input-mode-btn {
  background: rgba(255, 255, 255, 0.08);
}
.theme-dark .voice-call-back-btn svg { fill: #E0DAFF; }
.theme-dark .vc-input-mode-btn .vc-mode-icon { fill: #C4B5FD; }
.theme-dark .voice-call-mode-tag {
  background: rgba(255, 255, 255, 0.06);
}
.theme-dark .vc-trans-line.ai {
  background: rgba(255, 255, 255, 0.08);
  color: #E0DAFF;
  border-color: rgba(167, 139, 250, 0.2);
}
.theme-dark .vc-input-text-wrap {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(167, 139, 250, 0.2);
}
.theme-dark .vc-input-text { color: #E0DAFF; }
.theme-dark .vc-hold-talk-btn {
  background: rgba(255, 255, 255, 0.08);
  color: #E0DAFF;
  border-color: rgba(167, 139, 250, 0.3);
}
.theme-dark .voice-call-btn-icon {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(167, 139, 250, 0.2);
}
.theme-dark .voice-call-btn-icon svg { fill: #C4B5FD; }
.theme-dark .voice-call-replay-content {
  background: linear-gradient(135deg, #1F1B3A 0%, #2A2348 100%);
}
.theme-dark .voice-call-replay-body { color: #E0DAFF; }
.theme-dark .voice-call-replay-header { border-bottom-color: rgba(167, 139, 250, 0.2); }
