<section class="border-b border-gray-300 p-2 shrink-0 bg-control-panel">
  <div class="flex items-center gap-2">
    <a href="<?= mgmt_url('packaging-units') ?>" class="text-blue-600 hover:underline text-sm">&larr; 포장 단위 목록</a>
    <span class="text-gray-400">|</span>
    <span class="text-sm font-bold text-gray-700">변경 이력 — <?= esc($item->pu_bag_name) ?> (<?= esc($item->pu_bag_code) ?>)</span>
  </div>
</section>
<div class="border border-gray-300 rounded-lg p-4 overflow-auto mt-2">
  <?php
    $fieldLabelMap = [
      'pu_box_per_pack' => '박스당 팩 수',
      'pu_pack_per_sheet' => '팩당 낱장 수',
      'pu_start_date' => '적용시작일',
      'pu_end_date' => '적용종료일',
      'pu_state' => '상태',
    ];
  ?>
  <table class="w-full data-table">
    <thead>
      <tr>
        <th class="w-16 text-center">번호</th>
        <th class="text-left">변경 내용</th>
        <th class="text-right">이전 값</th>
        <th class="text-right">변경 값</th>
        <th class="text-center">변경일시</th>
      </tr>
    </thead>
    <tbody class="text-right">
      <?php foreach ($list as $row): ?>
      <tr>
        <td class="text-center"><?= esc($row->puh_idx) ?></td>
        <td class="text-left pl-2"><?= esc($fieldLabelMap[(string) $row->puh_field] ?? $row->puh_field) ?></td>
        <td><?= esc($row->puh_old_value) ?></td>
        <td><?= esc($row->puh_new_value) ?></td>
        <td class="text-center"><?= esc($row->puh_changed_at) ?></td>
      </tr>
      <?php endforeach; ?>
      <?php if (empty($list)): ?>
      <tr><td colspan="5" class="text-center text-gray-400 py-4">변경 이력이 없습니다.</td></tr>
      <?php endif; ?>
    </tbody>
  </table>
</div>
