<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 p-4 mt-2 bg-white max-w-xl">
  <form action="<?= base_url('admin/users/update/' . $member->mb_idx) ?>" 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', $member->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">비밀번호</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" placeholder="변경 시에만 입력"/>
    </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', $member->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', $member->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', $member->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) $member->mb_level) === (string) $lv ? 'selected' : '' ?>><?= esc($name) ?></option>
        <?php endforeach; ?>
      </select>
    </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 min-w-[12rem] w-56 max-w-full" id="mb_state" name="mb_state" required>
        <option value="1" <?= (int) old('mb_state', (int) $member->mb_state) === 1 ? 'selected' : '' ?>>정상</option>
        <option value="2" <?= (int) old('mb_state', (int) $member->mb_state) === 2 ? 'selected' : '' ?>>정지</option>
        <option value="0" <?= (int) old('mb_state', (int) $member->mb_state) === 0 ? 'selected' : '' ?>>탈퇴</option>
      </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>
