import Link from "next/link";
import { cn } from "@/lib/utils";

type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
  variant?: "primary" | "secondary" | "ghost" | "danger";
  size?: "sm" | "md" | "lg";
  href?: string;
};

const variants = {
  primary: "bg-accent text-black hover:bg-accent-dim shadow-[0_0_28px_rgba(255,122,0,0.35)]",
  secondary: "bg-surface-2 text-text hover:bg-[#2a2a2a] border border-border",
  ghost: "bg-transparent text-text hover:bg-white/5",
  danger: "bg-danger text-white hover:bg-red-600",
};

const sizes = {
  sm: "h-9 px-3 text-sm",
  md: "h-11 px-5 text-sm",
  lg: "h-13 px-7 text-base",
};

export function Button({
  className,
  variant = "primary",
  size = "md",
  href,
  children,
  ...props
}: ButtonProps) {
  const classes = cn(
    "inline-flex items-center justify-center gap-2 rounded-xl font-[family-name:var(--font-space)] font-semibold transition-all duration-300 disabled:opacity-50 disabled:pointer-events-none",
    variants[variant],
    sizes[size],
    className,
  );

  if (href) {
    return (
      <Link href={href} className={classes}>
        {children}
      </Link>
    );
  }

  return (
    <button className={classes} {...props}>
      {children}
    </button>
  );
}
