<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Daftar - Aplikasi Administrasi Akademik</title>
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #f4f4f4;
            font-family: Arial, sans-serif;
        }
        .container {
            margin-top: 50px;
        }
        .form-container {
            background-color: #fff;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        }
        .btn-custom {
            background-color: #28a745;
            color: white;
        }
        .btn-custom:hover {
            background-color: #218838;
        }
    </style>
</head>
<body>

    <div class="container">
        <h2 class="text-center mb-4">Pendaftaran Akun</h2>
        <div class="row justify-content-center">
            <div class="col-md-6">
                <div class="form-container">
                    <form action="proses_daftar.php" method="POST" onsubmit="return validateForm()">
                        <div class="form-group">
                            <label for="nama">Nama Lengkap</label>
                            <input type="text" class="form-control" id="nama" name="nama" placeholder="Masukkan nama lengkap" required aria-required="true">
                        </div>
                        <div class="form-group">
                            <label for="email">Email</label>
                            <input type="email" class="form-control" id="email" name="email" placeholder="Masukkan email" required aria-required="true">
                        </div>
                        <div class="form-group">
                            <label for="password">Kata Sandi</label>
                            <input type="password" class="form-control" id="password" name="password" placeholder="Masukkan kata sandi" required aria-required="true">
                        </div>
                        <div class="form-group">
                            <label for="confirm_password">Konfirmasi Kata Sandi</label>
                            <input type="password" class="form-control" id="confirm_password" name="confirm_password" placeholder="Konfirmasi kata sandi" required aria-required="true">
                        </div>
                        <div id="error_message" class="text-danger mb-3" style="display: none;">Kata sandi dan konfirmasi kata sandi tidak cocok.</div>
                        
                        <!-- Pilihan Role -->
                        <div class="form-group">
                            <label for="role">Peran</label>
                            <select class="form-control" id="role" name="role" required>
                                <option value="teknisi">teknisi</option>
                                <option value="pelanggan">pelanggan</option>
                            </select>
                        </div>
                        
                        <button type="submit" class="btn btn-custom btn-block">Daftar</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <footer class="text-center mt-5">
        <p>&copy; 2024 Universitas Jabal Ghafur. All rights reserved.</p>
    </footer>

    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
    <script>
        // Validasi form untuk memastikan password dan konfirmasi password cocok
        function validateForm() {
            const password = document.getElementById('password').value;
            const confirmPassword = document.getElementById('confirm_password').value;

            if (password !== confirmPassword) {
                document.getElementById('error_message').style.display = 'block';
                return false;
            }
            document.getElementById('error_message').style.display = 'none';
            return true;
        }
    </script>
</body>
</html>
