<?= $this->extend('layouts/admin') ?>
<?= $this->section('content') ?>

<div class="mb-4">
  <a href="<?= base_url('admin/users') ?>" class="btn btn-sm btn-outline-secondary">
    <i class="bi bi-arrow-left me-1"></i>Kembali
  </a>
  <h1 class="section-title mt-2 mb-0">Import Pengguna via CSV</h1>
</div>

<div class="row g-4">
  <div class="col-lg-6">
    <div class="card-stt p-4">
      <?php if (session()->has('error')): ?>
        <div class="alert alert-danger small py-2 mb-3"><?= esc(session('error')) ?></div>
      <?php endif; ?>

      <form method="post" action="<?= base_url('admin/users/import') ?>" enctype="multipart/form-data">
        <?= csrf_field() ?>
        <div class="mb-3">
          <label class="form-label small fw-semibold">File CSV <span class="text-danger">*</span></label>
          <input type="file" name="csv_file" class="form-control" accept=".csv" required>
          <div class="form-text">Maks. 5 MB · Format: nama, nim, email, peran</div>
        </div>
        <button type="submit" class="btn btn-primary">
          <i class="bi bi-upload me-2"></i>Import
        </button>
      </form>
    </div>
  </div>

  <div class="col-lg-6">
    <div class="card-stt p-4">
      <h6 class="fw-semibold mb-3">Format CSV</h6>
      <p class="small text-muted mb-2">Baris pertama (header) akan dilewati. Kolom yang diperlukan:</p>
      <table class="table table-sm small mb-3">
        <thead><tr><th>#</th><th>Kolom</th><th>Contoh</th></tr></thead>
        <tbody>
          <tr><td>1</td><td>Nama Lengkap</td><td>Budi Santoso</td></tr>
          <tr><td>2</td><td>NIM / NIDN</td><td>20210001</td></tr>
          <tr><td>3</td><td>Email</td><td>budi@student.stt.ac.id</td></tr>
          <tr><td>4</td><td>Peran</td><td>student / lecturer / admin</td></tr>
        </tbody>
      </table>
      <div class="alert alert-info small py-2 mb-0">
        <i class="bi bi-info-circle me-1"></i>
        Password default: <strong>Pass@[6 digit NIM]</strong>. Beritahu pengguna untuk segera mengubah password.
      </div>
    </div>
  </div>
</div>

<?= $this->endSection() ?>
