<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('header', null, []); ?> 
        <div class="flex items-center justify-between w-full">
            <div>
                <h1 class="text-lg font-semibold text-gray-800">Manage Business: <?php echo e($business->name); ?></h1>
                <p class="text-xs text-gray-400 mt-0.5">Oversee business settings, subscription status, and user management</p>
            </div>
            <a href="<?php echo e(route('super-admin.dashboard')); ?>" class="inline-flex items-center gap-1.5 text-sm text-gray-500 hover:text-indigo-600 transition">
                <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="M15 19l-7-7 7-7"/></svg>
                Back to Dashboard
            </a>
        </div>
     <?php $__env->endSlot(); ?>

    <?php if(session('success')): ?>
        <div class="bg-emerald-50 border border-emerald-100 rounded-xl p-4 mb-6 flex items-center gap-3">
            <span class="w-8 h-8 rounded-full bg-emerald-100 flex items-center justify-center text-emerald-600">
                <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4" /></svg>
            </span>
            <p class="text-xs font-semibold text-emerald-800"><?php echo e(session('success')); ?></p>
        </div>
    <?php endif; ?>

    <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
        <!-- Business settings & subscription -->
        <div class="bg-white border border-gray-100 rounded-xl p-6 shadow-sm space-y-4 h-fit">
            <h3 class="text-xs font-bold text-gray-400 uppercase tracking-wider border-b border-gray-50 pb-2">Business Details & Subscription</h3>
            <form method="POST" action="<?php echo e(route('super-admin.businesses.update', $business->id)); ?>" class="space-y-4">
                <?php echo csrf_field(); ?>
                <?php echo method_field('PUT'); ?>
                <input type="hidden" name="redirect_to_manage" value="1">

                <div>
                    <label class="block text-xs font-medium text-gray-500 mb-1">Business Name</label>
                    <input type="text" value="<?php echo e($business->name); ?>" disabled class="w-full bg-gray-50 rounded-xl border-gray-200 text-xs text-gray-400">
                </div>

                <div>
                    <label class="block text-xs font-medium text-gray-500 mb-1">NTN/CNIC</label>
                    <input type="text" value="<?php echo e($business->ntn_cnic ?: 'N/A'); ?>" disabled class="w-full bg-gray-50 rounded-xl border-gray-200 text-xs text-gray-400">
                </div>

                <div>
                    <label class="block text-xs font-medium text-gray-500 mb-1">Subscription Plan</label>
                    <select name="subscription_plan_id" class="w-full rounded-xl border-gray-200 text-xs focus:border-indigo-400 focus:ring-indigo-400">
                        <option value="">No Active Plan</option>
                        <?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($business->subscription_plan_id == $plan->id ? 'selected' : ''); ?>>
                                <?php echo e($plan->name); ?> (Rs. <?php echo e(number_format($plan->price)); ?>)
                            </option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>

                <div>
                    <label class="block text-xs font-medium text-gray-500 mb-1">Plan Expiry Date</label>
                    <input type="date" name="subscription_expires_at" value="<?php echo e($business->subscription_expires_at ? substr($business->subscription_expires_at, 0, 10) : ''); ?>" class="w-full rounded-xl border-gray-200 text-xs focus:border-indigo-400 focus:ring-indigo-400">
                </div>

                <div>
                    <label class="block text-xs font-medium text-gray-500 mb-1">Portal Access Status</label>
                    <select name="is_active" class="w-full rounded-xl border-gray-200 text-xs focus:border-indigo-400 focus:ring-indigo-400">
                        <option value="1" <?php echo e($business->is_active ? 'selected' : ''); ?>>Active / Approved</option>
                        <option value="0" <?php echo e(!$business->is_active ? 'selected' : ''); ?>>Blocked / Suspended</option>
                    </select>
                </div>

                <button type="submit" class="w-full py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl text-xs font-semibold transition">Save Changes</button>
            </form>
        </div>

        <!-- Users belonging to business -->
        <div class="lg:col-span-2 bg-white border border-gray-100 rounded-xl shadow-sm overflow-hidden flex flex-col">
            <div class="p-6 border-b border-gray-50">
                <h3 class="text-xs font-bold text-gray-400 uppercase tracking-wider">Business Users</h3>
                <p class="text-[10px] text-gray-400 mt-0.5">List of all users registered under this business tenant</p>
            </div>
            
            <div class="flex-1 overflow-x-auto">
                <table class="w-full text-left border-collapse text-xs">
                    <thead>
                        <tr class="bg-gray-50 border-b border-gray-100 text-gray-400 uppercase tracking-wider font-semibold">
                            <th class="px-6 py-3.5">Name</th>
                            <th class="px-6 py-3.5">Email</th>
                            <th class="px-6 py-3.5">Role</th>
                            <th class="px-6 py-3.5">Actions</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-gray-50">
                        <?php $__empty_1 = true; $__currentLoopData = $business->users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $u): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr class="hover:bg-gray-50 transition">
                                <td class="px-6 py-3.5 font-medium text-gray-800"><?php echo e($u->name); ?></td>
                                <td class="px-6 py-3.5 text-gray-500 font-mono"><?php echo e($u->email); ?></td>
                                <td class="px-6 py-3.5">
                                    <span class="px-2 py-0.5 rounded-lg bg-gray-100 text-gray-600 font-medium">
                                        <?php echo e($u->roles->pluck('name')->first() ?: 'User'); ?>

                                    </span>
                                </td>
                                <td class="px-6 py-3.5">
                                    <?php if(Auth::id() !== $u->id): ?>
                                        <a href="<?php echo e(route('super-admin.impersonate', $u->id)); ?>" class="inline-flex items-center gap-1.5 px-3 py-1 bg-indigo-50 hover:bg-indigo-100 text-indigo-700 rounded-lg font-semibold transition">
                                            <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M11 16l-4-4m0 0l4-4m-4 4h14" /></svg>
                                            Login As
                                        </a>
                                    <?php else: ?>
                                        <span class="text-gray-400">Current User</span>
                                    <?php endif; ?>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="4" class="px-6 py-10 text-center text-gray-400">
                                    No users found registered under this business.
                                </td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH /www/wwwroot/lifeelements.shiningerp.com/resources/views/super-admin/manage-business.blade.php ENDPATH**/ ?>