<x-guest-layout>

    {{-- Session status --}}
    @if (session('status'))
        <div class="status-msg">{{ session('status') }}</div>
    @endif

    <form method="POST" action="{{ route('login') }}">
        @csrf

        {{-- School Selection --}}
        <div class="field-group">
            <label for="school">School</label>
            <select id="school" name="school" required>
                <option value="" disabled {{ (old('school') ?? request('school')) ? '' : 'selected' }}>— Select your school —</option>
                @foreach(\App\Models\School::on('central')->orderBy('name')->get() as $school)
                    @php $selected = (old('school') ?? request('school')) == $school->name ? 'selected' : '' @endphp
                    <option value="{{ $school->name }}" {{ $selected }}>
                        {{ $school->name }}
                    </option>
                @endforeach
            </select>
            @error('school')
                <div class="error-msg">{{ $message }}</div>
            @enderror
        </div>

        {{-- Email --}}
        <div class="field-group">
            <label for="email">Email address</label>
            <input
                id="email"
                type="email"
                name="email"
                value="{{ old('email') }}"
                placeholder="you@school.edu"
                required
                autocomplete="username"
            >
            @error('email')
                <div class="error-msg">{{ $message }}</div>
            @enderror
        </div>

        {{-- Password --}}
        <div class="field-group">
            <label for="password">Password</label>
            <input
                id="password"
                type="password"
                name="password"
                placeholder="••••••••"
                required
                autocomplete="current-password"
            >
            @error('password')
                <div class="error-msg">{{ $message }}</div>
            @enderror
        </div>

        <hr class="auth-divider">

        {{-- Remember Me + Forgot --}}
        <div style="display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:0.75rem;">
            <label class="remember-label" for="remember" style="text-transform:none; letter-spacing:0;">
                <input id="remember" type="checkbox" name="remember">
                <span>Remember me</span>
            </label>

            @if (Route::has('password.request'))
                <a class="link-subtle" href="{{ route('password.request') }}">
                    Forgot password?
                </a>
            @endif
        </div>

        {{-- Submit --}}
        <div style="margin-top:1.75rem;">
            <button type="submit" class="btn-primary" style="width:100%;">
                <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
                    <path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"/>
                    <polyline points="10 17 15 12 10 7"/>
                    <line x1="15" y1="12" x2="3" y2="12"/>
                </svg>
                Sign In
            </button>
        </div>
    </form>

</x-guest-layout>
