<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-3xl">
  <form action="<?= mgmt_url('packaging-units/update/' . (int) $item->pu_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-32">봉투</label>
      <span class="text-sm font-mono"><?= esc($item->pu_bag_code) ?></span>
      <span class="text-sm text-gray-500"><?= esc($item->pu_bag_name) ?></span>
    </div>

    <div class="flex flex-wrap items-center gap-2">
      <label class="block text-sm font-bold text-gray-700 w-32">박스당 팩 수 <span class="text-red-500">*</span></label>
      <input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-32 text-right" name="pu_box_per_pack" type="number" min="1" value="<?= esc(old('pu_box_per_pack', $item->pu_box_per_pack)) ?>" required/>
      <span class="text-sm text-gray-500">팩</span>
    </div>

    <div class="flex flex-wrap items-center gap-2">
      <label class="block text-sm font-bold text-gray-700 w-32">팩당 낱장 수 <span class="text-red-500">*</span></label>
      <input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-32 text-right" name="pu_pack_per_sheet" type="number" min="1" value="<?= esc(old('pu_pack_per_sheet', $item->pu_pack_per_sheet)) ?>" required/>
      <span class="text-sm text-gray-500">장</span>
    </div>

    <div class="flex flex-wrap items-center gap-2">
      <label class="block text-sm font-bold text-gray-700 w-32">적용시작일 <span class="text-red-500">*</span></label>
      <input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-44" name="pu_start_date" type="date" value="<?= esc(old('pu_start_date', date('Y-m-d'))) ?>" required/>
    </div>

    <div class="flex flex-wrap items-center gap-2">
      <label class="block text-sm font-bold text-gray-700 w-32">적용종료일</label>
      <input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-44" name="pu_end_date" type="date" value="<?= esc(old('pu_end_date', $item->pu_end_date)) ?>"/>
    </div>

    <div class="flex flex-wrap items-center gap-2">
      <label class="block text-sm font-bold text-gray-700 w-32">상태 <span class="text-red-500">*</span></label>
      <select class="border border-gray-300 rounded px-3 py-1.5 text-sm w-32" name="pu_state" required>
        <option value="1" <?= (int) old('pu_state', $item->pu_state) === 1 ? 'selected' : '' ?>>사용</option>
        <option value="0" <?= (int) old('pu_state', $item->pu_state) === 0 ? 'selected' : '' ?>>미사용</option>
      </select>
    </div>

    <div class="flex gap-2 pt-2">
      <button type="submit" class="bg-btn-search text-white px-6 py-1.5 rounded-sm text-sm shadow hover:opacity-90 transition">수정</button>
      <a href="<?= mgmt_url('packaging-units') ?>" class="bg-gray-200 text-gray-700 px-6 py-1.5 rounded-sm text-sm hover:bg-gray-300 transition">취소</a>
    </div>
  </form>
</div>
