<flux:main>
    <div class="flex justify-between items-center">
        <div>
            <flux:heading size="xl">{{ $pageTitle }}</flux:heading>
        </div>
        <div>
            <flux:button href="{{ route('studio.catalog.perfume.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">
                                    <flux:field>
                                        <flux:label>Nama <span class="text-red-500 ms-1">*</span></flux:label>
                                        <flux:input placeholder="Blue Emotion"
                                            wire:model.live.debounce.500ms="form.name" autofocus autocomplete="off" />
                                        <flux:error name="form.name" />
                                    </flux:field>

                                    <flux:field>
                                        <flux:label>SKU <span class="text-red-500 ms-1">*</span></flux:label>
                                        <flux:input placeholder="001" wire:model.live.debounce.500ms="form.sku"
                                            autocomplete="off" copyable />
                                        <flux:error name="form.sku" />
                                    </flux:field>

                                    <div class="lg:col-span-2">
                                        <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                                            <flux:select variant="listbox" searchable placeholder="Pilih Merek"
                                                label="Merek" wire:model.live.debounce.500ms="form.brand_id">
                                                @foreach ($brands as $key => $value)
                                                    <flux:select.option value="{{ $key }}">{{ $value }}
                                                    </flux:select.option>
                                                @endforeach
                                            </flux:select>

                                            <flux:field>
                                                <flux:label>Harga Beli <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="xxx" x-mask:dynamic="$money($input, ',')"
                                                        wire:model.live.debounce.500ms="form.cost_price"
                                                        autocomplete="off" />
                                                </flux:input.group>
                                                <flux:error name="form.cost_price" />
                                            </flux:field>

                                            <flux:field>
                                                <flux:label>Harga Jual <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="xxx" x-mask:dynamic="$money($input, ',')"
                                                        wire:model.live.debounce.500ms="form.sale_price"
                                                        autocomplete="off" />
                                                </flux:input.group>
                                                <flux:error name="form.sale_price" />
                                            </flux:field>
                                        </div>
                                    </div>

                                    <div class="md:col-span-2">
                                        <flux:input label="Base Notes" placeholder="A, B, C"
                                            wire:model.live.debounce.500ms="form.base_notes" autocomplete="off" />
                                    </div>

                                    <div class="md:col-span-2">
                                        <flux:input label="Middle Notes" placeholder="A, B, C"
                                            wire:model.live.debounce.500ms="form.middle_notes" autocomplete="off" />
                                    </div>

                                    <div class="md:col-span-2">
                                        <flux:input label="Top Notes" placeholder="A, B, C"
                                            wire:model.live.debounce.500ms="form.top_notes" autocomplete="off" />
                                    </div>

                                    <div class="md:col-span-2">
                                        <flux:editor label="Deskripsi" wire:model="form.description"
                                            placeholder="Blue Emotion adalah parfum pria dengan aroma segar dan sedikit pedas, memadukan citrus, rempah, dan sentuhan kayu, cocok untuk penggunaan sehari-hari maupun acara formal."
                                            auotocomplete="off" class="**:data-[slot=content]:min-h-[100px]!" />
                                    </div>
                                </div>
                            </flux:card>
                        </div>
                    </div>
                </div>

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

                    <flux:card class="space-y-6 p-6">
                        <flux:field>
                            <flux:label>Kategori <span class="text-red-500 ms-1">*</span></flux:label>
                            <flux:select variant="listbox" multiple searchable placeholder="Pilih kategori"
                                wire:model.live.debounce.500ms="form.category_ids">
                                <flux:select.option wire:click="selectAllCategories" wire:ignore>Pilih Semua
                                </flux:select.option>
                                <flux:select.option wire:click="deselectAllCategories" wire:ignore>Hapus Semua
                                </flux:select.option>
                                @foreach ($categories as $key => $value)
                                    <flux:select.option value="{{ $key }}">{{ $value }}
                                    </flux:select.option>
                                @endforeach
                            </flux:select>
                            <flux:error name="form.category_ids" />
                        </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>

                    <flux:card class="space-y-6 p-6">
                        <div class="space-y-3">
                            <h3 class="text-sm font-medium">Gambar</h3>
                            <div class="dropzone-wrapper">
                                <livewire:dropzone wire:model="form.image" :rules="['image', 'mimes:png,jpeg', 'max:10420']" :max-files="1"
                                    :key="'image'" :files="$form->image" />
                                @error('form.image')
                                    <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>
