<?php 
ob_start();
session_start();
include_once("include/functions.php");

if(!empty($_POST['email_id']))
$suc=admin_login();
?>

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="Admin login page for LMS dashboard.">
  <title>Admin Login | LMS</title>

  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css" rel="stylesheet">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
  <script src="validations.js"></script>
  
  <link rel="stylesheet" href="css/auth.css">
</head>
<body class="auth-body">
  <main class="auth-wrap">
    <section class="auth-card">
      <div class="auth-card__brand">
        <span class="brand-icon"><i class="bi bi-shield-lock-fill"></i></span>
        <div>
          <h1>LMS Admin</h1>
          <p>Secure login to access the admin dashboard</p>
        </div>
      </div>
      	
		<?php
		  if(!empty($_GET['fail']))
		  {
		 ?>
			<div class="alert alert-danger" role="alert"> <center> <strong style="color:black"> Invalid Credentials.... </strong> </center> </div>
		<?php
			}
		?> 
           
		<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data" onSubmit="return validate_login();">
       	  <div class="mb-3">
            <label class="form-label" for="firstName">Email Address</label>
            <input type="text" class="form-control" id="email_id" name="email_id"  placeholder="admin@lms.com">
            <div class="invalid-feedback">Enter Valid Email Address.</div>
          </div>

        <div class="mb-3">
          <label for="password" class="form-label">Password</label>
          <div class="input-group input-group-modern">
            <input type="password" class="form-control" id="password" name="password" placeholder="Enter Your Password" autocomplete="current-password">
            <button class="btn btn-light border-0" type="button" id="togglePassword" aria-label="Toggle password visibility">
              <i class="bi bi-eye"></i>
            </button>
            <div class="invalid-feedback">Password Required.</div>
          </div>
        </div>

        <div class="confirm-box" style="display:none">
            <div class="form-check">
                <input class="form-check-input" type="checkbox" id="confirmCheck">
                <label class="form-check-label" for="confirmCheck">
                    Remember Me
                </label>
            </div>
            <div class="confirm-error">You Must Confirm Before Login.</div>
        </div>

        <button type="submit" class="btn btn-primary w-100 auth-submit" id="loginSubmitBtn">
          <span class="btn-label">Login To Dashboard</span>
        </button>
                
      </form>
    </section>
  </main>

  <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
  <script src="js/auth.js"></script>
</body>
</html>
