<div class="content-wrapper">
    <section class="content-header">
        <h1>Profil Pengguna</h1>
    </section>

    <section class="content">
        <div class="row">
            <!-- Form Edit Profil -->
            <div class="col-lg-6">
                <div class="box box-primary">
                    <div class="box-header">
                        <h3 class="box-title">Edit Profil</h3>
                    </div>
                    <div class="box-body">

                        <?php if ($this->session->flashdata('alert')): ?>
                            <div class="alert alert-success">
                                <?php echo $this->session->flashdata('alert'); ?>
                            </div>
                        <?php endif; ?>

                        <form method="post" action="<?php echo base_url('dashboard/profile_update'); ?>" enctype="multipart/form-data">
                            <input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>" />

                            <!-- Foto Profil -->
                            <div class="form-group text-center">
                                <label>Foto Profil</label><br>
                                <?php if ($user->pengguna_sampul): ?>
                                    <img src="<?php echo base_url('gambar/pengguna/' . $user->pengguna_sampul); ?>" alt="Foto Profil" width="150">
                                <?php else: ?>
                                    <img src="<?php echo base_url('gambar/pengguna/default.jpg'); ?>" alt="Foto Profil" width="150">
                                <?php endif; ?>

                                <input type="file" name="foto" class="form-control" />
                                <small>Opsional, pilih file jika ingin mengganti foto profil.</small>
                                <input type="hidden" name="foto_lama" value="<?php echo $user->pengguna_sampul; ?>">
                            </div>

                            <!-- Username -->
                            <div class="form-group">
                                <label>Username</label>
                                <input type="text" name="username" class="form-control" value="<?php echo $user->pengguna_username; ?>" readonly>
                            </div>

                            <!-- Nama -->
                            <div class="form-group">
                                <label>Nama Lengkap</label>
                                <input type="text" name="nama" class="form-control" value="<?php echo $user->pengguna_nama; ?>" required>
                            </div>

                            <!-- Email -->
                            <div class="form-group">
                                <label>Email</label>
                                <input type="email" name="email" class="form-control" value="<?php echo $user->pengguna_email; ?>" required>
                            </div>

                            <!-- Level -->
                            <div class="form-group">
                                <label>Level</label>
                                <input type="text" class="form-control" value="<?php echo $user->pengguna_level; ?>" readonly>
                            </div>

                            <!-- Nama Satker -->
                            <div class="form-group">
                                <label>Nama Satker</label>
                                <input type="text" class="form-control" value="<?php echo $user->nama_satker; ?>" readonly>
                            </div>

                            <div class="box-footer">
                                <div class="form-group">
                                    <input type="submit" class="btn btn-success" value="Simpan Perubahan">
                                    <a href="<?php echo base_url('dashboard/ganti_password'); ?>" class="btn btn-danger">
                                        Ganti Password
                                    </a>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
