<?php

$pageTitle = 'Quên mật khẩu - PET SPA';


/*
|--------------------------------------------------------------------------
| FLASH MESSAGE
|--------------------------------------------------------------------------
*/

$successMessage =
    $successMessage
    ?? ($_SESSION['flash_success'] ?? null);

$errorMessage =
    $errorMessage
    ?? ($_SESSION['flash_error'] ?? null);


unset(
    $_SESSION['flash_success'],
    $_SESSION['flash_error']
);


require BASE_PATH
    . '/app/views/layouts/header.php';

require BASE_PATH
    . '/app/views/layouts/navbar.php';

?>


<main>

<section class="auth-section">

<div class="container">

<div class="auth-card mx-auto">


    <div class="text-center mb-4">

        <div class="auth-icon">
            🐾
        </div>

        <h1 class="auth-title">
            Quên mật khẩu
        </h1>

        <p class="text-muted">
            Nhập email của tài khoản để đặt lại mật khẩu.
        </p>

    </div>



    <!-- THÀNH CÔNG -->

    <?php if (!empty($successMessage)): ?>

        <div
            class="alert alert-success"
            role="alert"
        >
            <i class="bi bi-check-circle-fill me-2"></i>

            <?= htmlspecialchars(
                $successMessage
            ) ?>
        </div>

    <?php endif; ?>



    <!-- LỖI -->

    <?php if (!empty($errorMessage)): ?>

        <div
            class="alert alert-danger"
            role="alert"
        >
            <i class="bi bi-exclamation-triangle-fill me-2"></i>

            <?= htmlspecialchars(
                $errorMessage
            ) ?>
        </div>

    <?php endif; ?>



    <!-- FORM -->

    <form
        action="<?= BASE_URL ?>/?url=forgot-password"
        method="POST"
    >

        <input
            type="hidden"
            name="_token"
            value="<?= htmlspecialchars(
                $_SESSION['csrf_token'] ?? ''
            ) ?>"
        >


        <div class="mb-4">

            <label class="form-label">
                Email *
            </label>

            <input
                type="email"
                name="email"
                class="form-control"
                maxlength="190"
                placeholder="Nhập email đã đăng ký"
                autocomplete="email"
                required
            >

        </div>


        <button
            type="submit"
            class="btn btn-primary btn-lg w-100"
        >
            <i class="bi bi-key me-2"></i>

            Đặt lại mật khẩu
        </button>

    </form>



    <p class="text-center mt-4 mb-0">

        <a
            href="<?= BASE_URL ?>/?url=login"
            class="text-decoration-none"
        >
            <i class="bi bi-arrow-left me-1"></i>
            Quay lại đăng nhập
        </a>

    </p>


</div>

</div>

</section>

</main>


<?php

require BASE_PATH
    . '/app/views/layouts/footer.php';

?>