<x-admin-layout :title="$item->exists ? 'Edit Membership Tier' : 'Create Membership Tier'">
    <x-admin.form-panel :back-route="route('admin.membership-tiers.index')">
        <form method="POST" action="{{ $item->exists ? route('admin.membership-tiers.update', $item) : route('admin.membership-tiers.store') }}" class="space-y-4">
            @csrf
            @if ($item->exists) @method('PUT') @endif

            <div class="grid grid-cols-2 gap-4">
                <div>
                    <label class="block text-sm font-medium">Name</label>
                    <input name="name" value="{{ old('name', $item->name) }}" class="admin-input" required>
                </div>
                <div>
                    <label class="block text-sm font-medium">Slug</label>
                    <input name="slug" value="{{ old('slug', $item->slug) }}" class="admin-input" required>
                </div>
            </div>
            <div>
                <label class="block text-sm font-medium">Description</label>
                <textarea name="description" rows="3" class="admin-input">{{ old('description', $item->description) }}</textarea>
            </div>
            <div class="grid grid-cols-3 gap-4">
                <div>
                    <label class="block text-sm font-medium">Price (cents)</label>
                    <input type="number" name="price_cents" value="{{ old('price_cents', $item->price_cents) }}" class="admin-input" required>
                </div>
                <div>
                    <label class="block text-sm font-medium">Currency</label>
                    <input name="currency" value="{{ old('currency', $item->currency ?? 'AED') }}" class="admin-input" required maxlength="3">
                </div>
                <div>
                    <label class="block text-sm font-medium">Billing Period</label>
                    <select name="billing_period" class="admin-input" required>
                        <option value="month" @selected(old('billing_period', $item->billing_period) === 'month')>Month</option>
                        <option value="year" @selected(old('billing_period', $item->billing_period) === 'year')>Year</option>
                    </select>
                </div>
            </div>
            <div class="grid grid-cols-3 gap-4">
                <div>
                    <label class="block text-sm font-medium">Badge Text</label>
                    <input name="badge_text" value="{{ old('badge_text', $item->badge_text) }}" class="admin-input">
                </div>
                <div>
                    <label class="block text-sm font-medium">CTA Variant</label>
                    <select name="cta_variant" class="admin-input" required>
                        <option value="ghost" @selected(old('cta_variant', $item->cta_variant ?? 'ghost') === 'ghost')>Ghost</option>
                        <option value="primary" @selected(old('cta_variant', $item->cta_variant) === 'primary')>Primary</option>
                    </select>
                </div>
                <div>
                    <label class="block text-sm font-medium">Sort Order</label>
                    <input type="number" name="sort_order" value="{{ old('sort_order', $item->sort_order ?? 0) }}" class="admin-input" required>
                </div>
            </div>
            <div class="flex gap-6">
                <label class="flex items-center gap-2">
                    <input type="checkbox" name="is_featured" value="1" @checked(old('is_featured', $item->is_featured ?? false))>
                    <span class="text-sm font-medium">Featured</span>
                </label>
                <label class="flex items-center gap-2">
                    <input type="checkbox" name="is_active" value="1" @checked(old('is_active', $item->is_active ?? true))>
                    <span class="text-sm font-medium">Active</span>
                </label>
            </div>
            <button type="submit" class="admin-btn-primary">Save</button>
        </form>
    </x-admin.form-panel>
</x-admin-layout>
