<!-- Page Title -->
<div class="d-flex justify-content-between align-items-center mb-4">
    <h3 class="mb-0" style="color: var(--sidebar-bg);">
        <i class="bi bi-people me-2"></i>Manajemen Admin
    </h3>
    <a href="<?php echo site_url('admin/tambah_admin'); ?>" class="btn btn-success">
        <i class="bi bi-person-plus me-2"></i>Tambah Admin
    </a>
</div>

<!-- Data Table -->
<div class="card">
    <div class="card-header">
        <h5 class="mb-0">Daftar Administrator</h5>
    </div>
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-hover datatable">
                <thead>
                    <tr>
                        <th>No</th>
                        <th>Username</th>
                        <th>Nama Lengkap</th>
                        <th>Email</th>
                        <th>Level</th>
                        <th>Status</th>
                        <th>Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $no = 1; ?>
                    <?php foreach ($admins as $admin): ?>
                        <tr>
                            <td><?php echo $no++; ?></td>
                            <td><strong><?php echo $admin->username; ?></strong></td>
                            <td><?php echo $admin->nama_lengkap; ?></td>
                            <td><?php echo $admin->email; ?></td>
                            <td>
                                <?php if ($admin->level == 'admin'): ?>
                                    <span class="badge bg-primary">Administrator</span>
                                <?php else: ?>
                                    <span class="badge bg-secondary">Operator</span>
                                <?php endif; ?>
                            </td>
                            <td>
                                <?php if ($admin->is_active == 1): ?>
                                    <span class="badge bg-success">Aktif</span>
                                <?php else: ?>
                                    <span class="badge bg-danger">Nonaktif</span>
                                <?php endif; ?>
                            </td>
                            <td>
                                <?php if ($admin->id != $this->session->userdata('admin_id')): ?>
                                    <a href="<?php echo base_url('admin/edit_admin/' . $admin->id); ?>"
                                        class="btn btn-sm btn-warning">
                                        <i class="bi bi-pencil"></i>
                                    </a>
                                    <a href="<?php echo base_url('admin/delete_admin/' . $admin->id); ?>"
                                        class="btn btn-sm btn-danger confirm-delete">
                                        <i class="bi bi-trash"></i>
                                    </a>
                                <?php else: ?>
                                    <span class="text-muted">Current User</span>
                                <?php endif; ?>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>

<!-- Information Card -->
<div class="card mt-4">
    <div class="card-header">
        <h5 class="mb-0"><i class="bi bi-info-circle me-2"></i>Informasi Hak Akses</h5>
    </div>
    <div class="card-body">
        <div class="row">
            <div class="col-md-6">
                <h6>Level Administrator:</h6>
                <ul>
                    <li><span class="badge bg-primary">Administrator</span> - Akses penuh ke semua fitur</li>
                    <li><span class="badge bg-secondary">Operator</span> - Hanya bisa melihat data dan generate token
                    </li>
                </ul>
            </div>
            <div class="col-md-6">
                <h6>Best Practices:</h6>
                <ul>
                    <li>Gunakan password yang kuat</li>
                    <li>Nonaktifkan akun yang sudah tidak digunakan</li>
                    <li>Hanya admin level yang bisa menambah/menghapus admin lain</li>
                    <li>Simpan log aktivitas admin</li>
                </ul>
            </div>
        </div>
    </div>
</div>