<?php $__env->startSection('title', 'Manage Users - Social Scheduler'); ?>

<?php $__env->startSection('content'); ?>
<div class="topbar">
    <h4 class="mb-0 fw-bold"><i class="bi bi-people me-2 text-primary"></i>Manage Users</h4>
    <a href="<?php echo e(route('admin.dashboard')); ?>" class="btn btn-outline-secondary">
        <i class="bi bi-arrow-left me-1"></i> Back to Admin
    </a>
</div>

<div class="card">
    <div class="card-body p-0">
        <div class="table-responsive">
            <table class="table table-hover mb-0 align-middle">
                <thead class="table-light">
                    <tr>
                        <th>ID</th>
                        <th>Name</th>
                        <th>Email</th>
                        <th>Role</th>
                        <th>Posts</th>
                        <th>Accounts</th>
                        <th>Joined</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td><?php echo e($user->id); ?></td>
                        <td class="fw-semibold"><?php echo e($user->name); ?></td>
                        <td><?php echo e($user->email); ?></td>
                        <td>
                            <span class="badge <?php echo e($user->isAdmin() ? 'bg-danger' : 'bg-info'); ?>">
                                <?php echo e(ucfirst($user->role)); ?>

                            </span>
                        </td>
                        <td><?php echo e($user->posts()->count()); ?></td>
                        <td><?php echo e($user->socialAccounts()->count()); ?></td>
                        <td class="text-muted" style="font-size: 0.875rem;"><?php echo e($user->created_at->format('M d, Y')); ?></td>
                        <td>
                            <div class="btn-group">
                                <form action="<?php echo e(route('admin.users.toggle-role', $user)); ?>" method="POST" class="d-inline">
                                    <?php echo csrf_field(); ?>
                                    <button type="submit" class="btn btn-sm btn-outline-warning"
                                            onclick="return confirm('Toggle user role to <?php echo e($user->isAdmin() ? 'User' : 'Admin'); ?>?')">
                                        <i class="bi bi-shield-<?php echo e($user->isAdmin() ? 'minus' : 'plus'); ?>"></i>
                                        <?php echo e($user->isAdmin() ? 'Demote' : 'Promote'); ?>

                                    </button>
                                </form>
                                <?php if($user->id !== auth()->id()): ?>
                                <form action="<?php echo e(route('admin.users.destroy', $user)); ?>" method="POST" class="d-inline">
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('DELETE'); ?>
                                    <button type="submit" class="btn btn-sm btn-outline-danger"
                                            onclick="return confirm('Delete user <?php echo e($user->name); ?>? This cannot be undone.')">
                                        <i class="bi bi-trash"></i>
                                    </button>
                                </form>
                                <?php endif; ?>
                            </div>
                        </td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table>
        </div>
        <div class="p-3">
            <?php echo e($users->links()); ?>

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

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/polyttfr/public_html/resources/views/admin/users.blade.php ENDPATH**/ ?>