@php
    $breadcrumbs = [
        ['label' => __('common.home'), 'url' => route('dashboard.index')],
        ['label' => __('me.leave_title'), 'url' => route('me.leaves.index')],
        ['label' => __('leave.create_title')],
    ];
    $typeOptions = $types->mapWithKeys(fn ($t) => [$t->id => $t->name])->all();
@endphp

<x-ui.layout.page
    :title="__('leave.create_title')"
    page-icon="fe fe-plus"
    :breadcrumbs="$breadcrumbs"
>
    <x-slot:actions>
        <x-ui.buttons.secondary :href="route('me.leaves.index')" icon="fe fe-arrow-left">
            {{ __('leave.actions.back') }}
        </x-ui.buttons.secondary>
    </x-slot:actions>

    <div class="card border-0 shadow-sm">
        <div class="card-body">
            <form method="POST" action="{{ route('me.leaves.store') }}" class="row g-3" enctype="multipart/form-data">
                @csrf
                <div class="col-md-6">
                    <x-ui.form.search-select
                        name="leave_type_id"
                        lookup="leave_types"
                        :label="__('leave.fields.leave_type')"
                        :options="$typeOptions"
                        :selected="old('leave_type_id')"
                        :placeholder="__('common.select')"
                        required
                    />
                </div>
                <div class="col-md-6">
                    <x-ui.form.select
                        name="is_half_day"
                        :label="__('leave.fields.is_half_day')"
                        :options="[0 => __('common.no'), 1 => __('common.yes')]"
                        :selected="old('is_half_day', 0)"
                    />
                </div>
                <div class="col-md-6">
                    <x-ui.form.input name="start_date" type="date" :label="__('leave.fields.start_date')" :value="old('start_date')" required />
                </div>
                <div class="col-md-6">
                    <x-ui.form.input name="end_date" type="date" :label="__('leave.fields.end_date')" :value="old('end_date')" required />
                </div>
                <div class="col-md-6">
                    <x-ui.form.input name="attachment" type="file" :label="__('leave.fields.attachment')" />
                </div>
                <div class="col-12">
                    <x-ui.form.input name="reason" :label="__('leave.fields.reason')" :value="old('reason')" />
                </div>
                <div class="col-12">
                    <x-ui.buttons.primary type="submit" icon="fe fe-send">
                        {{ __('leave.actions.submit') }}
                    </x-ui.buttons.primary>
                </div>
            </form>
        </div>
    </div>
</x-ui.layout.page>
