<x-app-layout>
    <div class="py-12 bg-gray-50 min-h-screen">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-6">
            
            <div class="flex flex-col sm:flex-row sm:items-center sm:justify-between bg-white p-6 rounded-2xl border border-gray-100 shadow-sm gap-4">
                <div>
                    <h2 class="text-2xl font-black text-gray-800 tracking-tight">Edit Kategori Produk</h2>
                    <p class="text-sm text-gray-400 font-medium mt-0.5">Perbarui informasi, kode klasifikasi, atau status operasional dari kategori produk Tempe Zhi.</p>
                </div>
                <div>
                    <a href="{{ route('admin.kategori-produk.index') }}" class="inline-flex items-center gap-2 bg-white hover:bg-gray-50 text-gray-600 px-5 py-2.5 rounded-xl font-bold text-xs border border-gray-200 shadow-sm transition-all active:scale-95 whitespace-nowrap">
                        Kembali ke List
                    </a>
                </div>
            </div>

            <div class="bg-white overflow-hidden shadow-sm rounded-2xl p-6 md:p-8 border border-gray-100">
                
                @if ($errors->any())
                    <div class="mb-6 p-4 bg-red-50 border-l-4 border-red-500 text-red-700 rounded-r-xl">
                        <ul class="list-disc list-inside text-sm font-medium">
                            @foreach ($errors->all() as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                        </ul>
                    </div>
                @endif

                <form action="{{ route('admin.kategori-produk.update', $kategori->id) }}" method="POST" class="space-y-6">
                    @csrf
                    @method('PUT')

                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div class="space-y-2">
                            <label for="kode_kategori" class="text-xs font-bold text-gray-400 uppercase tracking-wider block">Kode Kategori</label>
                            <input type="text" 
                                   name="kode_kategori" 
                                   id="kode_kategori"
                                   value="{{ old('kode_kategori', $kategori->kode_kategori) }}"
                                   class="w-full px-4 py-3 rounded-xl border border-gray-200 text-sm font-bold text-gray-800 focus:ring-2 focus:ring-green-700/20 focus:border-green-700 transition-all" 
                                   required>
                        </div>

                        <div class="space-y-2">
                            <label for="nama_kategori" class="text-xs font-bold text-gray-400 uppercase tracking-wider block">Nama Kategori</label>
                            <input type="text" 
                                   name="nama_kategori" 
                                   id="nama_kategori"
                                   value="{{ old('nama_kategori', $kategori->nama_kategori) }}"
                                   class="w-full px-4 py-3 rounded-xl border border-gray-200 text-sm font-bold text-gray-800 focus:ring-2 focus:ring-green-700/20 focus:border-green-700 transition-all" 
                                   required>
                        </div>
                    </div>

                    <div class="space-y-2">
                        <label for="deskripsi" class="text-xs font-bold text-gray-400 uppercase tracking-wider block">Deskripsi Singkat</label>
                        <textarea name="deskripsi" 
                                  id="deskripsi"
                                  rows="3" 
                                  class="w-full px-4 py-3 rounded-xl border border-gray-200 text-sm font-bold text-gray-800 focus:ring-2 focus:ring-green-700/20 focus:border-green-700 transition-all">{{ old('deskripsi', $kategori->deskripsi) }}</textarea>
                    </div>

                    <div class="space-y-2">
                        <label for="status" class="text-xs font-bold text-gray-400 uppercase tracking-wider block">Status Kategori</label>
                        <select name="status" 
                                id="status"
                                class="w-full px-4 py-3 rounded-xl border border-gray-200 text-sm font-bold text-gray-700 focus:ring-2 focus:ring-green-700/20 focus:border-green-700 transition-all bg-white">
                            <option value="aktif" {{ old('status', $kategori->status) == 'aktif' ? 'selected' : '' }}>Aktif</option>
                            <option value="nonaktif" {{ old('status', $kategori->status) == 'nonaktif' ? 'selected' : '' }}>Non-Aktif</option>
                        </select>
                    </div>

                    <div class="flex justify-end items-center gap-3 pt-4 border-t border-gray-50">
                        <a href="{{ route('admin.kategori-produk.index') }}" class="px-5 py-2.5 rounded-xl font-bold text-xs text-gray-500 hover:text-gray-700 transition-colors">
                            Batalkan
                        </a>
                        <button type="submit" class="inline-flex items-center gap-2 bg-green-700 hover:bg-green-800 text-white px-6 py-2.5 rounded-xl font-bold text-xs shadow-md transition-all active:scale-95">
                            Simpan Perubahan
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</x-app-layout>