<div class="modal fade" id="create" tabindex="-1" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered modal-lg ">
        <div class="modal-content">

            <div class="modal-header">
                <h5 class="modal-title">Tambah Produk Buket</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>

            {{-- UPDATE 1: Action Route ke Store --}}
            <form action="{{ route('admin.produk-buket.store') }}" method="POST" enctype="multipart/form-data">
                @csrf

                <div class="modal-body">
                    <div class="row gx-3">
                        <div class="col-12 col-md-7">

                            {{-- Nama Buket --}}
                            <div class="mb-2">
                                <label class="form-label">Nama Buket</label>
                                <input type="text" name="nama"
                                    class="form-control @error('nama') is-invalid @enderror" style="font-size: 14px;"
                                    placeholder="Masukkan Nama Buket" value="{{ old('nama') }}">
                                @error('nama')
                                    <div class="invalid-feedback" style="font-size: 12px;">{{ $message }}</div>
                                @enderror
                            </div>
                            <div class="row">
                                {{-- Input Ukuran --}}
                                <div class="col-6 mb-2">
                                    <label class="form-label">Ukuran</label>
                                    <select class="form-select  @error('ukuran') is-invalid @enderror" name="ukuran"
                                        style="font-size: 14px;">
                                        <option value="" selected disabled>Pilih...</option>
                                        {{-- Value harus sama persis dengan enum di migrasi --}}
                                        <option value="S" {{ old('ukuran') == 'S' ? 'selected' : '' }}>Small (S)
                                        </option>
                                        <option value="M" {{ old('ukuran') == 'M' ? 'selected' : '' }}>Medium (M)
                                        </option>
                                        <option value="L" {{ old('ukuran') == 'L' ? 'selected' : '' }}>Large (L)
                                        </option>
                                    </select>
                                </div>

                                {{-- Input Kategori --}}
                                <div class="col-6 mb-2">
                                    <label class="form-label">Kategori</label>
                                    <select class="form-select @error('kategori') is-invalid @enderror" name="kategori"
                                        style="font-size: 14px;">
                                        <option value="" selected disabled>Pilih...</option>
                                        {{-- Sesuaikan value dengan: single, fresh, premium_fresh, artificial --}}
                                        <option value="single" {{ old('kategori') == 'single' ? 'selected' : '' }}>
                                            Single Flower</option>
                                        <option value="fresh" {{ old('kategori') == 'fresh' ? 'selected' : '' }}>Fresh
                                            Flower</option>
                                        <option value="premium_fresh"
                                            {{ old('kategori') == 'premium_fresh' ? 'selected' : '' }}>Premium Fresh
                                        </option>
                                        <option value="artificial"
                                            {{ old('kategori') == 'artificial' ? 'selected' : '' }}>Artificial</option>
                                    </select>
                                </div>
                            </div>

                            {{-- Harga Buket --}}
                            <div class="mb-2">
                                <label class="form-label">Harga Buket</label>
                                {{-- UPDATE 3: Tambah name="harga" --}}
                                <input type="number" class="form-control @error('harga') is-invalid @enderror"
                                    name="harga" value="{{ old('harga') }}" style="font-size: 14px;"
                                    placeholder="Masukkan Harga Buket">
                                @error('harga')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                                <p class="mb-0"><small class="text-muted mb-0">Dalam Rupiah</small>
                                </p>
                            </div>

                            {{-- Request Khusus --}}
                            <div class="mb-2">
                                <label class="form-label">Request Khusus</label>
                                {{-- UPDATE 4: Tambah name="request_khusus" --}}
                                <input type="text" class="form-control" name="request_khusus"
                                    value="{{ old('request_khusus') }}" style="font-size: 14px;"
                                    placeholder="Masukkan Opsi Custom">
                            </div>

                            {{-- Deskripsi Buket --}}
                            <div class="mb-2">
                                <label class="form-label">Deskripsi Buket</label>
                                {{-- UPDATE 5: Tambah name="deskripsi" --}}
                                <textarea class="form-control @error('deskripsi') is-invalid @enderror" name="deskripsi" rows="4"
                                    style="font-size: 14px;" placeholder="Masukkan Deskripsi Buket">{{ old('deskripsi') }}</textarea>
                                @error('deskripsi')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>

                        </div>

                        <div class="col-12 col-md-5">
                            <div class="mb-3">
                                <label class="form-label">Upload Foto Buket</label>

                                {{-- Area Upload Custom --}}
                                <div class="upload-area p-4 text-centerd d-flex flex-column align-items-center justify-content-center"
                                    onclick="document.getElementById('createFotoInput').click()"
                                    style="cursor: pointer;">

                                    <i class="bi bi-file-earmark-arrow-up fs-5 text-secondary mb-3"></i>
                                    <span class="fw-semibold text-dark">Klik untuk Upload</span>
                                    <small class="text-muted">Max 2MB (JPG/PNG)</small>

                                    {{-- Input File Tersembunyi (ID UNIK: createFotoInput) --}}
                                    <input type="file" id="createFotoInput" class="d-none" name="foto"
                                        accept="image/*">
                                </div>
                                @error('foto')
                                    <div class="text-danger mt-1" style="font-size: 12px;">{{ $message }}</div>
                                @enderror
                            </div>

                            {{-- 7. Preview Foto (Fixed Container) --}}
                            <div class="mb-3">
                                <label class="form-label">Preview</label>
                                <div class="border rounded d-flex justify-content-center align-items-center position-relative overflow-hidden"
                                    style="height: 200px; background-color: #f8f9fa;">

                                    {{-- Placeholder Teks (ID UNIK: createPlaceholder) --}}
                                    <div id="createPlaceholder" class="text-center text-muted">
                                        <i class="bi bi-image fs-4"></i>
                                        <p class="mb-0" style="font-size: 12px;">Belum ada foto dipilih</p>
                                    </div>

                                    {{-- Gambar Preview (ID UNIK: createImgPreview) --}}
                                    <img id="createImgPreview" src="#" class="d-none w-100 h-100"
                                        style="object-fit: contain;">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer justify-content-end border-top-0 pt-0">
                    <button type="submit" class="btn btn-primary rounded-pill terima px-3 py-2">
                        Simpan
                    </button>
                </div>
            </form>

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