import React from 'react';

interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
  variant?: 'primary' | 'secondary' | 'ghost' | 'danger';
  size?: 'xs' | 'sm' | 'md';
  icon?: React.ReactNode;
}

export const Button: React.FC<ButtonProps> = ({
  variant = 'primary',
  size = 'sm',
  icon,
  children,
  className = '',
  ...props
}) => {
  // Base classes for the button
  const baseClasses = 'inline-flex items-center justify-center font-semibold tracking-wider transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed select-none font-sans shrink-0 border';

  // Variant classes
  const variantClasses = {
    primary: 'bg-ink-900 hover:bg-ink-800 text-ink-0 border-transparent shadow-sm hover-lift',
    secondary: 'bg-ink-100 hover:bg-ink-200 text-ink-800 border-ink-200',
    ghost: 'bg-transparent hover:bg-ink-100 text-ink-700 border-ink-200',
    danger: 'bg-red-500 hover:bg-red-600 text-white border-transparent shadow-sm',
  };

  // Size classes
  const sizeClasses = {
    xs: 'text-[10px] uppercase tracking-wider py-1.5 px-3 rounded-lg gap-1.5',
    sm: 'text-xs uppercase tracking-wider py-2 px-3.5 rounded-lg gap-2',
    md: 'text-xs uppercase tracking-wider py-2.5 px-4.5 rounded-xl gap-2.5',
  };

  const combinedClassName = `${baseClasses} ${variantClasses[variant]} ${sizeClasses[size]} ${className}`;

  return (
    <button className={combinedClassName} {...props}>
      {icon && <span className="inline-flex items-center justify-center shrink-0">{icon}</span>}
      <span>{children}</span>
    </button>
  );
};

export default Button;
