<?php
// views/login.php

// Tampilkan pesan dari sesi
if (isset($_SESSION['error_message'])) {
    echo "<div style='color: #dc3545; background-color: #f8d7da; padding: 12px; border-radius: 6px; text-align: center; margin-bottom: 15px; font-weight: 600;'>" 
        . htmlspecialchars($_SESSION['error_message']) . "</div>";
    unset($_SESSION['error_message']);
}
if (isset($_SESSION['success_message'])) {
    echo "<div style='color: #28a745; background-color: #d4edda; padding: 12px; border-radius: 6px; text-align: center; margin-bottom: 15px; font-weight: 600;'>" 
        . htmlspecialchars($_SESSION['success_message']) . "</div>";
    unset($_SESSION['success_message']);
}
?>

<div style="max-width: 420px; margin: 60px auto; padding: 30px 25px; border-radius: 10px; background: #fff; box-shadow: 0 10px 25px rgba(0,0,0,0.1);">
    <h2 style="text-align: center; color: #222; margin-bottom: 25px;">Masuk ke Akun Anda</h2>

    <form action="index.php?hal=login_authenticate" method="POST" style="display: flex; flex-direction: column; gap: 20px;">
        <div>
            <label for="username" style="display: block; margin-bottom: 6px; font-weight: 600; color: #444;">Username</label>
            <input type="text" id="username" name="username" required placeholder="Masukkan username"
                   style="width: 100%; padding: 12px 14px; font-size: 15px; border: 1px solid #ccc; border-radius: 6px;">
        </div>

        <div>
            <label for="password" style="display: block; margin-bottom: 6px; font-weight: 600; color: #444;">Password</label>
            <input type="password" id="password" name="password" required placeholder="Masukkan password"
                   style="width: 100%; padding: 12px 14px; font-size: 15px; border: 1px solid #ccc; border-radius: 6px;">
        </div>

        <div style="text-align: right; margin-top: -10px;">
            <a href="index.php?hal=forgot_password_request" style="color: #007bff; font-size: 14px; text-decoration: none;">Lupa password?</a>
        </div>

        <button type="submit"
                style="padding: 14px; background-color: #007bff; color: white; font-size: 17px; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; transition: 0.2s;">
            Login
        </button>

        <p style="text-align: center; color: #666; font-size: 14px;">
            Belum punya akun?
            <a href="index.php?hal=register_create" style="color: #007bff; font-weight: 600; text-decoration: none;">Daftar di sini</a>
        </p>
    </form>
</div>
