/* ============================================================
   云传音AI - 公共样式表
   ============================================================ */

/* CSS 变量 */
:root {
  --bg-color: #fff8f0;
  --primary: #b95743;
  --primary-hover: #a04a38;
  --primary-light: rgba(185, 87, 67, 0.1);
  --text-primary: #3b2f2a;
  --text-secondary: #77665f;
  --accent: #748b72;
  --card-bg: #ffffff;
  --border-color: #e8ddd5;
  --input-bg: #fdfbf8;
  --radius: 20px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --shadow: 0 2px 16px rgba(59, 47, 42, 0.08);
  --shadow-lg: 0 8px 32px rgba(59, 47, 42, 0.12);
  --font-title: 'Songti SC', STSong, 'SimSun', serif;
  --font-body: 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
  --font-handwriting: 'Kaiti SC', STKaiti, 'KaiTi', serif;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

/* 重置 */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background-color: var(--bg-color);
  min-height: 100dvh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

/* ============================================================
   布局容器
   ============================================================ */
.app-container {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  background: var(--bg-color);
}

.page-content {
  padding: 20px 24px;
  padding-top: calc(20px + var(--safe-top));
  padding-bottom: calc(80px + var(--safe-bottom));
}

/* ============================================================
   卡片
   ============================================================ */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

/* ============================================================
   按钮
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  background: #d4a99e;
  cursor: not-allowed;
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary-light);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-group {
  display: flex;
  gap: 12px;
}

.btn-group .btn {
  flex: 1;
}

/* ============================================================
   表单
   ============================================================ */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--input-bg);
  transition: border-color 0.2s;
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
}

.form-input::placeholder {
  color: #bfb5ad;
}

/* 上传区域 */
.upload-area {
  width: 100%;
  min-height: 120px;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-xs);
  background: var(--input-bg);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s;
}
.upload-area:hover {
  border-color: var(--primary);
}

.form-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

/* ============================================================
   首页
   ============================================================ */
.home-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 40px 24px;
  position: relative;
  overflow: hidden;
}

.home-page::before {
  content: '';
  position: absolute;
  top: -100px;
  right: -100px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(185, 87, 67, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.home-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 40px;
}

.home-logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #e8d5f5, #d5e8f5);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.home-logo-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.home-card {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 40px 28px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.home-title {
  font-family: var(--font-title);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.home-desc {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 32px;
}

.home-buttons {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.home-buttons .btn {
  flex: 1;
}

.home-hint {
  font-size: 13px;
  color: #bfb5ad;
}

.home-footer {
  margin-top: 40px;
  font-size: 13px;
  color: #bfb5ad;
}

.home-footer a {
  color: #bfb5ad;
  text-decoration: underline;
}

/* ============================================================
   登录/注册页
   ============================================================ */
.auth-page {
  min-height: 100dvh;
  padding: 20px 24px;
  padding-top: calc(20px + var(--safe-top));
}

.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--primary);
  margin-bottom: 24px;
  cursor: pointer;
}

.auth-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.auth-header-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #e8d5f5, #d5e8f5);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.auth-header-text {
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
}

.auth-title {
  font-family: var(--font-title);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
  line-height: 1.6;
}

.auth-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--primary);
  font-weight: 600;
}

/* ============================================================
   底部Tab栏
   ============================================================ */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
  padding-bottom: var(--safe-bottom);
  z-index: 100;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  min-height: 56px;
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.tab-item .tab-icon {
  font-size: 22px;
  margin-bottom: 2px;
  color: #bfb5ad;
}

.tab-item .tab-label {
  font-size: 11px;
  color: #bfb5ad;
}

.tab-item.active .tab-icon,
.tab-item.active .tab-label {
  color: var(--primary);
}

/* ============================================================
   顶部导航栏
   ============================================================ */
.nav-bar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  padding: 0 16px;
  padding-top: var(--safe-top);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  z-index: 99;
}

.nav-bar .nav-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.nav-bar .nav-back {
  position: absolute;
  left: 16px;
  font-size: 14px;
  color: var(--primary);
  cursor: pointer;
}

/* ============================================================
   列表项
   ============================================================ */
.list-item {
  display: flex;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.15s;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:active {
  background: var(--primary-light);
}

.list-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-right: 14px;
  flex-shrink: 0;
}

.list-item-content {
  flex: 1;
}

.list-item-title {
  font-size: 15px;
  color: var(--text-primary);
}

.list-item-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.list-item-arrow {
  color: #d4ccc6;
  font-size: 14px;
}

/* ============================================================
   数字人卡片
   ============================================================ */
.avatar-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: transform 0.15s;
}

.avatar-card:active {
  transform: scale(0.98);
}

.avatar-card-img {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border-color);
}

.avatar-card-info {
  flex: 1;
  min-width: 0;
}

.avatar-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.avatar-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   浮动按钮
   ============================================================ */
.fab {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  right: calc(50% - 220px);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(185, 87, 67, 0.35);
  cursor: pointer;
  transition: transform 0.2s;
  z-index: 90;
}

.fab:active {
  transform: scale(0.9);
}

@media (max-width: 480px) {
  .fab {
    right: 20px;
  }
}

/* ============================================================
   个人中心
   ============================================================ */
.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 0;
  margin-bottom: 16px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border-color);
}

.profile-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.profile-username {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ============================================================
   会员卡片
   ============================================================ */
.membership-card {
  background: linear-gradient(135deg, var(--primary), #d4755f);
  border-radius: var(--radius);
  padding: 24px;
  color: #fff;
  margin-bottom: 20px;
}

.membership-card .plan-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.membership-card .plan-expire {
  font-size: 14px;
  opacity: 0.85;
}

/* ============================================================
   弹窗/遮罩
   ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--card-bg);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px;
  padding-bottom: calc(24px + var(--safe-bottom));
  width: 100%;
  max-width: 480px;
  transform: translateY(100%);
  transition: transform 0.3s;
}

.modal-overlay.show .modal-content {
  transform: translateY(0);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: center;
}

/* ============================================================
   Toast 提示
   ============================================================ */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-xs);
  font-size: 14px;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  max-width: 280px;
  text-align: center;
}

.toast.show {
  opacity: 1;
}

/* ============================================================
   空状态
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state-text {
  font-size: 15px;
}

/* ============================================================
   加载动画
   ============================================================ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   公告标记
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e74c3c;
  display: inline-block;
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 760px) {
  .app-container {
    max-width: 100%;
  }
  .tab-bar {
    max-width: 100%;
  }
}

@media (min-width: 481px) {
  .app-container {
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.06);
  }
}

/* ============================================================
   通话页面样式
   ============================================================ */
.call-page {
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: #fff;
}

/* 顶部信息栏 */
.call-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
}
.call-back {
  font-size: 24px;
  color: #fff;
  text-decoration: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.call-header-info {
  flex: 1;
  text-align: center;
}
.call-avatar-name {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}
.call-timer {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.call-type-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.8);
}

/* 内容区 */
.call-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* 语音模式 */
.voice-mode {
  text-align: center;
  width: 100%;
}
.voice-avatar-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto 24px;
}
.voice-avatar {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255,255,255,0.2);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.voice-status {
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  margin-top: 16px;
}

/* 声波动画 */
.voice-wave {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  align-items: flex-end;
  height: 20px;
}
.voice-wave span {
  display: block;
  width: 3px;
  background: var(--primary);
  border-radius: 2px;
  animation: voiceWave 0.8s ease-in-out infinite;
}
.voice-wave span:nth-child(1) { height: 8px; animation-delay: 0s; }
.voice-wave span:nth-child(2) { height: 14px; animation-delay: 0.1s; }
.voice-wave span:nth-child(3) { height: 20px; animation-delay: 0.2s; }
.voice-wave span:nth-child(4) { height: 14px; animation-delay: 0.3s; }
.voice-wave span:nth-child(5) { height: 8px; animation-delay: 0.4s; }

@keyframes voiceWave {
  0%, 100% { transform: scaleY(0.5); opacity: 0.5; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* 视频模式 */
.video-mode {
  width: 100%;
  height: 100%;
  position: relative;
}
.remote-video {
  width: 100%;
  height: 100%;
  min-height: 300px;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
}
.remote-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.local-video {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 100px;
  height: 140px;
  background: #333;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.3);
}
.local-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 底部控制栏 */
.call-controls {
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: 24px 16px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
.ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: #fff;
}
.ctrl-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: background 0.2s;
}
.ctrl-btn:active .ctrl-icon {
  background: rgba(255,255,255,0.25);
}
.ctrl-btn.active .ctrl-icon {
  background: rgba(255,255,255,0.3);
}
.ctrl-label {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
}

/* 挂断按钮 */
.ctrl-btn-hangup .ctrl-icon {
  background: #e74c3c;
  font-size: 22px;
}
.ctrl-btn-hangup:active .ctrl-icon {
  background: #c0392b;
}
