import { ReactNode } from "react";

interface BadgeProps {
  children: ReactNode;
  variant?: "default" | "success" | "warning" | "danger" | "info" | "rose";
  size?: "sm" | "md";
  dot?: boolean;
}

const variants = {
  default: "bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300",
  success: "bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-400",
  warning: "bg-yellow-100 dark:bg-yellow-900/40 text-yellow-700 dark:text-yellow-400",
  danger: "bg-red-100 dark:bg-red-900/40 text-red-700 dark:text-red-400",
  info: "bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-400",
  rose: "bg-rose-100 dark:bg-rose-900/40 text-rose-600 dark:text-rose-400",
};

const dotColors = {
  default: "bg-gray-400",
  success: "bg-green-500",
  warning: "bg-yellow-500",
  danger: "bg-red-500",
  info: "bg-blue-500",
  rose: "bg-rose-500",
};

const sizes = {
  sm: "text-[10px] px-1.5 py-0.5 rounded-md",
  md: "text-xs px-2 py-0.5 rounded-lg",
};

export function Badge({ children, variant = "default", size = "md", dot = false }: BadgeProps) {
  return (
    <span className={`inline-flex items-center gap-1 font-medium ${variants[variant]} ${sizes[size]}`}>
      {dot && <span className={`w-1.5 h-1.5 rounded-full ${dotColors[variant]}`} />}
      {children}
    </span>
  );
}
