<?php
if (Auth('admin')->User()->dashboard_style == 'light') {
    $text = 'dark';
    $bg = 'light';
} else {
    $bg = 'dark';
    $text = 'light';
}
?>


<?php $__env->startSection('title', $title ?? 'Flight Bookings Management'); ?>

<?php $__env->startSection('content'); ?>
    <?php echo $__env->make('admin.topmenu', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('admin.sidebar', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <div class="main-panel">
        <div class="content">
            <div class="page-inner">
                <div class="mt-2 mb-4">
                    <h1 class="title1 text-<?php echo e($text); ?>"><?php echo e($title ?? 'Flight Bookings Management'); ?></h1>
                    <p class="text-muted mt-1">Manage and review military flight booking requests</p>
                </div>

                <?php if (isset($component)) { $__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4 = $component; } ?>
<?php $component = $__env->getContainer()->make(Illuminate\View\AnonymousComponent::class, ['view' => 'components.danger-alert','data' => []]); ?>
<?php $component->withName('danger-alert'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4)): ?>
<?php $component = $__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4; ?>
<?php unset($__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4); ?>
<?php endif; ?>
                <?php if (isset($component)) { $__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4 = $component; } ?>
<?php $component = $__env->getContainer()->make(Illuminate\View\AnonymousComponent::class, ['view' => 'components.success-alert','data' => []]); ?>
<?php $component->withName('success-alert'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4)): ?>
<?php $component = $__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4; ?>
<?php unset($__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4); ?>
<?php endif; ?>

                <!-- Statistics Cards -->
                <div class="row mb-4">
                    <div class="col-xl-3 col-md-6 mb-4">
                        <div class="card border-left-primary shadow h-100 py-2">
                            <div class="card-body">
                                <div class="row no-gutters align-items-center">
                                    <div class="col mr-2">
                                        <div class="text-xs font-weight-bold text-primary text-uppercase mb-1">Total Bookings</div>
                                        <div class="h5 mb-0 font-weight-bold text-<?php echo e($text); ?>"><?php echo e($stats['total']); ?></div>
                                    </div>
                                    <div class="col-auto">
                                        <i class="fas fa-plane fa-2x text-gray-300"></i>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="col-xl-3 col-md-6 mb-4">
                        <div class="card border-left-warning shadow h-100 py-2">
                            <div class="card-body">
                                <div class="row no-gutters align-items-center">
                                    <div class="col mr-2">
                                        <div class="text-xs font-weight-bold text-warning text-uppercase mb-1">Unread</div>
                                        <div class="h5 mb-0 font-weight-bold text-<?php echo e($text); ?>"><?php echo e($stats['unread']); ?></div>
                                    </div>
                                    <div class="col-auto">
                                        <i class="fas fa-envelope fa-2x text-gray-300"></i>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="col-xl-3 col-md-6 mb-4">
                        <div class="card border-left-success shadow h-100 py-2">
                            <div class="card-body">
                                <div class="row no-gutters align-items-center">
                                    <div class="col mr-2">
                                        <div class="text-xs font-weight-bold text-success text-uppercase mb-1">Processed</div>
                                        <div class="h5 mb-0 font-weight-bold text-<?php echo e($text); ?>"><?php echo e($stats['read']); ?></div>
                                    </div>
                                    <div class="col-auto">
                                        <i class="fas fa-check-circle fa-2x text-gray-300"></i>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="col-xl-3 col-md-6 mb-4">
                        <div class="card border-left-info shadow h-100 py-2">
                            <div class="card-body">
                                <div class="row no-gutters align-items-center">
                                    <div class="col mr-2">
                                        <div class="text-xs font-weight-bold text-info text-uppercase mb-1">This Week</div>
                                        <div class="h5 mb-0 font-weight-bold text-<?php echo e($text); ?>"><?php echo e($stats['recent']); ?></div>
                                    </div>
                                    <div class="col-auto">
                                        <i class="fas fa-calendar-week fa-2x text-gray-300"></i>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Search and Filter Section -->
                <div class="mb-5 row">
                    <div class="col-md-12">
                        <div class="card p-md-4 p-2">
                            <div class="card-header py-3">
                                <h6 class="m-0 font-weight-bold text-primary">
                                    <i class="fas fa-search mr-2"></i>Search & Filter Bookings
                                </h6>
                            </div>
                            <div class="card-body">
                                <form method="GET" action="<?php echo e(route('admin.flight-bookings.index')); ?>" class="row">
                                    <div class="col-md-4 mb-3">
                                        <label for="search" class="form-label text-<?php echo e($text); ?> font-weight-bold">Search Bookings</label>
                                        <input type="text" class="form-control text-<?php echo e($text); ?>" id="search" name="search"
                                               value="<?php echo e(request('search')); ?>"
                                               placeholder="Search by name, email, cities, or service branch...">
                                    </div>
                                    <div class="col-md-3 mb-3">
                                        <label for="status" class="form-label text-<?php echo e($text); ?> font-weight-bold">Status Filter</label>
                                        <select class="form-control text-<?php echo e($text); ?>" id="status" name="status">
                                            <option value="">All Status</option>
                                            <option value="unread" <?php echo e(request('status') === 'unread' ? 'selected' : ''); ?>>Unread</option>
                                            <option value="read" <?php echo e(request('status') === 'read' ? 'selected' : ''); ?>>Read</option>
                                            <option value="replied" <?php echo e(request('status') === 'replied' ? 'selected' : ''); ?>>Replied</option>
                                            <option value="archived" <?php echo e(request('status') === 'archived' ? 'selected' : ''); ?>>Archived</option>
                                        </select>
                                    </div>
                                    <div class="col-md-3 d-flex align-items-end mb-3">
                                        <button type="submit" class="btn btn-primary mr-2">
                                            <i class="fas fa-search mr-1"></i>Search
                                        </button>
                                        <a href="<?php echo e(route('admin.flight-bookings.index')); ?>" class="btn btn-secondary">
                                            <i class="fas fa-undo mr-1"></i>Reset
                                        </a>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Flight Bookings Table -->
                <div class="mb-5 row">
                    <div class="col-md-12">
                        <div class="card p-md-4 p-2">
                            <div class="card-header py-3">
                                <h6 class="m-0 font-weight-bold text-primary">
                                    <i class="fas fa-plane mr-2"></i>Flight Bookings (<?php echo e($bookings->total()); ?> total)
                                </h6>
                            </div>
                            <div class="card-body">
                                <?php if($bookings->count() > 0): ?>
                                    <div class="table-responsive">
                                        <table class="table table-bordered" width="100%" cellspacing="0">
                                            <thead class="thead-light">
                                                <tr>
                                                    <th class="text-<?php echo e($text); ?>">ID</th>
                                                    <th class="text-<?php echo e($text); ?>">Passenger Details</th>
                                                    <th class="text-<?php echo e($text); ?>">Flight Details</th>
                                                    <th class="text-<?php echo e($text); ?>">Service Info</th>
                                                    <th class="text-<?php echo e($text); ?>">Submitted</th>
                                                    <th class="text-<?php echo e($text); ?>">Status</th>
                                                    <th class="text-<?php echo e($text); ?>">Actions</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php $__currentLoopData = $bookings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $booking): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <tr>
                                                        <td class="font-weight-bold text-<?php echo e($text); ?>">
                                                            FB-<?php echo e(str_pad($booking->id, 6, '0', STR_PAD_LEFT)); ?>

                                                        </td>
                                                        <td class="text-<?php echo e($text); ?>">
                                                            <div class="font-weight-bold"><?php echo e($booking->fname); ?></div>
                                                            <small class="text-muted"><?php echo e($booking->email); ?></small>
                                                            <br>
                                                            <small class="text-muted">📞 <?php echo e($booking->phone); ?></small>
                                                        </td>
                                                        <td class="text-<?php echo e($text); ?>">
                                                            <?php if($booking->departure_city && $booking->destination_city): ?>
                                                                <div>
                                                                    <span class="badge badge-info"><?php echo e($booking->departure_city); ?></span>
                                                                    <i class="fas fa-arrow-right mx-1"></i>
                                                                    <span class="badge badge-success"><?php echo e($booking->destination_city); ?></span>
                                                                </div>
                                                                <?php if($booking->departure_date): ?>
                                                                    <small class="text-muted">📅 <?php echo e(date('M d, Y', strtotime($booking->departure_date))); ?></small>
                                                                <?php endif; ?>
                                                                <?php if($booking->passengers): ?>
                                                                    <br><small class="text-muted">👥 <?php echo e($booking->passengers); ?></small>
                                                                <?php endif; ?>
                                                            <?php else: ?>
                                                                <span class="text-muted">No flight details</span>
                                                            <?php endif; ?>
                                                        </td>
                                                        <td class="text-<?php echo e($text); ?>">
                                                            <?php if($booking->rank): ?>
                                                                <span class="badge badge-secondary"><?php echo e($booking->rank); ?></span><br>
                                                            <?php endif; ?>
                                                            <?php if($booking->service_branch): ?>
                                                                <small class="text-muted"><?php echo e($booking->service_branch); ?></small>
                                                            <?php endif; ?>
                                                            <?php if($booking->military_status): ?>
                                                                <br><small class="text-muted"><?php echo e($booking->military_status); ?></small>
                                                            <?php endif; ?>
                                                        </td>
                                                        <td class="text-<?php echo e($text); ?>"><?php echo e($booking->formatted_created_at); ?></td>
                                                        <td>
                                                            <?php if($booking->status === 'unread'): ?>
                                                                <span class="badge badge-warning">
                                                                    <i class="fas fa-envelope mr-1"></i>Unread
                                                                </span>
                                                            <?php elseif($booking->status === 'read'): ?>
                                                                <span class="badge badge-info">
                                                                    <i class="fas fa-envelope-open mr-1"></i>Read
                                                                </span>
                                                            <?php elseif($booking->status === 'replied'): ?>
                                                                <span class="badge badge-success">
                                                                    <i class="fas fa-reply mr-1"></i>Replied
                                                                </span>
                                                            <?php elseif($booking->status === 'archived'): ?>
                                                                <span class="badge badge-secondary">
                                                                    <i class="fas fa-archive mr-1"></i>Archived
                                                                </span>
                                                            <?php endif; ?>
                                                        </td>
                                                        <td>
                                                            <div class="btn-group" role="group">
                                                                <a href="<?php echo e(route('admin.flight-bookings.show', $booking)); ?>"
                                                                   class="btn btn-sm btn-info" title="View Details">
                                                                    <i class="fas fa-eye"></i>
                                                                </a>

                                                                <?php if($booking->status === 'unread'): ?>
                                                                    <form method="POST" action="<?php echo e(route('admin.flight-bookings.update-status', $booking)); ?>" class="d-inline">
                                                                        <?php echo csrf_field(); ?>
                                                                        <?php echo method_field('PATCH'); ?>
                                                                        <input type="hidden" name="status" value="read">
                                                                        <button type="submit" class="btn btn-sm btn-primary" title="Mark as Read"
                                                                                onclick="return confirm('Mark this booking as read?')">
                                                                            <i class="fas fa-envelope-open"></i>
                                                                        </button>
                                                                    </form>
                                                                <?php endif; ?>

                                                                <?php if($booking->status !== 'replied'): ?>
                                                                    <form method="POST" action="<?php echo e(route('admin.flight-bookings.update-status', $booking)); ?>" class="d-inline">
                                                                        <?php echo csrf_field(); ?>
                                                                        <?php echo method_field('PATCH'); ?>
                                                                        <input type="hidden" name="status" value="replied">
                                                                        <button type="submit" class="btn btn-sm btn-success" title="Mark as Replied"
                                                                                onclick="return confirm('Mark this booking as replied?')">
                                                                            <i class="fas fa-reply"></i>
                                                                        </button>
                                                                    </form>
                                                                <?php endif; ?>

                                                                <form method="POST" action="<?php echo e(route('admin.flight-bookings.destroy', $booking)); ?>" class="d-inline">
                                                                    <?php echo csrf_field(); ?>
                                                                    <?php echo method_field('DELETE'); ?>
                                                                    <button type="submit" class="btn btn-sm btn-danger" title="Delete"
                                                                            onclick="return confirm('Are you sure you want to delete this flight booking? This action cannot be undone.')">
                                                                        <i class="fas fa-trash"></i>
                                                                    </button>
                                                                </form>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </tbody>
                                        </table>
                                    </div>

                                    <!-- Pagination -->
                                    <div class="d-flex justify-content-center">
                                        <?php echo e($bookings->appends(request()->query())->links()); ?>

                                    </div>
                                <?php else: ?>
                                    <div class="text-center py-5">
                                        <i class="fas fa-plane fa-3x text-gray-300 mb-3"></i>
                                        <h5 class="text-<?php echo e($text); ?>">No flight bookings found</h5>
                                        <p class="text-muted">
                                            <?php if(request('search') || request('status')): ?>
                                                Try adjusting your search criteria or filters.
                                            <?php else: ?>
                                                No flight booking requests have been submitted yet.
                                            <?php endif; ?>
                                        </p>
                                    </div>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

<?php if(session('success')): ?>
    <script>
        Swal.fire({
            icon: 'success',
            title: 'Success!',
            text: '<?php echo e(session('success')); ?>',
            confirmButtonColor: '#28a745'
        });
    </script>
<?php endif; ?>

<?php if(session('error')): ?>
    <script>
        Swal.fire({
            icon: 'error',
            title: 'Error!',
            text: '<?php echo e(session('error')); ?>',
            confirmButtonColor: '#dc3545'
        });
    </script>
<?php endif; ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\milit\resources\views/admin/flight-booking/index.blade.php ENDPATH**/ ?>