@page
@model Media.JoshHeaps.Net.Pages.LoginModel
@{
    ViewData["Title"] = "Login";
    Layout = "_Layout";
}

@section Styles {
    <link rel="stylesheet" href="~/css/auth.css" asp-append-version="true" />
}

@section Scripts {
    <script src="~/js/auth.js" asp-append-version="true"></script>
}

<div class="auth-container">
    <div class="auth-card">
        <div class="auth-header">
            <h1>Welcome Back</h1>
            <p>Sign in to your account to continue</p>
        </div>

        @if (!string.IsNullOrEmpty(Model.ErrorMessage))
        {
            <div class="alert alert-danger">
                @Model.ErrorMessage
            </div>
        }

        @if (!string.IsNullOrEmpty(Model.SuccessMessage))
        {
            <div class="alert alert-success">
                @Model.SuccessMessage
            </div>
        }

        @if (!string.IsNullOrEmpty(Model.WarningMessage))
        {
            <div class="alert alert-warning">
                @Model.WarningMessage
            </div>
        }

        <form id="loginForm" method="post">
            @Html.AntiForgeryToken()
            <div class="form-group">
                <label for="email" class="form-label">Email or Username</label>
                <input type="text" class="form-control" id="email" name="email"
                       value="@Model.Email" autocomplete="username" required />
                <div class="invalid-feedback"></div>
            </div>

            <div class="form-group">
                <label for="password" class="form-label">Password</label>
                <div class="password-wrapper">
                    <input type="password" class="form-control" id="password" name="password"
                           autocomplete="current-password" required />
                    <button type="button" class="password-toggle">Show</button>
                </div>
                <div class="invalid-feedback"></div>
            </div>

            <div class="checkbox-wrapper">
                <input type="checkbox" id="rememberMe" name="rememberMe"
                       @(Model.RememberMe ? "checked" : "") />
                <label for="rememberMe">Remember me</label>
            </div>

            <button type="submit" class="btn-primary">Sign In</button>
        </form>

        <div class="auth-footer">
            <p>Don't have an account? <a href="/Register">Sign up</a></p>
        </div>
    </div>
</div>
