import * as React from 'react';

import { cn } from '@/lib/utils';

const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<'input'>>(
  ({ className, type, inputMode, ...props }, ref) => {
    // Default `type=number` to a numeric keyboard on mobile when the caller
    // didn't explicitly override `inputMode`. Without this, iOS shows the
    // full QWERTY keyboard for prices/dimensions/etc. — common audit gripe.
    // `decimal` covers both whole numbers and decimals; if the caller wants
    // strict integer input they pass `inputMode="numeric"` explicitly.
    const resolvedInputMode = inputMode ?? (type === 'number' ? 'decimal' : undefined);
    return (
      <input
        type={type}
        inputMode={resolvedInputMode}
        className={cn(
          'flex h-11 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
          className,
        )}
        ref={ref}
        {...props}
      />
    );
  },
);
Input.displayName = 'Input';

export { Input };
