<x-app-layout>
    <div class="max-w-4xl mx-auto py-10 px-4 sm:px-6 lg:px-8">
        <div class="bg-white rounded-lg shadow-md overflow-hidden">
            <div class="p-6">
                <h2 class="text-2xl font-bold text-gray-800 mb-6 text-center">
                    Register for Computer Education Services
                </h2>
                
                @if (session('success'))
                    <div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mb-6" role="alert">
                        {{ session('success') }}
                    </div>
                @endif

                <form action="{{ route('register.store') }}" method="POST" class="space-y-6">
                    @csrf
                    
                    <div class="grid gap-4 sm:grid-cols-2">
                        <div>
                            <label for="full_name" class="block text-sm font-medium text-gray-700 mb-1">
                                Full Name
                            </label>
                            <input type="text" id="full_name" name="full_name"
                                class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
                                value="{{ old('full_name') }}" required>
                            @error('full_name')
                                <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
                            @enderror
                        </div>
                        
                        <div>
                            <label for="email" class="block text-sm font-medium text-gray-700 mb-1">
                                Email Address
                            </label>
                            <input type="email" id="email" name="email"
                                class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
                                value="{{ old('email') }}" required>
                            @error('email')
                                <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
                            @enderror
                        </div>
                    </div>
                    
                    <div class="grid gap-4 sm:grid-cols-2">
                        <div>
                            <label for="phone" class="block text-sm font-medium text-gray-700 mb-1">
                                Phone Number
                            </label>
                            <input type="tel" id="phone" name="phone"
                                class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
                                value="{{ old('phone') }}" required>
                            @error('phone')
                                <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
                            @enderror
                        </div>
                        
                        <div>
                            <label for="course" class="block text-sm font-medium text-gray-700 mb-1">
                                Course
                            </label>
                            <select id="course" name="course"
                                class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
                                required>
                                <option value="">Select a Course</option>
                                <option value="Basic Computer Skills" {{ old('course') == 'Basic Computer Skills' ? 'selected' : '' }}>
                                    Basic Computer Skills
                                </option>
                                <option value="Web Development" {{ old('course') == 'Web Development' ? 'selected' : '' }}>
                                    Web Development
                                </option>
                                <option value="Data Science" {{ old('course') == 'Data Science' ? 'selected' : '' }}>
                                    Data Science
                                </option>
                                <option value="Cybersecurity" {{ old('course') == 'Cybersecurity' ? 'selected' : '' }}>
                                    Cybersecurity
                                </option>
                            </select>
                            @error('course')
                                <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
                            @enderror
                        </div>
                    </div>
                    
                    <div class="grid gap-4 sm:grid-cols-2">
                        <div>
                            <label for="session" class="block text-sm font-medium text-gray-700 mb-1">
                                Session
                            </label>
                            <select id="session" name="session"
                                class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
                                required>
                                <option value="">Select a Session</option>
                                <option value="Morning (9AM-12PM)" {{ old('session') == 'Morning (9AM-12PM)' ? 'selected' : '' }}>
                                    Morning (9AM-12PM)
                                </option>
                                <option value="Afternoon (1PM-4PM)" {{ old('session') == 'Afternoon (1PM-4PM)' ? 'selected' : '' }}>
                                    Afternoon (1PM-4PM)
                                </option>
                                <option value="Evening (5PM-8PM)" {{ old('session') == 'Evening (5PM-8PM)' ? 'selected' : '' }}>
                                    Evening (5PM-8PM)
                                </option>
                            </select>
                            @error('session')
                                <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
                            @enderror
                        </div>
                        
                        <div class="col-span-2 sm:col-span-1">
                            <label for="message" class="block text-sm font-medium text-gray-700 mb-1">
                                Message (Optional)
                            </label>
                            <textarea id="message" name="message" rows="3"
                                class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">{{ old('message') }}</textarea>
                            @error('message')
                                <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
                            @enderror
                        </div>
                    </div>
                    
                    <div class="flex justify-end pt-4">
                        <button type="submit"
                            class="px-6 py-2 bg-blue-600 text-white font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition">
                            Submit Registration
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</x-app-layout>