<flux:main>
    <div class="flex justify-between items-center">
        <div>
            <flux:heading size="xl">{{ $pageTitle }}</flux:heading>
        </div>
        <div>
            <flux:button href="{{ route('studio.manage.article.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">
                    <flux:card class="space-y-6 p-6">
                        <flux:field>
                            <flux:label>Judul <span class="text-red-500 ms-1">*</span></flux:label>
                            <flux:input placeholder="Tips Memilih Parfum" wire:model.live.debounce.500ms="form.title"
                                autofocus autocomplete="off" />
                            <flux:error name="form.title" />
                        </flux:field>

                        <flux:field>
                            <flux:label>Cuplikasn <span class="text-red-500 ms-1">*</span></flux:label>
                            <flux:editor wire:model="form.excerpt" placeholder="Masukkan inti artikel yang menarik"
                                auotocomplete="off" class="**:data-[slot=content]:min-h-[100px]!" />
                            <flux:error name="form.excerpt" />
                        </flux:field>

                        <flux:field>
                            <flux:label>Konten <span class="text-red-500 ms-1">*</span></flux:label>
                            <flux:editor wire:model="form.content" placeholder="Masukkan konten artikel"
                                auotocomplete="off" class="**:data-[slot=content]:min-h-[100px]!" />
                            <flux:error name="form.content" />
                        </flux:field>
                    </flux:card>
                </div>

                <div class="w-full lg:w-1/3 space-y-4">
                    <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\ArticleStatus::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">
                        <div class="space-y-3">
                            <h3 class="text-sm font-medium">Thumbnail <span class="text-red-500 ms-1">*</span></h3>
                            <div class="dropzone-wrapper">
                                <livewire:dropzone wire:model="form.thumbnail" :rules="['image', 'mimes:png,jpeg', 'max:10420']" :max-files="1"
                                    :key="'thumbnail'" :files="$form->thumbnail" />
                                @error('form.thumbnail')
                                    <div role="alert" aria-live="polite" aria-atomic="true"
                                        class="mt-3 text-sm font-medium text-red-500 dark:text-red-400">
                                        <svg class="shrink-0 [:where(&amp;)]:size-5 inline" data-flux-icon=""
                                            xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"
                                            aria-hidden="true" data-slot="icon">
                                            <path fill-rule="evenodd"
                                                d="M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"
                                                clip-rule="evenodd"></path>
                                        </svg>
                                        {{ $message }}
                                    </div>
                                @enderror
                            </div>
                        </div>
                    </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>
