<flux:main>
    <div class="flex justify-between items-center">
        <div>
            <flux:heading size="xl">{{ $pageTitle }}</flux:heading>
        </div>
    </div>

    <div class="mt-6">
        <flux:separator variant="subtle" class="my-8" />

        <div class="flex flex-col lg:flex-row gap-4 lg:gap-6">
            <div class="w-80">
                <flux:heading size="lg">Akun</flux:heading>
                <flux:subheading>Pengaturan untuk kredensial masuk Anda.</flux:subheading>
            </div>

            <div class="flex-1 space-y-6">
                <div class="grid grid-cols-1 gap-4 lg:grid-cols-2 items-start">
                    <div class="col-span-1 lg:col-span-2">
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                            <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="accountForm.username"
                                    autocomplete="off" />
                                <flux:error name="accountForm.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="accountForm.email" autocomplete="off" />
                                <flux:error name="accountForm.email" />
                            </flux:field>

                            <flux:input label="Status Akun" wire:model="accountForm.status" readonly />

                            <flux:input label="Email Terverifikasi Pada" wire:model="accountForm.email_verified_at"
                                readonly />

                        </div>
                    </div>
                </div>

                @can('update account')
                    <div class="flex justify-end">
                        <flux:button variant="primary" class="sm:w-auto cursor-pointer" wire:click="updateAccount">
                            Simpan
                        </flux:button>
                    </div>
                @endcan
            </div>
        </div>
    </div>

    <flux:separator variant="subtle" class="my-8" />

    <div class="flex flex-col lg:flex-row gap-4 lg:gap-6">
        <div class="w-80">
            <flux:heading size="lg">Profil</flux:heading>
            <flux:subheading>Informasi mengenai data diri Anda.</flux:subheading>
        </div>

        <div class="flex-1 space-y-6">
            <div class="grid grid-cols-1 gap-4 lg:grid-cols-2 items-start">
                <div class="col-span-1 lg:col-span-2">
                    <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="John Doe"
                                    wire:model.live.debounce.500ms="profileForm.full_name" autofocus
                                    autocomplete="off" />
                                <flux:error name="profileForm.full_name" />
                            </flux:field>
                        </div>

                        <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="profileForm.phone_number" autocomplete="off" />
                            <flux:error name="profileForm.phone_number" />
                        </flux:field>

                        <flux:field>
                            <flux:label>Gaji Pokok</flux:label>
                            <flux:input.group>
                                <flux:input.group.prefix>Rp</flux:input.group.prefix>
                                <flux:input wire:model="profileForm.base_salary" readonly placeholder="1.500.000" />
                            </flux:input.group>
                            <flux:error name="profileForm.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="profileForm.birthdate"
                                placeholder="Pilih Tanggal" autocomplete="off" locale="id-ID" selectable-header />
                            <flux:error name="profileForm.birthdate" />
                        </flux:field>

                        <flux:input label="Tanggal Bergabung" wire:model="profileForm.hire_date" readonly />

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

                        <flux:field>
                            <flux:label>Jenis Kelamin <span class="text-red-500 ms-1">*</span></flux:label>
                            <flux:radio.group wire:model.live="profileForm.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="profileForm.gender" />
                        </flux:field>

                        <flux:input label="Status Kerja" wire:model="profileForm.status" readonly />
                    </div>
                </div>
            </div>

            @can('update profile')
                <div class="flex justify-end">
                    <flux:button variant="primary" class="sm:w-auto cursor-pointer" wire:click="updateProfile">
                        Simpan
                    </flux:button>
                </div>
            @endcan
        </div>
    </div>

    <flux:separator variant="subtle" class="my-8" />

    <div class="flex flex-col lg:flex-row gap-4 lg:gap-6">
        <div class="w-80">
            <flux:heading size="lg">Kata Sandi</flux:heading>
            <flux:subheading>Atur ulang kata sandi Anda.</flux:subheading>
        </div>

        <div class="flex-1 space-y-6">
            <flux:field>
                <flux:label>Kata Sandi Saat Ini <span class="text-red-500 ms-1">*</span></flux:label>
                <flux:input placeholder="********" type="password"
                    wire:model.live.debounce.500ms="passwordForm.current_password" viewable />
                <flux:error name="passwordForm.current_password" />
            </flux:field>

            <flux:field>
                <flux:label>Kata Sandi Baru <span class="text-red-500 ms-1">*</span></flux:label>
                <flux:input placeholder="********" type="password"
                    wire:model.live.debounce.500ms="passwordForm.new_password" viewable />
                <flux:error name="passwordForm.new_password" />
            </flux:field>

            <flux:field>
                <flux:label>Konfirmasi Kata Sandi <span class="text-red-500 ms-1">*</span></flux:label>
                <flux:input placeholder="********" type="password"
                    wire:model.live.debounce.500ms="passwordForm.new_confirm_password" viewable />
                <flux:error name="passwordForm.new_confirm_password" />
            </flux:field>

            @can('update password')
                <div class="flex justify-end">
                    <flux:button variant="primary" class="sm:w-auto cursor-pointer" wire:click="updatePassword">
                        Simpan
                    </flux:button>
                </div>
            @endcan
        </div>
    </div>

    <flux:separator variant="subtle" class="my-8" />

    <div class="flex flex-col lg:flex-row gap-4 lg:gap-6 pb-10">
        <div class="w-80">
            <flux:heading size="lg">Notifikasi</flux:heading>
            <flux:subheading>Izinkan notifikasi untuk menerima pemberitahuan.</flux:subheading>
        </div>

        <div class="flex-1 space-y-6">
            <flux:fieldset class="space-y-4">
                <flux:switch checked label="Communication emails"
                    description="Receive emails about your account activity." />

                <flux:separator variant="subtle" />

                <flux:switch checked label="Marketing emails"
                    description="Receive emails about new products, features, and more." />

                <flux:separator variant="subtle" />

                <flux:switch label="Social emails"
                    description="Receive emails for friend requests, follows, and more." />

                <flux:separator variant="subtle" />

                <flux:switch label="Security emails"
                    description="Receive emails about your account activity and security." />
            </flux:fieldset>
        </div>
    </div>
</flux:main>
