<x-app-layout>
    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
            {{ isset($package) ? 'Edit Paket' : 'Tambah Paket Baru' }}
        </h2>
    </x-slot>

    <div class="py-12">
        <div class="max-w-3xl mx-auto sm:px-6 lg:px-8">
            <div class="bg-white dark:bg-gray-800 shadow-sm sm:rounded-lg p-6">
                <form action="{{ isset($package) ? route('admin.packages.update', $package) : route('admin.packages.store') }}" method="POST">
                    @csrf
                    @if(isset($package)) @method('PUT') @endif

                    <div class="mb-4">
                        <x-input-label for="name" value="Nama Paket" />
                        <x-text-input id="name" name="name" class="mt-1 w-full" value="{{ old('name', $package->name ?? '') }}" required />
                    </div>

                    <div class="grid grid-cols-2 gap-4 mb-4">
                        <div>
                            <x-input-label for="price" value="Harga (Rp)" />
                            <x-text-input id="price" name="price" type="number" class="mt-1 w-full" value="{{ old('price', $package->price ?? '') }}" required />
                        </div>
                        <div>
                            <x-input-label for="duration_days" value="Durasi (Hari)" />
                            <x-text-input id="duration_days" name="duration_days" type="number" class="mt-1 w-full" value="{{ old('duration_days', $package->duration_days ?? '') }}" required />
                        </div>
                    </div>

                    <div class="mb-6">
                        <x-input-label for="description" value="Deskripsi Paket" />
                        <textarea id="description" name="description" rows="3" class="mt-1 block w-full border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm">{{ old('description', $package->description ?? '') }}</textarea>
                    </div>

                    <div class="flex items-center gap-4">
                        <x-primary-button class="bg-indigo-600 hover:bg-indigo-700">
                            Simpan Paket
                        </x-primary-button>
                        <a href="{{ route('admin.packages.index') }}" class="text-gray-500 underline">Batal</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</x-app-layout>
