<div class="max-w-lg">
  <div class="flex items-center justify-between mb-4">
    <h3 class="text-base font-bold text-gray-700">재고 수량 조정 (실사)</h3>
  </div>

  <form action="<?= base_url('bag/inventory/adjust') ?>" method="POST" class="space-y-4">
    <?= csrf_field() ?>

    <div>
      <label class="block text-sm font-bold text-gray-700 mb-1">봉투코드 <span class="text-red-500">*</span></label>
      <select name="bag_code" required class="w-full border border-gray-300 rounded px-3 py-2 text-sm">
        <option value="">선택</option>
        <?php foreach ($inventory as $item): ?>
        <option value="<?= esc($item->bi_bag_code) ?>"><?= esc($item->bi_bag_code) ?> — <?= esc($item->bi_bag_name) ?> (현재: <?= number_format((int)$item->bi_qty) ?>)</option>
        <?php endforeach; ?>
      </select>
    </div>

    <div>
      <label class="block text-sm font-bold text-gray-700 mb-1">조정 유형 <span class="text-red-500">*</span></label>
      <select name="adjust_type" required class="w-full border border-gray-300 rounded px-3 py-2 text-sm">
        <option value="set">실사 수량으로 설정</option>
        <option value="add">증가 (+)</option>
        <option value="sub">감소 (-)</option>
      </select>
    </div>

    <div>
      <label class="block text-sm font-bold text-gray-700 mb-1">수량 <span class="text-red-500">*</span></label>
      <input type="number" name="qty" required min="0" value="0" class="w-full border border-gray-300 rounded px-3 py-2 text-sm"/>
    </div>

    <div>
      <label class="block text-sm font-bold text-gray-700 mb-1">사유</label>
      <input type="text" name="reason" placeholder="실사 조정, 오류 수정 등" class="w-full border border-gray-300 rounded px-3 py-2 text-sm"/>
    </div>

    <div class="flex gap-2 pt-2">
      <button type="submit" class="bg-btn-search text-white px-6 py-2 rounded-sm text-sm">조정</button>
      <a href="<?= base_url('bag/inventory') ?>" class="bg-gray-200 text-gray-700 px-6 py-2 rounded-sm text-sm">취소</a>
    </div>
  </form>
</div>
