<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-3xl">
  <form action="<?= base_url('admin/bag-prices/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-28">봉투 <span class="text-red-500">*</span></label>
      <select class="border border-gray-300 rounded px-3 py-1.5 text-sm w-60" name="bp_bag_code" required>
        <option value="">선택</option>
        <?php foreach ($bagCodes as $cd): ?>
        <option value="<?= esc($cd->cd_code) ?>" <?= old('bp_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-28">발주단가 <span class="text-red-500">*</span></label>
      <input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-40 text-right" name="bp_order_price" type="number" step="0.01" value="<?= esc(old('bp_order_price', '0')) ?>" 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-28">도매가 <span class="text-red-500">*</span></label>
      <input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-40 text-right" name="bp_wholesale" type="number" step="0.01" value="<?= esc(old('bp_wholesale', '0')) ?>" 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-28">소비자가 <span class="text-red-500">*</span></label>
      <input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-40 text-right" name="bp_consumer" type="number" step="0.01" value="<?= esc(old('bp_consumer', '0')) ?>" 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-28">적용시작일 <span class="text-red-500">*</span></label>
      <input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-44" name="bp_start_date" type="date" value="<?= esc(old('bp_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-28">적용종료일</label>
      <input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-44" name="bp_end_date" type="date" value="<?= esc(old('bp_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="<?= base_url('admin/bag-prices') ?>" 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>
