<?php

declare(strict_types=1);

require_once __DIR__ . '/helpers.php';

user_module_boot();

$userRecord = find_user_or_abort((int) ($_GET['id'] ?? 0));
$pageTitle = 'View User';

require dirname(__DIR__, 2) . '/includes/header.php';
require dirname(__DIR__, 2) . '/includes/sidebar.php';
require dirname(__DIR__, 2) . '/includes/topbar.php';
require dirname(__DIR__, 2) . '/includes/flash.php';
?>
<section class="panel-card">
    <div class="panel-card-header mb-4">
        <div>
            <p class="eyebrow mb-1">User profile</p>
            <h2 class="h4 mb-0"><?php echo e($userRecord['full_name']); ?></h2>
        </div>
        <div class="d-flex gap-2">
            <a class="btn btn-outline-jlfc" href="<?php echo e(base_url('app/modules/users/edit.php?id=' . (int) $userRecord['id'])); ?>">Edit</a>
            <a class="btn btn-outline-danger" href="<?php echo e(base_url('app/modules/users/delete.php?id=' . (int) $userRecord['id'])); ?>">Delete</a>
        </div>
    </div>
    <div class="row g-3">
        <div class="col-md-6">
            <div class="feature-tile"><i class="bi bi-envelope"></i>
                <div>
                    <h4>Email</h4>
                    <p><?php echo e($userRecord['email']); ?></p>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="feature-tile"><i class="bi bi-telephone"></i>
                <div>
                    <h4>Phone</h4>
                    <p><?php echo e($userRecord['phone'] ?: 'Not provided'); ?></p>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="feature-tile"><i class="bi bi-person-badge"></i>
                <div>
                    <h4>Role</h4>
                    <p><?php echo e($userRecord['role_name']); ?></p>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="feature-tile"><i class="bi bi-shield-check"></i>
                <div>
                    <h4>Status</h4>
                    <p><?php echo e(ucfirst($userRecord['status'])); ?></p>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="feature-tile"><i class="bi bi-flag"></i>
                <div>
                    <h4>Assigned club</h4>
                    <p><?php echo e($userRecord['club_name'] ?? 'No club assigned'); ?></p>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="feature-tile"><i class="bi bi-clock-history"></i>
                <div>
                    <h4>Last login</h4>
                    <p><?php echo e($userRecord['last_login'] ?? 'Never'); ?></p>
                </div>
            </div>
        </div>
    </div>
</section>
<?php require dirname(__DIR__, 2) . '/includes/footer.php'; ?>