/* ===== Voice Call Page ===== */
:root {
  --bg: #0a0a0c;
  --bg-glass: rgba(255,255,255,0.04);
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --accent-dim: rgba(99, 102, 241, 0.12);
  --success: #22c55e;
  --danger: #ef4444;
  --text: #e8e8ed;
  --text-sec: #9898a0;
  --text-muted: #5e5e66;
  --wave-color: #6366f1;
  --wave-ai: #818cf8;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Noto Sans SC', 'PingFang SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.call-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 500px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* ===== Top Bar ===== */
.call-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  position: relative;
  z-index: 5;
}

.back-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-glass);
  border: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sec);
  text-decoration: none;
  font-size: 16px;
  transition: all 0.2s;
}

.back-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}

.call-timer {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-sec);
  font-variant-numeric: tabular-nums;
}

.call-timer.active {
  color: var(--success);
}

/* ===== Center ===== */
.call-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 0 24px;
  position: relative;
}

/* Avatar */
.avatar-ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.4s ease;
}

.avatar-ring::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: all 0.4s ease;
}

.avatar-inner {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--wave-ai));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

/* States */
.avatar-ring.listening {
  background: rgba(34, 197, 94, 0.12);
  box-shadow: 0 0 40px rgba(34, 197, 94, 0.15);
}

.avatar-ring.listening::before {
  border-color: rgba(34, 197, 94, 0.3);
  animation: pulse-ring 1.5s ease-out infinite;
}

.avatar-ring.speaking {
  background: rgba(99, 102, 241, 0.15);
  box-shadow: 0 0 40px var(--accent-glow);
  animation: barge-hint 3s ease-in-out infinite;
}

.avatar-ring.speaking::before {
  border-color: rgba(99, 102, 241, 0.3);
  animation: pulse-ring 1s ease-out infinite;
}

@keyframes barge-hint {
  0%, 100% { box-shadow: 0 0 40px var(--accent-glow); }
  50% { box-shadow: 0 0 40px var(--accent-glow), 0 0 15px rgba(34, 197, 94, 0.15); }
}

.avatar-ring.thinking {
  background: rgba(234, 179, 8, 0.1);
  box-shadow: 0 0 30px rgba(234, 179, 8, 0.1);
}

.avatar-ring.thinking::before {
  border-color: rgba(234, 179, 8, 0.2);
  animation: pulse-ring 2s ease-out infinite;
}

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

/* Waveform */
.waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 40px;
  opacity: 0;
  transition: opacity 0.3s;
}

.waveform.active {
  opacity: 1;
}

.wave-bar {
  width: 3px;
  height: 6px;
  background: var(--wave-color);
  border-radius: 2px;
  transition: height 0.08s ease;
}

.waveform.ai-speaking .wave-bar {
  background: var(--wave-ai);
}

.waveform.listening .wave-bar {
  background: var(--success);
}

/* Status text */
.call-status {
  font-size: 15px;
  color: var(--text-sec);
  text-align: center;
  transition: color 0.3s;
}

.call-status.listening {
  color: var(--success);
}

.call-status.speaking {
  color: var(--wave-ai);
}

.call-status.thinking {
  color: #eab308;
}

/* Language toggle */
.lang-toggle {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lang-pill-call {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 16px;
  padding: 5px 28px 5px 12px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  line-height: 1.4;
  transition: all 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23818cf8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.lang-pill-call:hover {
  background-color: rgba(99, 102, 241, 0.22);
  border-color: #6366f1;
}

.lang-pill-call:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.lang-pill-call option {
  background: #1a1a1f;
  color: #e8e8ed;
  font-size: 13px;
}

/* Realtime Caption */
.realtime-caption {
  display: none;
  padding: 16px 24px;
  margin: 12px 0;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 16px;
  font-size: 18px;
  line-height: 1.6;
  color: #fff;
  text-align: center;
  max-width: 85%;
  max-height: 120px;       /* 固定最大高度，避免文字多时拉得过大 */
  overflow-y: auto;        /* 内容超出时显示滚动条 */
  word-wrap: break-word;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: fadeIn 0.2s ease;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

/* 滚动条样式 */
.realtime-caption::-webkit-scrollbar {
  width: 4px;
}
.realtime-caption::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
}
.realtime-caption::-webkit-scrollbar-track {
  background: transparent;
}

.caption-logo {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.caption-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.caption-text {
  flex: 1;
  text-align: left;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Transcript */
.transcript {
  display: none;
}

.transcript-item {
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  max-width: 85%;
  animation: slideUp 0.2s ease;
}

.transcript-item.user {
  background: var(--accent);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.transcript-item.ai {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Bottom Controls ===== */
.call-bottom {
  padding: 24px 20px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
}

.call-controls {
  display: flex;
  align-items: center;
  gap: 28px;
}

.ctrl-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.ctrl-btn svg {
  pointer-events: none;
}

/* Mute / Speaker buttons */
.mute-btn, .speaker-btn {
  background: var(--bg-glass);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-sec);
}

.mute-btn:hover, .speaker-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}

.mute-btn.active {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

.speaker-btn.active {
  background: var(--accent-dim);
  border-color: rgba(99, 102, 241, 0.3);
  color: var(--accent);
}

/* Call button */
.call-btn {
  width: 72px;
  height: 72px;
  background: var(--success);
  color: #fff;
  box-shadow: 0 4px 20px rgba(34, 197, 94, 0.3);
}

.call-btn:hover {
  background: #16a34a;
  box-shadow: 0 4px 24px rgba(34, 197, 94, 0.4);
}

.call-btn.active {
  background: var(--danger);
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
}

.call-btn.active:hover {
  background: #dc2626;
  box-shadow: 0 4px 24px rgba(239, 68, 68, 0.4);
}

/* Scrollbar */
.transcript::-webkit-scrollbar {
  width: 3px;
}

.transcript::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
}

/* ===== Responsive ===== */
@media (max-width: 400px) {
  .avatar-ring { width: 100px; height: 100px; }
  .avatar-inner { width: 66px; height: 66px; }
  .call-controls { gap: 20px; }
  .ctrl-btn { width: 48px; height: 48px; }
  .call-btn { width: 64px; height: 64px; }
}

/* Landscape */
@media (orientation: landscape) and (max-height: 500px) {
  .call-center { gap: 12px; }
  .avatar-ring { width: 80px; height: 80px; }
  .avatar-inner { width: 56px; height: 56px; }
  .transcript { max-height: 60px; }
  .call-bottom { padding: 12px 20px; }
}
