<div class="max-w-lg mx-auto">
  <h2 class="mb-6"><%= title %>.</h2>
  <div class="card">
    <form action="<%= item ? `/users/${item.id}?_method=PUT` : '/users' %>" method="POST" class="space-y-4">
      <div>
        <label class="label">Nama</label>
        <input type="text" name="nama" required class="input" value="<%= item ? item.nama : '' %>" />
      </div>
      <div>
        <label class="label">Email</label>
        <input type="email" name="email" required class="input" value="<%= item ? item.email : '' %>" />
      </div>
      <div>
        <label class="label">Password <% if (item) { %><span class="text-mute font-normal">(kosongkan jika tidak diubah)</span><% } %></label>
        <input type="password" name="password" minlength="6" class="input" <%= item ? '' : 'required' %> />
      </div>
      <div>
        <label class="label">Role</label>
        <select name="role" class="input">
          <option value="wali_kelas" <%= item && item.role === 'wali_kelas' ? 'selected' : '' %>>Wali Kelas</option>
          <option value="admin" <%= item && item.role === 'admin' ? 'selected' : '' %>>Admin</option>
        </select>
      </div>
      <div class="flex gap-2 pt-2">
        <button class="btn-primary btn-sm"><%= item ? 'Simpan' : 'Tambah' %></button>
        <a href="/users" class="btn-secondary btn-sm">Batal</a>
      </div>
    </form>
  </div>
</div>
