<?php
require ("../dbconnect.php");

$msg = "";
if(isset($_POST['submit'])){
    $email = mysqli_real_escape_string($con,$_POST['email']);   
    $password = mysqli_real_escape_string($con,$_POST['password']);
    $sql = "select * from admin_users where email = '$email' and password = '$password'";
    $res = mysqli_query($con,$sql);
    $count = mysqli_num_rows($res);
    if($count>0){
      $_SESSION['ADMIN_LOGIN']='yes';
      $_SESSION['ADMIN_EMAIL']=$email;
      header("location: check.php");
      die();
    }else{
      $msg = "Please enter valid login details";
    }   
}

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Admin Login</title>
    <link rel="stylesheet" href="../css/bootstrap.css">
    <link rel="stylesheet" href="../css/font-awesome.min.css">
    <style>
        /* Global Styles */
        body {
            margin: 0;
            padding: 0;
            background-image: url('../img/reback.jpg'); /* Path to your image */
            background-size: cover;
            background-position: center;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            font-family: 'Roboto', sans-serif;
        }

        .login-box {
            background-color: rgba(0, 0, 0, 0.5); /* Transparent background */
            padding: 30px 40px;
            box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.3);
            border-radius: 10px;
            max-width: 400px;
            width: 100%;
        }

        h2 {
            color: #fff;
            text-align: center;
            margin-bottom: 20px;
            font-size: 24px;
        }

        .form-group label {
            font-size: 16px;
            color: #fff;
        }

        .form-control {
            border-radius: 25px;
            padding: 15px;
            border: 2px solid #ddd;
            font-size: 16px;
            margin-bottom: 15px;
        }

        .btn-primary {
            width: 100%;
            background: linear-gradient(45deg, #0066cc, #0052cc);
            color: #fff;
            border: none;
            border-radius: 25px;
            padding: 12px;
            font-size: 18px;
            cursor: pointer;
        }

        .btn-primary:hover {
            background: linear-gradient(45deg, #0052cc, #003c99);
        }

        .text-danger {
            color: red;
            text-align: center;
            font-weight: bold;
            margin-top: 10px;
        }

        .fa-fw {
            margin-right: 10px;
        }

        /* Responsive */
        @media (max-width: 480px) {
            .login-box {
                width: 90%;
                padding: 20px;
            }
        }

    </style>
</head>
<body>

<div class="login-box">
    <h2>Admin Login</h2>
    <form action="" method="post">
        <div class="form-group">
            <label><i class="fa fa-user fa-fw"></i>Email *</label>
            <input type="email" name="email" class="form-control" placeholder="Enter your email" required />
        </div>

        <div class="form-group">
            <label><i class="fa fa-lock fa-fw"></i>Password *</label>
            <input type="password" name="password" class="form-control" placeholder="Enter your password" required />
        </div>

        <button type="submit" name="submit" class="btn btn-primary">
            Login
        </button>
    </form>
    <div class="text-danger"><?php echo $msg ?></div>
</div>

</body>
</html>