import React from 'react';

interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
  label?: string;
  error?: string;
  inputClassName?: string;
}

export function Input({ label, error, className = "", inputClassName = "", id, ...props }: InputProps) {
  const inputId = id || (label ? label.toLowerCase().replace(/\s+/g, '-') : undefined);
  
  return (
    <div className={`flex flex-col gap-1.5 ${className}`}>
      {label && <label htmlFor={inputId} className="text-xs font-semibold text-rima-muted uppercase tracking-wider">{label}</label>}
      <input
        id={inputId}
        className={`bg-rima-surface/50 border ${error ? 'border-rima-danger' : 'border-rima-border focus:border-rima-primary'} rounded-xl px-4 py-2.5 text-sm text-rima-text placeholder-rima-muted/50 focus:outline-none focus:ring-1 focus:ring-rima-primary transition-all ${inputClassName}`}
        {...props}
      />
      {error && <span className="text-xs text-rima-danger mt-1">{error}</span>}
    </div>
  );
}
