<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/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-32">봉투 <span class="text-red-500">*</span></label>
      <select class="border border-gray-300 rounded px-3 py-1.5 text-sm w-60" name="pu_bag_code" required>
        <option value="">선택</option>
        <?php foreach ($bagCodes as $cd): ?>
        <option value="<?= esc($cd->cd_code) ?>" <?= old('pu_bag_code') === $cd->cd_code ? 'selected' : '' ?>>
          <?= esc($cd->cd_code) ?> — <?= esc($cd->cd_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-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', '1')) ?>" 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', '1')) ?>" 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')) ?>"/>
      <span class="text-sm text-gray-400">비워두면 현재 적용중</span>
    </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>
