import * as React from 'react';
import { cva, type VariantProps } from 'class-variance-authority';

import { cn } from '@/lib/utils';

const badgeVariants = cva(
  'inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 uppercase',
  {
    variants: {
      variant: {
        default: 'border-transparent bg-neutral-200 text-neutral-800 shadow hover:bg-neutral-300',
        destructive: 'border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80',
        outline: 'text-foreground',
        pending: 'border-transparent bg-yellow-700 text-yellow-700-foreground shadow hover:bg-yellow-800/80',
        approved: 'border-transparent bg-green-600 text-green-600-foreground shadow hover:bg-green-600/80',
        rejected: 'border-transparent bg-red-700 text-red-700-foreground shadow hover:bg-red-800/80',
        contributor: 'border-transparent bg-blue-700 text-blue-700-foreground shadow hover:bg-blue-800/80',
        owner: 'border-transparent bg-amber-800 text-amber-800-foreground shadow hover:bg-amber-800/80',
        error: 'border-transparent bg-red-500 text-white shadow hover:bg-red-500/80',
        username: 'border-transparent bg-neutral-500 text-neutral-100 shadow hover:bg-neutral-600 w-fit',
      },
    },
    defaultVariants: {
      variant: 'default',
    },
  }
);

export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {}

function Badge({ className, variant, ...props }: BadgeProps) {
  return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
}

export { Badge, badgeVariants };
