<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="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="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>

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

    @if ($hasMemberData)
        <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 Member</flux:heading>
                <flux:subheading>Informasi mengenai data keanggotaan 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="profileForm.name" autofocus
                                        autocomplete="off" />
                                    <flux:error name="profileForm.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="profileForm.phone_number" autocomplete="off" />
                                <flux:error name="profileForm.phone_number" />
                            </flux:field>

                            <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>
                        </div>
                    </div>
                </div>

                <div class="flex justify-end">
                    <flux:button variant="primary" class="sm:w-auto cursor-pointer" wire:click="updateProfile">
                        Simpan
                    </flux:button>
                </div>
            </div>
        </div>
    @endif

    <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="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="passwordForm.new_password" viewable />
                <flux:error name="passwordForm.new_password" />
            </flux:field>

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

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