<?php
session_start();
include("../db.php");

if(isset($_POST['login'])){

$email=$_POST['email'];
$password=md5($_POST['password']);

$q=mysqli_query($conn,"SELECT * FROM admin WHERE username='$email' AND password='$password'");

if(mysqli_num_rows($q)){
$_SESSION['admin']=true;
header("Location:dashboard.php");
}

else{
$error="Invalid Login Details";
}

}
?>

<!DOCTYPE html>
<html>
<head>

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Radios OnAIR Admin</title>

<style>

body{
margin:0;
font-family:Arial;
background:#0f6c74;
display:flex;
align-items:center;
justify-content:center;
height:100vh;
}

.login-box{
background:#ffffff;
width:340px;
padding:35px;
border-radius:14px;
text-align:center;
box-shadow:0 10px 25px rgba(0,0,0,0.2);
}

.logo{
font-size:22px;
font-weight:bold;
color:#0f6c74;
margin-bottom:10px;
}

.subtext{
font-size:13px;
color:#777;
margin-bottom:25px;
}

.input-box{
display:flex;
align-items:center;
background:#f4f4f4;
border-radius:8px;
margin-bottom:15px;
padding:10px;
}

.input-box span{
margin-right:8px;
font-size:16px;
}

.input-box input{
border:none;
background:none;
outline:none;
width:100%;
font-size:14px;
}

button{
width:100%;
background:#0f6c74;
border:none;
color:white;
padding:12px;
border-radius:8px;
font-size:15px;
cursor:pointer;
margin-top:10px;
}

button:hover{
background:#0a5258;
}

.forgot{
font-size:12px;
margin-top:15px;
color:#666;
}

.error{
color:red;
font-size:13px;
margin-bottom:10px;
}

</style>

</head>

<body>

<div class="login-box">

<div class="logo">📻 Radios OnAIR Admin</div>

<div class="subtext">
Secure access to admin dashboard
</div>

<?php if(isset($error)){ ?>
<div class="error"><?php echo $error; ?></div>
<?php } ?>

<form method="post">

<div class="input-box">
<span>📧</span>
<input type="text" name="email" placeholder="Admin Email" required>
</div>

<div class="input-box">
<span>🔒</span>
<input type="password" name="password" placeholder="Password" required>
</div>

<button name="login">Login</button>

</form>

<div class="forgot">
Forgot Password?
</div>

</div>

</body>
</html>