<div class="tab-pane fade" id="tab-employment" role="tabpanel">
    <div class="row g-3">
        <div class="col-md-6">
            <label class="form-label fw-semibold">Employee ID</label>
            <input type="text" name="code" class="form-control @error('code') is-invalid @enderror" value="{{ $val('code') }}">
            @error('code')<div class="invalid-feedback">{{ $message }}</div>@enderror
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Designation</label>
            <select name="designation" class="form-select">
                <option value="">— Select —</option>
                @foreach($designationOptions as $name => $label)
                <option value="{{ $name }}" {{ $val('designation') === $name ? 'selected' : '' }}>{{ $label }}</option>
                @endforeach
                @if($val('designation') && !$designationOptions->has($val('designation')))
                <option value="{{ $val('designation') }}" selected>{{ $val('designation') }}</option>
                @endif
            </select>
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Department</label>
            <select name="department" class="form-select">
                <option value="">— Select —</option>
                @foreach($departmentOptions as $name => $label)
                <option value="{{ $name }}" {{ $val('department') === $name ? 'selected' : '' }}>{{ $label }}</option>
                @endforeach
                @if($val('department') && !$departmentOptions->has($val('department')))
                <option value="{{ $val('department') }}" selected>{{ $val('department') }}</option>
                @endif
            </select>
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Project</label>
            <select name="project" class="form-select">
                <option value="">— Select —</option>
                @foreach($projectOptions as $name => $label)
                <option value="{{ $name }}" {{ $val('project') === $name ? 'selected' : '' }}>{{ $label }}</option>
                @endforeach
                @if($val('project') && !$projectOptions->has($val('project')))
                <option value="{{ $val('project') }}" selected>{{ $val('project') }}</option>
                @endif
            </select>
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Branch</label>
            <select name="branch" class="form-select">
                <option value="">— Select —</option>
                @foreach($branchOptions as $name => $label)
                <option value="{{ $name }}" {{ $val('branch') === $name ? 'selected' : '' }}>{{ $label }}</option>
                @endforeach
                @if($val('branch') && !$branchOptions->has($val('branch')))
                <option value="{{ $val('branch') }}" selected>{{ $val('branch') }}</option>
                @endif
            </select>
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Tax ID / TIN</label>
            <input type="text" name="tax_id_tin" class="form-control" value="{{ $val('tax_id_tin') }}">
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Hire Date</label>
            <input type="text" name="joining_date" class="form-control axis-report-datepicker" value="{{ $dateVal('joining_date') }}" autocomplete="off">
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Release Date</label>
            <input type="text" name="release_date" class="form-control axis-report-datepicker" value="{{ $dateVal('release_date') }}" autocomplete="off">
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Date of Confirmation</label>
            <input type="text" name="date_of_confirmation" class="form-control axis-report-datepicker" value="{{ $dateVal('date_of_confirmation') }}" autocomplete="off">
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Duty Type</label>
            <select name="duty_type" class="form-select">
                <option value="">— Select —</option>
                @foreach($opts::dutyTypes() as $option)
                <option value="{{ $option }}" {{ $val('duty_type') === $option ? 'selected' : '' }}>{{ $option }}</option>
                @endforeach
            </select>
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Date of Resign</label>
            <input type="text" name="date_of_resign" class="form-control axis-report-datepicker" value="{{ $dateVal('date_of_resign') }}" autocomplete="off">
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Reason for Resign</label>
            <input type="text" name="reason_for_resign" class="form-control" value="{{ $val('reason_for_resign') }}">
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Terminated Employee</label>
            <select name="terminated_employee" class="form-select">
                @foreach($opts::yesNo() as $label => $value)
                <option value="{{ $value }}" {{ (string) old('terminated_employee', ($employee && $employee->terminated_employee) ? '1' : '0') === $value ? 'selected' : '' }}>{{ $label }}</option>
                @endforeach
            </select>
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">PaySlip Send Method</label>
            <select name="payslip_send_method" class="form-select">
                <option value="">— Select —</option>
                @foreach($opts::payslipSendMethods() as $option)
                <option value="{{ $option }}" {{ $val('payslip_send_method') === $option ? 'selected' : '' }}>{{ $option }}</option>
                @endforeach
            </select>
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Highest Education</label>
            <input type="text" name="highest_education" class="form-control" value="{{ $val('highest_education') }}">
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Last Organization</label>
            <input type="text" name="last_organization" class="form-control" value="{{ $val('last_organization') }}">
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Last Increment Date</label>
            <input type="text" name="last_increment_date" class="form-control axis-report-datepicker" value="{{ $dateVal('last_increment_date') }}" autocomplete="off">
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Last Gross Salary</label>
            <input type="number" step="0.01" min="0" name="last_gross_salary" class="form-control" value="{{ $val('last_gross_salary') }}">
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Salary Payment Method</label>
            <select name="salary_payment_method" class="form-select">
                <option value="">— Select —</option>
                @foreach($opts::salaryPaymentMethods() as $option)
                <option value="{{ $option }}" {{ $val('salary_payment_method') === $option ? 'selected' : '' }}>{{ $option }}</option>
                @endforeach
            </select>
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Bank Name</label>
            <input type="text" name="bank_name" class="form-control" value="{{ $val('bank_name') }}">
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Branch Name</label>
            <input type="text" name="branch_name" class="form-control" value="{{ $val('branch_name') }}">
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Account No</label>
            <input type="text" name="account_no" class="form-control" value="{{ old('account_no', $employee?->bank_account ?? '') }}">
        </div>
        <div class="col-md-6">
            <label class="form-label fw-semibold">Account Type</label>
            <select name="account_type" class="form-select">
                <option value="">— Select —</option>
                @foreach($opts::accountTypes() as $option)
                <option value="{{ $option }}" {{ $val('account_type') === $option ? 'selected' : '' }}>{{ $option }}</option>
                @endforeach
            </select>
        </div>
        <div class="col-12">
            <label class="form-label fw-semibold">Notes</label>
            <textarea name="employment_notes" class="form-control" rows="3">{{ $val('employment_notes') }}</textarea>
        </div>

        <div class="col-12">
            <label class="form-label fw-semibold">Documents</label>
            @if($employee && $employee->documents->isNotEmpty())
            <ul class="list-group mb-2">
                @foreach($employee->documents as $doc)
                <li class="list-group-item d-flex justify-content-between align-items-center py-2">
                    <span style="font-size:13px"><i class="bi bi-paperclip me-1"></i>{{ $doc->original_name }}</span>
                    @if(auth()->user()->hasPermission('masters','edit'))
                    <form method="POST" action="{{ route('masters.employees.documents.destroy', [$employee, $doc]) }}" onsubmit="return confirm('Remove this document?')">
                        @csrf @method('DELETE')
                        <button type="submit" class="btn btn-outline-danger btn-sm"><i class="bi bi-trash"></i></button>
                    </form>
                    @endif
                </li>
                @endforeach
            </ul>
            @endif
            <input type="file" name="documents[]" class="form-control" multiple>
            <div class="form-text">Attach files (max 10 MB each).</div>
        </div>
    </div>
</div>
