<?php
// Koneksi langsung tanpa require config
$host = 'localhost';
$db   = 'pendamping_sekolah';
$user = 'root';   // ganti jika berbeda
$pass = '';       // ganti jika ada password MySQL

try {
    $pdo = new PDO(
        "mysql:host=$host;dbname=$db;charset=utf8mb4",
        $user, $pass,
        [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
    );

    $hash = password_hash('Admin@2024', PASSWORD_BCRYPT, ['cost' => 12]);
    $stmt = $pdo->prepare("UPDATE users SET password = ? WHERE username = 'admin'");
    $stmt->execute([$hash]);

    echo "<h2 style='color:green'>✅ Berhasil!</h2>";
    echo "<p>Password admin sudah direset ke: <strong>Admin@2024</strong></p>";
    echo "<p><a href='modules/auth/login.php'>→ Klik di sini untuk Login</a></p>";
    echo "<hr><p style='color:red'>⚠️ Hapus file ini sekarang!</p>";

} catch (Exception $e) {
    echo "<h2 style='color:red'>❌ Error</h2>";
    echo "<p>" . $e->getMessage() . "</p>";
    echo "<p>Cek konfigurasi: host=<b>$host</b>, db=<b>$db</b>, user=<b>$user</b></p>";
}
?>