<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Daftar - TaniDesa</title>
    <link rel="stylesheet" href="{{ asset('template/admin/compiled/css/app.css') }}">
    <link rel="stylesheet" href="{{ asset('template/admin/compiled/css/auth.css') }}">
</head>

<body>
    <div id="auth">
        <div class="row h-100">
            <div class="col-lg-6 col-12 mx-auto">
                <div id="auth-left">
                    <h1 class="auth-title">Daftar.</h1>
                    <p class="auth-subtitle mb-4">Bergabunglah dengan komunitas TaniDesa.</p>

                    <form action="{{ route('register.proses') }}" method="POST">
                        @csrf
                        
                        <div class="form-group mb-3">
                            <label class="fw-bold">Saya ingin mendaftar sebagai:</label>
                            <select name="role" id="role" class="form-select" onchange="toggleForm()">
                                <option value="pembeli">Pembeli (Ingin Belanja)</option>
                                <option value="petani">Petani (Ingin Jualan)</option>
                            </select>
                        </div>

                        <div class="form-group position-relative has-icon-left mb-3">
                            <input type="text" name="nama_lengkap" class="form-control" placeholder="Nama Lengkap" required>
                            <div class="form-control-icon"><i class="bi bi-person"></i></div>
                        </div>

                        <div class="form-group position-relative has-icon-left mb-3">
                            <input type="text" name="username" class="form-control" placeholder="Username" required>
                            <div class="form-control-icon"><i class="bi bi-person-badge"></i></div>
                        </div>

                        <div class="form-group position-relative has-icon-left mb-3">
                            <input type="password" name="password" class="form-control" placeholder="Password" required>
                            <div class="form-control-icon"><i class="bi bi-shield-lock"></i></div>
                        </div>
                        
                        <div class="form-group position-relative has-icon-left mb-3">
                            <input type="number" name="no_hp" class="form-control" placeholder="No HP / WA" required>
                            <div class="form-control-icon"><i class="bi bi-telephone"></i></div>
                        </div>

                        <div class="form-group position-relative has-icon-left mb-3">
                            <textarea name="alamat" class="form-control" placeholder="Alamat Lengkap" required></textarea>
                            <div class="form-control-icon"><i class="bi bi-geo-alt"></i></div>
                        </div>

                        {{-- Input Khusus Petani (Hidden Awal) --}}
                        <div id="form-petani" style="display: none;">
                            <div class="form-group position-relative has-icon-left mb-3">
                                <input type="text" name="nama_usaha" class="form-control" placeholder="Nama Usaha / Toko Tani">
                                <div class="form-control-icon"><i class="bi bi-shop"></i></div>
                            </div>
                            <div class="alert alert-warning py-2"><small>Akun Petani butuh verifikasi Admin.</small></div>
                        </div>

                        <button class="btn btn-primary btn-block btn-lg shadow-lg mt-3">Daftar Sekarang</button>
                    </form>
                    <div class="text-center mt-4">
                        <p class="text-gray-600">Sudah punya akun? <a href="{{ route('login') }}" class="font-bold">Login</a>.</p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        function toggleForm() {
            var role = document.getElementById('role').value;
            var formPetani = document.getElementById('form-petani');
            if(role === 'petani') {
                formPetani.style.display = 'block';
            } else {
                formPetani.style.display = 'none';
            }
        }
    </script>
</body>
</html>