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

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-2 focus:ring-[var(--accent)] focus:ring-offset-2',
  {
    variants: {
      variant: {
        default:
          'border-transparent bg-[var(--accent)] text-[var(--accent-foreground)]',
        secondary:
          'border-transparent bg-[var(--surface-200)] text-[var(--text-secondary)]',
        outline:
          'border-[var(--border)] text-[var(--text-secondary)]',
        success:
          'border-[var(--success-border)] bg-[var(--success-bg)] text-[var(--success)]',
        warning:
          'border-[var(--warning-border)] bg-[var(--warning-bg)] text-[var(--warning)]',
        error:
          'border-[var(--error-border)] bg-[var(--error-bg)] text-[var(--error)]',
        info:
          'border-[var(--info-border)] bg-[var(--info-bg)] text-[var(--info)]',
      },
    },
    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 };
