{{--
    Shared create/edit fields for an employee.

    $employee     — the Employee being edited, or a fresh instance with defaults
    $teams        — all teams, for the team picker
    $locations    — all locations, for the location picker
    $designationSuggestions — distinct designations already on file, for autocomplete
    $squadSuggestions       — distinct squad names already on file, for autocomplete
--}}
@php
    /** @var \App\Models\Employee $employee */
@endphp

<x-form.fieldset legend="Identity">
    <div class="row g-3">
        <div class="col-md-4">
            <x-form.input
                name="employee_code"
                label="Employee Code"
                :value="$employee->employee_code"
                placeholder="AUM10042"
                autocomplete="off"
                help="Company payroll ID. Must be unique."
                required />
        </div>

        <div class="col-md-4">
            <x-form.input
                name="first_name"
                label="First Name"
                :value="$employee->first_name"
                placeholder="Priya"
                autocomplete="off"
                required />
        </div>

        <div class="col-md-4">
            <x-form.input
                name="last_name"
                label="Last Name"
                :value="$employee->last_name"
                placeholder="Sharma"
                autocomplete="off" />
        </div>
    </div>
</x-form.fieldset>

<x-form.fieldset legend="Contact">
    <div class="row g-3">
        <div class="col-md-4">
            <x-form.input
                name="email"
                label="Work Email"
                type="email"
                :value="$employee->email"
                placeholder="priya@aumnitechworks.com"
                autocomplete="off"
                help="Must be unique. Optional — not every employee has one yet." />
        </div>

        <div class="col-md-4">
            <x-form.input
                name="personal_email"
                label="Personal Email"
                type="email"
                :value="$employee->personal_email"
                autocomplete="off"
                help="Used for exit correspondence." />
        </div>

        <div class="col-md-4">
            <x-form.input
                name="phone"
                label="Phone"
                :value="$employee->phone"
                autocomplete="off" />
        </div>
    </div>
</x-form.fieldset>

<x-form.fieldset legend="Employment">
    <div class="row g-3">
        <div class="col-md-6">
            <x-form.select
                name="team_id"
                label="Team"
                placeholder="No team"
                :selected="$employee->team_id"
                :options="$teams->pluck('name', 'id')->all()" />
        </div>

        <div class="col-md-6">
            <x-form.select
                name="location_id"
                label="Location"
                placeholder="No location"
                :selected="$employee->location_id"
                :options="$locations->pluck('name', 'id')->all()" />
        </div>

        <div class="col-md-6">
            <x-form.datalist
                name="designation"
                label="Designation"
                :value="$employee->designation"
                :options="$designationSuggestions"
                placeholder="Software Engineer"
                help="Start typing, or enter a new one." />
        </div>

        <div class="col-md-6">
            <x-form.datalist
                name="squad"
                label="Squad"
                :value="$employee->squad"
                :options="$squadSuggestions"
                placeholder="Platform"
                help="A squad, pod or account grouping — separate from team." />
        </div>
    </div>
</x-form.fieldset>

<x-form.fieldset legend="Status">
    <div class="row g-3">
        <div class="col-md-4">
            <x-form.select
                name="status"
                label="Status"
                :selected="$employee->status?->value"
                :options="\App\Enums\EmployeeStatus::options()"
                required />
        </div>

        <div class="col-md-4">
            <x-form.date
                name="date_of_joining"
                label="Date of Joining"
                :value="$employee->date_of_joining" />
        </div>

        <div class="col-md-4">
            <x-form.date
                name="date_of_exit"
                label="Date of Exit"
                :value="$employee->date_of_exit"
                help="Only set once the employee has actually left." />
        </div>
    </div>
</x-form.fieldset>

<x-form.fieldset legend="Notes">
    <x-form.textarea
        name="notes"
        label="Notes"
        :value="$employee->notes"
        :rows="3"
        help="Visible to every user who can view this record." />
</x-form.fieldset>
