/**
 * Chat color tokens — single source of truth.
 *
 * Every role-conditional class for chat surfaces lives here.
 * Components consume via `useChatBubbleStyles` / `useChatRoleStyles`,
 * never via raw Tailwind literals.
 *
 * Why centralize:
 *   1. One file to edit when the design system changes (e.g. light-theme
 *      contrast tweaks, palette swap).
 *   2. Eliminates the "first-token-on-bg-primary-was-text-white" class
 *      of bugs where each call site picks its own foreground.
 *   3. Lets us snapshot-test color decisions later.
 */

/** Bubble surface classes (background + text), keyed by message state. */
export const BUBBLE_SURFACE = {
  /** User-authored bubble - a quiet neutral surface aligned to the right. */
  user: 'bg-muted text-foreground',
  /** Assistant replies use a lighter neutral surface than user messages. */
  assistant: 'bg-muted/40 text-foreground',
  /** Assistant bubble when the turn failed — destructive tint. */
  error: 'bg-destructive/10 text-destructive rounded-tl-md border border-destructive/30',
} as const;

/**
 * Shared media-block surface — the single frame every non-prose
 * `message.blocks` renderer sits in (image, video, gallery, map, audio,
 * code, json, mermaid). Owning the frame here (instead of each
 * renderer inventing its own) guarantees one consistent corner radius,
 * hairline border and soft shadow across all block kinds — the calm,
 * uniform media-card look of Telegram / WhatsApp.
 *
 * `rounded-2xl` (16px) — large, soft messenger corner.
 * `border-border`     — hairline, theme-aware.
 * `shadow-sm`         — gentle lift off the transcript background.
 * `overflow-hidden`   — clips inner content (maps, images) to the radius.
 * `bg-card`           — neutral surface so a renderer with a transparent
 *                       body (json tree) still reads as a card.
 */
export const BLOCK_SURFACE =
  'overflow-hidden rounded-2xl border border-border bg-card shadow-sm' as const;

/**
 * Anchor (link) classes for markdown content rendered inside a bubble.
 *
 * User and assistant prose now share neutral surfaces, so both roles use the
 * theme's primary link color with a restrained underline.
 *
 * On the neutral assistant bubble we keep the brand-primary color so links
 * still pop without competing with the body text.
 */
export const ANCHOR = {
  user:
    'text-primary underline decoration-primary/50 underline-offset-2 ' +
    'hover:text-primary/80 hover:decoration-primary transition-colors break-all',
  assistant: 'text-primary underline hover:text-primary/80 transition-colors break-all',
} as const;

/** Inline secondary action (e.g. "Show more / less"). Same logic as anchors. */
export const TOGGLE = {
  user: 'text-primary hover:text-primary/80',
  assistant: 'text-primary hover:text-primary/80',
} as const;

/** Destructive surface — used by ErrorBanner and the delete action. */
export const DESTRUCTIVE_SURFACE = {
  /** Banner / card variant: border + tint + text. */
  banner:
    'border border-destructive/40 bg-destructive/10 text-destructive',
  /** Subtle hover for destructive buttons inside the banner / menu. */
  hover: 'hover:bg-destructive/15',
  /** Strong-hover variant (e.g. trash overlay on attachments). */
  hoverStrong:
    'hover:bg-destructive hover:text-destructive-foreground',
  /** Inline destructive text utility. */
  text: 'text-destructive',
  /** Hover style for menu items that delete data. */
  menuItem:
    'text-destructive focus:text-destructive hover:bg-destructive/15 hover:text-destructive',
} as const;

/** Tool-call result text. */
export const TOOL_CALL = {
  errorText: 'text-destructive',
} as const;

export type ChatBubbleSurface = keyof typeof BUBBLE_SURFACE;
