import { forwardRef } from "react";

/**
 * Radio
 *
 * size:        "lg" | "xl" | (default)
 * label:       string | ReactNode - visible label; omit for standalone input
 * labelHidden: boolean - visually hide label while keeping it accessible
 */
const Radio = forwardRef(function Radio(
  { size, label, labelHidden = false, className = "", ...props },
  ref
) {
  const inputClasses = [
    "prs-radio",
    size === "lg" && "prs-radio-lg",
    size === "xl" && "prs-radio-xl",
    className,
  ]
    .filter(Boolean)
    .join(" ");

  const input = <input type="radio" ref={ref} className={inputClasses} {...props} />;

  if (!label) return input;

  return (
    <label className="prs-radio-label">
      {input}
      <span className={labelHidden ? "sr-only" : "prs-label-text"}>{label}</span>
    </label>
  );
});

export default Radio;
