/* ===== 全局重置 & 基础变量 ===== */

/* ---------- 浅色主题（默认） ---------- */
:root,
:root[data-theme="light"] {
  --bg-primary: #f7f7fb;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f0f0f7;
  --text-primary: #1a1a24;
  --text-secondary: #5a5a72;
  --text-muted: #8e8ea8;
  --accent: #6d4aff;
  --accent-hover: #5a37f0;
  --accent-glow: rgba(109, 74, 255, 0.14);
  --border: #e4e4ef;
  --border-light: #d2d2e2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(20, 20, 50, 0.08);
  --shadow-sm: 0 1px 3px rgba(20, 20, 50, 0.06);
  --header-bg: rgba(255, 255, 255, 0.9);
  --transition: all 0.2s ease;
  --header-h: 56px;
  color-scheme: light;
}

/* ---------- 深色主题 ---------- */
:root[data-theme="dark"] {
  --bg-primary: #0f0f14;
  --bg-secondary: #1a1a24;
  --bg-card: #22222f;
  --bg-hover: #2a2a3a;
  --text-primary: #e8e8f0;
  --text-secondary: #9898b0;
  --text-muted: #5a5a72;
  --accent: #7c5cff;
  --accent-hover: #8f73ff;
  --accent-glow: rgba(124, 92, 255, 0.25);
  --border: #2e2e42;
  --border-light: #3a3a52;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --header-bg: rgba(15, 15, 20, 0.92);
  color-scheme: dark;
}

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

html, body {
  height: 100%;
  overflow-x: hidden;
}

/* 主题切换时平滑过渡（避免首屏闪烁） */
html.theme-ready body,
html.theme-ready .card,
html.theme-ready .shortcut-item,
html.theme-ready .search-box {
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
  color: inherit;
}

input {
  font-family: inherit;
  outline: none;
  border: none;
  background: none;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

/* ===== 右上角控制区（主题切换） ===== */
.top-controls {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 100;
}

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--bg-hover);
  transform: translateY(-1px);
}

.theme-toggle:active {
  transform: translateY(0);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* 图标显示逻辑：浅色主题显示月亮（点击进深色），深色主题显示太阳 */
.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun { display: none; }

:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* ===== 通用卡片 ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.card:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
}

/* ===== 加载动画 ===== */
.loading-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: dot-bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== 工具类 ===== */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
