@extends('layouts.auth')

@section('title', 'Register')

@section('content')
    <h2 class="auth-title">REGISTER</h2>

    @if (session('error'))
        <div class="alert alert-danger">
            {{ session('error') }}
        </div>
    @endif

    <form method="POST" action="{{ route('register') }}">
        @csrf

        <div class="mb-3">
            <input type="text" class="form-control @error('name') is-invalid @enderror" 
                placeholder="Masukkan Nama Anda" name="name" value="{{ old('name') }}" required autofocus>
            @error('name')
                <span class="invalid-feedback" role="alert">
                    <strong>{{ $message }}</strong>
                </span>
            @enderror
        </div>

        <div class="mb-3">
            <input type="email" class="form-control @error('email') is-invalid @enderror" 
                placeholder="Masukkan Email Anda" name="email" value="{{ old('email') }}" required>
            @error('email')
                <span class="invalid-feedback" role="alert">
                    <strong>{{ $message }}</strong>
                </span>
            @enderror
        </div>

        <div class="mb-3">
            <input type="text" class="form-control @error('phone') is-invalid @enderror" 
                placeholder="Masukkan Nomor HP Anda" name="phone" value="{{ old('phone') }}" 
                required oninput="this.value = this.value.replace(/[^0-9]/g, '')" maxlength="15">
            @error('phone')
                <span class="invalid-feedback" role="alert">
                    <strong>{{ $message }}</strong>
                </span>
            @enderror
        </div>

        {{-- <div class="mb-3">
            <label class="d-block mb-2">Jenis Kelamin</label>
            <div class="d-flex">
                <div class="form-check me-3">
                    <input class="form-check-input" type="radio" name="gender" id="laki" value="Laki-laki" {{ old('gender') == 'Laki-laki' ? 'checked' : '' }}>
                    <label class="form-check-label" for="laki">Laki-laki</label>
                </div>
                <div class="form-check">
                    <input class="form-check-input" type="radio" name="gender" id="perempuan" value="Perempuan" {{ old('gender') == 'Perempuan' ? 'checked' : '' }}>
                    <label class="form-check-label" for="perempuan">Perempuan</label>
                </div>
            </div>
            @error('gender')
                <span class="invalid-feedback d-block" role="alert">
                    <strong>{{ $message }}</strong>
                </span>
            @enderror
        </div> --}}

        <div class="mb-3">
            <input type="text" class="form-control @error('business_name') is-invalid @enderror" 
                placeholder="Masukkan Nama Badan Usaha" name="business_name" value="{{ old('business_name') }}" required>
            @error('business_name')
                <span class="invalid-feedback" role="alert">
                    <strong>{{ $message }}</strong>
                </span>
            @enderror
        </div>

        <div class="mb-3">
            <textarea class="form-control @error('business_address') is-invalid @enderror" 
                placeholder="Masukkan Alamat Badan Usaha" name="business_address" required>{{ old('business_address') }}</textarea>
            @error('business_address')
                <span class="invalid-feedback" role="alert">
                    <strong>{{ $message }}</strong>
                </span>
            @enderror
        </div>

        <div class="mb-3 position-relative">
            <input type="password" class="form-control @error('password') is-invalid @enderror" 
                placeholder="Masukkan Password" name="password" id="password" required>
            <span class="position-absolute top-50 end-0 translate-middle-y me-2 password-toggle" 
                  onclick="togglePassword('password')" style="cursor: pointer;">
                <i class="bi bi-eye-slash" id="password-icon"></i>
            </span>
            @error('password')
                <span class="invalid-feedback" role="alert">
                    <strong>{{ $message }}</strong>
                </span>
            @enderror
        </div>

        <div class="mb-3 position-relative">
            <input type="password" class="form-control" 
                placeholder="Konfirmasi Password" name="password_confirmation" id="password_confirmation" required>
            <span class="position-absolute top-50 end-0 translate-middle-y me-2 password-toggle" 
                  onclick="togglePassword('password_confirmation')" style="cursor: pointer;">
                <i class="bi bi-eye-slash" id="password_confirmation-icon"></i>
            </span>
        </div>

        <button type="submit" class="btn btn-auth">REGISTER</button>
    </form>

    <div class="auth-footer">
        Sudah Punya akun? <a href="{{ route('login') }}">Login</a>
    </div>
@endsection 