<?php include __DIR__ . '/../../layouts/header.php'; ?>
<?php include __DIR__ . '/../../layouts/sidebar.php'; ?>

<div class="row justify-content-center">
    <div class="col-md-8">
        <div class="d-flex justify-content-between align-items-center mb-4">
            <h2 class="mb-0">Admin Profile</h2>
        </div>

        <?php if (isset($_GET['success'])): ?>
            <div class="alert alert-success border-0 shadow-sm mb-4 rounded-4" role="alert">
                <i class="fas fa-check-circle me-2"></i> <?= htmlspecialchars($_GET['success']) ?>
            </div>
        <?php endif; ?>

        <?php if (isset($_GET['error'])): ?>
            <div class="alert alert-danger border-0 shadow-sm mb-4 rounded-4" role="alert">
                <i class="fas fa-exclamation-circle me-2"></i> <?= htmlspecialchars($_GET['error']) ?>
            </div>
        <?php endif; ?>

        <div class="card border-0 shadow-sm" style="border-radius: 20px;">
            <div class="card-body p-5">
                <div class="text-center mb-5">
                    <div class="bg-primary text-white rounded-circle d-inline-flex align-items-center justify-content-center mb-3" style="width: 80px; height: 80px; font-size: 30px;">
                        <?= strtoupper(substr($admin['name'], 0, 1)) ?>
                    </div>
                    <h4 class="fw-bold mb-1"><?= htmlspecialchars($admin['name']) ?></h4>
                    <p class="text-secondary"><?= htmlspecialchars($admin['email']) ?></p>
                </div>

                <form action="?page=profile&action=update" method="POST">
                    <div class="row g-4">
                        <div class="col-md-6">
                            <label class="form-label text-secondary small fw-bold">Full Name</label>
                            <input type="text" name="name" class="form-control form-control-lg bg-light border-0 px-4" value="<?= htmlspecialchars($admin['name']) ?>" required style="border-radius: 12px;">
                        </div>
                        <div class="col-md-6">
                            <label class="form-label text-secondary small fw-bold">Email Address</label>
                            <input type="email" name="email" class="form-control form-control-lg bg-light border-0 px-4" value="<?= htmlspecialchars($admin['email']) ?>" required style="border-radius: 12px;">
                        </div>
                        <div class="col-12 mt-5">
                            <button type="submit" class="btn btn-primary btn-lg rounded-pill px-5 w-100 py-3 fw-bold shadow-sm">Update Profile Information</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<?php include __DIR__ . '/../../layouts/footer.php'; ?>
