@import "tailwindcss";
@import "tw-animate-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;
  --scrollbar-thumb: color-mix(in oklab, var(--muted-foreground) 20%, transparent);
  --scrollbar-thumb-hover: color-mix(in oklab, var(--muted-foreground) 45%, transparent);
}

@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;
  }
  /* App-secret fields (SecretInput): render the value as dots via a disc-glyph
     font instead of type="password" / -webkit-text-security, both of which
     summon browser password managers (iCloud AutoFill, Chrome save/generate).
     :not(:placeholder-shown) keeps placeholders in the field's real font.
     !important so it beats font-mono/font-sans utilities on the same element. */
  .secret-masked:not(:placeholder-shown) {
    font-family: var(--font-secret-mask) !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 scroll regions */
@utility scrollbar-sidebar {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
  padding-inline-end: 2px;

  &::-webkit-scrollbar {
    width: 2px;
  }
  &::-webkit-scrollbar-track {
    background: transparent;
  }
  &::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border-radius: 9999px;
  }
  &::-webkit-scrollbar-thumb:hover {
    background-color: var(--scrollbar-thumb-hover);
  }
}

/* ── Aceternity-style effects (MCP registry wizard & detail dashboard) ──
   CSS-only ports of Aceternity UI patterns (spotlight, shimmer, meteors,
   dot hero, animated gradient border). All colors derive from theme tokens
   so white-label themes and dark mode are respected. */

@keyframes aceternity-shimmer {
  to {
    background-position: -220% 0;
  }
}

.aceternity-shimmer {
  background-image: linear-gradient(
    110deg,
    var(--primary) 42%,
    color-mix(in oklab, var(--primary), white 30%) 50%,
    var(--primary) 58%
  );
  background-size: 220% 100%;
  animation: aceternity-shimmer 2.8s linear infinite;
}

.aceternity-dots {
  background-image: radial-gradient(
    color-mix(in oklab, var(--primary) 35%, transparent) 1px,
    transparent 1px
  );
  background-size: 18px 18px;
  mask-image: radial-gradient(
    ellipse 70% 90% at 50% 0%,
    black 20%,
    transparent 72%
  );
}

@keyframes aceternity-meteor {
  0% {
    transform: rotate(215deg) translateX(0);
    opacity: 0.9;
  }
  70% {
    opacity: 0.9;
  }
  100% {
    transform: rotate(215deg) translateX(-320px);
    opacity: 0;
  }
}

.aceternity-meteor {
  position: absolute;
  height: 2px;
  width: 2px;
  border-radius: 9999px;
  background: color-mix(in oklab, var(--primary) 80%, white);
  transform: rotate(215deg);
  animation: aceternity-meteor linear infinite;
}

.aceternity-meteor::before {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 1px;
  background: linear-gradient(
    90deg,
    color-mix(in oklab, var(--primary) 60%, transparent),
    transparent
  );
}

@property --aceternity-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

@keyframes aceternity-border-spin {
  to {
    --aceternity-angle: 360deg;
  }
}

.aceternity-gradient-border {
  position: relative;
}

.aceternity-gradient-border::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(
    from var(--aceternity-angle),
    transparent 0%,
    color-mix(in oklab, var(--primary) 80%, transparent) 12%,
    transparent 28%
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: aceternity-border-spin 3.5s linear infinite;
  pointer-events: none;
}


/* ── Feedback pop-up ──
   Friendly greeting: the hand waves twice when the pop-up opens, then rests. */

@keyframes feedback-wave {
  0%,
  60%,
  100% {
    transform: rotate(0deg);
  }
  10%,
  30% {
    transform: rotate(16deg);
  }
  20%,
  40% {
    transform: rotate(-8deg);
  }
}

.feedback-wave {
  display: inline-block;
  transform-origin: 70% 75%;
  animation: feedback-wave 1.8s ease-in-out 0.4s 2;
}
