

<?php $__env->startSection('title', 'Guest List - WedBooker'); ?>
<?php $__env->startSection('page-title', 'Guest Management'); ?>
<?php $__env->startSection('page-description', 'Manage your wedding guests'); ?>

<?php $__env->startSection('content'); ?>
<div class="space-y-6">
    <!-- Filters and Actions -->
    <div class="glass-card rounded-2xl p-6 border border-white/10" data-aos="fade-up">
        <div class="flex flex-wrap gap-4 justify-between items-center">
            <div class="flex flex-wrap gap-3">
                <button onclick="filterGuests('all')" class="px-4 py-2 bg-purple-600 rounded-lg text-white text-sm hover:bg-purple-700 transition">All Guests</button>
                <button onclick="filterGuests('attending')" class="px-4 py-2 bg-white/10 rounded-lg text-gray-300 text-sm hover:bg-white/20 transition">Attending</button>
                <button onclick="filterGuests('not-attending')" class="px-4 py-2 bg-white/10 rounded-lg text-gray-300 text-sm hover:bg-white/20 transition">Not Attending</button>
                <button onclick="filterGuests('pending')" class="px-4 py-2 bg-white/10 rounded-lg text-gray-300 text-sm hover:bg-white/20 transition">Pending</button>
            </div>
            <div class="flex gap-3">
                <a href="<?php echo e(route('guests.export.csv')); ?>" class="px-4 py-2 bg-green-600 rounded-lg text-white text-sm hover:bg-green-700 transition">
                    <i class="fas fa-download mr-2"></i>Export CSV
                </a>
                <button onclick="document.getElementById('importFile').click()" class="px-4 py-2 bg-blue-600 rounded-lg text-white text-sm hover:bg-blue-700 transition">
                    <i class="fas fa-upload mr-2"></i>Import Guests
                </button>
                <a href="<?php echo e(route('guests.create')); ?>" class="px-4 py-2 bg-purple-600 rounded-lg text-white text-sm hover:bg-purple-700 transition">
                    <i class="fas fa-plus mr-2"></i>Add Guest
                </a>
                <form id="importForm" action="<?php echo e(route('guests.import')); ?>" method="POST" enctype="multipart/form-data" style="display: none;">
                    <?php echo csrf_field(); ?>
                    <input type="file" id="importFile" name="csv_file" accept=".csv" onchange="this.form.submit()">
                </form>
            </div>
        </div>
        
        <!-- Search -->
        <div class="mt-4">
            <div class="relative">
                <i class="fas fa-search absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"></i>
                <input type="text" id="searchInput" onkeyup="searchGuests()" placeholder="Search guests by name or email..." class="w-full pl-10 pr-4 py-2 bg-white/10 border border-white/20 rounded-lg text-white focus:outline-none focus:border-purple-500">
            </div>
        </div>
    </div>
    
    <!-- Guest Table -->
    <div class="glass-card rounded-2xl p-6 border border-white/10 overflow-x-auto" data-aos="fade-up">
        <div class="flex justify-between items-center mb-4">
            <h3 class="text-lg font-semibold text-white">All Guests</h3>
            <div class="flex gap-2">
                <button onclick="window.print()" class="px-3 py-1 bg-white/10 rounded text-gray-300 text-sm hover:bg-white/20 transition">
                    <i class="fas fa-print mr-1"></i>Print
                </button>
                <button onclick="selectAllGuests()" class="px-3 py-1 bg-white/10 rounded text-gray-300 text-sm hover:bg-white/20 transition">
                    <i class="fas fa-check-double mr-1"></i>Select All
                </button>
            </div>
        </div>
        
        <table class="data-table w-full" id="guestsTable">
            <thead>
                <tr class="border-b border-white/10">
                    <th class="text-left py-3 px-4 text-gray-400">
                        <input type="checkbox" id="selectAllCheckbox" class="rounded border-white/20 bg-white/10">
                    </th>
                    <th class="text-left py-3 px-4 text-gray-400">Name</th>
                    <th class="text-left py-3 px-4 text-gray-400">Email</th>
                    <th class="text-left py-3 px-4 text-gray-400">RSVP Status</th>
                    <th class="text-left py-3 px-4 text-gray-400">Accommodation</th>
                    <th class="text-left py-3 px-4 text-gray-400">Transport</th>
                    <th class="text-left py-3 px-4 text-gray-400">Activities</th>
                    <th class="text-left py-3 px-4 text-gray-400">Actions</th>
                 </tr>
            </thead>
            <tbody>
                <?php
                    $guests = [
                        ['id' => 1, 'name' => 'Sarah Johnson', 'email' => 'sarah@email.com', 'rsvp' => 'confirmed', 'accommodation' => 'Booked', 'transport' => 'Confirmed', 'activities' => '3'],
                        ['id' => 2, 'name' => 'Michael Brown', 'email' => 'michael@email.com', 'rsvp' => 'pending', 'accommodation' => 'Pending', 'transport' => '-', 'activities' => '1'],
                        ['id' => 3, 'name' => 'Emma Wilson', 'email' => 'emma@email.com', 'rsvp' => 'confirmed', 'accommodation' => 'Booked', 'transport' => 'Confirmed', 'activities' => '2'],
                        ['id' => 4, 'name' => 'James Taylor', 'email' => 'james@email.com', 'rsvp' => 'declined', 'accommodation' => '-', 'transport' => '-', 'activities' => '-'],
                        ['id' => 5, 'name' => 'Lisa Anderson', 'email' => 'lisa@email.com', 'rsvp' => 'confirmed', 'accommodation' => 'Booked', 'transport' => 'Pending', 'activities' => '4'],
                    ];
                ?>
                <?php $__currentLoopData = $guests; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $guest): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr class="hover:bg-white/5 transition guest-row" data-name="<?php echo e(strtolower($guest['name'])); ?>" data-email="<?php echo e(strtolower($guest['email'])); ?>" data-rsvp="<?php echo e($guest['rsvp']); ?>">
                    <td class="py-3 px-4">
                        <input type="checkbox" class="guest-checkbox rounded border-white/20 bg-white/10" value="<?php echo e($guest['id']); ?>">
                    </td>
                    <td class="py-3 px-4 text-white"><?php echo e($guest['name']); ?> </td>
                    <td class="py-3 px-4 text-gray-300"><?php echo e($guest['email']); ?> </td>
                    <td class="py-3 px-4">
                        <span class="badge badge-<?php echo e($guest['rsvp'] === 'confirmed' ? 'success' : ($guest['rsvp'] === 'pending' ? 'warning' : 'danger')); ?>">
                            <?php echo e(ucfirst($guest['rsvp'])); ?>

                        </span>
                     </td>
                    <td class="py-3 px-4">
                        <span class="badge <?php echo e($guest['accommodation'] === 'Booked' ? 'badge-success' : ($guest['accommodation'] === 'Pending' ? 'badge-warning' : 'badge-danger')); ?>">
                            <?php echo e($guest['accommodation']); ?>

                        </span>
                     </td>
                    <td class="py-3 px-4">
                        <span class="badge <?php echo e($guest['transport'] === 'Confirmed' ? 'badge-success' : ($guest['transport'] === 'Pending' ? 'badge-warning' : 'badge-danger')); ?>">
                            <?php echo e($guest['transport']); ?>

                        </span>
                     </td>
                    <td class="py-3 px-4 text-gray-300"><?php echo e($guest['activities']); ?> activities </td>
                    <td class="py-3 px-4">
                        <div class="flex gap-2">
                            <a href="<?php echo e(route('guests.edit', $guest['id'])); ?>" class="text-blue-400 hover:text-blue-300 transition" title="Edit Guest">
                                <i class="fas fa-edit"></i>
                            </a>
                            <button onclick="deleteGuest(<?php echo e($guest['id']); ?>)" class="text-red-400 hover:text-red-300 transition" title="Delete Guest">
                                <i class="fas fa-trash"></i>
                            </button>
                            <a href="" class="text-green-400 hover:text-green-300 transition" title="Send Invitation">
                                <i class="fas fa-envelope"></i>
                            </a>
                        </div>
                     </td>
                 </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>
         </table>
        
        <!-- Bulk Actions -->
        <div class="flex justify-between items-center mt-6 pt-4 border-t border-white/10">
            <div class="flex gap-2">
                <button onclick="bulkAction('send-invitation')" class="px-3 py-1 bg-green-600/20 text-green-400 rounded text-sm hover:bg-green-600/30 transition">
                    <i class="fas fa-envelope mr-1"></i>Send Invitations
                </button>
                <button onclick="bulkAction('export-selected')" class="px-3 py-1 bg-blue-600/20 text-blue-400 rounded text-sm hover:bg-blue-600/30 transition">
                    <i class="fas fa-download mr-1"></i>Export Selected
                </button>
                <button onclick="bulkAction('delete-selected')" class="px-3 py-1 bg-red-600/20 text-red-400 rounded text-sm hover:bg-red-600/30 transition">
                    <i class="fas fa-trash mr-1"></i>Delete Selected
                </button>
            </div>
            <div class="flex gap-2">
                <button class="px-3 py-1 bg-white/10 rounded text-gray-400 hover:bg-white/20 transition">Previous</button>
                <button class="px-3 py-1 bg-purple-600 rounded text-white">1</button>
                <button class="px-3 py-1 bg-white/10 rounded text-gray-400 hover:bg-white/20 transition">2</button>
                <button class="px-3 py-1 bg-white/10 rounded text-gray-400 hover:bg-white/20 transition">3</button>
                <button class="px-3 py-1 bg-white/10 rounded text-gray-400 hover:bg-white/20 transition">Next</button>
            </div>
        </div>
    </div>
</div>

<form id="deleteForm" method="POST" style="display: none;">
    <?php echo csrf_field(); ?>
    <?php echo method_field('DELETE'); ?>
</form>

<form id="bulkActionForm" method="POST" style="display: none;">
    <?php echo csrf_field(); ?>
    <input type="hidden" name="action" id="bulkAction">
    <input type="hidden" name="guest_ids" id="bulkGuestIds">
</form>

<?php $__env->startPush('scripts'); ?>
<script>
    // Search functionality
    function searchGuests() {
        const input = document.getElementById('searchInput');
        const filter = input.value.toLowerCase();
        const rows = document.getElementsByClassName('guest-row');
        
        for (let i = 0; i < rows.length; i++) {
            const name = rows[i].getAttribute('data-name');
            const email = rows[i].getAttribute('data-email');
            if (name.includes(filter) || email.includes(filter)) {
                rows[i].style.display = '';
            } else {
                rows[i].style.display = 'none';
            }
        }
    }
    
    // Filter by RSVP status
    function filterGuests(status) {
        const rows = document.getElementsByClassName('guest-row');
        
        for (let i = 0; i < rows.length; i++) {
            const rsvpStatus = rows[i].getAttribute('data-rsvp');
            if (status === 'all') {
                rows[i].style.display = '';
            } else if (status === 'attending' && rsvpStatus === 'confirmed') {
                rows[i].style.display = '';
            } else if (status === 'not-attending' && rsvpStatus === 'declined') {
                rows[i].style.display = '';
            } else if (status === 'pending' && rsvpStatus === 'pending') {
                rows[i].style.display = '';
            } else {
                rows[i].style.display = 'none';
            }
        }
        
        // Update button styles
        document.querySelectorAll('.filter-btn').forEach(btn => btn.classList.remove('bg-purple-600'));
        document.querySelectorAll('.filter-btn').forEach(btn => btn.classList.add('bg-white/10'));
        event.target.classList.remove('bg-white/10');
        event.target.classList.add('bg-purple-600');
    }
    
    // Select all guests
    function selectAllGuests() {
        const checkboxes = document.querySelectorAll('.guest-checkbox');
        const selectAll = document.getElementById('selectAllCheckbox');
        checkboxes.forEach(checkbox => {
            checkbox.checked = selectAll.checked;
        });
    }
    
    document.getElementById('selectAllCheckbox').addEventListener('change', function() {
        const checkboxes = document.querySelectorAll('.guest-checkbox');
        checkboxes.forEach(checkbox => {
            checkbox.checked = this.checked;
        });
    });
    
    // Delete single guest
    function deleteGuest(guestId) {
        if(confirm('Are you sure you want to delete this guest? This action cannot be undone.')) {
            const form = document.getElementById('deleteForm');
            form.submit();
        }
    }
    
    // Bulk actions
    function bulkAction(action) {
        const selectedGuests = [];
        const checkboxes = document.querySelectorAll('.guest-checkbox:checked');
        
        if(checkboxes.length === 0) {
            alert('Please select at least one guest');
            return;
        }
        
        checkboxes.forEach(checkbox => {
            selectedGuests.push(checkbox.value);
        });
        
        let message = '';
        switch(action) {
            case 'send-invitation':
                message = `Send invitations to ${selectedGuests.length} selected guest(s)?`;
                break;
            case 'export-selected':
                message = `Export ${selectedGuests.length} selected guest(s)?`;
                break;
            case 'delete-selected':
                message = `Delete ${selectedGuests.length} selected guest(s)? This action cannot be undone.`;
                break;
        }
        
        if(confirm(message)) {
            const form = document.getElementById('bulkActionForm');
            document.getElementById('bulkAction').value = action;
            document.getElementById('bulkGuestIds').value = selectedGuests.join(',');
            form.action = "<?php echo e(route('guests.bulk-action')); ?>";
            form.submit();
        }
    }
    
    // Export functionality
    function exportGuests() {
        window.location.href = "<?php echo e(route('guests.export.csv')); ?>";
    }
    
    // Add animation to cards on hover
    document.querySelectorAll('.glass-card').forEach(card => {
        card.addEventListener('mouseenter', function() {
            this.style.transform = 'translateY(-5px)';
        });
        card.addEventListener('mouseleave', function() {
            this.style.transform = 'translateY(0)';
        });
    });
</script>
<?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH D:\skietagency\wedding\code\resources\views/guests/index.blade.php ENDPATH**/ ?>