@props([
    'name',
    'label' => null,
    'type' => 'text',
    'value' => null,
    'placeholder' => null,
])

@php
    $error = $errors->first($name);
    $inputId = $attributes->get('id', $name);
@endphp

<div>
    @if($label)
        <label for="{{ $inputId }}" class="mb-2 block text-sm font-semibold text-slate-700">{{ $label }}</label>
    @endif
    <input
        id="{{ $inputId }}"
        name="{{ $name }}"
        type="{{ $type }}"
        @if($type !== 'file') value="{{ old($name, $value) }}" @endif
        placeholder="{{ $placeholder }}"
        {{ $attributes->except('id')->merge([
            'class' => 'block w-full rounded-lg border px-3 py-2 text-sm text-slate-700 shadow-sm focus:border-amber-400 focus:ring-amber-200 ' . ($error ? 'border-rose-400' : 'border-amber-100'),
        ]) }}
    >
    @if($error)
        <p class="mt-1 text-xs text-rose-600">{{ $error }}</p>
    @endif
</div>
