<?php include '../config/koneksi.php'; session_start(); ?>
<?php
if(isset($_POST['login'])){
    $username = mysqli_real_escape_string($conn, $_POST['username']);
    $password = $_POST['password'];
    $q = mysqli_query($conn, "SELECT * FROM admin WHERE username='$username'");
    if($a = mysqli_fetch_assoc($q)){
        // Ubah: cek password langsung tanpa hash
        if($password == $a['password']){
            $_SESSION['admin_id'] = $a['id'];
            $_SESSION['admin_user'] = $a['username'];
            header('Location: index.php'); exit;
        } else {
            echo '<div class="alert" style="background:#f8d7da;color:#721c24;">Password salah!</div>';
        }
    } else {
        echo '<div class="alert" style="background:#f8d7da;color:#721c24;">Username tidak ditemukan!</div>';
    }
}
?>
<!DOCTYPE html>
<html>
<head>
    <title>Login Admin - Ang Mansion</title>
    <link rel="stylesheet" type="text/css" href="style_admin.css">
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@600;700&display=swap');
        body {
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            background: linear-gradient(135deg, #3a5eff 0%, #1e2a78 100%);
            font-family: 'Montserrat', Arial, sans-serif;
        }
        .header {
            background: #6ea0ff;
            color: #fff;
            padding: 0 0 0 0;
            display: flex;
            align-items: center;
            justify-content: space-between;
            height: 70px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        }
        .logo {
            display: flex;
            align-items: center;
            font-size: 1.5em;
            font-weight: bold;
            margin-left: 30px;
            letter-spacing: 2px;
        }
        .login-container {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .box {
            background: rgba(255,255,255,0.95);
            border: 2px solid #c00;
            border-radius: 16px;
            padding: 30px 32px 32px 32px;
            box-shadow: 0 2px 16px rgba(0,0,0,0.08);
            min-width: 340px;
        }
        .btn {
            background: #c00;
            color: #fff;
            border: none;
            padding: 12px 0;
            border-radius: 6px;
            font-weight: 700;
            font-size: 1.1em;
            cursor: pointer;
            transition: background 0.2s;
        }
        .btn:hover {
            background: #1e2a78;
        }
        input {
            padding: 10px;
            font-size: 1.1em;
            border-radius: 6px;
            border: 1px solid #b0b0b0;
        }
        h2 {
            color: #1e2a78;
            text-align: center;
            margin-bottom: 18px;
        }
    </style>
</head>
<body>
    <div class="header">
        <div class="logo">
            <img src="../assets/images/LogoAngMansion-Putih.png" alt="Logo" style="height:38px;margin-right:10px;"> ANG MANSION
        </div>
        <div style="margin-right:30px;font-size:1.1em;font-weight:600;">Admin Panel</div>
    </div>
    <div class="login-container">
        <div class="box">
            <h2>Login Admin</h2>
            <form method="post" style="display:flex;flex-direction:column;gap:12px;">
                <input type="text" name="username" placeholder="Username" required>
                <input type="password" name="password" placeholder="Password" required>
                <button type="submit" name="login" class="btn">Login</button>
            </form>
        </div>
    </div>
</body>
</html> 