import { cn } from "@/lib/utils";
import { type HTMLAttributes } from "react";

type BadgeVariant = "default" | "unit-1" | "unit-2" | "unit-3" | "unit-4" | "unit-5" | "unit-6" | "unit-7" | "unit-8";

interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
  variant?: BadgeVariant;
}

const variantStyles: Record<BadgeVariant, string> = {
  default: "border border-border/70 bg-background text-muted",
  "unit-1": "border border-unit-1/20 bg-unit-1-light text-unit-1-dark",
  "unit-2": "border border-unit-2/20 bg-unit-2-light text-unit-2-dark",
  "unit-3": "border border-unit-3/20 bg-unit-3-light text-unit-3-dark",
  "unit-4": "border border-unit-4/20 bg-unit-4-light text-unit-4-dark",
  "unit-5": "border border-unit-5/20 bg-unit-5-light text-unit-5-dark",
  "unit-6": "border border-unit-6/20 bg-unit-6-light text-unit-6-dark",
  "unit-7": "border border-unit-7/20 bg-unit-7-light text-unit-7-dark",
  "unit-8": "border border-unit-8/20 bg-unit-8-light text-unit-8-dark",
};

export function Badge({ variant = "default", className, children, ...props }: BadgeProps) {
  return (
    <span
      className={cn(
        "inline-flex items-center rounded-full px-3 py-1 text-xs font-extrabold tracking-wide",
        variantStyles[variant],
        className,
      )}
      {...props}
    >
      {children}
    </span>
  );
}
