import * as React from 'react';
import { cva } from 'class-variance-authority';
import { cn } from '@/lib/utils';

const badgeVariants = cva(
  'inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-[3px] focus:ring-ring/50',
  {
    variants: {
      variant: {
        default:     'border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80',
        secondary:   'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',
        destructive: 'border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80',
        outline:     'text-foreground',
        // Bill status variants
        paid:      'bg-emerald-500/15 text-emerald-400 border-emerald-500/20',
        late:      'bg-orange-500/15 text-orange-400 border-orange-500/20',
        missed:    'bg-red-500/15 text-red-400 border-red-500/20',
        due_soon:  'bg-yellow-500/15 text-yellow-400 border-yellow-500/20',
        upcoming:  'bg-slate-500/15 text-slate-400 border-slate-500/20',
        autodraft: 'bg-amber-500/15 text-amber-400 border-amber-500/20',
      },
    },
    defaultVariants: {
      variant: 'default',
    },
  }
);

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

export { Badge, badgeVariants };
