<?php $__env->startSection('title', 'Tenant Onboarding Wizard'); ?>

<?php $__env->startSection('content'); ?>
<div class="max-w-4xl mx-auto space-y-6" x-data="{ step: 1 }">

    <div class="flex items-center justify-between">
        <div>
            <h1 class="text-xl font-bold text-slate-900 dark:text-white">New Tenant Onboarding Wizard</h1>
            <p class="text-xs text-slate-500 dark:text-slate-400">Step-by-step creation of new typing center tenant, owner account, and subscription.</p>
        </div>
        <a href="<?php echo e(route('platform.tenants')); ?>" class="px-4 py-2 bg-slate-200 dark:bg-slate-700 text-slate-700 dark:text-slate-200 font-semibold text-xs rounded-xl">Cancel</a>
    </div>

    <!-- Wizard Steps Progress Bar (Requirement 13) -->
    <div class="bg-white dark:bg-slate-800 rounded-3xl p-4 border border-slate-200 dark:border-slate-700/60 shadow-sm flex items-center justify-between text-xs font-bold text-slate-400">
        <div class="flex items-center space-x-2 rtl:space-x-reverse" :class="step >= 1 ? 'text-sky-600 dark:text-sky-400' : ''">
            <span class="w-6 h-6 rounded-full flex items-center justify-center border text-[11px]" :class="step >= 1 ? 'border-sky-600 bg-sky-50 dark:bg-sky-950' : 'border-slate-300'">1</span>
            <span class="hidden sm:inline">Company Details</span>
        </div>
        <span>➔</span>
        <div class="flex items-center space-x-2 rtl:space-x-reverse" :class="step >= 2 ? 'text-sky-600 dark:text-sky-400' : ''">
            <span class="w-6 h-6 rounded-full flex items-center justify-center border text-[11px]" :class="step >= 2 ? 'border-sky-600 bg-sky-50 dark:bg-sky-950' : 'border-slate-300'">2</span>
            <span class="hidden sm:inline">Owner Account</span>
        </div>
        <span>➔</span>
        <div class="flex items-center space-x-2 rtl:space-x-reverse" :class="step >= 3 ? 'text-sky-600 dark:text-sky-400' : ''">
            <span class="w-6 h-6 rounded-full flex items-center justify-center border text-[11px]" :class="step >= 3 ? 'border-sky-600 bg-sky-50 dark:bg-sky-950' : 'border-slate-300'">3</span>
            <span class="hidden sm:inline">Subscription & Features</span>
        </div>
        <span>➔</span>
        <div class="flex items-center space-x-2 rtl:space-x-reverse" :class="step >= 4 ? 'text-sky-600 dark:text-sky-400' : ''">
            <span class="w-6 h-6 rounded-full flex items-center justify-center border text-[11px]" :class="step >= 4 ? 'border-sky-600 bg-sky-50 dark:bg-sky-950' : 'border-slate-300'">4</span>
            <span class="hidden sm:inline">Confirmation</span>
        </div>
    </div>

    <form action="<?php echo e(route('platform.tenants.store')); ?>" method="POST" class="space-y-6">
        <?php echo csrf_field(); ?>

        <!-- Step 1: Company Details -->
        <div x-show="step === 1" class="bg-white dark:bg-slate-800 rounded-3xl p-6 border border-slate-200 dark:border-slate-700/60 shadow-sm space-y-4">
            <h3 class="text-sm font-bold text-slate-900 dark:text-white uppercase tracking-wider">Step 1 — Company Details</h3>

            <div class="grid grid-cols-1 md:grid-cols-2 gap-4 text-xs">
                <div>
                    <label class="block font-semibold text-slate-700 dark:text-slate-300 mb-1">Company Name *</label>
                    <input type="text" name="company_name" required class="w-full px-3 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl text-slate-900 dark:text-white" placeholder="e.g. Al Madina Typing Center LLC">
                </div>

                <div>
                    <label class="block font-semibold text-slate-700 dark:text-slate-300 mb-1">Legal Registered Name</label>
                    <input type="text" name="legal_name" class="w-full px-3 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl text-slate-900 dark:text-white" placeholder="e.g. Al Madina Government Transactions LLC">
                </div>

                <div>
                    <label class="block font-semibold text-slate-700 dark:text-slate-300 mb-1">Company Email *</label>
                    <input type="email" name="email" required class="w-full px-3 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl text-slate-900 dark:text-white" placeholder="info@company.ae">
                </div>

                <div>
                    <label class="block font-semibold text-slate-700 dark:text-slate-300 mb-1">Mobile Phone</label>
                    <input type="text" name="mobile" placeholder="+971 4 200 1234" class="w-full px-3 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl text-slate-900 dark:text-white">
                </div>

                <div>
                    <label class="block font-semibold text-slate-700 dark:text-slate-300 mb-1">Emirate *</label>
                    <select name="emirate" required class="w-full px-3 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl text-slate-900 dark:text-white">
                        <option value="Dubai" selected>Dubai</option>
                        <option value="Abu Dhabi">Abu Dhabi</option>
                        <option value="Sharjah">Sharjah</option>
                        <option value="Ajman">Ajman</option>
                        <option value="Ras Al Khaimah">Ras Al Khaimah</option>
                        <option value="Fujairah">Fujairah</option>
                        <option value="Umm Al Quwain">Umm Al Quwain</option>
                    </select>
                </div>

                <div>
                    <label class="block font-semibold text-slate-700 dark:text-slate-300 mb-1">TRN (Tax Reg #)</label>
                    <input type="text" name="trn" placeholder="100293847500003" class="w-full px-3 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl text-slate-900 dark:text-white">
                </div>
            </div>

            <div class="flex justify-end pt-4">
                <button type="button" @click="step = 2" class="px-6 py-2 bg-sky-600 hover:bg-sky-700 text-white font-bold text-xs rounded-xl shadow-sm">Next: Owner Account ➔</button>
            </div>
        </div>

        <!-- Step 2: Owner Credentials -->
        <div x-show="step === 2" class="bg-white dark:bg-slate-800 rounded-3xl p-6 border border-slate-200 dark:border-slate-700/60 shadow-sm space-y-4" x-cloak>
            <h3 class="text-sm font-bold text-slate-900 dark:text-white uppercase tracking-wider">Step 2 — Tenant Owner Account</h3>

            <div class="grid grid-cols-1 md:grid-cols-2 gap-4 text-xs">
                <div>
                    <label class="block font-semibold text-slate-700 dark:text-slate-300 mb-1">Owner Full Name *</label>
                    <input type="text" name="owner_name" required class="w-full px-3 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl text-slate-900 dark:text-white" placeholder="Mohammed Al Mansoori">
                </div>

                <div>
                    <label class="block font-semibold text-slate-700 dark:text-slate-300 mb-1">Owner Email *</label>
                    <input type="email" name="owner_email" required class="w-full px-3 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl text-slate-900 dark:text-white" placeholder="owner@company.ae">
                </div>

                <div>
                    <label class="block font-semibold text-slate-700 dark:text-slate-300 mb-1">Username *</label>
                    <input type="text" name="username" required class="w-full px-3 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl text-slate-900 dark:text-white" placeholder="owner.almadina">
                </div>

                <div>
                    <label class="block font-semibold text-slate-700 dark:text-slate-300 mb-1">Temporary Password *</label>
                    <input type="password" name="password" required value="Password123!" class="w-full px-3 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl text-slate-900 dark:text-white">
                </div>
            </div>

            <div class="pt-2 text-xs">
                <label class="flex items-center space-x-2 rtl:space-x-reverse cursor-pointer">
                    <input type="checkbox" name="must_change_password" value="1" checked class="w-4 h-4 text-sky-600 rounded">
                    <span class="text-slate-700 dark:text-slate-300 font-medium">Force password reset on first login</span>
                </label>
            </div>

            <div class="flex justify-between pt-4">
                <button type="button" @click="step = 1" class="px-5 py-2 bg-slate-200 dark:bg-slate-700 text-slate-700 dark:text-slate-200 font-bold text-xs rounded-xl">← Back</button>
                <button type="button" @click="step = 3" class="px-6 py-2 bg-sky-600 hover:bg-sky-700 text-white font-bold text-xs rounded-xl shadow-sm">Next: Subscription ➔</button>
            </div>
        </div>

        <!-- Step 3: Subscription & Features -->
        <div x-show="step === 3" class="bg-white dark:bg-slate-800 rounded-3xl p-6 border border-slate-200 dark:border-slate-700/60 shadow-sm space-y-4" x-cloak>
            <h3 class="text-sm font-bold text-slate-900 dark:text-white uppercase tracking-wider">Step 3 — Subscription & Limits</h3>

            <div class="grid grid-cols-1 md:grid-cols-2 gap-4 text-xs">
                <div>
                    <label class="block font-semibold text-slate-700 dark:text-slate-300 mb-1">Select Subscription Plan *</label>
                    <select name="plan_id" required class="w-full px-3 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl text-slate-900 dark:text-white">
                        <?php $__currentLoopData = $plans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $plan): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($plan->id); ?>" <?php echo e($plan->slug === 'professional' ? 'selected' : ''); ?>>
                                <?php echo e($plan->name); ?> (AED <?php echo e(number_format($plan->price_monthly, 2)); ?>/mo)
                            </option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>

                <div>
                    <label class="block font-semibold text-slate-700 dark:text-slate-300 mb-1">Billing Cycle *</label>
                    <select name="billing_cycle" class="w-full px-3 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl text-slate-900 dark:text-white">
                        <option value="monthly" selected>Monthly Billing</option>
                        <option value="yearly">Yearly Billing (10% Off)</option>
                    </select>
                </div>
            </div>

            <div class="flex justify-between pt-4">
                <button type="button" @click="step = 2" class="px-5 py-2 bg-slate-200 dark:bg-slate-700 text-slate-700 dark:text-slate-200 font-bold text-xs rounded-xl">← Back</button>
                <button type="button" @click="step = 4" class="px-6 py-2 bg-sky-600 hover:bg-sky-700 text-white font-bold text-xs rounded-xl shadow-sm">Next: Confirmation ➔</button>
            </div>
        </div>

        <!-- Step 4: Confirmation -->
        <div x-show="step === 4" class="bg-white dark:bg-slate-800 rounded-3xl p-6 border border-slate-200 dark:border-slate-700/60 shadow-sm space-y-4" x-cloak>
            <h3 class="text-sm font-bold text-slate-900 dark:text-white uppercase tracking-wider">Step 4 — Confirm Tenant Creation</h3>
            <p class="text-xs text-slate-500">Submitting will automatically create the tenant, main branch, owner user, roles, subscription, and usage wallets.</p>

            <div class="flex justify-between pt-4">
                <button type="button" @click="step = 3" class="px-5 py-2 bg-slate-200 dark:bg-slate-700 text-slate-700 dark:text-slate-200 font-bold text-xs rounded-xl">← Back</button>
                <button type="submit" class="px-8 py-2.5 bg-emerald-600 hover:bg-emerald-700 text-white font-extrabold text-xs rounded-xl shadow-lg shadow-emerald-600/25">
                    🚀 Create Tenant & Activate Workspace
                </button>
            </div>
        </div>

    </form>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\typingcenter\resources\views\platform\tenants\wizard.blade.php ENDPATH**/ ?>