@extends(theme()->layout())

@section('content')

    <section class="breadcrumb-section pt-0">
        <div class="container-fluid-lg">
            <div class="row">
                <div class="col-12">
                    <div class="breadcrumb-contain">
                        <h1>{{ __('template.welcome_back') }}</h1>
                        <nav>
                            <ol class="breadcrumb mb-0">
                                <li class="breadcrumb-item">
                                    <a href="/">
                                        <i class="fa-solid fa-house"></i>
                                    </a>
                                </li>
                                <li class="breadcrumb-item active">{{ __('template.welcome_back') }}</li>
                            </ol>
                        </nav>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- log in section start -->
    <section class="floral-auth-section">
        <div class="floral-auth-container">
            <!-- Left Panel - Illustration -->
            <div class="floral-auth-left-panel">
                <div class="floral-auth-shape floral-auth-shape-1"></div>
                <div class="floral-auth-shape floral-auth-shape-2"></div>
                <div class="floral-auth-shape floral-auth-shape-3"></div>

                <div class="floral-auth-illustration">
                    <img src="{{ theme()->publicPath('images/auth/floral-logo.svg') }}" alt="Florial" class="floral-auth-logo">

                    <h2>{{ __('template.welcome_back') }}</h2>
                    <p>{{ __('template.login_description') }}</p>
                </div>
            </div>

            <!-- Right Panel - Form -->
            <div class="floral-auth-right-panel">
                <div class="floral-auth-form-wrapper">
                    <div class="floral-auth-header">
                        <h1>{{ __('template.welcome_message') }}</h1>
                        <p>{{ __('auth.login_to_you_account') }}</p>
                    </div>

                    @error('email')
                    @if(session('unverified_email'))
                        <div class="floral-auth-error">{{ $message }}</div>

                        @php
                            $user = ViartasCore\Auth\Models\User::where('email', session('unverified_email'))->first();
                            $hash = $user ? md5($user->id . '.' . $user->email . '.' . $user->created_at->format('Y-m-d H:i:s')) : null;
                        @endphp

                        <form method="POST" action="{{ app_route(Viartas::driver()->app()->current()->tag.'.verification.resend', ['hash' => $hash]) }}" class="d-inline">
                            @csrf
                            <input type="hidden" name="email" value="{{ session('unverified_email') }}">
                            <button type="submit" class="floral-auth-btn mb-4">
                                {{ __('auth.click_here_to_request_another') }}
                            </button>
                        </form>
                    @endif
                    @enderror

                    @if (session('resent'))
                        <div class="floral-auth-alert floral-auth-alert-success mb-4">
                            {{ __('auth.a_fresh_verification_link_has_been_sent_to_your_email_address') }}
                        </div>
                    @endif

                    <form method="POST" action="{{ app_route('accounting.login.index') }}">
                        @csrf

                        <div class="floral-auth-form-group">
                            <label class="floral-auth-label" for="email">{{ __('auth.email') }}</label>
                            <input type="email"
                                   class="floral-auth-input @error('email') is-invalid @enderror"
                                   id="email"
                                   name="email"
                                   value="{{ old('email') }}"
                                   placeholder="{{ __('auth.email') }}">
                            @error('email')
                            <div class="floral-auth-error">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="floral-auth-form-group">
                            <label class="floral-auth-label" for="password">{{ __('auth.password') }}</label>
                            <input type="password"
                                   class="floral-auth-input @error('password') is-invalid @enderror"
                                   id="password"
                                   name="password"
                                   placeholder="{{ __('auth.password') }}">
                            @error('password')
                            <div class="floral-auth-error">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="floral-auth-options">
                            <div class="floral-auth-checkbox">
                                <input type="checkbox" id="remember" name="remember">
                                <label for="remember">{{ __('auth.remember_me') }}</label>
                            </div>
                            <a href="{{ app_route('web.password.request') }}" class="floral-auth-link">{{ __('auth.forgot_password') }}</a>
                        </div>

                        <button type="submit" class="floral-auth-btn">
                            {{ __('auth.login') }}
                        </button>
                    </form>

                    <div class="floral-auth-divider"></div>

                    <div class="floral-auth-footer">
                        <span>{{ __('auth.dont_have_account') }}</span>
                        <a href="{{ app_route('web.register.index') }}">{{ __('auth.sign_up') }}</a>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!-- log in section end -->
@endsection
