<flux:main>
    <div class="flex justify-between items-center">
        <div>
            <flux:heading size="xl">{{ $pageTitle }}</flux:heading>
        </div>
        <div>
            <flux:button href="{{ route('studio.master.user.index') }}" wire:navigate.hover class="text-sm">
                Kembali
            </flux:button>
        </div>
    </div>

    <div class="mt-6">
        <div class="flex flex-col gap-4">
            <div class="flex flex-col lg:flex-row gap-4">
                <div class="w-full lg:w-3/4 space-y-4">
                    <div class="grid grid-cols-1 gap-4 lg:grid-cols-2 items-start">
                        <div class="col-span-1 lg:col-span-2">
                            <flux:card class="space-y-6 p-6">
                                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                                    <div class="md:col-span-2">
                                        <flux:field>
                                            <flux:label>Nama Lengkap <span class="text-red-500 ms-1">*</span>
                                            </flux:label>
                                            <flux:input placeholder="Yoga Pangestu"
                                                wire:model.live.debounce.500ms="form.full_name" autofocus
                                                autocomplete="off" />
                                            <flux:error name="form.full_name" />
                                        </flux:field>
                                    </div>

                                    <flux:field>
                                        <flux:label>Nama Pengguna <span class="text-red-500 ms-1">*</span></flux:label>
                                        <flux:input placeholder="johndoe"
                                            wire:model.live.debounce.500ms="form.username" autocomplete="off" />
                                        <flux:error name="form.username" />
                                    </flux:field>

                                    <flux:field>
                                        <flux:label>Email <span class="text-red-500 ms-1">*</span></flux:label>
                                        <flux:input placeholder="info.pangestuyoga@gmail.com"
                                            wire:model.live.debounce.500ms="form.email" autocomplete="off" />
                                        <flux:error name="form.email" />
                                    </flux:field>

                                    <flux:field>
                                        <flux:label>Nomor Telepon <span class="text-red-500 ms-1">*</span></flux:label>
                                        <flux:input placeholder="0821 xxxx xxxx" mask="9999 9999 99999"
                                            wire:model.live.debounce.500ms="form.phone_number" autocomplete="off" />
                                        <flux:error name="form.phone_number" />
                                    </flux:field>

                                    <flux:field>
                                        <flux:label>Gaji Pokok <span class="text-red-500 ms-1">*</span></flux:label>
                                        <flux:input.group>
                                            <flux:input.group.prefix>Rp</flux:input.group.prefix>
                                            <flux:input placeholder="1.500.000" x-mask:dynamic="$money($input, ',')"
                                                wire:model.live.debounce.500ms="form.base_salary" autocomplete="off" />
                                        </flux:input.group>
                                        <flux:error name="form.base_salary" />
                                    </flux:field>

                                    <flux:field>
                                        <flux:label>Tanggal Lahir <span class="text-red-500 ms-1">*</span></flux:label>
                                        <flux:date-picker with-today wire:model.live.debounce.500ms="form.birthdate"
                                            autocomplete="off" locale="id-ID" selectable-header />
                                        <flux:error name="form.birthdate" />
                                    </flux:field>

                                    <flux:field>
                                        <flux:label>Tanggal Bergabung <span class="text-red-500 ms-1">*</span>
                                        </flux:label>
                                        <flux:date-picker with-today wire:model.live.debounce.500ms="form.hire_date"
                                            autocomplete="off" locale="id-ID" selectable-header />
                                        <flux:error name="form.hire_date" />
                                    </flux:field>

                                    <div class="md:col-span-2">
                                        <flux:field>
                                            <flux:label>Alamat <span class="text-red-500 ms-1">*</span></flux:label>
                                            <flux:textarea
                                                placeholder="Jl. Taman Pahlawan No.41, Nagri Kaler, Kec. Purwakarta, Kabupaten Purwakarta, Jawa Barat 41119"
                                                wire:model.live.debounce.500ms="form.address" autocomplete="off"
                                                rows="2" />
                                            <flux:error name="form.address" />
                                        </flux:field>
                                    </div>
                                </div>
                            </flux:card>
                        </div>
                    </div>
                </div>

                <div class="w-full lg:w-1/3 space-y-4">
                    <flux:card class="space-y-6 p-6">
                        <flux:field>
                            <flux:label>Jenis Kelamin <span class="text-red-500 ms-1">*</span></flux:label>
                            <flux:radio.group wire:model.live="form.gender" variant="buttons" class="w-full *:flex-1">
                                @foreach (\App\Enums\Gender::cases() as $gender)
                                    <flux:radio value="{{ $gender->value }}">
                                        {{ $gender->label() }}
                                    </flux:radio>
                                @endforeach
                            </flux:radio.group>
                            <flux:error name="form.gender" />
                        </flux:field>
                    </flux:card>

                    <flux:card class="space-y-6 p-6">
                        <flux:field>
                            <flux:label>Status <span class="text-red-500 ms-1">*</span></flux:label>
                            <flux:radio.group wire:model.live="form.status" variant="buttons" class="w-full *:flex-1">
                                @foreach (\App\Enums\UserStatus::cases() as $status)
                                    <flux:radio value="{{ $status->value }}">
                                        {{ $status->label() }}
                                    </flux:radio>
                                @endforeach
                            </flux:radio.group>
                            <flux:error name="form.status" />
                        </flux:field>
                    </flux:card>

                    <flux:card class="space-y-6 p-6">
                        <flux:field>
                            <flux:label>Outlet <span class="text-red-500 ms-1">*</span></flux:label>
                            <flux:select variant="listbox" multiple searchable placeholder="Pilih Outlet"
                                wire:model.live.debounce.500ms="form.outlet_ids">
                                <flux:select.option wire:click="selectAllOutlets" wire:ignore>Pilih Semua
                                </flux:select.option>
                                <flux:select.option wire:click="deselectAllOutlets" wire:ignore>Hapus Semua
                                </flux:select.option>
                                @foreach ($outlets as $key => $value)
                                    <flux:select.option value="{{ $key }}">{{ $value }}
                                    </flux:select.option>
                                @endforeach
                            </flux:select>
                            <flux:error name="form.outlet_ids" />
                        </flux:field>
                    </flux:card>
                </div>
            </div>

            <div class="flex justify-start">
                <flux:button variant="primary" class="sm:w-auto cursor-pointer" wire:click="save">
                    Simpan
                </flux:button>
            </div>
        </div>
    </div>
</flux:main>
