@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  :root {
    /* 亮色主题 */
    --background: 0 0% 100%;
    --foreground: 222.2 47.4% 11.2%;

    --card: 0 0% 100%;
    --card-foreground: 222.2 47.4% 11.2%;

    --popover: 0 0% 100%;
    --popover-foreground: 222.2 47.4% 11.2%;

    --primary: 222.2 47.4% 11.2%;
    --primary-foreground: 210 40% 98%;

    --secondary: 210 40% 96.1%;
    --secondary-foreground: 222.2 47.4% 11.2%;

    --muted: 210 40% 96.1%;
    --muted-foreground: 215.4 16.3% 46.9%;

    --accent: 210 40% 96.1%;
    --accent-foreground: 222.2 47.4% 11.2%;

    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 210 40% 98%;

    --border: 214.3 31.8% 91.4%;
    --input: 214.3 31.8% 91.4%;
    --ring: 222.2 47.4% 11.2%;

    --radius: 0.5rem;

    /* 状态颜色 */
    --status-success: 142 76% 36%;
    --status-warning: 38 92% 50%;
    --status-error: 0 84% 60%;
    --status-info: 199 89% 48%;

    /* 侧边栏 */
    --sidebar-background: 0 0% 98%;
    --sidebar-foreground: 240 5.3% 26.1%;
    --sidebar-primary: 240 5.9% 10%;
    --sidebar-primary-foreground: 0 0% 98%;
    --sidebar-accent: 240 4.8% 95.9%;
    --sidebar-accent-foreground: 240 5.9% 10%;
    --sidebar-border: 220 13% 91%;
    --sidebar-ring: 217.2 91.2% 59.8%;
  }

  .dark {
    /* 深色主题配色（参考 Codex） */
    --background: 224 71% 4%;
    --foreground: 213 31% 91%;

    --card: 224 71% 4%;
    --card-foreground: 213 31% 91%;

    --popover: 224 71% 4%;
    --popover-foreground: 213 31% 91%;

    --primary: 210 40% 98%;
    --primary-foreground: 222.2 47.4% 11.2%;

    --secondary: 217.2 32.6% 17.5%;
    --secondary-foreground: 210 40% 98%;

    --muted: 217.2 32.6% 17.5%;
    --muted-foreground: 215 20.2% 65.1%;

    --accent: 216 34% 17%;
    --accent-foreground: 210 40% 98%;

    --destructive: 0 63% 31%;
    --destructive-foreground: 210 40% 98%;

    --border: 216 34% 17%;
    --input: 216 34% 17%;
    --ring: 216 34% 17%;

    /* 状态颜色 */
    --status-success: 142 76% 36%;
    --status-warning: 38 92% 50%;
    --status-error: 0 84% 60%;
    --status-info: 199 89% 48%;

    /* 侧边栏 */
    --sidebar-background: 240 5.9% 10%;
    --sidebar-foreground: 240 4.8% 95.9%;
    --sidebar-primary: 224.3 76.3% 48%;
    --sidebar-primary-foreground: 0 0% 100%;
    --sidebar-accent: 240 3.7% 15.9%;
    --sidebar-accent-foreground: 240 4.8% 95.9%;
    --sidebar-border: 240 3.7% 15.9%;
    --sidebar-ring: 217.2 91.2% 59.8%;
  }
}

@layer base {
  * {
    @apply border-border;
  }
  body {
    @apply bg-background text-foreground;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
      'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
      sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* 自定义滚动条 */
@layer components {
  .custom-scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

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

  .custom-scrollbar::-webkit-scrollbar-thumb {
    @apply bg-muted-foreground/30 rounded-full;
  }

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

/* md-editor-rt 代码块导航栏在 ScrollArea/虚拟滚动内 sticky 定位异常 */
.md-editor-code-head {
  position: static !important;
}

/* 代码块样式 */
@layer components {
  .prose pre {
    @apply bg-muted rounded-lg p-4 overflow-x-auto;
  }

  .prose code {
    @apply text-sm font-mono;
  }

  .prose code:not(pre code) {
    @apply bg-muted px-1.5 py-0.5 rounded;
  }

  .prose pre code {
    @apply bg-transparent p-0;
  }

  .prose code.copyable-code-block__code {
    @apply bg-transparent p-0 rounded-none;
  }

  .prose code.copyable-code-block__code span {
    background: transparent !important;
  }

  .mention-completion-menu {
    scrollbar-width: thin;
    scrollbar-color: hsl(var(--muted-foreground) / 0.35) transparent;
  }

  .mention-completion-menu::-webkit-scrollbar {
    width: 8px;
    height: 0;
  }

  .mention-completion-menu::-webkit-scrollbar-track {
    background: transparent;
  }

  .mention-completion-menu::-webkit-scrollbar-thumb {
    background: hsl(var(--muted-foreground) / 0.35);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
  }
}

/* 动画 */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

@keyframes slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

/* 搜索高亮样式 */
.search-highlight {
  background-color: hsl(50 80% 60% / 0.3);
  border-radius: 2px;
  padding: 1px 0;
}

.search-highlight-current {
  background-color: hsl(50 100% 50%);
  border-radius: 2px;
  padding: 1px 2px;
  box-shadow: 0 0 0 2px hsl(50 100% 50% / 0.4);
}

.dark .search-highlight {
  background-color: hsl(50 70% 40% / 0.35);
}

.dark .search-highlight-current {
  background-color: hsl(50 95% 55%);
  box-shadow: 0 0 0 2px hsl(50 95% 55% / 0.4);
}
