<!DOCTYPE html>
<?php
session_start();
if (isset($_SESSION['email'])) {
    header('Location: dashboard.php');
    exit;
}
?>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Halaman Login</title>
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <script src="assets/js/bootstrap.bundle.min.js"></script>
</head>

<body>
    <div class="container-fluid">
        <form class="form-login" action="send.php" method="post">
            <div class="row justify-content-center align-items-center vh-100">
                <div class="col-md-4">
                    <div class="card">
                        <div class="card-header text-center">
                            <h3>Login</h3>
                        </div>
                        <?php

                        if (isset($_SESSION['status'])) {
                            $split = explode(',', $_SESSION['status']);
                            ?>
                            <div class="alert alert-<?php echo $split[0]; ?> alert-dismissible fade show" role="alert">
                                <?php echo $split[1];
                                if (count($split) > 2) {
                                    echo ' ' . $split[2];
                                } ?>
                                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                            </div>
                            <?php
                            session_unset();
                        }
                        ?>
                        <div class="card-body">
                            <div class="mb-3">
                                <label for="email" class="form-label">Email</label>
                                <input type="email" class="form-control" name="email" placeholder="Masukkan email"
                                    required>
                            </div>
                            <div class="mb-3">
                                <label for="password" class="form-label">Password</label>
                                <input type="password" class="form-control" name="password" placeholder="Masukkan password" required>
                            </div>
                            <!-- <a href="dashboard.html" class="btn btn-primary w-100">login</a> -->
                            <button type="submit" class="btn btn-primary w-100">Login</button>
                            <p>Belum punya akun? <a href="daftar.php">daftar</a></p>
                        </div>
                    </div>
                </div>
            </div>
            <p class="text-center">&copy;2025</p>
        </form>

    </div>
</body>

</html>