<section class="border-b border-gray-300 p-2 shrink-0 bg-control-panel">
  <span class="text-sm font-bold text-gray-700">회원 등록</span>
</section>
<div class="border border-gray-300 rounded-lg p-4 mt-2 bg-white max-w-xl">
  <form action="<?= base_url('admin/users/store') ?>" method="POST" class="space-y-4">
    <?= csrf_field() ?>
    <div class="flex flex-wrap items-center gap-2">
      <label class="block text-sm font-bold text-gray-700 w-20">아이디 <span class="text-red-500">*</span></label>
      <input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-48" id="mb_id" name="mb_id" type="text" value="<?= esc(old('mb_id')) ?>" required/>
    </div>
    <div class="flex flex-wrap items-center gap-2">
      <label class="block text-sm font-bold text-gray-700 w-20">비밀번호 <span class="text-red-500">*</span></label>
      <input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-48" id="mb_passwd" name="mb_passwd" type="password" required/>
      <p class="w-full text-xs text-gray-500 pl-20">8자 이상, 영문·숫자·특수문자를 모두 포함해야 합니다.</p>
    </div>
    <div class="flex flex-wrap items-center gap-2">
      <label class="block text-sm font-bold text-gray-700 w-20">이름 <span class="text-red-500">*</span></label>
      <input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-48" id="mb_name" name="mb_name" type="text" value="<?= esc(old('mb_name')) ?>" required/>
    </div>
    <div class="flex flex-wrap items-center gap-2">
      <label class="block text-sm font-bold text-gray-700 w-20">이메일</label>
      <input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-48" id="mb_email" name="mb_email" type="email" value="<?= esc(old('mb_email')) ?>"/>
    </div>
    <div class="flex flex-wrap items-center gap-2">
      <label class="block text-sm font-bold text-gray-700 w-20">연락처</label>
      <input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-48" id="mb_phone" name="mb_phone" type="text" value="<?= esc(old('mb_phone')) ?>"/>
    </div>
    <div class="flex flex-wrap items-center gap-2">
      <label class="block text-sm font-bold text-gray-700 w-20">역할 <span class="text-red-500">*</span></label>
      <select class="border border-gray-300 rounded px-3 py-1.5 text-sm w-48" id="mb_level" name="mb_level" required>
        <?php foreach (($assignableLevels ?? $roles->levelNames) as $lv => $name): ?>
        <option value="<?= $lv ?>" <?= (string) old('mb_level') === (string) $lv ? 'selected' : '' ?>><?= esc($name) ?></option>
        <?php endforeach; ?>
      </select>
    </div>
    <div class="flex gap-2 pt-2">
      <button type="submit" class="bg-btn-search text-white px-4 py-1.5 rounded-sm text-sm shadow hover:opacity-90 transition">등록</button>
      <a href="<?= base_url('admin/users') ?>" class="bg-white text-black border border-btn-print-border px-4 py-1.5 rounded-sm text-sm shadow hover:bg-gray-50 transition">목록</a>
    </div>
  </form>
</div>
