@import "tailwindcss";

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

@theme {
  --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-serif: "Tiempos", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "JetBrains Mono", "Fira Code", monospace;

  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.25rem;
}

@layer base {
  :root {
    --background: 47 33% 97%;
    --foreground: 28 8% 12%;
    --card: 48 25% 95%;
    --card-foreground: 28 8% 12%;
    --popover: 48 33% 98%;
    --popover-foreground: 28 8% 12%;
    --primary: 16 60% 60%;
    --primary-foreground: 0 0% 100%;
    --secondary: 30 15% 90%;
    --secondary-foreground: 28 8% 18%;
    --muted: 30 15% 92%;
    --muted-foreground: 28 8% 40%;
    --accent: 30 15% 88%;
    --accent-foreground: 28 8% 18%;
    --destructive: 0 72% 51%;
    --destructive-foreground: 0 0% 100%;
    --border: 30 12% 86%;
    --input: 30 12% 86%;
    --ring: 16 60% 60%;
    --radius: 0.75rem;

    --sidebar: 45 25% 94%;
    --sidebar-foreground: 28 8% 18%;
    --sidebar-muted: 28 8% 45%;
    --sidebar-hover: 30 18% 88%;
  }

  .dark {
    --background: 30 5% 12%;
    --foreground: 30 10% 92%;
    --card: 30 5% 14%;
    --card-foreground: 30 10% 92%;
    --popover: 30 5% 14%;
    --popover-foreground: 30 10% 92%;
    --primary: 16 60% 60%;
    --primary-foreground: 0 0% 100%;
    --secondary: 30 5% 20%;
    --secondary-foreground: 30 10% 92%;
    --muted: 30 5% 20%;
    --muted-foreground: 30 8% 65%;
    --accent: 30 5% 22%;
    --accent-foreground: 30 10% 92%;
    --destructive: 0 62% 50%;
    --destructive-foreground: 0 0% 100%;
    --border: 30 5% 22%;
    --input: 30 5% 22%;
    --ring: 16 60% 60%;

    --sidebar: 30 5% 10%;
    --sidebar-foreground: 30 10% 88%;
    --sidebar-muted: 30 8% 60%;
    --sidebar-hover: 30 5% 18%;
  }
}

@theme inline {
  --color-background: hsl(var(--background));
  --color-foreground: hsl(var(--foreground));
  --color-card: hsl(var(--card));
  --color-card-foreground: hsl(var(--card-foreground));
  --color-popover: hsl(var(--popover));
  --color-popover-foreground: hsl(var(--popover-foreground));
  --color-primary: hsl(var(--primary));
  --color-primary-foreground: hsl(var(--primary-foreground));
  --color-secondary: hsl(var(--secondary));
  --color-secondary-foreground: hsl(var(--secondary-foreground));
  --color-muted: hsl(var(--muted));
  --color-muted-foreground: hsl(var(--muted-foreground));
  --color-accent: hsl(var(--accent));
  --color-accent-foreground: hsl(var(--accent-foreground));
  --color-destructive: hsl(var(--destructive));
  --color-destructive-foreground: hsl(var(--destructive-foreground));
  --color-border: hsl(var(--border));
  --color-input: hsl(var(--input));
  --color-ring: hsl(var(--ring));
  --color-sidebar: hsl(var(--sidebar));
  --color-sidebar-foreground: hsl(var(--sidebar-foreground));
  --color-sidebar-muted: hsl(var(--sidebar-muted));
  --color-sidebar-hover: hsl(var(--sidebar-hover));
}

@layer base {
  * {
    border-color: hsl(var(--border));
  }
  html {
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }
  body {
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
  }
  h1, h2, h3 {
    font-family: var(--font-serif);
    letter-spacing: -0.01em;
  }
  ::selection {
    background-color: hsl(var(--primary) / 0.25);
  }
}

/* Custom scrollbars */
.scroll-area::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.scroll-area::-webkit-scrollbar-track {
  background: transparent;
}
.scroll-area::-webkit-scrollbar-thumb {
  background-color: hsl(var(--muted-foreground) / 0.25);
  border-radius: 9999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.scroll-area::-webkit-scrollbar-thumb:hover {
  background-color: hsl(var(--muted-foreground) / 0.4);
  background-clip: padding-box;
}

/* Markdown prose */
.prose-chat {
  color: hsl(var(--foreground));
  line-height: 1.7;
  font-size: 0.975rem;
}
.prose-chat p { margin: 0.75rem 0; }
.prose-chat p:first-child { margin-top: 0; }
.prose-chat p:last-child { margin-bottom: 0; }
.prose-chat h1, .prose-chat h2, .prose-chat h3, .prose-chat h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  margin: 1.5rem 0 0.75rem;
  line-height: 1.3;
}
.prose-chat h1 { font-size: 1.5rem; }
.prose-chat h2 { font-size: 1.3rem; }
.prose-chat h3 { font-size: 1.15rem; }
.prose-chat ul, .prose-chat ol { margin: 0.75rem 0; padding-left: 1.5rem; }
.prose-chat li { margin: 0.25rem 0; }
.prose-chat ul li { list-style: disc; }
.prose-chat ol li { list-style: decimal; }
.prose-chat a {
  color: hsl(var(--primary));
  text-decoration: underline;
  text-underline-offset: 2px;
}
.prose-chat blockquote {
  border-left: 3px solid hsl(var(--border));
  padding-left: 1rem;
  color: hsl(var(--muted-foreground));
  margin: 0.75rem 0;
  font-style: italic;
}
.prose-chat code {
  background: hsl(var(--muted));
  padding: 0.125rem 0.375rem;
  border-radius: 0.375rem;
  font-size: 0.875em;
  font-family: var(--font-mono);
}
.prose-chat pre {
  background: hsl(var(--muted));
  padding: 1rem;
  border-radius: 0.75rem;
  overflow-x: auto;
  margin: 1rem 0;
  font-size: 0.875em;
  border: 1px solid hsl(var(--border));
}
.prose-chat pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}
.prose-chat table {
  border-collapse: collapse;
  margin: 1rem 0;
  width: 100%;
}
.prose-chat th, .prose-chat td {
  border: 1px solid hsl(var(--border));
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.prose-chat th {
  background: hsl(var(--muted));
  font-weight: 600;
}
.prose-chat hr {
  border: 0;
  border-top: 1px solid hsl(var(--border));
  margin: 1.5rem 0;
}

/* Streaming caret */
.caret-blink::after {
  content: "▍";
  display: inline-block;
  color: hsl(var(--primary));
  animation: caret-blink 1s steps(2, end) infinite;
  margin-left: 1px;
  font-weight: 100;
}
@keyframes caret-blink {
  50% { opacity: 0; }
}

/* Spinner */
.spinner {
  border-radius: 9999px;
  border: 2px solid hsl(var(--muted));
  border-top-color: hsl(var(--primary));
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
