<div class="modal fade" id="edit{{ $b->id_buket }}" 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">Edit {{ $b->nama }}</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>

            {{-- UPDATE: Route ke Update & Method PUT --}}
            <form action="{{ route('admin.produk-buket.update', $b->id_buket) }}" method="POST"
                enctype="multipart/form-data">
                @csrf
                @method('PUT')

                <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', $b->nama) }}">
                                @error('nama')
                                    <div class="invalid-feedback" style="font-size: 12px;">{{ $message }}</div>
                                @enderror
                            </div>

                            <div class="row">
                                {{-- 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="S" {{ old('ukuran', $b->ukuran) == 'S' ? 'selected' : '' }}>
                                            Small (S)
                                        </option>
                                        <option value="M" {{ old('ukuran', $b->ukuran) == 'M' ? 'selected' : '' }}>
                                            Medium (M)
                                        </option>
                                        <option value="L" {{ old('ukuran', $b->ukuran) == 'L' ? 'selected' : '' }}>
                                            Large (L)
                                        </option>
                                    </select>
                                </div>

                                {{-- 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="single"
                                            {{ old('kategori', $b->kategori) == 'single' ? 'selected' : '' }}>Single
                                            Flower</option>
                                        <option value="fresh"
                                            {{ old('kategori', $b->kategori) == 'fresh' ? 'selected' : '' }}>Fresh
                                            Flower</option>
                                        <option value="premium_fresh"
                                            {{ old('kategori', $b->kategori) == 'premium_fresh' ? 'selected' : '' }}>
                                            Premium Fresh</option>
                                        <option value="artificial"
                                            {{ old('kategori', $b->kategori) == 'artificial' ? 'selected' : '' }}>
                                            Artificial</option>
                                    </select>
                                </div>
                            </div>

                            {{-- Harga --}}
                            <div class="mb-2">
                                <label class="form-label">Harga Buket</label>
                                <input type="number" class="form-control @error('harga') is-invalid @enderror"
                                    name="harga" value="{{ old('harga', $b->harga) }}" style="font-size: 14px;">
                                <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>
                                <input type="text" class="form-control" name="request_khusus"
                                    value="{{ old('request_khusus', $b->request_khusus) }}" style="font-size: 14px;">
                            </div>

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

                        <div class="col-12 col-md-5">
                            <div class="mb-3">
                                <label class="form-label">Upload Foto Buket</label>
                                {{-- UPDATE: ID Input Unik --}}
                                <div class="upload-area p-4 text-center d-flex flex-column align-items-center justify-content-center"
                                    onclick="document.getElementById('editFotoInput{{ $b->id_buket }}').click()"
                                    style="cursor: pointer; border: 2px dashed #dee2e6; border-radius: 10px;">

                                    <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 type="file" id="editFotoInput{{ $b->id_buket }}" class="d-none"
                                        name="foto" accept="image/*"
                                        onchange="previewEditImage(event, '{{ $b->id_buket }}')">
                                </div>
                                @error('foto')
                                    <div class="text-danger mt-1" style="font-size: 12px;">{{ $message }}</div>
                                @enderror
                            </div>

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

                                    {{-- UPDATE: Menampilkan Foto Lama --}}
                                    <div id="editPlaceholder{{ $b->id_buket }}" class="text-center text-muted d-none">
                                        <i class="bi bi-image fs-4"></i>
                                        <p class="mb-0" style="font-size: 12px;">Belum ada foto</p>
                                    </div>

                                    <img id="editImgPreview{{ $b->id_buket }}"
                                        src="{{ asset('storage/' . $b->foto) }}" class="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>
