/* main.css - 基础样式 + 重置 + 工具类 */
@import 'tokens.css';

/* Noto Color Emoji:跨平台统一 emoji 显示 */
/* ★ v4.1-fix7dao-v10: 不加 unicode-range 让浏览器加载全部字符 */
@font-face {
  font-family: 'NotoColorEmoji';
  src: url('/fonts/NotoColorEmoji.ttf') format('truetype'),
       url(/fonts/NotoColorEmoji.ttf);
  font-display: swap;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", "Apple Color Emoji", "Segoe UI Emoji", "NotoColorEmoji", "Segoe UI Symbol", "EmojiOne Color", "Twemoji Mozilla", sans-serif;
  font-size: var(--fs-base);
  color: var(--text-1);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}
button, input, textarea, select { font: inherit; outline: none; border: none; background: transparent; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-500); text-decoration: none; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

#app { height: 100dvh; min-height: 100vh; display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; background: var(--bg-app); position: relative; overflow: hidden; }

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-3); }
.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-lg { font-size: var(--fs-lg); }
.flex { display: flex; }
.flex-1 { flex: 1; min-width: 0; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 按钮系统(扁平化:统一圆角,无阴影无品牌光晕) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: var(--h-btn); padding: 0 var(--sp-4);
  border-radius: var(--r-md); font-size: var(--fs-base); font-weight: var(--fw-medium);
  transition: all var(--t-fast) var(--ease);
  white-space: nowrap; user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:active { transform: none; }
.btn-primary { background: var(--brand-500); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-primary:active { background: var(--brand-700); }
.btn-secondary { background: var(--brand-100); color: var(--brand-600); }
.btn-secondary:hover { background: var(--brand-200); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-block { width: 100%; }
.btn-sm { height: var(--h-btn-sm); padding: 0 var(--sp-3); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-lg { height: var(--h-btn-lg); padding: 0 var(--sp-6); font-size: var(--fs-md); }

/* 输入框(扁平化:focus 仅靠底色差,无外发光) */
.input {
  width: 100%; height: var(--h-input);
  padding: 0 var(--sp-4); border-radius: var(--r-md);
  background: var(--gray-100); color: var(--text-1);
  font-size: var(--fs-base);
  transition: all var(--t-fast) var(--ease);
}
.input:focus { background: var(--brand-50); }
.input::placeholder { color: var(--text-4); }

.input-field {
  display: flex; align-items: center; gap: var(--sp-3);
  height: var(--h-input); padding: 0 var(--sp-4);
  background: var(--gray-100); border-radius: var(--r-md);
  transition: all var(--t-fast) var(--ease);
}
.input-field:focus-within { background: var(--brand-50); }
.input-field input { flex: 1; height: 100%; background: transparent; }
.input-field-icon { color: var(--text-3); font-size: var(--fs-lg); flex-shrink: 0; }

/* 头像 */
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--avatar-palette);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-md); font-weight: var(--fw-semibold);
  flex-shrink: 0; user-select: none;
  position: relative; overflow: hidden;
}
.avatar-sm { width: 32px; height: 32px; font-size: var(--fs-sm); }
.avatar-lg { width: 64px; height: 64px; font-size: var(--fs-2xl); }
.avatar-xl { width: 96px; height: 96px; font-size: var(--fs-3xl); }

.avatar-wrap { position: relative; display: inline-flex; }
.online-dot {
  position: absolute; bottom: 0; right: 0;
  width: 12px; height: 12px; background: var(--success);
  border: 2px solid var(--bg-card); border-radius: 50%;
}
.online-dot.away { background: var(--warning); }
.online-dot.busy { background: var(--danger); }

/* 徽章 */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--danger); color: #fff;
  font-size: var(--fs-xs); font-weight: var(--fw-medium);
  border-radius: var(--r-pill);
}
.badge-success { background: var(--success); }
.badge-warning { background: var(--warning); }
.badge-info { background: var(--info); }
.badge-dot { width: 8px; height: 8px; min-width: 8px; padding: 0; border-radius: 50%; }

/* 图标按钮 */
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-lg); color: var(--text-2);
  transition: all var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--gray-100); }
.icon-btn:active { background: var(--gray-200); transform: scale(0.95); }

/* 滚动条美化 */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* 安全区(iOS 底部) */
@supports (padding: max(0px)) {
  .safe-bottom { padding-bottom: max(var(--sp-4), env(safe-area-inset-bottom)); }
  .safe-top { padding-top: max(0px, env(safe-area-inset-top)); }
}

/* === 修复:浏览器自动填充的粉黄背景(尤其 iOS Safari) === */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px var(--bg-card) inset !important;
  -webkit-text-fill-color: var(--text-1) !important;
  background-color: var(--bg-card) !important;
  background-image: none !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* ★ v4.3.0-fix28dao: 启动加载占位 - 顶级 splash 屏 */
.splash-screen {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #0c0a1f 100%);
  overflow: hidden;
  animation: splashFadeIn 0.5s var(--ease);
}
@keyframes splashFadeIn { from { opacity: 0; } to { opacity: 1; } }
.splash-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(14,165,233,0.18) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(251,146,60,0.15) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.04) 0%, transparent 60%);
  animation: splashBgPulse 4s ease-in-out infinite;
}
@keyframes splashBgPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.85; }
}
.splash-content {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 24px;
  z-index: 1;
  animation: splashContentIn 0.6s var(--ease) 0.1s both;
}
@keyframes splashContentIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.splash-logo {
  position: relative;
  width: 96px; height: 96px;
  display: flex; align-items: center; justify-content: center;
  animation: splashLogoSpin 12s linear infinite;
}
@keyframes splashLogoSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.splash-logo-blue,
.splash-logo-orange {
  position: absolute; top: 50%; left: 50%;
  width: 56px; height: 56px; border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: splashCirclePulse 2.4s ease-in-out infinite;
}
.splash-logo-blue { background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%); margin-left: -16px; box-shadow: 0 4px 16px rgba(14,165,233,0.4); }
.splash-logo-orange { background: linear-gradient(135deg, #fb923c 0%, #f97316 100%); margin-left: 16px; animation-delay: 1.2s; box-shadow: 0 4px 16px rgba(251,146,60,0.4); }
@keyframes splashCirclePulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.08); }
}
.splash-logo-line {
  position: absolute; top: 50%; left: 50%;
  width: 56px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
  transform: translate(-50%, -50%);
}
.splash-logo-dot {
  position: absolute; top: 50%; left: 50%;
  width: 8px; height: 8px; border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 12px rgba(255,255,255,0.8);
  animation: splashDotBeat 1.6s ease-in-out infinite;
}
@keyframes splashDotBeat {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.3); }
}
.splash-logo-star {
  position: absolute; width: 4px; height: 4px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 0 6px rgba(255,255,255,0.8);
  animation: splashStarTwinkle 2.4s ease-in-out infinite;
}
.splash-logo-star-1 { top: 8px; left: 50%; transform: translateX(-50%); animation-delay: 0s; }
.splash-logo-star-2 { top: 24px; right: 12px; animation-delay: 0.4s; }
.splash-logo-star-3 { bottom: 24px; right: 8px; animation-delay: 0.8s; }
.splash-logo-star-4 { bottom: 8px; left: 50%; transform: translateX(-50%); animation-delay: 1.2s; }
.splash-logo-star-5 { bottom: 24px; left: 12px; animation-delay: 1.6s; }
.splash-logo-star-6 { top: 24px; left: 8px; animation-delay: 2.0s; }
.splash-logo-star-7 { top: 50%; left: 50%; transform: translate(-50%, -50%); width: 2px; height: 2px; animation-delay: 0.2s; }
@keyframes splashStarTwinkle {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}
.splash-title {
  font-size: 28px; font-weight: 700; color: #fff;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.splash-slogan {
  font-size: 13px; color: rgba(255,255,255,0.6);
  letter-spacing: 4px;
  font-weight: 300;
}
.splash-progress {
  width: 120px; height: 2px;
  background: rgba(255,255,255,0.1);
  border-radius: 1px;
  overflow: hidden;
  margin-top: 8px;
}
.splash-progress-bar {
  width: 40%; height: 100%;
  background: linear-gradient(90deg, transparent, #fff, transparent);
  animation: splashProgress 1.6s ease-in-out infinite;
}
@keyframes splashProgress {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
@media (prefers-reduced-motion: reduce) {
  .splash-logo, .splash-bg, .splash-logo-blue, .splash-logo-orange,
  .splash-logo-dot, .splash-logo-star, .splash-progress-bar {
    animation: none;
  }
}
