<!-- Author  Raivis Rampāns
Created 12.03.2025
Editor Raivis
Modified 02.04.2025 -->

<head>
    <link rel="shortcut icon" href="../images/favicon.ico" type="image/x-icon"> <!-- Pievieno cilnei ikonu -->
</head>

<header>
    <?php include 'header.php'; ?> <!-- Pievieno klāt header.php no php mapītes -->
</header>

<body>
    <div class="container mt-5">
        <div class="row align-items-center">
            <!-- Bilde -->
            <div class="col-lg-6 text-center animate__animated animate__fadeInUp">
                <img src="../images/Register Notepad.png" class="img-fluid" alt="Register Notepad">
            </div>

            <!-- Reģistrācija -->
            <div class="col-lg-6 animate__animated animate__fadeInUp">
                <div class="p-4 shadow rounded">
                    <h2 class="fw-bold text-center">Create an Account</h2>

                    <?php if (!empty($errors)): ?>
                        <div class="alert alert-danger">
                            <?php foreach ($errors as $error) echo "<p>$error</p>"; ?>
                        </div>
                    <?php endif; ?>

                    <form action="ctrluserctrl.php" method="POST">
                        <div class="mb-3">
                            <label for="username" class="form-label">Username</label>
                            <input type="text" class="form-control" id="username" name="username" value="<?php echo isset($_SESSION['username']) ? $_SESSION['username'] : ''; ?>" required>
                        </div>
                        <div class="mb-3">
                            <label for="email" class="form-label">Email</label>
                            <input type="email" class="form-control" id="email" name="email" value="<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>" required>
                        </div>
                        <div class="mb-3">
                            <label for="password" class="form-label">Password</label>
                            <input type="password" class="form-control" id="password" name="password" required>
                        </div>
                        <div class="mb-3">
                            <label for="cpassword" class="form-label">Confirm Password</label>
                            <input type="password" class="form-control" id="cpassword" name="cpassword" required>
                        </div>
                        <button type="submit" name="signup" class="btn btn-outline-dark w-100">Register</button>
                    </form>
                    <p class="text-center mt-3">Already have an account? <a href="login.php">Login here</a></p>
                </div>
            </div>
        </div>
    </div>

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
</body>

<footer>
    <?php include 'footer.php'; ?> <!-- Pievieno klāt footer.php no php mapītes -->
</footer>