<?= $this->include('/Styles/header'); ?>

<main class="p-6">
  <div class="bg-white shadow rounded-lg p-6">
      <h2 class="text-2xl font-bold mb-4">Pending Orders</h2>

      <?php foreach($orders as $order): ?>
      <div class="border rounded-lg mb-6 p-4 shadow-sm">
        <div class="flex justify-between items-center mb-2">
          <h3 class="font-bold text-lg">Order #<?= $order['id'] ?> - ₹<?= $order['total_amount'] ?></h3>
          <a href="<?= base_url('adminOrder/confirm/'.$order['id']) ?>" 
             class="bg-green-600 text-white px-3 py-1 rounded hover:bg-green-700">Confirm</a>
        </div>

        <p><strong>Customer:</strong> <?= $order['customer_name'] ?> | <strong>Phone:</strong> <?= $order['phone'] ?></p>
        <p><strong>Apartment:</strong> <?= $order['apartName'] ?>, <?= $order['apartAddress'] ?></p>

        <table class="w-full border-collapse mt-3">
          <thead>
            <tr class="bg-gray-100">
              <th class="border px-3 py-2">Product Name</th>
              <th class="border px-3 py-2">Quantity</th>
              <th class="border px-3 py-2">Price</th>
            </tr>
          </thead>
          <tbody>
            <?php foreach($order['items'] as $item): ?>
            <tr>
              <td class="border px-3 py-1"><?= $item['product_name'] ?></td>
              <td class="border px-3 py-1"><?= $item['quantity'] ?></td>
              <td class="border px-3 py-1">₹<?= $item['price'] ?></td>
            </tr>
            <?php endforeach; ?>
          </tbody>
        </table>
      </div>
      <?php endforeach; ?>
  </div>
</main>

<?= $this->include('/Styles/footer'); ?>
