/* ============================================================
   鸡腿小站 · Apple 风格主题 v2（强制覆盖版）
   使用高优先级选择器，确保覆盖 new-api 的 18 个 :root 块
   ============================================================ */

/* ---------- 强制覆盖所有主题预设 ---------- */
html,
html:root,
html[data-theme-preset],
html[data-theme-preset="default"],
html[data-theme-preset="anthropic"],
html[data-theme-preset="forest-whisper"],
html[data-theme-preset="lake-view"],
html[data-theme-preset="lavender-dream"],
html[data-theme-preset="ocean-breeze"],
html[data-theme-preset="rose-garden"],
html[data-theme-preset="simple-large"],
html[data-theme-preset="sunset-glow"],
html[data-theme-preset="underground"] {
  --font-ui-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    system-ui, sans-serif !important;
  --font-body: var(--font-ui-sans) !important;
  --font-sans: var(--font-ui-sans) !important;

  --radius: 0.875rem !important;
  --radius-xs: 0.375rem !important;
  --radius-sm: 0.5rem !important;
  --radius-md: 0.75rem !important;
  --radius-lg: 1rem !important;
  --radius-xl: 1.25rem !important;

  --primary: #0071e3 !important;
  --primary-foreground: #ffffff !important;
  --ring: #0071e3 !important;
}

/* 浅色主题 */
html:not(.dark),
html[data-theme-preset="default"]:not(.dark) {
  --background: #f5f5f7 !important;
  --foreground: #1d1d1f !important;
  --card: #ffffff !important;
  --card-foreground: #1d1d1f !important;
  --popover: #ffffff !important;
  --popover-foreground: #1d1d1f !important;
  --secondary: #e8e8ed !important;
  --secondary-foreground: #1d1d1f !important;
  --muted: #f5f5f7 !important;
  --muted-foreground: #6e6e73 !important;
  --accent: #e8f2fd !important;
  --accent-foreground: #0071e3 !important;
  --border: #d2d2d7 !important;
  --input: #d2d2d7 !important;
  --destructive: #ff3b30 !important;
}

/* 深色主题 */
html.dark,
html[data-theme-preset].dark {
  --background: #000000 !important;
  --foreground: #f5f5f7 !important;
  --card: #1c1c1e !important;
  --card-foreground: #f5f5f7 !important;
  --popover: #1c1c1e !important;
  --popover-foreground: #f5f5f7 !important;
  --primary: #0a84ff !important;
  --primary-foreground: #ffffff !important;
  --ring: #0a84ff !important;
  --secondary: #2c2c2e !important;
  --secondary-foreground: #f5f5f7 !important;
  --muted: #1c1c1e !important;
  --muted-foreground: #98989d !important;
  --accent: #0a2a4a !important;
  --accent-foreground: #0a84ff !important;
  --border: #38383a !important;
  --input: #38383a !important;
  --destructive: #ff453a !important;
}

/* ---------- 字体强制 ---------- */
html,
body,
body *:not(i):not(.icon):not([class*="icon"]):not(svg):not(svg *) {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    system-ui, sans-serif !important;
  -webkit-font-smoothing: antialiased !important;
  -moz-osx-font-smoothing: grayscale !important;
}

/* 代码块保持等宽 */
code, pre, kbd, samp, textarea[class*="mono"], .font-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
}

/* ---------- 背景强制 ---------- */
html:not(.dark) body {
  background-color: #f5f5f7 !important;
}

html.dark body {
  background-color: #000 !important;
}

/* 顶部渐变光晕 */
body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60vh;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse 70% 60% at 50% -20%,
    rgba(0, 113, 227, 0.10), transparent 70%);
}

html.dark body::after {
  background: radial-gradient(ellipse 70% 60% at 50% -20%,
    rgba(10, 132, 255, 0.18), transparent 70%);
}

/* ---------- 圆角强制 ---------- */
.rounded, .rounded-sm, .rounded-md {
  border-radius: 0.75rem !important;
}
.rounded-lg {
  border-radius: 0.875rem !important;
}
.rounded-xl {
  border-radius: 1rem !important;
}
.rounded-2xl {
  border-radius: 1.25rem !important;
}

/* ---------- 卡片：白底 + 细边 + 柔和阴影 ---------- */
html:not(.dark) [class*="bg-card"],
html:not(.dark) .glass-1,
html:not(.dark) .glass-2,
html:not(.dark) .glass-3 {
  background-color: #ffffff !important;
  border-color: #e5e5ea !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.03) !important;
}

/* ---------- 按钮 ---------- */
button, .btn, [role="button"] {
  transition: all 0.24s cubic-bezier(0.4, 0, 0.2, 1) !important;
  letter-spacing: -0.01em !important;
  font-weight: 500 !important;
}

button:active, .btn:active {
  transform: scale(0.975) !important;
}

/* 主按钮苹果蓝 */
html:not(.dark) .bg-blue-500,
html:not(.dark) .bg-blue-600,
html:not(.dark) [class*="bg-primary"] {
  background-color: #0071e3 !important;
  box-shadow: 0 1px 3px rgba(0, 113, 227, 0.28) !important;
}

html:not(.dark) .bg-blue-500:hover,
html:not(.dark) .bg-blue-600:hover {
  background-color: #0077ed !important;
  box-shadow: 0 4px 14px rgba(0, 113, 227, 0.35) !important;
}

/* ---------- 输入框 ---------- */
input, textarea, select {
  transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
  border-radius: 0.625rem !important;
}

input:focus, textarea:focus, select:focus {
  outline: none !important;
  border-color: #0071e3 !important;
  box-shadow: 0 0 0 3.5px rgba(0, 113, 227, 0.16) !important;
}

html.dark input:focus,
html.dark textarea:focus,
html.dark select:focus {
  border-color: #0a84ff !important;
  box-shadow: 0 0 0 3.5px rgba(10, 132, 255, 0.24) !important;
}

/* ---------- 表格 ---------- */
table { border-collapse: separate !important; border-spacing: 0 !important; }

thead th {
  font-weight: 600 !important;
  font-size: 0.8125rem !important;
  color: #6e6e73 !important;
}

html.dark thead th { color: #98989d !important; }

tbody tr { transition: background-color 0.18s ease !important; }

tbody tr:hover { background-color: rgba(0, 113, 227, 0.045) !important; }
html.dark tbody tr:hover { background-color: rgba(10, 132, 255, 0.10) !important; }

/* 数字等宽 */
table td { font-variant-numeric: tabular-nums; }

/* ---------- 滚动条 macOS 风格 ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.18);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0, 0, 0, 0.32);
  background-clip: content-box;
}
html.dark ::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.22);
  background-clip: content-box;
}

/* ---------- 弹窗浮层阴影 ---------- */
[role="dialog"], [class*="popover"], [class*="dropdown"], [class*="Dialog"] {
  border-radius: 1rem !important;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.06) !important;
}

html.dark [role="dialog"],
html.dark [class*="popover"],
html.dark [class*="dropdown"] {
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08) !important;
}

/* ---------- 徽章胶囊化 ---------- */
[class*="badge"], [class*="Badge"] {
  border-radius: 999px !important;
  font-weight: 500 !important;
}

/* ---------- 链接 ---------- */
a { transition: color 0.2s ease, opacity 0.2s ease; }
a:hover { opacity: 0.82; }

/* ---------- 侧栏/顶栏毛玻璃 ---------- */
header, nav, aside, [class*="sidebar"], [class*="Sidebar"] {
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}

/* ---------- 动效曲线 ---------- */
*, *::before, *::after {
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- 减少动效 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
