import type { ButtonHTMLAttributes, ReactNode } from 'react';
import './button.css';

type Variant = 'primary' | 'secondary' | 'ai' | 'ghost' | 'danger';

interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
  variant?: Variant;
  leadingIcon?: ReactNode;
  block?: boolean;
}

/** design.md §1-4 — 주요 버튼(primary blue), AI 액션(ai-accent 보라). radius 4px. */
export function Button({
  variant = 'primary',
  leadingIcon,
  block,
  className = '',
  children,
  ...rest
}: ButtonProps) {
  return (
    <button
      className={`kx-btn kx-btn--${variant} ${block ? 'kx-btn--block' : ''} ${className}`}
      {...rest}
    >
      {leadingIcon && <span className="kx-btn__icon" aria-hidden="true">{leadingIcon}</span>}
      {children}
    </button>
  );
}
