import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"

import { cn } from "@/lib/utils"

const badgeVariants = cva(
  "inline-flex items-center justify-center rounded-full border px-3 py-1 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-[#005EB8] focus-visible:ring-2 focus-visible:ring-[#005EB8]/50 transition-all duration-300 overflow-hidden",
  {
    variants: {
      variant: {
        default: "bg-[#C41E3A] text-white border-transparent shadow-sm",
        secondary:
          "bg-[#005EB8] text-white border-transparent shadow-sm",
        destructive:
          "bg-[#DC2626] text-white border-transparent hover:bg-[#B91C1C]",
        outline:
          "border-[#005EB8] text-[#005EB8] bg-transparent hover:bg-[#E8F4FD]",
        ghost: "text-[#718096] hover:text-[#005EB8] hover:bg-[#F5F7FA]",
        success: "bg-[#16A34A] text-white border-transparent hover:bg-[#15803D]",
        warning: "bg-[#D97706] text-white border-transparent hover:bg-[#B45309]",
        info: "bg-[#0284C7] text-white border-transparent hover:bg-[#0369A1]",
      },
    },
    defaultVariants: {
      variant: "default",
    },
  }
)

function Badge({
  className,
  variant = "default",
  asChild = false,
  ...props
}: React.ComponentProps<"span"> &
  VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
  const Comp = asChild ? Slot : "span"

  return (
    <Comp
      data-slot="badge"
      data-variant={variant}
      className={cn(badgeVariants({ variant }), className)}
      {...props}
    />
  )
}

export { Badge, badgeVariants }
