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-full border px-2.5 py-0.5 text-[11px] font-semibold transition-colors focus:outline-none focus:ring-[3px] focus:ring-[var(--focus-ring)]",
  {
    variants: {
      variant: {
        default:
          "border-transparent bg-[var(--accent-deep)] text-[oklch(0.98_0.005_45)]",
        secondary:
          "border-[var(--hairline)] bg-[var(--surface-2)] text-[var(--ink-soft)]",
        destructive:
          "border-transparent bg-[var(--danger-soft)] text-[var(--danger)]",
        outline: "border-[var(--hairline)] text-[var(--ink-soft)]",
        success:
          "border-transparent bg-[var(--good-soft)] text-[var(--good)]",
        warning:
          "border-transparent bg-[var(--warn-soft)] text-[var(--warn)]",
      },
    },
    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 };
