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-[#1C1C1C] focus-visible:ring-2 focus-visible:ring-[#1C1C1C]/50 transition-all duration-300 overflow-hidden",
  {
    variants: {
      variant: {
        default: "bg-[#C41E3A] text-white border-transparent shadow-sm",
        secondary:
          "bg-[#1C1C1C] text-white border-transparent shadow-sm",
        destructive:
          "bg-[#C41E3A] text-white border-transparent hover:bg-[#A01830]",
        outline:
          "border-[#1C1C1C] text-[#1C1C1C] bg-transparent hover:bg-[#F5F5F5]",
        ghost: "text-[#5C5C5C] hover:text-[#1C1C1C] hover:bg-[#F5F5F5]",
        success: "bg-[#16A34A] text-white border-transparent hover:bg-[#15803D]",
        warning: "bg-[#D97706] text-white border-transparent hover:bg-[#B45309]",
        info: "bg-[#5C5C5C] text-white border-transparent hover:bg-[#3D3D3D]",
      },
    },
    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 }
