@import "tailwindcss";
@import "tw-animate-css";
@import "@daveyplate/better-auth-ui/css";
/* Streamdown animation keyframes (sd-fadeIn, sd-blurIn, sd-slideUp) and the
   [data-sd-animate] rule. Required for the word-by-word fade-in animation
   during chat streaming (animated={{ animation: "fadeIn", sep: "word" }}).
   Only adds sd-prefixed keyframes — no conflicts with Archestra themes. */
@import "streamdown/styles.css";
@import "./themes.css";

/* Tell Tailwind v4 JIT to scan streamdown's minified JS for dynamic class names
   (e.g. the caret pseudo-element utility, animation classes). Without this,
   Tailwind won't generate classes it can't find in our own source files.
   This only affects class generation — it does NOT import any CSS or styles.
   Streamdown uses standard semantic tokens (bg-sidebar, text-muted-foreground, etc.)
   that resolve to Archestra's CSS variables, so all themes are respected. */
@source "../../node_modules/streamdown/dist";

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

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --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);
  --color-ring: var(--ring);
  --color-input: var(--input);
  --color-border: var(--border);
  --color-destructive: var(--destructive);
  --color-accent-foreground: var(--accent-foreground);
  --color-accent: var(--accent);
  --color-muted-foreground: var(--muted-foreground);
  --color-muted: var(--muted);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-secondary: var(--secondary);
  --color-primary-foreground: var(--primary-foreground);
  --color-primary: var(--primary);
  --color-popover-foreground: var(--popover-foreground);
  --color-popover: var(--popover);
  --color-card-foreground: var(--card-foreground);
  --color-card: var(--card);
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --radius-2xl: calc(var(--radius) + 8px);
  --radius-3xl: calc(var(--radius) + 12px);
  --radius-4xl: calc(var(--radius) + 16px);
  --font-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --tracking-tighter: calc(var(--tracking-normal) - 0.05em);
  --tracking-tight: calc(var(--tracking-normal) - 0.025em);
  --tracking-wide: calc(var(--tracking-normal) + 0.025em);
  --tracking-wider: calc(var(--tracking-normal) + 0.05em);
  --tracking-widest: calc(var(--tracking-normal) + 0.1em);
  --tracking-normal: var(--tracking-normal);
  --shadow-2xl: var(--shadow-2xl);
  --shadow-xl: var(--shadow-xl);
  --shadow-lg: var(--shadow-lg);
  --shadow-md: var(--shadow-md);
  --shadow: var(--shadow);
  --shadow-sm: var(--shadow-sm);
  --shadow-xs: var(--shadow-xs);
  --shadow-2xs: var(--shadow-2xs);
  --spacing: var(--spacing);
  --letter-spacing: var(--letter-spacing);
  --shadow-offset-y: var(--shadow-offset-y);
  --shadow-offset-x: var(--shadow-offset-x);
  --shadow-spread: var(--shadow-spread);
  --shadow-blur: var(--shadow-blur);
  --shadow-opacity: var(--shadow-opacity);
  --color-shadow-color: var(--shadow-color);
  --color-destructive-foreground: var(--destructive-foreground);
}

/* Base styles and defaults - theme classes override --radius */
:root {
  --radius: 0.5rem;
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  --font-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --shadow-opacity: 0.1;
  --shadow-blur: 3px;
  --shadow-spread: 0px;
  --shadow-offset-x: 0;
  --shadow-offset-y: 1px;
  --letter-spacing: 0em;
  --spacing: 0.25rem;
  --shadow-color: oklch(0 0 0);
  --shadow-2xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05);
  --shadow-xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05);
  --shadow-2xl: 0 1px 3px 0px hsl(0 0% 0% / 0.25);
  --shadow-sm: 0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 1px 2px -1px hsl(0 0% 0% / 0.10);
  --shadow: 0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 1px 2px -1px hsl(0 0% 0% / 0.10);
  --shadow-md: 0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 2px 4px -1px hsl(0 0% 0% / 0.10);
  --shadow-lg: 0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 4px 6px -1px hsl(0 0% 0% / 0.10);
  --shadow-xl: 0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 8px 10px -1px hsl(0 0% 0% / 0.10);
  --tracking-normal: 0em;
}

@layer base {
  * {
    @apply border-border outline-ring/50;
  }
  body {
    @apply bg-background text-foreground;
    letter-spacing: var(--tracking-normal);
  }
  /* Fix Shiki syntax highlighting in dark mode - apply dark theme colors from CSS variables */
  .dark [data-streamdown="code-block-body"] span[style*="--shiki-dark"] {
    color: var(--shiki-dark) !important;
    background-color: transparent !important;
  }
  /* Code block styling - use accent color for background and tighten layout */
  [data-streamdown="code-block"] {
    background-color: var(--accent) !important;
    padding: 0 !important;
    gap: 0 !important;
    position: relative !important;
  }
  [data-streamdown="code-block-header"] {
    background-color: var(--accent) !important;
    height: auto !important;
    padding: 4px 0.75rem !important;
    transform: translateY(4px) !important;
  }
  /* Actions - position absolutely in the header row, remove pill background */
  [data-streamdown="code-block"] > .sticky {
    position: absolute !important;
    top: 0 !important;
    right: 0.75rem !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 10 !important;
  }
  [data-streamdown="code-block-body"] {
    padding-top: 0 !important;
  }
  [data-streamdown="code-block-actions"] {
    background: transparent !important;
    border: none !important;
    backdrop-filter: none !important;
    padding-top: 4px !important;
  }
  [data-streamdown="code-block-body"] {
    background-color: var(--accent) !important;
  }
  /* Inline code styling - use accent color for background */
  [data-streamdown="inline-code"] {
    background-color: var(--accent) !important;
  }
  /* Override Tailwind's font-sans to use our dynamic CSS variable */
  .font-sans {
    font-family: var(--font-sans) !important;
  }
  /* Streamdown streaming caret - the library sets --streamdown-caret inline style
     and expects Tailwind to generate *:last:after:content-[var(--streamdown-caret)].
     Since Tailwind v4 can't detect these dynamic classes from minified JS, we
     define the rules explicitly. */
  [style*="--streamdown-caret"] > *:last-child::after {
    content: var(--streamdown-caret);
    display: inline;
    vertical-align: baseline;
    animation: sd-caret-blink 1s steps(2) infinite;
  }
  @keyframes sd-caret-blink {
    0% { opacity: 1; }
    50% { opacity: 0; }
  }
  @keyframes archestra-chat-logo-bounce {
    0%, 100% {
      transform: translateY(-25%);
      animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }
    50% {
      transform: none;
      animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
  }
  /* Fix autofill styles for dark theme - browsers apply light backgrounds on autofill */
  input:-webkit-autofill,
  input:-webkit-autofill:hover,
  input:-webkit-autofill:focus,
  input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--background) inset !important;
    -webkit-text-fill-color: var(--foreground) !important;
    caret-color: var(--foreground) !important;
  }
}

button, div[role="menuitem"] {
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
}

div[role="option"] {
  cursor: pointer;
}

/* Fix emoji picker category headers using hardcoded bg-zinc-950 instead of theme popover color */
div:has(> [data-testid="emoji-picker-list-header"]) {
  background-color: var(--popover) !important;
  backdrop-filter: none !important;
}
[data-testid="emoji-picker-list-header"] {
  color: var(--muted-foreground) !important;
}

/* Thin scrollbar for sidebar */
[data-sidebar="sidebar"] {
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--sidebar-accent)) transparent;
}
[data-sidebar="sidebar"] ::-webkit-scrollbar {
  width: 2px;
}
[data-sidebar="sidebar"] ::-webkit-scrollbar-track {
  background: transparent;
}
[data-sidebar="sidebar"] ::-webkit-scrollbar-thumb {
  background-color: hsl(var(--sidebar-accent));
  border-radius: 9999px;
}
[data-sidebar="sidebar"] ::-webkit-scrollbar-thumb:hover {
  background-color: hsl(var(--sidebar-accent-foreground) / 0.3);
}
