<?php $__env->startSection('title', 'Contact Requests'); ?>
<?php $__env->startSection('page-title', 'Contact Requests'); ?>

<?php $__env->startSection('content'); ?>
<div class="grid grid-cols-2 lg:grid-cols-6 gap-4 mb-6">
    <?php
        $statCards = [
            ['Total', $stats['total'], 'bg-blue-50 text-blue-700 border-blue-100'],
            ['New', $stats['new'], 'bg-indigo-50 text-indigo-700 border-indigo-100'],
            ['Contacted', $stats['contacted'], 'bg-yellow-50 text-yellow-700 border-yellow-100'],
            ['Closed', $stats['closed'], 'bg-green-50 text-green-700 border-green-100'],
            ['Converted', $stats['converted'], 'bg-cyan-50 text-cyan-700 border-cyan-100'],
            ['Today', $stats['today'], 'bg-purple-50 text-purple-700 border-purple-100'],
        ];
    ?>
    <?php $__currentLoopData = $statCards; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as [$label, $val, $classes]): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <div class="bg-white rounded-xl border p-4 text-center <?php echo e($classes); ?>">
            <p class="text-2xl font-black"><?php echo e($val); ?></p>
            <p class="text-xs font-medium mt-0.5 uppercase tracking-wide"><?php echo e($label); ?></p>
        </div>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</div>

<form method="GET" action="<?php echo e(route('admin.contact-submissions.index')); ?>"
      class="bg-white rounded-xl border border-gray-100 shadow-sm p-4 mb-4">
    <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3">
        <input type="text" name="search" value="<?php echo e(request('search')); ?>"
               placeholder="Name, phone or email..."
               class="px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 col-span-1 sm:col-span-2 lg:col-span-2" />

        <select name="status" class="px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
            <option value="">All Statuses</option>
            <?php $__currentLoopData = ['new', 'contacted', 'closed']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($s); ?>" <?php echo e(request('status') === $s ? 'selected' : ''); ?>><?php echo e(ucfirst($s)); ?></option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </select>

        <div class="flex gap-2">
            <button type="submit" class="flex-1 bg-blue-600 hover:bg-blue-700 text-white text-sm font-semibold px-4 py-2 rounded-lg transition">
                Filter
            </button>
            <?php if(request()->hasAny(['search', 'status'])): ?>
                <a href="<?php echo e(route('admin.contact-submissions.index')); ?>" class="px-3 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 text-sm font-medium rounded-lg transition">
                    Clear
                </a>
            <?php endif; ?>
        </div>
    </div>
</form>

<div class="bg-white rounded-xl border border-gray-100 shadow-sm overflow-hidden">
    <div class="px-5 py-3 border-b border-gray-100 flex items-center justify-between">
        <span class="text-sm text-gray-500 font-medium"><?php echo e($submissions->total()); ?> requests found</span>
    </div>

    <?php if($submissions->isEmpty()): ?>
        <div class="text-center py-16 text-gray-400">
            <p class="text-sm">No contact requests found.</p>
        </div>
    <?php else: ?>
        <div class="overflow-x-auto">
            <table class="min-w-full divide-y divide-gray-100">
                <thead class="bg-gray-50 text-xs text-gray-500 uppercase tracking-wide">
                    <tr>
                        <th class="px-5 py-3 text-left">#</th>
                        <th class="px-5 py-3 text-left">Contact</th>
                        <th class="px-5 py-3 text-left hidden md:table-cell">Countries</th>
                        <th class="px-5 py-3 text-left hidden lg:table-cell">Study Level</th>
                        <th class="px-5 py-3 text-left">Status</th>
                        <th class="px-5 py-3 text-left hidden xl:table-cell">Date</th>
                        <th class="px-5 py-3 text-right">Actions</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-gray-50">
                    <?php $__currentLoopData = $submissions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr class="hover:bg-gray-50 transition">
                            <td class="px-5 py-4 text-xs text-gray-400">#<?php echo e($item->id); ?></td>
                            <td class="px-5 py-4">
                                <p class="font-semibold text-gray-800 text-sm"><?php echo e($item->name); ?></p>
                                <p class="text-xs text-gray-500"><?php echo e($item->phone); ?></p>
                                <p class="text-xs text-blue-500"><?php echo e($item->email); ?></p>
                            </td>
                            <td class="px-5 py-4 hidden md:table-cell">
                                <p class="text-sm text-gray-700"><?php echo e($item->country_name ?: '-'); ?></p>
                                <p class="text-xs text-gray-400"><?php echo e($item->second_country_name ?: 'No second choice'); ?></p>
                            </td>
                            <td class="px-5 py-4 hidden lg:table-cell">
                                <span class="text-sm text-gray-600"><?php echo e(str_replace('_', ' ', ucfirst($item->study_level))); ?></span>
                            </td>
                            <td class="px-5 py-4">
                                <span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-semibold <?php echo e($item->statusBadge()); ?>">
                                    <?php echo e(ucfirst($item->status)); ?>

                                </span>
                            </td>
                            <td class="px-5 py-4 hidden xl:table-cell text-xs text-gray-400">
                                <?php echo e($item->created_at->format('d M Y')); ?><br/>
                                <span class="text-gray-300"><?php echo e($item->created_at->format('h:i A')); ?></span>
                            </td>
                            <td class="px-5 py-4">
                                <div class="flex items-center justify-end gap-1.5">
                                    <a href="<?php echo e(route('admin.contact-submissions.show', $item)); ?>"
                                       class="px-3 py-1.5 text-xs font-semibold rounded-lg bg-blue-50 text-blue-700 hover:bg-blue-100 transition">
                                        View
                                    </a>
                                    <?php if($item->lead_id): ?>
                                        <a href="<?php echo e(route('admin.leads.show', $item->lead_id)); ?>"
                                           class="px-3 py-1.5 text-xs font-semibold rounded-lg bg-cyan-50 text-cyan-700 hover:bg-cyan-100 transition">
                                            Lead
                                        </a>
                                    <?php else: ?>
                                        <form method="POST" action="<?php echo e(route('admin.contact-submissions.convert', $item)); ?>"
                                              onsubmit="return confirm('Convert this contact request into a lead?')">
                                            <?php echo csrf_field(); ?>
                                            <button type="submit" class="px-3 py-1.5 text-xs font-semibold rounded-lg bg-emerald-50 text-emerald-700 hover:bg-emerald-100 transition">
                                                Convert
                                            </button>
                                        </form>
                                    <?php endif; ?>
                                    <form method="POST" action="<?php echo e(route('admin.contact-submissions.destroy', $item)); ?>"
                                          onsubmit="return confirm('Delete this contact request?')">
                                        <?php echo csrf_field(); ?>
                                        <?php echo method_field('DELETE'); ?>
                                        <button type="submit" class="px-3 py-1.5 text-xs font-semibold rounded-lg bg-red-50 text-red-600 hover:bg-red-100 transition">
                                            Delete
                                        </button>
                                    </form>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table>
        </div>

        <?php if($submissions->hasPages()): ?>
            <div class="px-5 py-4 border-t border-gray-100"><?php echo e($submissions->links()); ?></div>
        <?php endif; ?>
    <?php endif; ?>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/gpsmigration/public_html/gpsmigration.com/resources/views/admin/contact-submissions/index.blade.php ENDPATH**/ ?>