import { cn } from '@/lib/utils'
import { Badge } from '@/components/ui/badge'

export type StatusTone = 'success' | 'warning' | 'info' | 'danger' | 'neutral'

const toneClassName: Record<StatusTone, string> = {
  success:
    'border-success/25 bg-success/10 text-success-foreground dark:border-success/35 dark:bg-success/15',
  warning:
    'border-warning/25 bg-warning/10 text-warning-foreground dark:border-warning/35 dark:bg-warning/15',
  info: 'border-info/25 bg-info/10 text-info-foreground dark:border-info/35 dark:bg-info/15',
  danger:
    'border-danger/25 bg-danger/10 text-danger-foreground dark:border-danger/35 dark:bg-danger/15',
  neutral:
    'border-neutral/25 bg-neutral/10 text-neutral-foreground dark:border-neutral/35 dark:bg-neutral/15',
}

type StatusBadgeProps = {
  label: React.ReactNode
  tone?: StatusTone
  className?: string
}

export function StatusBadge({
  label,
  tone = 'neutral',
  className,
}: StatusBadgeProps) {
  return (
    <Badge
      variant='outline'
      className={cn(
        'gap-1.5 border font-medium',
        toneClassName[tone],
        className
      )}
    >
      <span className='size-1.5 rounded-full bg-current' />
      {label}
    </Badge>
  )
}
