<?php
session_start();

$valid_users = [
    'HENDRA HOST' => password_hash('HENDRA HOST', PASSWORD_DEFAULT),
];

if (isset($_SESSION['logged_in']) && $_SESSION['logged_in']) {
    header('Location: ultimate.php');
    exit;
}

$error = '';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $username = $_POST['username'] ?? '';
    $password = $_POST['password'] ?? '';

    if (array_key_exists($username, $valid_users) && password_verify($password, $valid_users[$username])) {
        $_SESSION['logged_in'] = true;
        $_SESSION['username'] = $username; 
        header('Location: ultimate.php');
        exit;
    } else {
        $error = "Username dan password Salah";
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CREATE PANEL HENDRA HOST</title>
<link rel="icon" type="image/png" href="favicon.png">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<style>
  body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: url('https://files.catbox.moe/mbew77.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    position: relative;
    z-index: 1;
  }

  /* Overlay hitam lembut agar kontras meningkat */
  body::before {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.35);
    z-index: 0;
  }

  /* BOX LOGIN TRANSPARAN & JELAS */
  .login-form {
    width: 100%;
    max-width: 400px;
    padding: 25px;
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    box-shadow: 0px 8px 25px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 2;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
    transition: all 0.3s ease-in-out;
  }

  .login-form:hover {
    background: rgba(255, 255, 255, 0.45);
    transform: translateY(-3px);
    box-shadow: 0px 12px 35px rgba(0, 0, 0, 0.4);
  }

  .login-form h2 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 28px;
    color: #ffffff;
    font-weight: 600;
  }

  .form-group {
    position: relative;
  }

  .form-control {
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: none;
    height: 50px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.85);
    color: #000;
  }

  .form-control::placeholder {
    color: #333;
  }

  .input-group-text {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    background: rgba(255, 255, 255, 0.85);
    border: none;
  }

  .input-group-text i {
    color: #444;
  }

  .btn-primary {
    background-color: #3498db;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s ease;
    height: 50px;
  }

  .btn-primary:hover {
    background-color: #2980b9;
    transform: scale(1.03);
  }

  .error-message {
    color: #ffb3b3;
    font-size: 14px;
    text-align: center;
    margin-top: 10px;
    font-weight: 500;
    text-shadow: 0 1px 1px rgba(0,0,0,0.5);
  }

  .info-box {
    text-align: center;
    font-size: 14px;
    color: #fff;
    margin-top: 25px;
    background: rgba(0,0,0,0.3);
    padding: 12px 14px;
    border-radius: 10px;
    font-weight: 500;
    backdrop-filter: blur(4px);
  }

  .wa-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #25D366;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    margin-top: 8px;
  }

  .wa-button i {
    margin-right: 8px;
    font-size: 18px;
  }

  .wa-button:hover {
    background-color: #1ebe5d;
    transform: scale(1.05);
    color: #fff;
  }
</style>
</head>
<body>
<div class="login-form">
  <h2><i class="fas fa-user"></i> Login</h2>
  <form method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" autocomplete="off">
    <div class="form-group">
      <div class="input-group-prepend">
        <span class="input-group-text"><i class="fas fa-user"></i></span>
      </div>
      <input type="text" class="form-control" id="username" name="username" placeholder="Username" required>
    </div>
    <div class="form-group">
      <div class="input-group-prepend">
        <span class="input-group-text"><i class="fas fa-lock"></i></span>
      </div>
      <input type="password" class="form-control" id="password" name="password" placeholder="Password" required>
    </div>
    <button type="submit" class="btn btn-primary btn-block">Login</button>
    <?php if (!empty($error)): ?>
      <div class="error-message"><?php echo $error; ?></div>
    <?php endif; ?>
  </form>

  <div class="info-box">
                 ‼️PERHATIAN‼️
    JIKA ANDA BELUM MENJADI MEMBER DAN INGIN MENGAKSES PANEL NYA<br>
    SILAHKAN KLIK TOMBOL DI BAWAH INI<br>
    <a href="https://wa.me/6281356870244" target="_blank" class="wa-button">
      <i class="fab fa-whatsapp"></i> HUBUNGI ADMIN HENDRA HOST
    </a>
  </div>
</div>

<!-- Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@1.16.0/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>