import { forwardRef, InputHTMLAttributes } from "react";
import { cn } from "@/utils/cn";

interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
  label: string;
  error?: string;
}

const Input = forwardRef<HTMLInputElement, InputProps>(
  ({ label, error, className, ...props }, ref) => {
    return (
      <div className="space-y-2">
        <label className="text-sm font-medium text-gray-950">
          {label}
        </label>

        <input
          ref={ref}
          className={cn(
            "w-full rounded-xl border border-gray-300 bg-white text-gray-900 px-4 py-3 outline-none transition-all",
            "focus:border-[#C9A227]",
            "focus:ring-2 focus:ring-[#C9A227]/20",
            className
          )}
          {...props}
        />

        {error && (
          <p className="text-sm text-red-500">
            {error}
          </p>
        )}
      </div>
    );
  }
);

Input.displayName = "Input";

export default Input;