<!DOCTYPE html>
<html lang="th">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> เข้าสู่ระบบ </title>
    <link rel="stylesheet" href="/css/login.css">
</head>
<body>
    <div class="container">
        <div class="left"></div>
        <div class="right">
            <h2>Welcome!</h2>
            <br>
            <h3>Login</h3>

            <br>
            <!--Toggle Button-->
            <div class="toggle-btn-container">
                <div class="toggle-btn">
                    <span id="switch"></span>
                    <button id="registerBtn" onclick="toggleSwitch('register')">Register</button>
                    <button id="loginBtn" class="active" onclick="toggleSwitch('login')">Login</button>
                </div>
            </div>

            <form action="/login" method="POST">
                <div class="input-group">
                    <label>Email:</label>
                    <input type="email" name="email" required>
                </div>
                <div class="input-group">
                    <label>Password:</label>
                    <input type="password" name="password" required>
                </div>
                <button type="submit" class="submit-btn">Confirm</button>
            </form>
        </div>
    </div>

    <script>
        function toggleSwitch(page) {
            const switchBtn = document.getElementById("switch");
            const loginBtn = document.getElementById("loginBtn");
            const registerBtn = document.getElementById("registerBtn");

            if (page === "register") {
                switchBtn.style.left = "0";
                loginBtn.classList.remove("active");
                registerBtn.classList.add("active");
                setTimeout(() => { window.location.href = "/register"; }, 300);
            } else {
                switchBtn.style.left = "50%";
                registerBtn.classList.remove("active");
                loginBtn.classList.add("active");
            }
        }
    </script>
</body>
</html>