<?php $__env->startSection('title'); ?>
    Booking Details - Hotel Management System
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <!-- Breadcrumb -->
    <div class="bg-white shadow-sm border-b border-gray-200 px-6 py-4">
        <div class="flex items-center justify-between">
            <div class="flex items-center text-sm text-gray-600">
                <i class="fas fa-home mr-2"></i>
                <span>/ <a href="<?php echo e(route('bookings.index')); ?>" class="text-blue-600 hover:text-blue-800">Reservation</a> / Booking #<?php echo e($booking->booking_id); ?></span>
            </div>
            <div class="flex space-x-2">
                <a href="<?php echo e(route('bookings.index')); ?>" class="bg-gray-500 hover:bg-gray-600 text-white px-4 py-2 rounded-lg transition-colors">
                    <i class="fas fa-arrow-left mr-2"></i>Back to Bookings
                </a>
                <?php if(auth()->check() && auth()->user()->hasPermissionTo('edit-bookings')): ?>
                <a href="<?php echo e(route('bookings.edit', $booking)); ?>" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg transition-colors">
                    <i class="fas fa-edit mr-2"></i>Edit Booking
                </a>
                <?php endif; ?>
            </div>
        </div>
    </div>

    <!-- Content -->
    <div class="p-6">
        <?php if(session('success')): ?>
            <div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mb-6">
                <i class="fas fa-check-circle mr-2"></i><?php echo e(session('success')); ?>

            </div>
        <?php endif; ?>

        <?php if(session('error')): ?>
            <div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-6">
                <i class="fas fa-exclamation-triangle mr-2"></i><?php echo e(session('error')); ?>

            </div>
        <?php endif; ?>

        <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
            <!-- Left Panel - Booking Summary -->
            <div class="lg:col-span-1">
                <div class="bg-white rounded-lg shadow-md">
                    <div class="px-6 py-4 border-b border-gray-200">
                        <h3 class="text-lg font-semibold text-gray-800">Booking Summary</h3>
                    </div>
                    
                    <div class="p-6 space-y-4">
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-gray-600">Booking ID:</span>
                            <span class="text-lg font-bold text-gray-900">#<?php echo e($booking->booking_id); ?></span>
                        </div>
                        
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-gray-600">Status:</span>
                            <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium <?php echo e($booking->getStatusBadgeColor()); ?>">
                                <?php echo e($booking->booking_status); ?>

                            </span>
                        </div>
                        
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-gray-600">Created:</span>
                            <span class="text-sm text-gray-900"><?php echo e($booking->created_at->format('M d, Y H:i')); ?></span>
                        </div>
                        
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-gray-600">Customers:</span>
                            <span class="text-sm text-gray-900"><?php echo e($booking->number_of_customers); ?></span>
                        </div>
                        
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-gray-600">Nights:</span>
                            <span class="text-sm text-gray-900"><?php echo e($booking->number_of_nights); ?></span>
                        </div>
                        
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-gray-600">Price/Night:</span>
                            <span class="text-sm text-gray-900">KES<?php echo e(number_format($booking->price_per_night, 2)); ?></span>
                        </div>
                        
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-gray-600">Total Price:</span>
                            <span class="text-lg font-bold text-green-600">KES<?php echo e(number_format($booking->total_price, 2)); ?></span>
                        </div>
                        
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-gray-600">Pay Amount:</span>
                            <span class="text-sm text-gray-900">KES<?php echo e(number_format($booking->advance_payment, 2)); ?></span>
                        </div>
                        
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-gray-600">Payment Status:</span>
                            <?php if($booking->payment_status): ?>
                                <span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
                                    Paid
                                </span>
                            <?php else: ?>
                                <span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-800">
                                    Unpaid
                                </span>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>

                <!-- Room Information -->
                <div class="bg-white rounded-lg shadow-md mt-6">
                    <div class="px-6 py-4 border-b border-gray-200">
                        <h3 class="text-lg font-semibold text-gray-800">Room Information</h3>
                    </div>
                    
                    <div class="p-6 space-y-4">
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-gray-600">Room Number:</span>
                            <span class="text-lg font-bold text-gray-900"><?php echo e($booking->room->room_no); ?></span>
                        </div>
                        
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-gray-600">Room Type:</span>
                            <span class="text-sm text-gray-900"><?php echo e($booking->room->roomType->room_type); ?></span>
                        </div>
                        
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-gray-600">Floor:</span>
                            <span class="text-sm text-gray-900"><?php echo e($booking->room->floor); ?></span>
                        </div>
                        
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-gray-600">Capacity:</span>
                            <span class="text-sm text-gray-900"><?php echo e($booking->room->capacity); ?> person(s)</span>
                        </div>
                    </div>
                </div>

                <!-- Dates Information -->
                <div class="bg-white rounded-lg shadow-md mt-6">
                    <div class="px-6 py-4 border-b border-gray-200">
                        <h3 class="text-lg font-semibold text-gray-800">Stay Dates</h3>
                    </div>
                    
                    <div class="p-6 space-y-4">
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-gray-600">Check In:</span>
                            <span class="text-sm text-gray-900"><?php echo e(\Carbon\Carbon::parse($booking->check_in)->format('M d, Y')); ?></span>
                        </div>
                        
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-gray-600">Check Out:</span>
                            <span class="text-sm text-gray-900"><?php echo e(\Carbon\Carbon::parse($booking->check_out)->format('M d, Y')); ?></span>
                        </div>
                        
                        <?php if($booking->checked_in_at): ?>
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-gray-600">Checked In At:</span>
                            <span class="text-sm text-gray-900"><?php echo e(\Carbon\Carbon::parse($booking->checked_in_at)->format('M d, Y H:i')); ?></span>
                        </div>
                        <?php endif; ?>
                        
                        <?php if($booking->checked_out_at): ?>
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-gray-600">Checked Out At:</span>
                            <span class="text-sm text-gray-900"><?php echo e(\Carbon\Carbon::parse($booking->checked_out_at)->format('M d, Y H:i')); ?></span>
                        </div>
                        <?php endif; ?>
                    </div>
                </div>
            </div>

            <!-- Right Panel - Customer Details & Actions -->
            <div class="lg:col-span-2">
                <!-- Customer Details -->
                <div class="bg-white rounded-lg shadow-md">
                    <div class="px-6 py-4 border-b border-gray-200">
                        <h3 class="text-lg font-semibold text-gray-800">Customer Details</h3>
                    </div>
                    
                    <div class="p-6">
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                            <?php $__currentLoopData = $booking->bookingCustomers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $customer): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="border border-gray-200 rounded-lg p-4">
                                <h4 class="text-lg font-semibold text-gray-800 mb-3">Customer <?php echo e($index + 1); ?></h4>
                                
                                <div class="space-y-3">
                                    <div>
                                        <span class="text-sm font-medium text-gray-600">Name:</span>
                                        <p class="text-sm text-gray-900"><?php echo e($customer->first_name); ?> <?php echo e($customer->last_name); ?></p>
                                    </div>
                                    
                                    <div>
                                        <span class="text-sm font-medium text-gray-600">Document:</span>
                                        <p class="text-sm text-gray-900"><?php echo e($customer->document_type); ?>: <?php echo e($customer->document_number ?: 'Not provided'); ?></p>
                                    </div>
                                    
                                    <div>
                                        <span class="text-sm font-medium text-gray-600">Nationality:</span>
                                        <p class="text-sm text-gray-900"><?php echo e($customer->nationality); ?></p>
                                    </div>
                                    
                                    <div>
                                        <span class="text-sm font-medium text-gray-600">Origin City:</span>
                                        <p class="text-sm text-gray-900"><?php echo e($customer->origin_city ?: 'Not specified'); ?></p>
                                    </div>
                                    
                                    <div>
                                        <span class="text-sm font-medium text-gray-600">Phone:</span>
                                        <p class="text-sm text-gray-900"><?php echo e($customer->phone ?: 'Not provided'); ?></p>
                                    </div>
                                    
                                    <div>
                                        <span class="text-sm font-medium text-gray-600">Email:</span>
                                        <p class="text-sm text-gray-900"><?php echo e($customer->email ?: 'Not provided'); ?></p>
                                    </div>
                                </div>
                            </div>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </div>
                    </div>
                </div>

                <!-- Observations -->
                <?php if($booking->observations): ?>
                <div class="bg-white rounded-lg shadow-md mt-6">
                    <div class="px-6 py-4 border-b border-gray-200">
                        <h3 class="text-lg font-semibold text-gray-800">Observations</h3>
                    </div>
                    
                    <div class="p-6">
                        <p class="text-gray-700"><?php echo e($booking->observations); ?></p>
                    </div>
                </div>
                <?php endif; ?>

                <!-- Transactions -->
                <?php if($booking->transactions->count() > 0): ?>
                <div class="bg-white rounded-lg shadow-md mt-6">
                    <div class="px-6 py-4 border-b border-gray-200">
                        <h3 class="text-lg font-semibold text-gray-800">Payment Transactions</h3>
                    </div>
                    
                    <div class="p-6">
                        <div class="overflow-x-auto">
                            <table class="min-w-full divide-y divide-gray-200">
                                <thead class="bg-gray-50">
                                    <tr>
                                        <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Date</th>
                                        <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Card Type</th>
                                        <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Transaction ID</th>
                                        <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Amount</th>
                                    </tr>
                                </thead>
                                <tbody class="bg-white divide-y divide-gray-200">
                                    <?php $__currentLoopData = $booking->transactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $transaction): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td class="px-4 py-2 text-sm text-gray-900"><?php echo e(\Carbon\Carbon::parse($transaction->payment_date)->format('M d, Y H:i')); ?></td>
                                        <td class="px-4 py-2 text-sm text-gray-900"><?php echo e($transaction->card_type); ?></td>
                                        <td class="px-4 py-2 text-sm text-gray-900"><?php echo e($transaction->payment_transaction_id); ?></td>
                                        <td class="px-4 py-2 text-sm font-medium text-green-600">KES<?php echo e(number_format($transaction->amount, 2)); ?></td>
                                    </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <?php endif; ?>

                <!-- Receipt -->
                <?php if($booking->receipt): ?>
                <div class="bg-white rounded-lg shadow-md mt-6">
                    <div class="px-6 py-4 border-b border-gray-200">
                        <h3 class="text-lg font-semibold text-gray-800">Receipt</h3>
                    </div>
                    
                    <div class="p-6">
                        <div class="flex items-center justify-between mb-4">
                            <div>
                                <p class="text-sm text-gray-600">Receipt #<?php echo e($booking->receipt->receipt_number); ?></p>
                                <p class="text-sm text-gray-600">Issued: <?php echo e($booking->receipt->issued_at->format('M d, Y H:i')); ?></p>
                                <p class="text-sm text-gray-600">Status: <?php echo e($booking->receipt->status); ?></p>
                            </div>
                            <div class="flex space-x-2">
                                <a href="<?php echo e(route('receipts.show', $booking->receipt)); ?>" 
                                   class="bg-blue-600 hover:bg-blue-700 text-white px-3 py-2 rounded-lg transition-colors text-sm">
                                    <i class="fas fa-eye mr-1"></i>View
                                </a>
                                <a href="<?php echo e(route('receipts.thermal', $booking->receipt)); ?>" 
                                   target="_blank"
                                   class="bg-orange-600 hover:bg-orange-700 text-white px-3 py-2 rounded-lg transition-colors text-sm">
                                    <i class="fas fa-receipt mr-1"></i>Thermal
                                </a>
                                <a href="<?php echo e(route('receipts.download', $booking->receipt)); ?>" 
                                   class="bg-green-600 hover:bg-green-700 text-white px-3 py-2 rounded-lg transition-colors text-sm">
                                    <i class="fas fa-download mr-1"></i>PDF
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
                <?php endif; ?>

                <!-- Action Buttons -->
                <div class="bg-white rounded-lg shadow-md mt-6">
                    <div class="px-6 py-4 border-b border-gray-200">
                        <h3 class="text-lg font-semibold text-gray-800">Actions</h3>
                    </div>
                    
                    <div class="p-6">
                        <div class="flex flex-wrap gap-3">
                            <?php if($booking->booking_status === 'Checked In'): ?>
                                <?php if(auth()->check() && auth()->user()->hasPermissionTo('edit-bookings')): ?>
                                <form action="<?php echo e(route('bookings.check-out', $booking)); ?>" method="POST" class="inline">
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('PATCH'); ?>
                                    <button type="submit" class="bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg transition-colors">
                                        <i class="fas fa-sign-out-alt mr-2"></i>Check Out
                                    </button>
                                </form>
                                <?php endif; ?>
                            <?php endif; ?>

                            <?php if(auth()->check() && auth()->user()->hasPermissionTo('edit-bookings')): ?>
                                <?php if(now()->format('Y-m-d') <= $booking->check_out): ?>
                                <a href="<?php echo e(route('bookings.edit', $booking)); ?>" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg transition-colors">
                                    <i class="fas fa-edit mr-2"></i>Edit Booking
                                </a>
                                <?php else: ?>
                                <span class="bg-gray-400 text-white px-4 py-2 rounded-lg cursor-not-allowed" title="Cannot edit after checkout date">
                                    <i class="fas fa-edit mr-2"></i>Edit Booking
                                </span>
                                <?php endif; ?>
                            <?php endif; ?>

                            <?php if(auth()->check() && auth()->user()->hasPermissionTo('delete-bookings')): ?>
                            <form action="<?php echo e(route('bookings.destroy', $booking)); ?>" method="POST" class="inline" onsubmit="return confirm('Are you sure you want to delete this booking?')">
                                <?php echo csrf_field(); ?>
                                <?php echo method_field('DELETE'); ?>
                                <button type="submit" class="bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg transition-colors">
                                    <i class="fas fa-trash mr-2"></i>Delete Booking
                                </button>
                            </form>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?> 
<?php echo $__env->make('backend.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home4/lvwxwpmy/public_html/hotelms/resources/views/backend/bookings/show.blade.php ENDPATH**/ ?>