@model LoginViewModel
@{
    ViewData["Title"] = "Login";
    if (Model.IsCompanionLogin)
    {
        Layout = null;
    }
}

@if (Model.IsCompanionLogin)
{
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Word Companion Login - PlotDirector</title>
        <link rel="stylesheet" href="~/css/word-companion.css" asp-append-version="true" />
    </head>
    <body class="word-companion-login-body">
        <main class="word-companion-login-shell">
            <header class="word-companion-login-header">
                <h1>PlotDirector</h1>
                <p>Word Companion</p>
            </header>

            @if (TempData["AuthMessage"] is string authMessage)
            {
                <div class="word-companion-login-alert">@authMessage</div>
            }

            <section class="word-companion-login-card">
                <form asp-action="Login" method="post" class="word-companion-login-form">
                    <input asp-for="ReturnUrl" type="hidden" />
                    <input asp-for="IsCompanionLogin" type="hidden" />
                    <div asp-validation-summary="ModelOnly" class="word-companion-login-validation"></div>

                    <div>
                        <label asp-for="Email">Email address</label>
                        <input asp-for="Email" autocomplete="email" />
                        <span asp-validation-for="Email"></span>
                    </div>
                    <div>
                        <label asp-for="Password">Password</label>
                        <input asp-for="Password" autocomplete="current-password" />
                        <span asp-validation-for="Password"></span>
                    </div>
                    <label class="word-companion-login-check">
                        <input asp-for="RememberMe" />
                        <span>Remember me</span>
                    </label>

                    <button type="submit">Login</button>
                    <div class="word-companion-login-links">
                        <a asp-action="Register">Create account</a>
                        <a asp-action="ForgotPassword">Forgot password?</a>
                        <a asp-action="ResendVerificationEmail">Need a new verification email?</a>
                    </div>
                </form>
            </section>
        </main>
    </body>
    </html>
}
else
{
    <div class="page-heading compact auth-page-heading">
        <div>
            <p class="eyebrow">Account</p>
            <h1>Login</h1>
            <p class="lead-text">Sign in to PlotDirector.</p>
        </div>
    </div>

    @if (TempData["AuthMessage"] is string authMessage)
    {
        <div class="alert alert-info">@authMessage</div>
    }

    <section class="edit-panel auth-card">
        <form asp-action="Login" method="post" class="asset-create-form auth-form">
            <input asp-for="ReturnUrl" type="hidden" />
            <input asp-for="IsCompanionLogin" type="hidden" />
            <div asp-validation-summary="ModelOnly" class="alert alert-warning"></div>

            <div class="auth-field-stack">
                <div>
                    <label class="form-label" asp-for="Email">Email address</label>
                    <input class="form-control" asp-for="Email" autocomplete="email" />
                    <span class="text-danger" asp-validation-for="Email"></span>
                </div>
                <div>
                    <label class="form-label" asp-for="Password">Password</label>
                    <input class="form-control" asp-for="Password" autocomplete="current-password" />
                    <span class="text-danger" asp-validation-for="Password"></span>
                </div>
                <div>
                    <label class="form-check">
                        <input class="form-check-input" asp-for="RememberMe" />
                        <span class="form-check-label">Remember me</span>
                    </label>
                </div>
            </div>

            <div class="auth-actions">
                <button class="btn btn-primary" type="submit">Login</button>
                <a class="btn btn-outline-secondary" asp-action="Register">Create an account</a>
                <a class="btn btn-outline-secondary" asp-action="ForgotPassword">Forgot password?</a>
            </div>
            <p class="auth-help">
                <a asp-action="ResendVerificationEmail">Need a new verification email?</a>
            </p>
        </form>
    </section>
}

@if (!Model.IsCompanionLogin)
{
    @section Scripts {
        <partial name="_ValidationScriptsPartial" />
    }
}
