<?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: gallery.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">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">

<style>
*{
    margin:0;
    padding:0;
    box-sizing:border-box;
    font-family: 'Segoe UI', sans-serif;
}

body{
    height:100vh;
    display:flex;
    justify-content:center;
    align-items:center;
    background:linear-gradient(135deg,#0f2027,#203a43,#2c5364);
}

.login-container{
    width:380px;
    background:rgba(255,255,255,0.08);
    backdrop-filter:blur(15px);
    border-radius:15px;
    padding:40px 30px;
    box-shadow:0 0 25px rgba(0,0,0,0.5);
    text-align:center;
    animation:fadeIn 1s ease-in-out;
}

@keyframes fadeIn{
    from{opacity:0; transform:translateY(-20px);}
    to{opacity:1; transform:translateY(0);}
}

.login-container h2{
    color:#fff;
    margin-bottom:10px;
    font-weight:600;
}

.login-container p{
    color:#ccc;
    font-size:14px;
    margin-bottom:25px;
}

.input-group{
    position:relative;
    margin-bottom:20px;
}

.input-group input{
    width:100%;
    padding:12px 40px;
    border:none;
    border-radius:30px;
    outline:none;
    font-size:15px;
}

.input-group i{
    position:absolute;
    top:50%;
    left:15px;
    transform:translateY(-50%);
    color:#555;
}

.btn-login{
    width:100%;
    padding:12px;
    border:none;
    border-radius:30px;
    background:linear-gradient(45deg,#ff512f,#dd2476);
    color:#fff;
    font-size:16px;
    cursor:pointer;
    transition:0.3s;
}

.btn-login:hover{
    background:linear-gradient(45deg,#dd2476,#ff512f);
    transform:scale(1.05);
}

.error-msg{
    color:#ff4d4d;
    margin-top:15px;
    font-weight:bold;
}

.footer-text{
    margin-top:20px;
    font-size:12px;
    color:#bbb;
}
</style>

<div class="login-container">
    <h2>👑  Admin</h2>
    <p>Secure Admin Control Panel</p>

    <form method="post">
        <div class="input-group">
            <i class="fa fa-envelope"></i>
             <input type="email" name="email" class="form-control" placeholder="Enter your email" required />
        </div>

        <div class="input-group">
            <i class="fa fa-lock"></i>
             <input type="password" name="password" class="form-control" placeholder="Enter your password" required />
        </div>

        <button type="submit" name="submit" class="btn-login">
            Login Now
        </button>
    </form>

    <div class="error-msg"><?php echo $msg ?></div>

    <div class="footer-text">
        © <?php echo date('Y'); ?>  Admin Panel
    </div>
</div>

</body>
</html>