<x-admin-layout>
    <x-slot name="header">
        <div class="flex justify-between items-center">
            <div>
                <h2 class="font-bold text-2xl text-gray-900 leading-tight">
                    {{ __('Provision New Law Firm') }}
                </h2>
                <p class="text-sm text-gray-500 mt-1">Create a new tenant database and send access credentials.</p>
            </div>
            <a href="{{ route('admin.tenants.index') }}" class="text-sm text-gray-600 hover:text-gray-900 font-medium flex items-center gap-2">
                <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path></svg>
                Back to Firms
            </a>
        </div>
    </x-slot>

    <div class="py-12 bg-gray-50 min-h-screen">
        <div class="max-w-3xl mx-auto px-4 sm:px-6 lg:px-8">

            <form action="{{ route('admin.tenants.store') }}" method="POST">
                @csrf

                <div class="bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden mb-6">
                    <div class="px-8 py-6 border-b border-gray-50 bg-gray-50/50">
                        <h3 class="text-lg font-semibold text-gray-900">Firm Identity</h3>
                        <p class="text-sm text-gray-500">Enter the public details for the law firm.</p>
                    </div>

                    <div class="p-8 space-y-6">
                        <div>
                            <label class="block text-sm font-semibold text-gray-700 mb-2">Firm Legal Name</label>
                            <div class="relative rounded-md shadow-sm">
                                <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                    <svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"></path></svg>
                                </div>
                                <input type="text" name="firm_name" value="{{ old('firm_name') }}"
                                    class="focus:ring-indigo-500 focus:border-indigo-500 block w-full pl-10 sm:text-sm border-gray-300 rounded-lg py-3"
                                    placeholder="e.g. Specter & Ross LLP" required>
                            </div>
                        </div>

                        <div>
                            <label class="block text-sm font-semibold text-gray-700 mb-2">Administrator Email</label>
                            <div class="relative rounded-md shadow-sm">
                                <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                    <svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"></path></svg>
                                </div>
                                <input type="email" name="email" value="{{ old('email') }}"
                                    class="focus:ring-indigo-500 focus:border-indigo-500 block w-full pl-10 sm:text-sm border-gray-300 rounded-lg py-3"
                                    placeholder="admin@firm.com" required>
                            </div>
                            <p class="mt-2 text-xs text-gray-500">We will send the initial password and login instructions here.</p>
                        </div>
                    </div>
                </div>

                <div class="bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden mb-8">
                    <div class="px-8 py-6 border-b border-gray-50 bg-gray-50/50">
                        <h3 class="text-lg font-semibold text-gray-900">System Access</h3>
                        <p class="text-sm text-gray-500">Configure how the firm will access the platform.</p>
                    </div>

                    <div class="p-8 space-y-8">
                        <div>
                            <label class="block text-sm font-semibold text-gray-700 mb-2">Subdomain Identifier</label>
                            <div class="flex rounded-lg shadow-sm">
                                <span class="inline-flex items-center px-4 rounded-l-lg border border-r-0 border-gray-300 bg-gray-50 text-gray-500 sm:text-sm">
                                    https://
                                </span>
                                <input type="text" name="subdomain" value="{{ old('subdomain') }}"
                                    class="flex-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full min-w-0 rounded-none sm:text-sm border-gray-300 py-3"
                                    placeholder="firm-name" required>
                                <span class="inline-flex items-center px-4 rounded-r-lg border border-l-0 border-gray-300 bg-gray-50 text-gray-500 font-medium sm:text-sm">
                                    .{{ config('tenancy.central_domains')[0] }}
                                </span>
                            </div>
                            <p class="mt-2 text-xs text-gray-500">Only lowercase letters, numbers, and dashes.</p>
                        </div>

                        <div>
                            <label class="block text-sm font-semibold text-gray-700 mb-3">Select Subscription Plan</label>
                            <div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
                                <label class="cursor-pointer relative">
                                    <input type="radio" name="plan" value="free" class="peer sr-only">
                                    <div class="rounded-xl border border-gray-200 bg-white p-4 hover:border-gray-300 peer-checked:border-indigo-600 peer-checked:bg-indigo-50 peer-checked:ring-1 peer-checked:ring-indigo-600 transition-all h-full">
                                        <div class="flex flex-col h-full justify-between">
                                            <div>
                                                <span class="block text-xs font-bold text-gray-400 uppercase tracking-wider mb-1">Trial</span>
                                                <span class="block text-lg font-bold text-gray-900">Free</span>
                                            </div>
                                            <div class="mt-4 text-xs text-gray-500">
                                                Limited to 1 User & 3 Active Cases.
                                            </div>
                                        </div>
                                    </div>
                                </label>

                                <label class="cursor-pointer relative">
                                    <input type="radio" name="plan" value="premium" class="peer sr-only" checked>
                                    <div class="rounded-xl border border-indigo-200 bg-white p-4 hover:border-indigo-300 peer-checked:border-indigo-600 peer-checked:bg-indigo-50 peer-checked:ring-1 peer-checked:ring-indigo-600 transition-all relative h-full">
                                        <div class="absolute -top-3 left-1/2 transform -translate-x-1/2 bg-indigo-600 text-white px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wide">
                                            Popular
                                        </div>
                                        <div class="flex flex-col h-full justify-between">
                                            <div>
                                                <span class="block text-xs font-bold text-indigo-400 uppercase tracking-wider mb-1">Standard</span>
                                                <span class="block text-lg font-bold text-gray-900">Premium</span>
                                            </div>
                                            <div class="mt-4 text-xs text-gray-500">
                                                Up to 10 Users, Unlimited Cases & Support.
                                            </div>
                                        </div>
                                    </div>
                                </label>

                                <label class="cursor-pointer relative">
                                    <input type="radio" name="plan" value="enterprise" class="peer sr-only">
                                    <div class="rounded-xl border border-gray-200 bg-white p-4 hover:border-gray-300 peer-checked:border-slate-800 peer-checked:bg-slate-50 peer-checked:ring-1 peer-checked:ring-slate-800 transition-all h-full">
                                        <div class="flex flex-col h-full justify-between">
                                            <div>
                                                <span class="block text-xs font-bold text-slate-500 uppercase tracking-wider mb-1">Corporate</span>
                                                <span class="block text-lg font-bold text-gray-900">Enterprise</span>
                                            </div>
                                            <div class="mt-4 text-xs text-gray-500">
                                                Unlimited Everything + Dedicated API Access.
                                            </div>
                                        </div>
                                    </div>
                                </label>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="flex items-center justify-end gap-4">
                    <a href="{{ route('admin.tenants.index') }}" class="text-sm font-medium text-gray-600 hover:text-gray-900 transition">Cancel</a>
                    <button type="submit" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-3 px-8 rounded-xl shadow-lg shadow-indigo-200 transform transition hover:-translate-y-0.5 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
                        Provision Firm
                    </button>
                </div>

            </form>
        </div>
    </div>
</x-admin-layout>
