<?php include_once 'header.php'; ?>

<section class="lg:bg-background-tertiary min-h-content pb-16 lg:pb-0" style="background: #5e1914;">
	<div class="container mx-auto md:py-4 lg:py-8 lg:px-3" style="background: #5e1914;">
		<div class="bg-background-default rounded-2xl p-4 lg:px-10 mx-auto md:w-4/5 lg:w-3/5" style="background: #5e1914;">
			<section class="flex justify-center rounded-full bg-separator w-full lg:w-3/5 mx-auto overflow-hidden lg:mt-3 mb-6">
				<a class="w-1/2 justify-center bg-inverse rounded-full text-primary font-semibold py-2" href="<?php echo $alamat_website . 'auth-register'; ?>">Daftar</a>
				<a class="w-1/2 justify-center opacity-70" href="<?php echo $alamat_website . 'auth-login'; ?>">Login</a>
			</section>
			<form method="POST" action="<?php echo $alamat_website . 'process_register'; ?>">
				<div class="relative mt-4 lg:mt-5 rounded-xl group border border-separator focus-within:border-primary focus-within:ring-1">
					<div class="absolute left-0 -top-4 lg:-top-[14px] mx-2 z-20">
						<label class="text-[10px] lg:text-xs opacity-70 px-1 bg-background-default rounded-full ">Username</label>
					</div>
					<div class="relative">
						<input label="Username" name="nama_pengguna_anggota" id="user_name" placeholder="6-14 Karakter Huruf Atau Angka" class="p-3 text-sm lg:text-base w-full rounded-lg border bg-transparent border-transparent focus:outline-none" type="text" required>
					</div>
				</div>
				<div class="relative mt-4 lg:mt-5 rounded-xl group border border-separator focus-within:border-primary focus-within:ring-1">
					<div class="absolute left-0 -top-4 lg:-top-[14px] mx-2 z-20">
						<label class="text-[10px] lg:text-xs opacity-70 px-1 bg-background-default rounded-full ">Password</label>
					</div>
					<div class="relative">
						<input label="Password" name="kata_sandi_anggota" placeholder="6-14 Karakter Huruf,Angka Atau Symbols" class="p-3 text-sm lg:text-base w-full rounded-lg border bg-transparent border-transparent focus:outline-none" type="password" required>
						<span class="absolute px-2 flex items-center rounded-md opacity-70 cursor-pointer right-[1px] top-[1px] bottom-[1px]">
							<svg width="20" height="20" viewbox="0 0 24 24" fill="var(--base)" xmlns="http://www.w3.org/2000/svg" size="20">
								<path fill-rule="evenodd" clip-rule="evenodd" d="M15.92 12.799a4 4 0 0 0-4.719-4.719l.923.923a3 3 0 0 1 2.873 2.873l.923.923Zm-6.527-2.285a3 3 0 0 0 4.093 4.093l.726.726a4 4 0 0 1-5.545-5.545l.726.726Z" fill="var(--base)"></path>
								<path fill-rule="evenodd" clip-rule="evenodd" d="m16.154 17.275-.735-.734c-1.064.579-2.22.959-3.419.959-1.672 0-3.262-.74-4.633-1.726-1.367-.984-2.474-2.182-3.17-3.026-.423-.515-.467-.604-.467-.748 0-.143.044-.233.468-.748.67-.812 1.72-1.953 3.018-2.915L6.5 7.623C5.17 8.63 4.104 9.793 3.426 10.616l-.059.072c-.33.399-.637.77-.637 1.312s.307.913.637 1.312l.059.072c.725.88 1.894 2.149 3.357 3.201C8.243 17.635 10.036 18.5 12 18.5c1.51 0 2.92-.511 4.154-1.225ZM9.19 6.07c.88-.35 1.824-.569 2.81-.569 1.964 0 3.758.865 5.217 1.915 1.463 1.052 2.632 2.321 3.357 3.201l.059.072c.33.399.637.77.637 1.312s-.307.913-.637 1.312l-.059.072a19.988 19.988 0 0 1-1.983 2.086l-.708-.708a18.943 18.943 0 0 0 1.92-2.014c.424-.515.467-.604.467-.748 0-.143-.043-.233-.468-.748-.695-.844-1.802-2.042-3.17-3.026C15.263 7.24 13.673 6.5 12 6.5c-.694 0-1.375.128-2.031.348l-.78-.78Z" fill="var(--base)"></path>
								<path d="m5 2 16 16" stroke="var(--base)"></path>
							</svg>
						</span>
					</div>
				</div>
				<div class="relative mt-4 lg:mt-5 rounded-xl group border border-separator focus-within:border-primary focus-within:ring-1">
					<div class="absolute left-0 -top-4 lg:-top-[14px] mx-2 z-20">
						<label class="text-[10px] lg:text-xs opacity-70 px-1 color:black">Konfirmasi Password</label>
					</div>
					<div class="relative">
						<input label="Confirm Password" placeholder="Ulangi pasword seperti Di atas" class="p-3 text-sm lg:text-base w-full rounded-lg border bg-transparent border-transparent focus:outline-none" type="password" required>
						<span class="absolute px-2 flex items-center rounded-md opacity-70 cursor-pointer right-[1px] top-[1px] bottom-[1px]">
							<svg width="20" height="20" viewbox="0 0 24 24" fill="var(--base)" xmlns="http://www.w3.org/2000/svg" size="20">
								<path fill-rule="evenodd" clip-rule="evenodd" d="M15.92 12.799a4 4 0 0 0-4.719-4.719l.923.923a3 3 0 0 1 2.873 2.873l.923.923Zm-6.527-2.285a3 3 0 0 0 4.093 4.093l.726.726a4 4 0 0 1-5.545-5.545l.726.726Z" fill="var(--base)"></path>
								<path fill-rule="evenodd" clip-rule="evenodd" d="m16.154 17.275-.735-.734c-1.064.579-2.22.959-3.419.959-1.672 0-3.262-.74-4.633-1.726-1.367-.984-2.474-2.182-3.17-3.026-.423-.515-.467-.604-.467-.748 0-.143.044-.233.468-.748.67-.812 1.72-1.953 3.018-2.915L6.5 7.623C5.17 8.63 4.104 9.793 3.426 10.616l-.059.072c-.33.399-.637.77-.637 1.312s.307.913.637 1.312l.059.072c.725.88 1.894 2.149 3.357 3.201C8.243 17.635 10.036 18.5 12 18.5c1.51 0 2.92-.511 4.154-1.225ZM9.19 6.07c.88-.35 1.824-.569 2.81-.569 1.964 0 3.758.865 5.217 1.915 1.463 1.052 2.632 2.321 3.357 3.201l.059.072c.33.399.637.77.637 1.312s-.307.913-.637 1.312l-.059.072a19.988 19.988 0 0 1-1.983 2.086l-.708-.708a18.943 18.943 0 0 0 1.92-2.014c.424-.515.467-.604.467-.748 0-.143-.043-.233-.468-.748-.695-.844-1.802-2.042-3.17-3.026C15.263 7.24 13.673 6.5 12 6.5c-.694 0-1.375.128-2.031.348l-.78-.78Z" fill="var(--base)"></path>
								<path d="m5 2 16 16" stroke="var(--base)"></path>
							</svg>
						</span>
					</div>
				</div>
				<div class="flex -mx-1">
					<div class="w-4/12 lg:w-1/4 px-1">
						<div class="relative mt-4 lg:mt-5 rounded-xl group border border-separator focus-within:border-primary focus-within:ring-1">
							<div class="absolute left-0 -top-4 lg:-top-[14px] mx-2 z-20 bg-background-default ">
								<label class="text-[10px] lg:text-xs opacity-70 px-1">Kode Negara</label>
							</div>
							<div class="relative">
								<input label="Country Code" class="p-3 text-sm lg:text-base w-full rounded-lg border bg-transparent border-transparent focus:outline-none" value="+62">
								<span class="absolute px-2 flex items-center rounded-md opacity-70 cursor-pointer right-[1px] top-[1px] bottom-[1px]">
									<svg width="24" height="24" viewbox="0 0 24 24" fill="var(--base)" xmlns="http://www.w3.org/2000/svg" size="24">
										<path d="m11.808 14.77-3.715-4.458A.8.8 0 0 1 8.708 9h6.584a.8.8 0 0 1 .614 1.312l-3.714 4.458a.25.25 0 0 1-.384 0Z" fill="var(--base)"></path>
									</svg>
								</span>
							</div>
						</div>
					</div>
					<div class="w-8/12 lg:w-3/4 px-1">
						<div class="relative mt-4 lg:mt-5 rounded-xl group border border-separator focus-within:border-primary focus-within:ring-1">
							<div class="absolute left-0 -top-4 lg:-top-[14px] mx-2 z-20"></div>
							<div class="relative">
								<input placeholder="Contoh: 8123456789" name="telepon_anggota" class="p-3 text-sm lg:text-base w-full rounded-lg border bg-transparent border-transparent focus:outline-none" type="number" required>
							</div>
						</div>
					</div>
				</div>
				<section class="my-4">
					<section class="p-3 rounded-xl cursor-pointer border border-caption relative lg:bg-background-default">
						<div class="absolute -top-2 left-2 px-1">
							<p class="text-[10px] lg:text-xs opacity-70">-- Pilih Bank Anda  --</p>
						</div>
						<div id="custom-select" class="flex items-center">
							<p id="selected-option" class="text-xs flex-auto mt-2">-- Memilih --</p>
							<div class="flex-none">
								<svg width="25" height="25" viewbox="0 0 24 24" fill="var(--base)" xmlns="http://www.w3.org/2000/svg" size="25">
									<path d="m11.808 14.77-3.715-4.458A.8.8 0 0 1 8.708 9h6.584a.8.8 0 0 1 .614 1.312l-3.714 4.458a.25.25 0 0 1-.384 0Z" fill="var(--base)"></path>
								</svg>
							</div>
						</div>
						<div id="overlay" class="lg:hidden fixed z-[1000] transition duration-500 ease-in-out w-0"></div>
						<div id="dropdown" class="fixed lg:absolute z-[9999] left-0 right-0 bottom-0 lg:bottom-[unset] lg:mt-5 overflow-hidden bg-background-secondary rounded-tl-3xl rounded-tr-3xl lg:rounded-xl transition-all duration-500 ease-out max-h-0">
							<div class="flex justify-between px-4 pt-5 mb-3 lg:hidden">
								<button id="close-dropdown" class="ml-auto">
									<svg width="24" height="24" viewbox="0 0 24 24" fill="var(--base)" xmlns="http://www.w3.org/2000/svg" size="24">
										<path d="M18 6 6 18M6 6l12 12" stroke="var(--base)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
									</svg>
								</button>
							</div>
							<div class="max-h-[70vh] lg:max-h-[30vh] px-5 pb-8 lg:pb-4 overflow-auto">
								<div class="dropdown-item border-b border-separator last:border-transparent py-3 hover:lg:bg-background-tertiary transition duration-300 ease-in-out">
									<p class="text-sm px-1">BCA</p>
								</div>
								<div class="dropdown-item border-b border-separator last:border-transparent py-3 hover:lg:bg-background-tertiary transition duration-300 ease-in-out">
									<p class="text-sm px-1">BNI</p>
								</div>
								<div class="dropdown-item border-b border-separator last:border-transparent py-3 hover:lg:bg-background-tertiary transition duration-300 ease-in-out">
									<p class="text-sm px-1">BRI</p>
								</div>
								<div class="dropdown-item border-b border-separator last:border-transparent py-3 hover:lg:bg-background-tertiary transition duration-300 ease-in-out">
									<p class="text-sm px-1">BSI</p>
								</div>
								<div class="dropdown-item border-b border-separator last:border-transparent py-3 hover:lg:bg-background-tertiary transition duration-300 ease-in-out">
									<p class="text-sm px-1">CIMB Niaga</p>
								</div>
								<div class="dropdown-item border-b border-separator last:border-transparent py-3 hover:lg:bg-background-tertiary transition duration-300 ease-in-out">
									<p class="text-sm px-1">DANA</p>
								</div>
								<div class="dropdown-item border-b border-separator last:border-transparent py-3 hover:lg:bg-background-tertiary transition duration-300 ease-in-out">
									<p class="text-sm px-1">OVO</p>
								</div>
								<div class="dropdown-item border-b border-separator last:border-transparent py-3 hover:lg:bg-background-tertiary transition duration-300 ease-in-out">
									<p class="text-sm px-1">GOPAY</p>
								</div>
								<div class="dropdown-item border-b border-separator last:border-transparent py-3 hover:lg:bg-background-tertiary transition duration-300 ease-in-out">
									<p class="text-sm px-1">JENIUS</p>
								</div>
								<div class="dropdown-item border-b border-separator last:border-transparent py-3 hover:lg:bg-background-tertiary transition duration-300 ease-in-out">
									<p class="text-sm px-1">LINKAJA</p>
								</div>
								<div class="dropdown-item border-b border-separator last:border-transparent py-3 hover:lg:bg-background-tertiary transition duration-300 ease-in-out">
									<p class="text-sm px-1">Bank Mandiri</p>
								</div>
								<div class="dropdown-item border-b border-separator last:border-transparent py-3 hover:lg:bg-background-tertiary transition duration-300 ease-in-out">
									<p class="text-sm px-1">Maybank</p>
								</div>
								<div class="dropdown-item border-b border-separator last:border-transparent py-3 hover:lg:bg-background-tertiary transition duration-300 ease-in-out">
									<p class="text-sm px-1">MEGA</p>
								</div>
								<div class="dropdown-item border-b border-separator last:border-transparent py-3 hover:lg:bg-background-tertiary transition duration-300 ease-in-out">
									<p class="text-sm px-1">PANIN</p>
								</div>
								<div class="dropdown-item border-b border-separator last:border-transparent py-3 hover:lg:bg-background-tertiary transition duration-300 ease-in-out">
									<p class="text-sm px-1">Bank Permata</p>
								</div>
								<div class="dropdown-item border-b border-separator last:border-transparent py-3 hover:lg:bg-background-tertiary transition duration-300 ease-in-out">
									<p class="text-sm px-1">KOSPIN-PERMATA</p>
								</div>
								<div class="dropdown-item border-b border-separator last:border-transparent py-3 hover:lg:bg-background-tertiary transition duration-300 ease-in-out">
									<p class="text-sm px-1">SINARMAS</p>
								</div>
							</div>
						</div>
						<!-- Hidden input for bank_anggota -->
						<input type="hidden" name="bank_anggota" id="bank_anggota" required>
					</section>
				</section>
				<div class="relative mt-4 lg:mt-5 rounded-xl group border border-separator focus-within:border-primary focus-within:ring-1">
					<div class="absolute left-0 -top-4 lg:-top-[14px] mx-2 z-20 bg-background-default ">
						<label class="text-[10px] lg:text-xs opacity-70 px-1">Nama Lengkap sesuai Rekening Bank</label>
					</div>
					<div class="relative">
						<input placeholder="Nama Akun Bank" name="nama_rekening_anggota" label="Nama Lengkap sesuai Rekening Bank" class="p-3 text-sm lg:text-base w-full rounded-lg border bg-transparent border-transparent focus:outline-none" type="text" required>
					</div>
				</div>
				<div class="relative mt-4 lg:mt-5 rounded-xl group border border-separator focus-within:border-primary focus-within:ring-1">
					<div class="absolute left-0 -top-4 lg:-top-[14px] mx-2 z-20 bg-background-default ">
						<label class="text-[10px] lg:text-xs opacity-70 px-1">Nomor Lengkap sesuai Rekening Bank</label>
                        </div>
					<div class="relative">
						<input placeholder="Nomor Rekening" name="nomor_rekening_anggota" label="Nomor Rekening" class="p-3 text-sm lg:text-base w-full rounded-lg border bg-transparent border-transparent focus:outline-none" type="number" required>
					</div>
				</div>
				<div class="relative mt-4 lg:mt-5 rounded-xl group border border-separator focus-within:border-primary focus-within:ring-1">
					<div class="absolute left-0 -top-4 lg:-top-[14px] mx-2 z-20 bg-background-default ">
						<label class="text-[10px] lg:text-xs opacity-70 px-1 bg-background-default rounded-full ">Email</label>
					</div>
					<div class="relative">
						<input label="Email" name="email_anggota" placeholder="Masukkan alamat email Anda" class="p-3 text-sm lg:text-base w-full rounded-lg border bg-transparent border-transparent focus:outline-none" type="email" required>
					</div>
				</div>


			<div class="relative mt-4 lg:mt-5 rounded-xl group border border-separator focus-within:border-primary focus-within:ring-1">
    <div class="absolute left-0 -top-4 lg:-top-[14px] mx-2 z-20 bg-background-default">
        <label for="upline" class="text-[10px] lg:text-xs opacity-70 px-1">Kode Referensi (Opsional)</label>
    </div>
    <div class="relative">
        <input id="upline" name="upline" placeholder="Enter referral code" class="p-3 text-sm lg:text-base w-full rounded-lg border bg-transparent border-transparent focus:outline-none" type="text" value="<?php echo isset($_GET['refferal']) ? htmlspecialchars($_GET['refferal']) : ''; ?>" readonly>
    </div>
</div>

				<p class="mt-6 mb-8 text-xs lg:text-sm lg:text-center">
                Dengan masuk atau mendaftar, Anda menyetujui <a target="_blank" class="text-error inline-block">syarat dan Ketentuan</a>
				</p>
				<div class="flex justify-center my-4">
					<button type="submit" aria-label="Button Registration Form" aria-labelledby="Button Registration Form" class="bg-primary lg:hover:brightness-95 text-white rounded-xl text-sm lg:text-base font-semibold w-full lg:w-1/2 justify-center py-3">Daftar</button>
				</div>
			</form>
		</div>
	</div>
</section>
<?php include_once 'footer.php'; ?>
<style>
	.open {
		max-height: 500px;
		/* Set a large enough max-height for the dropdown when open */
		transition: max-height 0.5s ease-in-out;
	}

	.w-0 {
		width: 0;
	}

	.w-full {
		width: 100%;
	}
</style>
<script>
	document.addEventListener('DOMContentLoaded', function() {
		const customSelect = document.getElementById('custom-select');
		const dropdown = document.getElementById('dropdown');
		const overlay = document.getElementById('overlay');
		const selectedOption = document.getElementById('selected-option');
		const bankAnggotaInput = document.getElementById('bank_anggota');
		const closeDropdown = document.getElementById('close-dropdown');
		const dropdownItems = document.querySelectorAll('.dropdown-item');

		customSelect.addEventListener('click', function() {
			dropdown.classList.toggle('open');
			overlay.classList.toggle('w-0');
			overlay.classList.toggle('w-full');
		});

		closeDropdown.addEventListener('click', function(e) {
			e.stopPropagation();
			dropdown.classList.remove('open');
			overlay.classList.add('w-0');
			overlay.classList.remove('w-full');
		});

		dropdownItems.forEach(item => {
			item.addEventListener('click', function() {
				const trimmedText = this.textContent.trim();
				selectedOption.textContent = trimmedText;
				bankAnggotaInput.value = trimmedText;
				dropdown.classList.remove('open');
				overlay.classList.add('w-0');
				overlay.classList.remove('w-full');
			});
		});

		document.addEventListener('click', function(e) {
			if (!customSelect.contains(e.target) && !dropdown.contains(e.target)) {
				dropdown.classList.remove('open');
				overlay.classList.add('w-0');
				overlay.classList.remove('w-full');
			}
		});
	});
</script>
