<?php
session_start();
$csrf_token = bin2hex(random_bytes(32));
$_SESSION['csrf_token'] = $csrf_token;
?>

<!DOCTYPE html>
<html lang="en">

<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<title>Backoffice - AuraGaming v.1.0</title>
	<meta content='width=device-width, initial-scale=1.0, shrink-to-fit=no' name='viewport' />
	<link rel="icon" href="assets/img/aura__gaming.ico" type="image/x-icon" />

	<!-- Fonts and icons -->
	<script src="assets/js/plugin/webfont/webfont.min.js"></script>
	<script>
		WebFont.load({
			google: {
				"families": ["Public Sans:300,400,500,600,700"]
			},
			custom: {
				"families": ["Font Awesome 5 Solid", "Font Awesome 5 Regular", "Font Awesome 5 Brands", "simple-line-icons"],
				urls: ['assets/css/fonts.min.css']
			},
			active: function() {
				sessionStorage.fonts = true;
			}
		});
	</script>

	<!-- CSS Files -->
	<link rel="stylesheet" href="assets/css/bootstrap.min.css">
	<link rel="stylesheet" href="assets/css/plugins.min.css">
	<link rel="stylesheet" href="assets/css/kaiadmin.min.css">
</head>

<body class="login">
	<div class="wrapper wrapper-login wrapper-login-full p-0">
		<div class="login-aside w-50 d-flex flex-column align-items-center justify-content-center text-center bg-secondary-gradient">
			<h1 class="title fw-bold text-white mb-3">Selamat datang di portal admin kami!</h1>
			<p class="subtitle text-white op-7">Masuklah dan jadilah bagian dari kesuksesan kami!</p>
		</div>
		<div class="login-aside w-50 d-flex align-items-center justify-content-center bg-white">
			<div class="container container-login container-transparent animated fadeIn">
				<h3 class="text-center">Sign In</h3>
				<div class="login-form">
					<!-- Login Form -->
					<form method="POST" action="proses-login">
						<input type="hidden" name="csrf_token" value="<?= $csrf_token; ?>">
						<div class="form-group">
							<label for="username"><b>Username</b></label>
							<input id="username" name="username" type="text" class="form-control" required>
						</div>
						<div class="form-group">
							<label for="password"><b>Password</b></label>
							<a href="#" class="link float-end">Forget Password ?</a>
							<div class="position-relative">
								<input id="password" name="password" type="password" class="form-control" required>
								<div class="show-password">
									<i class="icon-eye"></i>
								</div>
							</div>
						</div>
						<div class="form-group form-action-d-flex mb-3">
							<div class="form-check">
								<input type="checkbox" class="form-check-input" id="rememberme">
								<label class="custom-control-label m-0" for="rememberme">Remember Me</label>
							</div>
							<button type="submit" class="btn btn-secondary col-md-5 float-end mt-3 mt-sm-0 fw-bold">Sign In</button>
						</div>
					</form>
					<!-- End of Login Form -->

					<div class="login-account">
					</div>
				</div>
			</div>

		</div>
	</div>

	<!--   Core JS Files   -->
	<script src="assets/js/core/jquery-3.7.1.min.js"></script>
	<script src="assets/js/core/popper.min.js"></script>
	<script src="assets/js/core/bootstrap.min.js"></script>
	<!-- Bootstrap Notify -->
	<script src="assets/js/plugin/bootstrap-notify/bootstrap-notify.min.js"></script>
	<!-- Sweet Alert -->
	<script src="assets/js/plugin/sweetalert/sweetalert.min.js"></script>
	<!-- Kaiadmin JS -->
	<script src="assets/js/kaiadmin.min.js"></script>

	<script>
		$(document).ready(function() {
			<?php if (isset($_SESSION['success'])): ?>
				$.notify({
					icon: 'icon-bell',
					title: 'Berhasil',
					message: '<?php echo $_SESSION['success']; ?>'
				}, {
					type: 'success',
					placement: {
						from: "top",
						align: "right"
					},
					time: 5000,
					delay: 0
				});
				<?php unset($_SESSION['success']); ?>
			<?php endif; ?>

			<?php if (isset($_SESSION['error'])): ?>
				$.notify({
					icon: 'icon-bell',
					title: 'Gagal',
					message: '<?php echo $_SESSION['error']; ?>'
				}, {
					type: 'danger',
					placement: {
						from: "top",
						align: "right"
					},
					time: 5000,
					delay: 0
				});
				<?php unset($_SESSION['error']); ?>
			<?php endif; ?>
		});
	</script>

</body>

</html>