@extends('frontend.master')
@section('title', 'View Trip Register | E-Visa')
@section('content')
@php
$countries = App\Models\Country::select('id', 'name')->orderBy('name', 'asc')->get();
@endphp
@push('style')
    <style>
        .select2-container .selection .select2-selection__arrow b::after{
            display: none !important;
        }
    </style>
@endpush
<section class="credential-section">
    <div class="credential-container">
        <div class="credential-card credential-card--wide">
            <h3 class="credential-title">Create your e-Visa account</h3>

            <form action="{{ route('register') }}" method="post">
                @csrf

                @if ($errors->any())
                    <div class="credential-error">
                        <ul>
                            @foreach ($errors->all() as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                        </ul>
                    </div>
                @endif

                <!-- PERSONAL INFO -->
                <h6 class="credential-subtitle">Personal Information</h6>

                <div class="credential-grid">
                    <div class="credential-field">
                        <input type="text" name="first_name"
                               value="{{ old('first_name') }}"
                               placeholder="Your First Name" required>
                    </div>

                    <div class="credential-field">
                        <input type="text" name="last_name"
                               value="{{ old('last_name') }}"
                               placeholder="Your Last Name" required>
                    </div>
                </div>

                <div class="credential-field">
                    <select name="nationality" class="select2" required>
                        <option value="">-- Choose Nationality --</option>
                        @foreach ($countries as $country)
                            <option value="{{ $country->id }}"
                                {{ old('nationality') == $country->id ? 'selected' : '' }}>
                                {{ $country->name }}
                            </option>
                        @endforeach
                    </select>
                </div>

                <!-- LOGIN INFO -->
                <h6 class="credential-subtitle">Login Information</h6>

                <div class="credential-field">
                    <input type="email" name="email"
                           value="{{ old('email') }}"
                           placeholder="Your Email" required>
                </div>

                <div class="credential-grid">
                    <div class="credential-field">
                        <input type="password" name="password"
                               placeholder="Password" required>
                    </div>

                    <div class="credential-field">
                        <input type="password" name="password_confirmation"
                               placeholder="Repeat Password" required>
                    </div>
                </div>

                <div class="credential-footer">
                    <strong>Already have an account?</strong>
                    <a href="{{ route('login') }}">Login Now</a>
                </div>

                <button type="submit" class="credential-btn">
                    Register
                </button>
            </form>
        </div>
    </div>
</section>

@endsection
