{{--
    Частичный шаблон: рендер одного поля веб-формы.
    Используется внутри components/web-form.blade.php.
    Переменная: $field — массив {label, name, type, width, required, options}
--}}
@php
    $required = !empty($field['required']);
    $type     = $field['type'] ?? 'text';
    $name     = $field['name'] ?? '';
    $label    = $field['label'] ?? '';
    $options  = $field['options'] ?? [];
@endphp

@if($type !== 'checkbox')
    <label>{{ $label }}@if($required) <span style="color:var(--red)">*</span>@endif</label>
@endif

@if($type === 'textarea')
    <textarea data-wf-name="{{ $name }}"
              {{ $required ? 'required' : '' }}
              placeholder="{{ $label }}"
              rows="4"></textarea>

@elseif($type === 'select')
    <select data-wf-name="{{ $name }}" {{ $required ? 'required' : '' }}>
        <option value="">— Выберите —</option>
        @foreach($options as $opt)
            <option value="{{ $opt }}">{{ $opt }}</option>
        @endforeach
    </select>

@elseif($type === 'checkbox')
    <div style="display:flex;align-items:center;gap:10px">
        <input type="checkbox" data-wf-name="{{ $name }}" id="wf_{{ $name }}"
               {{ $required ? 'required' : '' }}
               style="width:16px;height:16px;accent-color:var(--red);cursor:pointer;flex-shrink:0">
        <label for="wf_{{ $name }}" style="font-size:13px;color:var(--muted);cursor:pointer;margin:0">
            {{ $label }}
        </label>
    </div>

@else
    <input type="{{ $type }}" data-wf-name="{{ $name }}"
           {{ $required ? 'required' : '' }}
           placeholder="{{ $label }}">
@endif
