/**
 * 站点全局设计系统 theme.css
 * 统一色彩 / 圆角 / 阴影 / 字体 / 间距 / 动效 / 断点
 * 支持 [data-theme="light|dark"]
 */

/* ========== CSS Variables ========== */
:root {
  /* 品牌色 */
  --brand-purple: #7C3AED;
  --brand-cyan: #06B6D4;
  --brand-gradient: linear-gradient(135deg, #7C3AED 0%, #06B6D4 100%);
  --brand-gradient-reverse: linear-gradient(135deg, #06B6D4 0%, #7C3AED 100%);
  --brand-purple-light: #A78BFA;
  --brand-cyan-light: #67E8F9;

  /* 语义色 */
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-danger: #EF4444;
  --color-info: #3B82F6;

  /* 浅色主题 */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F8FAFC;
  --bg-tertiary: #F1F5F9;
  --bg-accent: #FAF5FF;
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --border-color: #E2E8F0;
  --border-strong: #CBD5E1;

  /* 圆角 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 999px;

  /* 阴影 */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-glow-purple: 0 0 30px rgba(124, 58, 237, 0.3);
  --shadow-glow-cyan: 0 0 30px rgba(6, 182, 212, 0.3);

  /* 字体 */
  --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;
  --text-6xl: 4rem;

  /* 间距 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;

  /* 动效 */
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* 断点（仅作参考，实际用 media query） */
  --breakpoint-xs: 480px;
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;
}

/* 深色主题 */
[data-theme="dark"] {
  --bg-primary: #0F172A;
  --bg-secondary: #1E293B;
  --bg-tertiary: #334155;
  --bg-accent: #1A1338;
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --border-color: #334155;
  --border-strong: #475569;
}

/* ========== Reset & Base ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.theme-transitioning {
  transition: background-color 0.3s ease, color 0.3s ease;
}

img, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--brand-purple);
  text-decoration: none;
  transition: var(--transition-fast);
}

a:hover {
  color: var(--brand-cyan);
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

/* ========== Typography ========== */
.text-gradient {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.font-black { font-weight: 900; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition-base);
  white-space: nowrap;
  line-height: 1.4;
  min-height: 44px; /* 移动端触摸目标 */
}

.btn:disabled,
.btn.is-loading {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--primary {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.btn--primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), var(--shadow-glow-purple);
}

.btn--primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn--secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1.5px solid var(--border-strong);
}

.btn--secondary:hover:not(:disabled) {
  border-color: var(--brand-purple);
  color: var(--brand-purple);
  background: var(--bg-accent);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn--danger {
  background: var(--color-danger);
  color: #fff;
}

.btn--sm {
  padding: 6px 12px;
  font-size: var(--text-xs);
  min-height: 32px;
}

.btn--lg {
  padding: 14px 28px;
  font-size: var(--text-base);
  min-height: 52px;
}

.btn--icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-full);
}

.btn--block {
  width: 100%;
}

/* ========== Form Controls ========== */
.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: var(--transition-fast);
  outline: none;
}

.form-control:focus {
  border-color: var(--brand-purple);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
  margin-top: var(--space-1);
}

/* ========== Cards ========== */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card__header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
}

.card__body {
  padding: var(--space-6);
}

.card__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

/* ========== Badge ========== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.4;
}

.badge--success { background: rgba(16, 185, 129, 0.15); color: var(--color-success); }
.badge--warning { background: rgba(245, 158, 11, 0.15); color: var(--color-warning); }
.badge--danger { background: rgba(239, 68, 68, 0.15); color: var(--color-danger); }
.badge--info { background: rgba(59, 130, 246, 0.15); color: var(--color-info); }
.badge--purple { background: rgba(124, 58, 237, 0.15); color: var(--brand-purple); }

/* ========== Avatar ========== */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--text-sm);
  color: #fff;
  flex-shrink: 0;
  background: var(--brand-gradient);
  position: relative;
  overflow: hidden;
}

.avatar--sm { width: 32px; height: 32px; font-size: var(--text-xs); }
.avatar--lg { width: 48px; height: 48px; font-size: var(--text-base); }
.avatar--xl { width: 64px; height: 64px; font-size: var(--text-xl); }
.avatar--2xl { width: 96px; height: 96px; font-size: var(--text-3xl); }

.avatar__status {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-primary);
  background: var(--color-success);
}

.avatar__status--offline {
  background: var(--text-muted);
}

/* 预设头像色块（20 种） */
.avatar-seed-0 { background: linear-gradient(135deg, #7C3AED, #EC4899); }
.avatar-seed-1 { background: linear-gradient(135deg, #06B6D4, #3B82F6); }
.avatar-seed-2 { background: linear-gradient(135deg, #F59E0B, #EF4444); }
.avatar-seed-3 { background: linear-gradient(135deg, #10B981, #06B6D4); }
.avatar-seed-4 { background: linear-gradient(135deg, #8B5CF6, #EC4899); }
.avatar-seed-5 { background: linear-gradient(135deg, #3B82F6, #8B5CF6); }
.avatar-seed-6 { background: linear-gradient(135deg, #EF4444, #F59E0B); }
.avatar-seed-7 { background: linear-gradient(135deg, #14B8A6, #10B981); }
.avatar-seed-8 { background: linear-gradient(135deg, #F97316, #EC4899); }
.avatar-seed-9 { background: linear-gradient(135deg, #6366F1, #06B6D4); }
.avatar-seed-10 { background: linear-gradient(135deg, #A855F7, #7C3AED); }
.avatar-seed-11 { background: linear-gradient(135deg, #0EA5E9, #6366F1); }
.avatar-seed-12 { background: linear-gradient(135deg, #22C55E, #14B8A6); }
.avatar-seed-13 { background: linear-gradient(135deg, #E11D48, #F97316); }
.avatar-seed-14 { background: linear-gradient(135deg, #7C3AED, #06B6D4); }
.avatar-seed-15 { background: linear-gradient(135deg, #F43F5E, #A855F7); }
.avatar-seed-16 { background: linear-gradient(135deg, #0D9488, #3B82F6); }
.avatar-seed-17 { background: linear-gradient(135deg, #D946EF, #EC4899); }
.avatar-seed-18 { background: linear-gradient(135deg, #84CC16, #10B981); }
.avatar-seed-19 { background: linear-gradient(135deg, #6366F1, #EC4899); }

/* ========== Utility ========== */
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.text-center { text-align: center; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ========== Selection ========== */
::selection {
  background: rgba(124, 58, 237, 0.25);
  color: var(--text-primary);
}

/* ========== Focus visible ========== */
:focus-visible {
  outline: 2px solid var(--brand-purple);
  outline-offset: 2px;
}

/* ========== Container ========== */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

@media (min-width: 768px) {
  .container {
    padding: 0 var(--space-6);
  }
}

/* ========== Theme Toggle Button ========== */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-base);
}

.theme-toggle:hover {
  background: var(--bg-tertiary);
  color: var(--brand-purple);
  border-color: var(--brand-purple);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  transition: transform 0.4s ease;
}

.theme-toggle.is-rotating svg {
  transform: rotate(180deg);
}
