@extends('admin.layouts.app')

@section('title', 'Booking Management - NRT SA Admin')

@section('content')
<div class="p-6">
    <!-- Header -->
    <div class="mb-8">
        <h1 class="text-3xl font-bold text-white mb-2 font-display text-glow">Booking Management</h1>
        <p class="text-gray-300 font-body">Manage customer bookings and reservations</p>
    </div>

    <!-- Bookings List -->
    <div class="glass-card p-6 rounded-xl">
        <div class="overflow-x-auto">
            <table class="w-full text-left">
                <thead>
                    <tr class="border-b border-gray-700">
                        <th class="py-3 px-4 text-gray-300 font-body">Customer</th>
                        <th class="py-3 px-4 text-gray-300 font-body">Vehicle</th>
                        <th class="py-3 px-4 text-gray-300 font-body">Pickup Date</th>
                        <th class="py-3 px-4 text-gray-300 font-body">Dropoff Date</th>
                        <th class="py-3 px-4 text-gray-300 font-body">Status</th>
                        <th class="py-3 px-4 text-gray-300 font-body">Actions</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse($bookings as $booking)
                    <tr class="border-b border-gray-800">
                        <td class="py-3 px-4">
                            <div>
                                <p class="text-white font-body font-semibold">{{ $booking->name }}</p>
                                <p class="text-gray-400 text-sm font-body">{{ $booking->email }}</p>
                                <p class="text-gray-400 text-sm font-body">{{ $booking->phone }}</p>
                            </div>
                        </td>
                        <td class="py-3 px-4 text-gray-300 font-body">{{ $booking->vehicle->name ?? 'N/A' }}</td>
                        <td class="py-3 px-4 text-gray-300 font-body">{{ $booking->pickup_date->format('M d, Y') }}</td>
                        <td class="py-3 px-4 text-gray-300 font-body">{{ $booking->dropoff_date->format('M d, Y') }}</td>
                        <td class="py-3 px-4">
                            <span class="px-2 py-1 rounded-full text-xs font-body
                                @if($booking->status === 'pending') bg-yellow-100 text-yellow-800
                                @elseif($booking->status === 'confirmed') bg-green-100 text-green-800
                                @elseif($booking->status === 'completed') bg-blue-100 text-blue-800
                                @else bg-red-100 text-red-800
                                @endif">
                                {{ ucfirst($booking->status) }}
                            </span>
                        </td>
                        <td class="py-3 px-4">
                            <div class="flex space-x-2">
                                <a href="{{ route('admin.bookings.show', $booking) }}" class="text-blue-400 hover:text-blue-300">
                                    <i class="fas fa-eye"></i>
                                </a>
                                <a href="{{ route('admin.bookings.edit', $booking) }}" class="text-green-400 hover:text-green-300">
                                    <i class="fas fa-edit"></i>
                                </a>
                                <form method="POST" action="{{ route('admin.bookings.destroy', $booking) }}" class="inline" onsubmit="return confirm('Are you sure you want to delete this booking?')">
                                    @csrf
                                    @method('DELETE')
                                    <button type="submit" class="text-red-400 hover:text-red-300">
                                        <i class="fas fa-trash"></i>
                                    </button>
                                </form>
                            </div>
                        </td>
                    </tr>
                    @empty
                    <tr>
                        <td colspan="6" class="py-8 text-center text-gray-400 font-body">No bookings found</td>
                    </tr>
                    @endforelse
                </tbody>
            </table>
        </div>

        @if($bookings->hasPages())
        <div class="mt-6">
            {{ $bookings->links() }}
        </div>
        @endif
    </div>
</div>
@endsection
