<x-app-layout>
    @section('page-title', $pageTitle)

    <div class="card shadow-sm border-0">
        <div class="card-header bg-white d-flex align-items-center">
            <a href="{{ route('admin.buku.index') }}" class="btn btn-light me-2">
                <i class="bi bi-arrow-left"></i>
            </a>
            <h5 class="my-0 fw-bold">Formulir Edit Buku</h5>
        </div>
        <div class="card-body">
            <form action="#" method="POST">
                {{-- Form ini tidak akan berfungsi karena tidak ada backend --}}
                <div class="row">
                    <div class="col-md-8">
                        <div class="mb-3">
                            <label for="judul" class="form-label">Judul Buku</label>
                            <input type="text" class="form-control" id="judul" value="{{ $buku['judul'] }}">
                        </div>
                        <div class="mb-3">
                            <label for="penulis" class="form-label">Penulis</label>
                            <input type="text" class="form-control" id="penulis" value="{{ $buku['penulis'] }}">
                        </div>
                        <div class="row">
                            <div class="col-md-6 mb-3">
                                <label for="kategori" class="form-label">Kategori</label>
                                <input type="text" class="form-control" id="kategori" value="{{ $buku['kategori'] }}">
                            </div>
                            <div class="col-md-6 mb-3">
                                <label for="tahun" class="form-label">Tahun Terbit</label>
                                <input type="number" class="form-control" id="tahun" value="{{ $buku['tahun'] }}">
                            </div>
                        </div>
                         <div class="mb-3">
                            <label class="form-label">Tipe Akses</label>
                            @php
                                $tipe_akses = is_array($buku['tipe_akses']) ? $buku['tipe_akses'] : [$buku['tipe_akses']];
                            @endphp
                            <div class="form-check">
                                <input class="form-check-input" type="checkbox" id="tipe_offline" @if(in_array('offline', $tipe_akses)) checked @endif>
                                <label class="form-check-label" for="tipe_offline">Peminjaman Offline</label>
                            </div>
                            <div class="form-check">
                                <input class="form-check-input" type="checkbox" id="tipe_online" @if(in_array('online', $tipe_akses)) checked @endif>
                                <label class="form-check-label" for="tipe_online">Baca Online</label>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="mb-3">
                            <label for="cover" class="form-label">Cover Buku</label>
                            <input type="file" class="form-control" id="cover">
                            <img src="{{ asset($buku['cover']) }}" alt="Cover saat ini" class="img-thumbnail mt-2" width="150">
                        </div>
                         <div class="mb-3">
                            <label for="file_pdf" class="form-label">File PDF</label>
                            <input type="file" class="form-control" id="file_pdf">
                            @if(isset($buku['file_pdf']))
                                <small class="text-muted">File saat ini: {{ $buku['file_pdf'] }}</small>
                            @endif
                        </div>
                    </div>
                </div>
                <hr>
                <div class="d-flex justify-content-end">
                    <button type="submit" class="btn btn-primary">Simpan Perubahan</button>
                </div>
            </form>
        </div>
    </div>
</x-app-layout>