@extends('layouts.app')

@section('title', 'Two-factor verification')

@section('content')
    <div class="app-content content">
        <div class="content-wrapper">
            <div class="content-body">
                <div class="auth-wrapper auth-basic px-2">
                    <div class="auth-inner my-2">
                        <div class="card mb-0">
                            <div class="card-body">
                                <a href="{{ route('home') }}" class="brand-logo loot-auth-brand">
                                    @if(brand_logo())
                                        <img src="{{ Storage::url(brand_logo()) }}" alt="{{ brand_name() }}">
                                    @else
                                        <span class="loot-brand"><span class="loot-brand-mark">{{ brand_mark() }}</span>{{ brand_name() }}</span>
                                    @endif
                                </a>

                                <h4 class="card-title mb-1">Two-factor verification</h4>
                                <p class="card-text mb-2">
                                    @if($method === 'email')
                                        We emailed a 6-digit code to your address. Enter it below to finish signing in.
                                    @else
                                        Open your authenticator app and enter the current 6-digit code for {{ brand_name() }}.
                                    @endif
                                </p>

                                @if(session('success'))
                                    <div class="alert alert-success"><div class="alert-body">{{ session('success') }}</div></div>
                                @endif

                                <form method="POST" action="{{ route('two-factor.verify') }}" class="mt-2">
                                    @csrf
                                    <div class="mb-1">
                                        <label for="code" class="form-label">Verification code</label>
                                        <input type="text" inputmode="numeric" autocomplete="one-time-code"
                                               class="form-control form-control-lg text-center @error('code') is-invalid @enderror"
                                               id="code" name="code" placeholder="000000" maxlength="6"
                                               style="letter-spacing:6px; font-weight:800;" autofocus required>
                                        @error('code')
                                            <span class="invalid-feedback" role="alert"><strong>{{ $message }}</strong></span>
                                        @enderror
                                    </div>
                                    <button class="btn btn-success w-100" type="submit">Verify &amp; sign in</button>
                                </form>

                                @if($method === 'email')
                                    <form method="POST" action="{{ route('two-factor.resend') }}" class="mt-1">
                                        @csrf
                                        <button class="btn btn-outline-secondary w-100" type="submit">Resend code</button>
                                    </form>
                                @endif

                                <p class="text-center mt-2">
                                    <a href="{{ route('login') }}">Back to sign in</a>
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
