<?php
require_once __DIR__ . '/config/database.php';
require_once __DIR__ . '/app/helpers/auth.php';
require_once __DIR__ . '/app/helpers/csrf.php';
require_once __DIR__ . '/app/helpers/rbac.php';
requireLogin();
$page_js = 'profile.js';
include 'views/layouts/header.php';
include 'views/layouts/sidebar.php';
$userName = $_SESSION['user_name'] ?? 'User';
?>
<main class="main-content">
<?php include 'views/layouts/topbar.php'; ?>
<div class="container-fluid p-4">
<div id="alertBox" class="alert d-none"></div>
<div class="row g-4">
<div class="col-lg-6">
<div class="card shadow-sm border-0"><div class="card-body p-4">
<h5 class="card-title mb-3"><i class="bi bi-person me-2"></i>My Profile</h5>
<form id="profileForm">
<div class="mb-3"><label class="form-label">Name</label><input type="text" id="profileName" class="form-control"></div>
<div class="mb-3"><label class="form-label">Email</label><input type="email" id="profileEmail" class="form-control" readonly></div>
<div class="mb-3"><label class="form-label">Phone</label><input type="text" id="profilePhone" class="form-control"></div>
<div class="mb-3"><label class="form-label">Role</label><input type="text" id="profileRole" class="form-control" readonly></div>
<button type="submit" class="btn btn-primary" id="btnSaveProfile"><i class="bi bi-check-lg"></i> Update Profile</button>
</form>
</div></div>
</div>
<div class="col-lg-6">
<div class="card shadow-sm border-0"><div class="card-body p-4">
<h5 class="card-title mb-3"><i class="bi bi-lock me-2"></i>Change Password</h5>
<form id="passwordForm">
<div class="mb-3"><label class="form-label">Current Password</label><input type="password" id="currentPassword" class="form-control"></div>
<div class="mb-3"><label class="form-label">New Password</label><input type="password" id="newPassword" class="form-control"></div>
<div class="mb-3"><label class="form-label">Confirm New Password</label><input type="password" id="confirmPassword" class="form-control"></div>
<button type="submit" class="btn btn-warning" id="btnChangePassword"><i class="bi bi-key"></i> Change Password</button>
</form>
</div></div>
</div>
</div>
</div>
</main>
<script>
window.CSRF_TOKEN = <?= json_encode(generateCsrfToken(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?>;
</script>
<?php include 'views/layouts/footer.php'; ?>
