@import "tailwindcss";
@custom-variant dark (&:where(.dark, .dark *));
@plugin "@tailwindcss/typography";
@import "highlight.js/styles/github-dark.min.css";

@theme {
  --color-primary: #0057ff;
  --color-primary-hover: #004ad9;
  --color-primary-light: #e6f0ff;
  --color-background-light: #ffffff;
  --color-background-dark: #18181b;
  --color-sidebar-light: #f9f9fa;
  --color-sidebar-dark: #202023;
  --color-modal-sidebar: #f5f6f7;
  --color-input-border: #e5e7eb;
  --color-input-focus: #3b82f6;

  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "Consolas", "Monaco", "Courier New", monospace;

  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-3xl: 2rem;

  --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-input: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-modal: 0 20px 50px -12px rgba(0, 0, 0, 0.15);
  --shadow-menu: 0 10px 40px -10px rgba(0, 0, 0, 0.1);
  --shadow-message: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-tooltip: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-glow: 0 0 15px rgba(59, 130, 246, 0.3);

  --animate-cursor-blink: blink 1s step-end infinite;
  --animate-pulse-slow: pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  --animate-slide-up: slideUpFade 0.2s ease-out forwards;
  --animate-fade-in: fadeIn 0.15s ease-out;
  --animate-slide-in-right: slideInRight 0.3s ease-out forwards;

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

  @keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
  }

  @keyframes slideUpFade {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }

  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  @keyframes streamFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }
}

/* Tailwind v4 兼容：初始化 translate/scale/rotate CSS 变量默认值 */
*, *::before, *::after {
  --tw-translate-x: 0;
  --tw-translate-y: 0;
}

html, body {
  /* 防止移动端隐藏元素撑宽页面导致内容被截断 */
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  --slider-track: #e5e7eb;
}

html.dark body {
  --slider-track: #374151;
}

/* 主题切换过渡动效：仅在切换瞬间启用，避免影响正常交互性能 */
html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition: background-color 0.3s ease, color 0.2s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* Custom scrollbar */
.custom-scrollbar::-webkit-scrollbar {
  width: 4px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background-color: transparent;
  border-radius: 20px;
}
.custom-scrollbar:hover::-webkit-scrollbar-thumb {
  background-color: #d1d5db;
}
html.dark .custom-scrollbar:hover::-webkit-scrollbar-thumb {
  background-color: #4b5563;
}

/* No scrollbar utility */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Typing cursor */
.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background-color: currentColor;
  vertical-align: text-bottom;
  opacity: 0.6;
  animation: blink 0.8s ease-in-out infinite;
  border-radius: 1px;
  margin-left: 1px;
}

/* Terminal window font */
.terminal-window {
  font-family: "Consolas", "Monaco", "Courier New", monospace;
}

/* Chat font size (controlled by settings) */
:root {
  --chat-font-size: 16px;
}

/* Streaming prose: last block element fades in as new paragraphs arrive */
.streaming-prose > p:last-child,
.streaming-prose > ul:last-child,
.streaming-prose > ol:last-child,
.streaming-prose > blockquote:last-child,
.streaming-prose > h1:last-child,
.streaming-prose > h2:last-child,
.streaming-prose > h3:last-child,
.streaming-prose > h4:last-child,
.streaming-prose > pre:last-child,
.streaming-prose > table:last-child {
  animation: streamFadeIn 0.4s ease forwards;
}

/* Prose overrides */
.prose p {
  margin-bottom: 0.8em;
}
.prose ul {
  list-style-type: disc;
  padding-left: 1.5em;
  margin-bottom: 0.8em;
}
.prose ol {
  list-style-type: decimal;
  padding-left: 1.5em;
  margin-bottom: 0.8em;
}

/* 输入框底部安全区域适配（兼容 iOS 回家条与手机浏览器工具栏） */
.pb-input {
  padding-bottom: 24px;
}
@media (max-width: 767px) {
  .pb-input {
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
  }
}
