// components/ui/Button.tsx
"use client";

import { cn } from "@/utils/cn.utils";
import { LucideIcon } from "lucide-react";
import React from "react";

type ButtonProps = {
  name?: string;
  onClick?: () => void;
  icon?: LucideIcon;
  variant?: "primary" | "secondary" | "outline" | "transpart" | "danger";
  size?: "sm" | "md" | "lg";
  children?: React.ReactNode;
} & React.ButtonHTMLAttributes<HTMLButtonElement>;

export default function Button({
  name,
  onClick,
  icon: Icon,
  variant = "primary",
  size = "md",
  className,
  children,
  ...props
}: ButtonProps) {
  const baseStyles =
    "flex items-center gap-1.5 font-medium rounded-lg transition-all focus:outline-none";

  const variants: Record<string, string> = {
    primary: "bg-[#0B1E3F] text-white hover:bg-[#0B1E3F]",
    secondary: "bg-gray-200 text-gray-800 hover:bg-gray-300",
    outline: "border border-gray-300 text-gray-700 hover:bg-gray-50",
    transpart: "bg-transparent text-gray-700 hover:bg-gray-200",
    danger: "bg-red-600 text-white hover:bg-red-700",
  };

  const sizes: Record<string, string> = {
    sm: "px-2.5 py-1 text-sm",
    md: "px-3.5 py-1.5 text-sm",
    lg: "px-5 py-2 text-base",
  };

  return (
    <button
      onClick={onClick}
      className={cn(baseStyles, variants[variant], sizes[size], className)}
      {...props}
    >
      {Icon && <Icon className="w-4 h-4" />}
      {name}
      {children}
    </button>
  );
}
