<!-- [DEF:Input:Component] -->
<!--
@TIER: TRIVIAL
@SEMANTICS: input, form-field, ui-atom
@PURPOSE:   Standardized text input component with label and error handling.
@LAYER:     Atom

@INVARIANT: Consistent spacing and focus states.
-->

<script lang="ts">
  // [SECTION: PROPS]
  export let label: string = "";
  export let value: string = "";
  export let placeholder: string = "";
  export let error: string = "";
  export let disabled: boolean = false;
  export let type: 'text' | 'password' | 'email' | 'number' = 'text';
  // [/SECTION: PROPS]

  let id = "input-" + Math.random().toString(36).substr(2, 9);
</script>

<!-- [SECTION: TEMPLATE] -->
<div class="flex flex-col gap-1.5 w-full">
  {#if label}
    <label for={id} class="text-sm font-medium text-gray-700">
      {label}
    </label>
  {/if}
  
  <input
    {id}
    {type}
    {placeholder}
    {disabled}
    bind:value
    class="flex h-10 w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm ring-offset-white file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 {error ? 'border-red-500' : ''}"
  />

  {#if error}
    <span class="text-xs text-red-500">{error}</span>
  {/if}
</div>
<!-- [/SECTION: TEMPLATE] -->

<!-- [/DEF:Input:Component] -->