<?php $__env->startSection('title', 'Event Registration'); ?>

<?php $__env->startSection('content'); ?>
<div class="container mt-5 mb-5">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card shadow-lg">
                <div class="card-header bg-primary text-white">
                    <h4 class="mb-0">
                        <i class="fas fa-clipboard-list"></i> Event Registration Form
                    </h4>
                </div>

                <div class="card-body p-4">
                    <div class="text-center mb-4">
                        <img src="<?php echo e(asset('images/logo.png')); ?>" alt="RnR Fit Logo" style="max-width: 180px;">
                    </div>
                    <?php if($errors->any()): ?>
                        <div class="alert alert-danger alert-dismissible fade show" role="alert">
                            <h5 class="alert-heading">
                                <i class="fas fa-exclamation-circle"></i> Validation Errors
                            </h5>
                            <ul class="mb-0">
                                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <li><?php echo e($error); ?></li>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </ul>
                            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                        </div>
                    <?php endif; ?>

                    <form action="<?php echo e(route('registration.store')); ?>" method="POST" novalidate>
                        <?php echo csrf_field(); ?>

                        <!-- Student Name -->
                        <div class="mb-3">
                            <label for="student_name" class="form-label">
                                <i class="fas fa-user"></i> Student Name <span class="text-danger">*</span>
                            </label>
                            <input 
                                type="text" 
                                class="form-control <?php $__errorArgs = ['student_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" 
                                id="student_name" 
                                name="student_name"
                                placeholder="Enter student name"
                                value="<?php echo e(old('student_name')); ?>"
                                pattern="[a-zA-Z\s]+"
                                maxlength="100"
                                required
                            >
                            <?php $__errorArgs = ['student_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="invalid-feedback d-block">
                                    <?php echo e($message); ?>

                                </div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        <!-- Parent Name -->
                        <div class="mb-3">
                            <label for="parent_name" class="form-label">
                                <i class="fas fa-user-tie"></i> Parent Name <span class="text-danger">*</span>
                            </label>
                            <input 
                                type="text" 
                                class="form-control <?php $__errorArgs = ['parent_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" 
                                id="parent_name" 
                                name="parent_name"
                                placeholder="Enter parent name"
                                value="<?php echo e(old('parent_name')); ?>"
                                pattern="[a-zA-Z\s]+"
                                maxlength="100"
                                required
                            >
                            <?php $__errorArgs = ['parent_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="invalid-feedback d-block">
                                    <?php echo e($message); ?>

                                </div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        <!-- Email -->
                        <div class="mb-3">
                            <label for="email" class="form-label">
                                <i class="fas fa-envelope"></i> Email Address <span class="text-danger">*</span>
                            </label>
                            <input 
                                type="email" 
                                class="form-control <?php $__errorArgs = ['email'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" 
                                id="email" 
                                name="email"
                                placeholder="Enter email address"
                                value="<?php echo e(old('email')); ?>"
                                required
                            >
                            <?php $__errorArgs = ['email'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="invalid-feedback d-block">
                                    <?php echo e($message); ?>

                                </div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        <!-- Phone Number -->
                        <div class="mb-3">
                            <label for="phone" class="form-label">
                                <i class="fas fa-phone"></i> Phone Number <span class="text-danger">*</span>
                            </label>
                            <input 
                                type="tel" 
                                class="form-control <?php $__errorArgs = ['phone'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" 
                                id="phone" 
                                name="phone"
                                placeholder="Enter 10-digit phone number"
                                value="<?php echo e(old('phone')); ?>"
                                pattern="[0-9]{10}"
                                maxlength="10"
                                required
                            >
                            <small class="form-text text-muted">
                                Please enter a valid 10-digit phone number
                            </small>
                            <?php $__errorArgs = ['phone'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="invalid-feedback d-block">
                                    <?php echo e($message); ?>

                                </div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        <!-- Event Selection -->
                        <div class="mb-4">
                            <label for="eventid" class="form-label">
                                <i class="fas fa-calendar-alt"></i> Select Event <span class="text-danger">*</span>
                            </label>
                            <select 
                                class="form-select <?php $__errorArgs = ['eventid'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" 
                                id="eventid" 
                                name="eventid"
                                required
                            >
                                <option value="">-- Choose an event --</option>
                                <?php $__empty_1 = true; $__currentLoopData = $events; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $event): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <option value="<?php echo e($event->Id); ?>" @selected(old('eventid') == $event->Id)>
                                        <?php echo e($event->Name); ?> 
                                        - 
                                        <?php if($event->dFees == 0): ?>
                                            <strong class="text-success">FREE</strong>
                                        <?php else: ?>
                                            <strong class="text-primary">₹<?php echo e(number_format($event->getActualFees(), 2)); ?></strong>
                                        <?php endif; ?>
                                        (<?php echo e($event->Regstart->format('d M Y')); ?> - <?php echo e($event->regend->format('d M Y')); ?>)
                                    </option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <option disabled>No events available for registration</option>
                                <?php endif; ?>
                            </select>
                            <?php $__errorArgs = ['eventid'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="invalid-feedback d-block">
                                    <?php echo e($message); ?>

                                </div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        <!-- Event Details Display -->
                        <div id="eventDetails" class="alert alert-info d-none" role="alert">
                            <h6 class="alert-heading mb-2">Event Details</h6>
                            <div class="row small">
                                <div class="col-md-6">
                                    <strong>Event Date:</strong> <span id="eventDateDisplay"></span>
                                </div>
                                <div class="col-md-6">
                                    <strong>Fee:</strong> <span id="eventFeeDisplay"></span>
                                </div>
                            </div>
                        </div>

                        <!-- Submit Button -->
                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-primary btn-lg">
                                <i class="fas fa-check-circle"></i> Register for Event
                            </button>
                        </div>

                    </form>
                </div>
            </div>

            <!-- Info Box -->
            <div class="alert alert-light mt-4" role="alert">
                <h6 class="alert-heading">
                    <i class="fas fa-info-circle"></i> Registration Information
                </h6>
                <p class="mb-0 small">
                    After submitting this form, you will be redirected to complete the payment process.
                    A confirmation email will be sent to you with your registration details and receipt.
                </p>
            </div>
        </div>
    </div>
</div>

<?php $__env->startPush('scripts'); ?>
<script>
    document.addEventListener('DOMContentLoaded', function() {
        const eventSelect = document.getElementById('eventid');
        const eventDetails = document.getElementById('eventDetails');
        const events = <?php echo json_encode($events->keyBy('Id')->toArray(), 15, 512) ?>;

        eventSelect.addEventListener('change', function() {
            const eventId = this.value;
            
            if (eventId && events[eventId]) {
                const event = events[eventId];
                document.getElementById('eventDateDisplay').textContent = 
                    new Date(event.EventDate).toLocaleDateString('en-IN', {
                        year: 'numeric',
                        month: 'long',
                        day: 'numeric'
                    });
                
                const fee = parseFloat(event.dFees);
                document.getElementById('eventFeeDisplay').textContent = 
                    fee === 0 ? 'FREE' : '₹' + fee.toFixed(2);
                
                eventDetails.classList.remove('d-none');
            } else {
                eventDetails.classList.add('d-none');
            }
        });
    });
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\events.rnrfit.com\resources\views/registration/create.blade.php ENDPATH**/ ?>