/**
 * Trouve-KA — composant UI Button (éditorial sharp : bordure encre, ombre dure)
 * Author: Simon-Pierre Boucher
 * Contact: contact@spboucher.ai
 */

import { forwardRef, type ButtonHTMLAttributes } 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-ctl border-[1.5px] font-display text-sm font-bold transition-colors active:translate-x-[2px] active:translate-y-[2px] active:shadow-none disabled:pointer-events-none disabled:opacity-50",
  {
    variants: {
      variant: {
        default:
          "border-ink bg-ink text-lime shadow-off-btn hover:bg-green-deep",
        secondary:
          "border-ink bg-lime text-ink shadow-[4px_4px_0_rgba(217,242,107,0.25)] hover:bg-lime-soft",
        outline: "border-ink bg-surface text-ink shadow-off-field hover:bg-lime",
        ghost: "border-transparent text-ink-2 hover:border-ink hover:text-ink",
        danger:
          "border-ink bg-danger text-paper shadow-off-btn hover:bg-[#9c352e]",
      },
      size: {
        sm: "h-9 px-3.5 text-xs",
        md: "h-11 px-5",
        lg: "h-12 px-7 text-base",
      },
    },
    defaultVariants: {
      variant: "default",
      size: "md",
    },
  },
);

export interface ButtonProps
  extends ButtonHTMLAttributes<HTMLButtonElement>,
    VariantProps<typeof buttonVariants> {}

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

export { Button, buttonVariants };
