// components/Input.tsx
import React, { forwardRef } from 'react';
import { InputProps } from '../lib/interfaces';

const Input = forwardRef<HTMLInputElement, InputProps>(
  ({ label, error, className = '', ...props }, ref) => {
    return (
      <div className="mb-4">
        <label className="block text-gray-800 text-sm font-medium mb-1">
          {label}
        </label>
        <input
          ref={ref}
          className={`
            w-full px-6 py-4 rounded-full border border-gray-300 
            focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent
            transition-all duration-200 ease-in-out
            placeholder-gray-400 text-gray-700
            ${error ? 'border-red-500 ring-2 ring-red-200' : ''}
            ${className}
          `}
          {...props}
        />
        {error && (
          <p className="mt-1 text-sm text-red-600">{error}</p>
        )}
      </div>
    );
  }
);

Input.displayName = 'Input';

export default Input;