@extends('layouts.auth')

@section('title', 'Register Admin')

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

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

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

        <div class="mb-3">
            <input type="text" class="form-control @error('name') is-invalid @enderror" 
                placeholder="Masukkan Nama Admin" 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 Admin" 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 Admin" name="phone" value="{{ old('phone') }}" required>
            @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="password" class="form-control @error('password') is-invalid @enderror" 
                placeholder="Masukkan Password" name="password" required>
            @error('password')
                <span class="invalid-feedback" role="alert">
                    <strong>{{ $message }}</strong>
                </span>
            @enderror
        </div>

        <div class="mb-3">
            <input type="password" class="form-control" 
                placeholder="Konfirmasi Password" name="password_confirmation" required>
        </div>

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

    <div class="auth-footer">
        <a href="{{ route('admin.users') }}">Kembali ke Daftar Admin</a>
    </div>
@endsection 