@import "tailwindcss";
@import "tw-animate-css";
@import "@/assets/main.css";

@custom-variant dark (&:is(.dark *));

:root {
  --radius: 0.625rem;

  /* Light mode colors - 更护眼的暖色调配色 */
  --background: oklch(0.95 0.008 85);
  --foreground: oklch(0.3 0.02 85);
  --card: oklch(0.97 0.006 85);
  --card-foreground: oklch(0.3 0.02 85);
  --popover: oklch(0.97 0.006 85);
  --popover-foreground: oklch(0.3 0.02 85);
  --primary: oklch(0.35 0.03 240);
  --primary-foreground: oklch(0.98 0.005 85);
  --secondary: oklch(0.92 0.01 85);
  --secondary-foreground: oklch(0.3 0.02 85);
  --muted: oklch(0.92 0.01 85);
  --muted-foreground: oklch(0.5 0.02 85);
  --accent: oklch(0.92 0.01 85);
  --accent-foreground: oklch(0.3 0.02 85);
  --destructive: oklch(0.5 0.15 25);
  --destructive-foreground: oklch(0.98 0.005 85);
  --border: oklch(0.86 0.012 85);
  --input: oklch(0.86 0.012 85);
  --ring: oklch(0.704 0.04 256.788);
  --chart-1: oklch(0.646 0.222 41.116);
  --chart-2: oklch(0.6 0.118 184.704);
  --chart-3: oklch(0.398 0.07 227.392);
  --chart-4: oklch(0.828 0.189 84.429);
  --chart-5: oklch(0.769 0.188 70.08);
  --sidebar: oklch(0.96 0.006 85);
  --sidebar-foreground: oklch(0.3 0.02 85);
  --sidebar-primary: oklch(0.35 0.03 240);
  --sidebar-primary-foreground: oklch(0.98 0.005 85);
  --sidebar-accent: oklch(0.92 0.01 85);
  --sidebar-accent-foreground: oklch(0.3 0.02 85);
  --sidebar-border: oklch(0.86 0.012 85);
  --sidebar-ring: oklch(0.704 0.04 256.788);
}

.dark {
  --background: oklch(0.1 0.015 264.695);
  --foreground: oklch(0.984 0.003 247.858);
  --card: oklch(0.15 0.02 264.695);
  --card-foreground: oklch(0.984 0.003 247.858);
  --popover: oklch(0.15 0.02 264.695);
  --popover-foreground: oklch(0.984 0.003 247.858);
  --primary: oklch(0.729 0.113 255.508);
  --primary-foreground: oklch(0.984 0.003 247.858);
  --secondary: oklch(0.25 0.025 260.031);
  --secondary-foreground: oklch(0.984 0.003 247.858);
  --muted: oklch(0.25 0.025 260.031);
  --muted-foreground: oklch(0.604 0.04 256.788);
  --accent: oklch(0.25 0.025 260.031);
  --accent-foreground: oklch(0.984 0.003 247.858);
  --destructive: oklch(0.604 0.191 22.216);
  --border: oklch(0.25 0.025 260.031);
  --input: oklch(0.25 0.025 260.031);
  --ring: oklch(0.551 0.027 264.364);
  --chart-1: oklch(0.488 0.243 264.376);
  --chart-2: oklch(0.696 0.17 162.48);
  --chart-3: oklch(0.769 0.188 70.08);
  --chart-4: oklch(0.627 0.265 303.9);
  --chart-5: oklch(0.645 0.246 16.439);
  --sidebar: oklch(0.15 0.02 264.695);
  --sidebar-foreground: oklch(0.984 0.003 247.858);
  --sidebar-primary: oklch(0.488 0.243 264.376);
  --sidebar-primary-foreground: oklch(0.984 0.003 247.858);
  --sidebar-accent: oklch(0.25 0.025 260.031);
  --sidebar-accent-foreground: oklch(0.984 0.003 247.858);
  --sidebar-border: oklch(0.25 0.025 260.031);
  --sidebar-ring: oklch(0.551 0.027 264.364);
}

@theme inline {
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-card: var(--card);
  --color-card-foreground: var(--card-foreground);
  --color-popover: var(--popover);
  --color-popover-foreground: var(--popover-foreground);
  --color-primary: var(--primary);
  --color-primary-foreground: var(--primary-foreground);
  --color-secondary: var(--secondary);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-muted: var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-accent: var(--accent);
  --color-accent-foreground: var(--accent-foreground);
  --color-destructive: var(--destructive);
  --color-destructive-foreground: var(--destructive-foreground);
  --color-border: var(--border);
  --color-input: var(--input);
  --color-ring: var(--ring);
  --color-chart-1: var(--chart-1);
  --color-chart-2: var(--chart-2);
  --color-chart-3: var(--chart-3);
  --color-chart-4: var(--chart-4);
  --color-chart-5: var(--chart-5);
  --color-sidebar: var(--sidebar);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-ring: var(--sidebar-ring);
}

@layer base {
  * {
    @apply border-border outline-ring/50;
  }

  html {
    /* 平滑过渡 */
    transition: background-color 0.3s ease, color 0.3s ease;
    /* 禁用文本大小调整，防止移动端自动放大文本 */
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body {
    @apply bg-background text-foreground;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* 滚动条样式 */
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    @apply bg-transparent;
  }

  ::-webkit-scrollbar-thumb {
    @apply bg-border rounded-lg;
  }

  ::-webkit-scrollbar-thumb:hover {
    @apply bg-muted-foreground/50;
  }
}

/* 自定义动画 */
@keyframes fade-in {
  from {
    opacity: 0;
    transform: translate3d(0, 10px, 0);
  }

  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

.animate-fade-in {
  animation: fade-in 0.3s ease-out;
}

/* 侧边栏导航按钮悬停效果 */
aside nav a {
  transition: all 0.2s ease;
}

aside nav a:hover button {
  transform: translate3d(4px, 0, 0);
}

/* 资源数字更新动画 */
@keyframes pulse-resource {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.8;
  }
}

.resource-pulse {
  animation: pulse-resource 2s ease-in-out infinite;
}

/* Popover 和 Tooltip 样式修复 - 使用硬编码颜色 */
.popover-content-custom {
  background-color: oklch(0.15 0.02 264.695) !important;
  color: oklch(0.984 0.003 247.858) !important;
  border-color: oklch(0.25 0.025 260.031) !important;
}

/* 亮色模式 */
:root:not(.dark) .popover-content-custom {
  background-color: oklch(0.97 0.006 85) !important;
  color: oklch(0.3 0.02 85) !important;
  border-color: oklch(0.86 0.012 85) !important;
}

.tooltip-content-custom {
  background-color: oklch(0.984 0.003 247.858) !important;
  color: oklch(0.1 0.015 264.695) !important;
}

:root:not(.dark) .tooltip-content-custom {
  background-color: oklch(0.3 0.02 85) !important;
  color: oklch(0.95 0.008 85) !important;
}

/* 修复 Edge-to-Edge 模式下 Portal 容器的定位问题 */
[data-reka-portal],
[data-radix-portal] {
  position: fixed !important;
  left: 0 !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  pointer-events: none;
  padding: 0 !important;
  margin: 0 !important;
}

[data-reka-portal] > *,
[data-radix-portal] > * {
  pointer-events: auto;
}