<div class="mf-form mf-form-grid" data-standard-form>
    <div class="mf-col-6">
        <label class="mf-field-label" for="task-branch">Branch</label>
        <select id="task-branch" class="mf-input" name="branch_id" required>
            <option value="">Select branch</option>
            @foreach($branches as $branch)
                <option value="{{ $branch->id }}" @selected((string) old('branch_id', $task->branch_id) === (string) $branch->id)>{{ $branch->name }}</option>
            @endforeach
        </select>
    </div>

    <div class="mf-col-6">
        <label class="mf-field-label" for="task-assigned-to">Assign to staff</label>
        <select id="task-assigned-to" class="mf-input" name="assigned_to">
            <option value="">Unassigned</option>
            @foreach($staff as $user)
                <option value="{{ $user->id }}" @selected((string) old('assigned_to', $task->assigned_to) === (string) $user->id)>{{ $user->name }} · {{ $user->employee_number ?: 'Staff' }}</option>
            @endforeach
        </select>
    </div>

    <div class="mf-col-12">
        <label class="mf-field-label" for="task-title">Task title</label>
        <input id="task-title" class="mf-input" name="title" maxlength="255" required value="{{ old('title', $task->title) }}" placeholder="Enter a clear task title">
    </div>

    <div class="mf-col-4">
        <label class="mf-field-label" for="task-category">Category</label>
        <select id="task-category" class="mf-input" name="category" required>
            @foreach($categories as $value)
                <option value="{{ $value }}" @selected(old('category', $task->category) === $value)>{{ str($value)->replace('_', ' ')->headline() }}</option>
            @endforeach
        </select>
    </div>

    <div class="mf-col-4">
        <label class="mf-field-label" for="task-priority">Priority</label>
        <select id="task-priority" class="mf-input" name="priority" required>
            @foreach($priorities as $value)
                <option value="{{ $value }}" @selected(old('priority', $task->priority) === $value)>{{ str($value)->headline() }}</option>
            @endforeach
        </select>
    </div>

    <div class="mf-col-4">
        <label class="mf-field-label" for="task-due-at">Due date / time</label>
        <input id="task-due-at" class="mf-input" type="datetime-local" name="due_at" value="{{ old('due_at', $task->due_at?->format('Y-m-d\TH:i')) }}">
    </div>

    <div class="mf-col-12">
        <label class="mf-field-label" for="task-description">Description</label>
        <textarea id="task-description" class="mf-input" rows="5" name="description" placeholder="Add task details, instructions, or expected outcome">{{ old('description', $task->description) }}</textarea>
        <p class="mf-field-help">Include enough detail for the assigned staff member to complete the task without extra clarification.</p>
    </div>
</div>