<div class="row justify-content-center">
    <div class="col-lg-8">
        <div class="card shadow-sm mb-4">
            <div class="card-body">
                <h4 class="card-title mb-3">Profil Pekerja</h4>
                <?php if (!empty($message)): ?>
                    <div class="alert alert-success"><?= htmlspecialchars($message) ?></div>
                <?php endif; ?>
                <?php if (!empty($error)): ?>
                    <div class="alert alert-danger"><?= htmlspecialchars($error) ?></div>
                <?php endif; ?>
                <div class="row g-3">
                    <div class="col-md-6">
                        <label class="form-label text-muted">Nama</label>
                        <div class="form-control-plaintext fw-semibold"><?= htmlspecialchars($user['name'] ?? '-') ?></div>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label text-muted">ID Pengguna</label>
                        <div class="form-control-plaintext"><?= htmlspecialchars($user['login_id'] ?? '-') ?></div>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label text-muted">Lokasi Bekerja</label>
                        <div class="form-control-plaintext"><?= htmlspecialchars($profile['location'] ?? '-') ?></div>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label text-muted">Tarikh Lantikan</label>
                        <div class="form-control-plaintext"><?= htmlspecialchars($profile['hire_date'] ?? '-') ?></div>
                    </div>
                </div>
            </div>
        </div>

        <?php if (!empty($leaveStats)): ?>
        <div class="card shadow-sm mb-4">
            <div class="card-body">
                <h4 class="card-title mb-3">Maklumat Cuti</h4>
                <div class="row g-3">
                    <div class="col-md-4">
                        <label class="form-label text-muted">Jumlah Cuti Dibenarkan</label>
                        <div class="display-6 fw-semibold text-info">
                            <?= number_format($leaveStats['allowed']) ?> hari
                        </div>
                    </div>
                    <div class="col-md-4">
                        <label class="form-label text-muted">Jumlah Cuti Semasa</label>
                        <div class="display-6 fw-semibold text-warning">
                            <?= number_format($leaveStats['used']) ?> hari
                        </div>
                    </div>
                    <div class="col-md-4">
                        <label class="form-label text-muted">Baki Cuti</label>
                        <div class="display-6 fw-semibold text-success">
                            <?= number_format($leaveStats['remaining']) ?> hari
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php endif; ?>

        <div class="card shadow-sm">
            <div class="card-body">
                <h5 class="card-title mb-3">Kemaskini Maklumat</h5>
                <form method="post" action="index.php?route=profile/update" class="row g-3">
                    <?= $csrf ?>
                    <div class="col-md-6">
                        <label class="form-label">Email</label>
                        <input type="email" name="email" class="form-control" value="<?= htmlspecialchars($user['email'] ?? '') ?>" required>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">No. Telefon</label>
                        <input type="text" name="phone" class="form-control" value="<?= htmlspecialchars($profile['phone'] ?? '') ?>">
                    </div>
                    <div class="col-12">
                        <label class="form-label">Alamat Rumah</label>
                        <textarea name="address" class="form-control" rows="3"><?= htmlspecialchars($profile['address'] ?? '') ?></textarea>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Nama Bank</label>
                        <input type="text" name="bank_name" class="form-control" value="<?= htmlspecialchars($profile['bank_name'] ?? '') ?>">
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">No. Akaun Bank</label>
                        <input type="text" name="account_no" class="form-control" value="<?= htmlspecialchars($profile['account_no'] ?? '') ?>">
                    </div>
                    <div class="col-12 d-flex gap-2">
                        <button class="btn btn-primary">Simpan</button>
                        <a class="btn btn-outline-secondary" href="index.php?route=dashboard">Kembali</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>


