@import "tailwindcss";
@import "tw-animate-css";
@import "@fontsource/inter/300.css";
@import "@fontsource/inter/400.css";
@import "@fontsource/inter/500.css";
@import "@fontsource/inter/600.css";
@import "@fontsource/inter/700.css";
@import "@fontsource/jetbrains-mono/400.css";
@import "@fontsource/jetbrains-mono/500.css";

/* Sonner toast styles */
[data-sonner-toaster] {
  --width: 356px;
  --border-radius: var(--radius);
  font-family: inherit;
  z-index: 9999 !important;
}

[data-sonner-toast] {
  background: var(--popover) !important;
  color: var(--popover-foreground) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

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

@theme inline {
  --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);
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --color-sidebar-ring: var(--sidebar-ring);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar: var(--sidebar);
  --color-chart-5: var(--chart-5);
  --color-chart-4: var(--chart-4);
  --color-chart-3: var(--chart-3);
  --color-chart-2: var(--chart-2);
  --color-chart-1: var(--chart-1);
  --radius-2xl: calc(var(--radius) + 8px);
  --radius-3xl: calc(var(--radius) + 12px);
  --radius-4xl: calc(var(--radius) + 16px);
}

:root {
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.985 0 0);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);
  --radius: 0.625rem;
  --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.985 0 0);
  --sidebar-foreground: oklch(0.145 0 0);
  --sidebar-primary: oklch(0.205 0 0);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.97 0 0);
  --sidebar-accent-foreground: oklch(0.205 0 0);
  --sidebar-border: oklch(0.922 0 0);
  --sidebar-ring: oklch(0.708 0 0);
}

.dark {
  --background: oklch(0.22 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.26 0 0);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.26 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.922 0 0);
  --primary-foreground: oklch(0.205 0 0);
  --secondary: oklch(0.32 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.32 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.32 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --destructive-foreground: oklch(0.985 0 0);
  --border: oklch(1 0 0 / 12%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);
  --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.26 0 0);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.488 0.243 264.376);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.32 0 0);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: oklch(1 0 0 / 12%);
  --sidebar-ring: oklch(0.556 0 0);
}

@layer base {
  * {
    @apply outline-ring/50;
    font-family: inherit;
  }

  *,
  ::before,
  ::after {
    border-color: transparent;
  }

  .border,
  [class*="border-"] {
    border-color: var(--border);
  }

  body {
    @apply bg-background text-foreground antialiased;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }

  .font-code,
  .font-mono,
  code,
  pre {
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
  }
}

/* 高级感增强 - 微妙的渐变背景 */
body {
  background: linear-gradient(135deg, var(--background) 0%, oklch(from var(--background) calc(l * 0.98) c h) 100%);
  background-attachment: fixed;
}

.dark body {
  background: linear-gradient(135deg, var(--background) 0%, oklch(from var(--background) calc(l * 1.05) c h) 100%);
}

/* 卡片增强 - 添加微妙阴影 */
[data-slot="card"] {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05), 0 1px 2px -1px rgb(0 0 0 / 0.05);
}

[data-slot="card"]:hover {
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.08);
}

.dark [data-slot="card"] {
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
}

.dark [data-slot="card"]:hover {
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
}

/* 按钮增强 - 更流畅的交互 */
button,
[role="button"] {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

button:active,
[role="button"]:active {
  transform: scale(0.98);
}

/* 输入框增强 - 聚焦效果 */
input:focus,
textarea:focus,
select:focus {
  box-shadow: 0 0 0 3px oklch(from var(--ring) l c h / 0.1);
  transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 链接增强 */
a {
  transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 表格增强 - 悬停效果 */
table tbody tr {
  transition: background-color 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

table tbody tr:hover {
  background-color: oklch(from var(--muted) l c h / 0.5);
}

/* 模态框和弹出层增强 - 背景模糊 */
[role="dialog"]::backdrop,
[data-state="open"]::backdrop {
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* 代码块增强 */
code,
pre {
  background: oklch(from var(--muted) l c h / 0.5);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.125rem 0.375rem;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875em;
}

pre code {
  padding: 0;
  background: transparent;
}

/* Windows 小字体优化 */
.text-xs,
.text-sm,
[class*="text-xs"],
[class*="text-sm"] {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* 表格和列表中的小字体优化 */
table,
[role="table"] {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 命令和路径文本优化 */
code,
pre,
[class*="font-mono"] {
  -webkit-font-smoothing: auto;
  -moz-osx-font-smoothing: auto;
  font-weight: 400;
}

/* 徽章和标签增强 */
[class*="badge"],
[class*="tag"] {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

[class*="badge"]:hover,
[class*="tag"]:hover {
  box-shadow: 0 2px 4px 0 rgb(0 0 0 / 0.1);
}

/* 加载动画增强 */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }

  100% {
    background-position: 1000px 0;
  }
}

.skeleton {
  background: linear-gradient(90deg,
      oklch(from var(--muted) l c h / 0.3) 0%,
      oklch(from var(--muted) l c h / 0.5) 50%,
      oklch(from var(--muted) l c h / 0.3) 100%);
  background-size: 1000px 100%;
  animation: shimmer 2s infinite linear;
}

/* 滚动条美化增强 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: oklch(from var(--muted-foreground) l c h / 0.2);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: oklch(from var(--muted-foreground) l c h / 0.3);
  background-clip: padding-box;
}

.dark ::-webkit-scrollbar-thumb {
  background: oklch(from var(--muted-foreground) l c h / 0.3);
  background-clip: padding-box;
}

.dark ::-webkit-scrollbar-thumb:hover {
  background: oklch(from var(--muted-foreground) l c h / 0.4);
  background-clip: padding-box;
}

/* 选中文本样式 */
::selection {
  background: oklch(from var(--primary) l c h / 0.2);
  color: var(--foreground);
}

.dark ::selection {
  background: oklch(from var(--primary) l c h / 0.3);
}

/* Number input spinner - Refined SVG version with more spacing */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  /* Increased width for better hit area and visibility */
  height: 20px;
  cursor: pointer;
  opacity: 0.5;
  /* Premium SVG Arrows: Increased gap between up and down arrows */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 17 5 5 5-5'/%3E%3Cpath d='m7 7 5-5 5 5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px;
  transition: opacity 0.2s ease;
  margin-right: 2px;
}

/* Hover effect: Smoothly light up the arrows */
input[type="number"]:hover::-webkit-inner-spin-button {
  opacity: 0.9;
}

/* Light mode support */
:root:not(.dark) input[type="number"]::-webkit-inner-spin-button {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 17 5 5 5-5'/%3E%3Cpath d='m7 7 5-5 5 5'/%3E%3C/svg%3E");
}

/* Date/Time picker enhancement */
input[type="datetime-local"],
input[type="date"],
input[type="time"] {
  color-scheme: light;
}

.dark input[type="datetime-local"],
.dark input[type="date"],
.dark input[type="time"] {
  color-scheme: dark;
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

input[type="datetime-local"]:hover::-webkit-calendar-picker-indicator,
input[type="date"]:hover::-webkit-calendar-picker-indicator,
input[type="time"]:hover::-webkit-calendar-picker-indicator {
  opacity: 0.9;
}

/* Custom scrollbar styles */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: oklch(0.7 0 0 / 30%);
  border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: oklch(0.6 0 0 / 50%);
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb {
  background: oklch(0.5 0 0 / 40%);
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: oklch(0.6 0 0 / 60%);
}

/* Firefox scrollbar */
.custom-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: oklch(0.7 0 0 / 30%) transparent;
}

.dark .custom-scrollbar {
  scrollbar-color: oklch(0.5 0 0 / 40%) transparent;
}

/* Hide scrollbar but keep functionality */
.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* ApexCharts tooltip fix */
.apexcharts-tooltip {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
}

.apexcharts-tooltip-title {
  display: none !important;
}