import * as React from "react";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";

const buttonVariants = cva(
  "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm font-semibold transition-all focus-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",
  {
    variants: {
      variant: {
        primary:
          "bg-steel-900 text-white shadow-[0_10px_30px_-12px_rgba(15,26,42,0.45)] hover:bg-steel-800 hover:-translate-y-0.5 active:translate-y-0",
        secondary:
          "bg-white text-steel-900 border border-steel-200 hover:border-steel-900 hover:-translate-y-0.5",
        outline:
          "border border-white/30 bg-white/5 text-white backdrop-blur-sm hover:bg-white/10 hover:border-white/60",
        ghost:
          "text-steel-700 hover:text-steel-900 hover:bg-steel-50",
        accent:
          "bg-gradient-to-br from-steel-800 to-steel-900 text-white hover:from-steel-700 hover:to-steel-800 hover:-translate-y-0.5 shadow-[0_10px_30px_-12px_rgba(15,26,42,0.6)]",
      },
      size: {
        default: "h-11 px-6 py-2",
        sm: "h-9 px-4 text-xs",
        lg: "h-12 px-7 text-[15px]",
        xl: "h-14 px-9 text-base",
        icon: "h-11 w-11",
      },
    },
    defaultVariants: {
      variant: "primary",
      size: "default",
    },
  }
);

export interface ButtonProps
  extends React.ButtonHTMLAttributes<HTMLButtonElement>,
    VariantProps<typeof buttonVariants> {
  asChild?: boolean;
}

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
  ({ className, variant, size, ...props }, ref) => {
    return (
      <button
        ref={ref}
        className={cn(buttonVariants({ variant, size, className }))}
        {...props}
      />
    );
  }
);
Button.displayName = "Button";

export { Button, buttonVariants };
