/**
 * Canonical status & priority color definitions.
 *
 * Every component that renders a status indicator (StatusIcon, StatusBadge,
 * agent status dots, etc.) should import from here so colors stay consistent.
 *
 * [nexus] Migrated to design system tokens — see MIGRATION-PLAN.md §3, §6.
 * All entries use semantic tokens (bg-destructive, bg-warning, bg-success,
 * bg-primary, bg-muted) instead of raw palette utilities. Dark-mode variants
 * are handled automatically by the token system in index.css.
 */

// ---------------------------------------------------------------------------
// Issue status colors
// [nexus] Migrated to design system tokens — see MIGRATION-PLAN.md
// ---------------------------------------------------------------------------

/** StatusIcon circle: text + border classes */
export const issueStatusIcon: Record<string, string> = {
  // backlog / not-started → muted (softer than plain idle)
  backlog: "text-muted-foreground border-border",
  // todo → muted foreground (neutral "not yet started")
  todo: "text-muted-foreground border-border",
  // in_progress / active / running → primary accent
  in_progress: "text-primary border-primary/60",
  // in_review → warning (awaiting action)
  in_review: "text-warning border-warning/60",
  // done / completed / success
  done: "text-success border-success/60",
  // cancelled / archived → muted, dim
  cancelled: "text-muted-foreground/70 border-border",
  // blocked → softer destructive (distinct from hard "error")
  blocked: "text-destructive border-destructive/50",
};

export const issueStatusIconDefault = "text-muted-foreground border-border";

/** Text-only color for issue statuses (dropdowns, labels) */
export const issueStatusText: Record<string, string> = {
  backlog: "text-muted-foreground",
  todo: "text-muted-foreground",
  in_progress: "text-primary",
  in_review: "text-warning",
  done: "text-success",
  cancelled: "text-muted-foreground/70",
  blocked: "text-destructive",
};

export const issueStatusTextDefault = "text-muted-foreground";

// ---------------------------------------------------------------------------
// Badge colors — used by StatusBadge for all entity types
// [nexus] Migrated to design system tokens — see MIGRATION-PLAN.md
// ---------------------------------------------------------------------------

export const statusBadge: Record<string, string> = {
  // Agent statuses
  active: "bg-success/15 text-success border border-success/30",
  running: "bg-primary/15 text-primary border border-primary/30",
  paused: "bg-warning/15 text-warning border border-warning/30",
  idle: "bg-muted text-muted-foreground border border-border",
  archived: "bg-muted/40 text-muted-foreground/70 border border-border",

  // Goal statuses
  planned: "bg-muted/60 text-muted-foreground border border-border",
  achieved: "bg-success/15 text-success border border-success/30",
  completed: "bg-success/15 text-success border border-success/30",

  // Run statuses
  failed: "bg-destructive/15 text-destructive border border-destructive/30",
  // [nexus] timed_out mapped to warning (closer semantic than "error") — note in report
  timed_out: "bg-warning/15 text-warning border border-warning/30",
  succeeded: "bg-success/15 text-success border border-success/30",
  error: "bg-destructive/15 text-destructive border border-destructive/30",
  terminated: "bg-destructive/15 text-destructive border border-destructive/30",
  pending: "bg-warning/15 text-warning border border-warning/30",

  // Approval statuses
  pending_approval: "bg-warning/15 text-warning border border-warning/30",
  revision_requested: "bg-warning/15 text-warning border border-warning/30",
  approved: "bg-success/15 text-success border border-success/30",
  rejected: "bg-destructive/15 text-destructive border border-destructive/30",

  // Issue statuses — consistent hues with issueStatusIcon above
  backlog: "bg-muted/60 text-muted-foreground border border-border",
  todo: "bg-muted/60 text-muted-foreground border border-border",
  in_progress: "bg-primary/15 text-primary border border-primary/30",
  in_review: "bg-warning/15 text-warning border border-warning/30",
  blocked: "bg-destructive/10 text-destructive border border-destructive/25",
  done: "bg-success/15 text-success border border-success/30",
  cancelled: "bg-muted/40 text-muted-foreground/70 border border-border",
};

export const statusBadgeDefault = "bg-muted text-muted-foreground border border-border";

// ---------------------------------------------------------------------------
// Agent status dot — solid background for small indicator dots
// [nexus] Migrated to design system tokens — see MIGRATION-PLAN.md
// ---------------------------------------------------------------------------

export const agentStatusDot: Record<string, string> = {
  running: "bg-primary animate-pulse",
  active: "bg-success",
  paused: "bg-warning",
  idle: "bg-muted-foreground",
  pending_approval: "bg-warning",
  error: "bg-destructive",
  archived: "bg-muted-foreground/50",
};

export const agentStatusDotDefault = "bg-muted-foreground";

// ---------------------------------------------------------------------------
// Priority colors
// [nexus] Migrated to design system tokens — see MIGRATION-PLAN.md
// urgent/critical → destructive, high → warning, medium → primary, low → muted
// ---------------------------------------------------------------------------

export const priorityColor: Record<string, string> = {
  critical: "text-destructive",
  high: "text-warning",
  medium: "text-primary",
  low: "text-muted-foreground",
};

export const priorityColorDefault = "text-muted-foreground";
