<div class="orderList_ajax_area left">
    <div class="order-quick-view">
        <div class="quick-view-header">
            <div class="title">
                <i class="icofont-info-circle text-primary"></i>
                <h4><?= lang('order_details'); ?></h4>
            </div>
            <a href="javascript:;" class="close_view"><i class="fa fa-times"></i></a>
        </div>

        <?php $shop_id = restaurant()->id; ?>
        <?php foreach ($item_list as $key => $order) : ?>
            <div class="quick-view-content">
                <!-- Order ID & Type Header -->
                <div class="order-main-info-card">
                    <div class="order-id-badge">
                        <span class="label"><?= lang('order_id'); ?></span>
                        <span class="value">#<?= $order['uid']; ?></span>
                    </div>
                    
                    <div class="order-type-badge-modern">
                        <?= order_type($order['order_type']); ?>
                    </div>
                </div>

                <!-- Contextual Info (Delivery, Reservation, etc.) -->
                <div class="contextual-info-grid">
                    <?php if ($order['order_type'] == 1 || $order['order_type'] == 5) : ?>
                        <div class="info-pill-modern">
                            <i class="icofont-delivery-time"></i>
                            <span><?= lang('delivery_charge'); ?>: <?= $order['delivery_charge'] != 0 ? currency_position($order['delivery_charge'], $shop_id) : lang('free'); ?></span>
                        </div>
                    <?php endif; ?>

                    <?php if ($order['order_type'] == 2) : ?>
                        <div class="info-pill-modern">
                            <i class="fa fa-calendar"></i>
                            <span><?= full_time($order['reservation_date'], $shop_id); ?></span>
                        </div>
                        <div class="info-pill-modern">
                            <i class="fa fa-users"></i>
                            <span><?= lang('total_person'); ?>: <?= $order['total_person']; ?></span>
                        </div>
                    <?php endif; ?>

                    <?php if ($order['order_type'] == 4) : ?>
                        <div class="info-pill-modern text-warning">
                            <i class="fa fa-clock-o"></i>
                            <span><?= lang('pickup'); ?>: <?= !empty($order['pickup_time']) ? $order['pickup_time'] : time_format_12($order['reservation_date']); ?></span>
                        </div>
                    <?php endif; ?>

                    <?php if ($order['order_type'] == 6 || $order['order_type'] == 7) : ?>
                        <?php if (!empty($order['table_no'])) : ?>
                            <div class="info-pill-modern text-success">
                                <i class="icofont-restaurant"></i>
                                <span><?= lang('table'); ?>: <?= __table($order['table_no'])->name ?? ''; ?></span>
                            </div>
                        <?php endif; ?>
                    <?php endif; ?>
                </div>

                <!-- Customer Details Card -->
                <div class="modern-detail-card mt-20">
                    <div class="card-section-title"><?= lang('customer_info'); ?></div>
                    <div class="detail-rows">
                        <?php if ($order['is_guest_login'] == 1) : ?>
                            <div class="detail-row">
                                <span class="label"><?= lang('name'); ?></span>
                                <span class="value"><?= lang('walk_in_customer'); ?></span>
                            </div>
                        <?php else : ?>
                            <div class="detail-row">
                                <span class="label"><?= lang('name'); ?></span>
                                <span class="value"><?= html_escape($order['name']); ?></span>
                            </div>
                        <?php endif; ?>
                        
                        <div class="detail-row">
                            <span class="label"><?= lang('phone'); ?></span>
                            <span class="value"><?= html_escape($order['phone']); ?></span>
                        </div>
                        
                        <div class="detail-row">
                            <span class="label"><?= lang('order_date'); ?></span>
                            <span class="value"><?= full_time(html_escape($order['created_at']), $shop_id); ?></span>
                        </div>
                    </div>
                </div>

                <!-- Items List -->
                <div class="modern-detail-card mt-20">
                    <div class="card-section-title"><?= lang('items'); ?></div>
                    <div class="quick-items-list">
                        <?php $p = __order($order, $order['item_list']); ?>
                        <?php foreach ($order['item_list'] as $key => $row) : ?>
                            <div class="quick-item">
                                <div class="item-main">
                                    <span class="qty"><?= $row['qty']; ?> x</span>
                                    <span class="name"><?= html_escape($row['title'] ?? $row['package_name']); ?></span>
                                </div>
                                <span class="price"><?= currency_position($row['sub_total'], $shop_id); ?></span>
                            </div>
                        <?php endforeach; ?>
                    </div>

                    <!-- Price Summary -->
                    <div class="quick-price-summary">
                        <div class="summary-row">
                            <span><?= lang('sub_total'); ?></span>
                            <span><?= currency_position($order['order_type'] == 7 ? $order['total'] : $p->subtotal, $shop_id); ?></span>
                        </div>
                        <?php if ($p->discount != 0) : ?>
                            <div class="summary-row text-danger">
                                <span><?= lang('discount'); ?></span>
                                <span>-<?= currency_position($p->discount, $shop_id); ?></span>
                            </div>
                        <?php endif; ?>
                        <div class="summary-row total">
                            <span><?= lang('total'); ?></span>
                            <span><?= currency_position($order['order_type'] == 7 ? $order['total'] : $p->grand_total, $shop_id); ?></span>
                        </div>
                    </div>
                </div>

                <!-- Actions Footer -->
                <div class="quick-view-actions mt-25 pb-20">
                    <?php if ($order['status'] == 0) : ?>
                        <?php if (restaurant()->es_time == 0) : ?>
                            <a href="<?= base_url('admin/restaurant/order_status_by_ajax/' . $order['uid'] . '/1'); ?>" data-shop="<?= $order['shop_id']; ?>" class="btn btn-primary orderStatus w-100 mb-10"><i class="fa fa-check"></i> &nbsp; <?= lang('mark_as_accepted'); ?></a>
                        <?php else : ?>
                            <a href="javascript:;" class="btn btn-primary showTimeModal w-100 mb-10" data-shop="<?= $order['shop_id']; ?>" data-id="<?= $order['uid']; ?>"><i class="fa fa-check-circle"></i> &nbsp; <?= lang('mark_as_accepted'); ?></a>
                        <?php endif; ?>
                    <?php endif; ?>
                    
                    <?php if ($order['status'] == 1) : ?>
                        <a href="<?= base_url('admin/restaurant/order_status_by_ajax/' . $order['uid'] . '/2'); ?>" data-shop="<?= $order['shop_id']; ?>" class="btn btn-success orderStatus w-100 mb-10"><i class="fa fa-check-square-o"></i> &nbsp; <?= lang('mark_as_completed'); ?></a>
                    <?php endif; ?>

                    <a href="<?= base_url('admin/order-details/' . $order['uid']); ?>" class="btn btn-outline-primary w-100"><i class="fa fa-eye"></i> &nbsp; <?= lang('full_details'); ?></a>
                </div>
            </div>
        <?php endforeach; ?>
    </div>
</div>

<?php include 'estimate_time_modal.php'; ?>