<div class="col-12 mb-4 mt-15">
  <div class="modern-card recent-orders-card">
    <div class="card-header">
      <h3 class="card-title">
        <i class="fas fa-receipt"></i>
        <?= !empty(lang('recent_orders')) ? lang('recent_orders') : "Recent Orders" ?>
      </h3>
      <div class="header-actions">
        <span class="order-count-badge"><?= !empty($recent_orders) ? count($recent_orders) : 0 ?></span>
        <a href="<?= base_url('admin/restaurant/order_list') ?>" class="btn-view-all">
          <?= !empty(lang('view_all')) ? lang('view_all') : "View All" ?>
          <i class="fas fa-arrow-right"></i>
        </a>
      </div>
    </div>
    <div class="card-body">
      <?php
        $recent_orders = $this->admin_m->get_recent_orders($_ENV['ID'], 5);
        if (!empty($recent_orders)):
      ?>
        <div class="recent-orders-list">
          <?php foreach ($recent_orders as $order): ?>
            <div class="order-item">
              <div class="order-icon">
                <?php
                  $icon_class = '';
                  $icon_bg = '';
                  if ($order->status == 0) {
                    $icon_class = 'fa-clock';
                    $icon_bg = 'icon-pending';
                  } elseif ($order->status == 2) {
                    $icon_class = 'fa-check-circle';
                    $icon_bg = 'icon-completed';
                  } elseif ($order->status == 3) {
                    $icon_class = 'fa-times-circle';
                    $icon_bg = 'icon-cancelled';
                  } else {
                    $icon_class = 'fa-shopping-bag';
                    $icon_bg = 'icon-default';
                  }
                ?>
                <i class="fas <?= $icon_class ?> <?= $icon_bg ?>"></i>
              </div>
              <div class="order-content">
                <div class="order-header">
                  <span class="order-number">#<?= $order->id ?></span>
                  <span class="order-time"><?= date('M d, H:i', strtotime($order->created_at)) ?></span>
                </div>
                <div class="order-details">
                  <div class="order-customer">
                    <i class="fas fa-user"></i>
                    <span><?= isset($order->customer_name) ? $order->customer_name : 'Guest' ?></span>
                  </div>
                  <div class="order-amount">
                    <span class="amount-label"><?= !empty(lang('total')) ? lang('total') : "Total" ?>:</span>
                    <span class="amount-value"><?= currency_position($order->total, $_ENV['ID']) ?></span>
                  </div>
                </div>
              </div>
              <div class="order-status">
                <?php
                  $status_class = '';
                  $status_text = '';
                  if ($order->status == 0) {
                    $status_class = 'status-pending';
                    $status_text = !empty(lang('pending')) ? lang('pending') : 'Pending';
                  } elseif ($order->status == 2) {
                    $status_class = 'status-completed';
                    $status_text = !empty(lang('completed')) ? lang('completed') : 'Completed';
                  } elseif ($order->status == 3) {
                    $status_class = 'status-cancelled';
                    $status_text = !empty(lang('cancelled')) ? lang('cancelled') : 'Cancelled';
                  }
                ?>
                <span class="status-badge <?= $status_class ?>">
                  <i class="fas fa-circle"></i>
                  <?= $status_text ?>
                </span>
              </div>
            </div>
          <?php endforeach; ?>
        </div>
      <?php else: ?>
        <div class="empty-state">
          <div class="empty-icon">
            <i class="fas fa-inbox"></i>
          </div>
          <p><?= !empty(lang('no_recent_orders')) ? lang('no_recent_orders') : "No recent orders" ?></p>
          <a href="<?= base_url('admin/restaurant/order_list') ?>" class="btn-create-order">
            <i class="fas fa-plus"></i>
            <?= !empty(lang('view_orders')) ? lang('view_orders') : "View Orders" ?>
          </a>
        </div>
      <?php endif; ?>
    </div>
  </div>
</div>
