@extends('admin.layouts.app')

@section('title', __('dashboard.create_admin'))

@section('content')
<x-admin.page-header :title="__('dashboard.create_admin')" :breadcrumbs="[__('models.admins') => route('admin.admins.index'), __('models.create') => '']" />

<div class="row">
    <div class="col-lg-12">
        <form action="{{ route('admin.admins.store') }}" method="POST" enctype="multipart/form-data" class="ajax-form">
            @csrf

            <div class="row">
                <!-- Admin Info -->
                <div class="col-lg-8">
                    <div class="card">
                        <div class="card-header">
                            <h5 class="card-title mb-0">{{ __('dashboard.admin_information') }}</h5>
                        </div>
                        <div class="card-body">
                            <div class="row">
                                <div class="col-md-6">
                                    <x-admin.form-input
                                        :label="__('dashboard.name')"
                                        name="name"
                                        :placeholder="__('dashboard.enter_name')"
                                        :required="true"
                                    />
                                </div>
                                <div class="col-md-6">
                                    <x-admin.form-input
                                        :label="__('dashboard.email')"
                                        name="email"
                                        type="email"
                                        :placeholder="__('dashboard.enter_email')"
                                        :required="true"
                                    />
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-6">
                                    <x-admin.form-input
                                        :label="__('dashboard.phone')"
                                        name="phone"
                                        :placeholder="__('dashboard.enter_phone')"
                                    />
                                </div>
                                <div class="col-md-6">
                                    <div class="mb-3">
                                        <label class="form-label">{{ __('dashboard.status') }}</label>
                                        <select name="is_active" class="form-select">
                                            <option value="1" selected>{{ __('models.active') }}</option>
                                            <option value="0">{{ __('models.inactive') }}</option>
                                        </select>
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-6">
                                    <x-admin.form-input
                                        :label="__('dashboard.password')"
                                        name="password"
                                        type="password"
                                        :placeholder="__('dashboard.enter_password')"
                                        :required="true"
                                    />
                                </div>
                                <div class="col-md-6">
                                    <x-admin.form-input
                                        :label="__('dashboard.confirm_password')"
                                        name="password_confirmation"
                                        type="password"
                                        :placeholder="__('dashboard.confirm_password')"
                                        :required="true"
                                    />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Image & Role -->
                <div class="col-lg-4">
                    <div class="card">
                        <div class="card-header">
                            <h5 class="card-title mb-0">{{ __('models.image') }}</h5>
                        </div>
                        <div class="card-body">
                            <x-image name="image" />
                        </div>
                    </div>

                    <div class="card">
                        <div class="card-header">
                            <h5 class="card-title mb-0">{{ __('models.roles') }}</h5>
                        </div>
                        <div class="card-body">
                            @foreach($roles as $role)
                                <div class="form-check mb-2">
                                    <input class="form-check-input" type="checkbox" name="roles[]" value="{{ $role->name }}" id="role_{{ $role->id }}">
                                    <label class="form-check-label" for="role_{{ $role->id }}">
                                        {{ $role->name }}
                                    </label>
                                </div>
                            @endforeach
                            @if($roles->isEmpty())
                                <p class="text-muted mb-0">{{ __('dashboard.no_roles_available') }}</p>
                            @endif
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-12">
                    <div class="d-flex gap-2">
                        <button type="submit" class="btn btn-success">
                            <i class="ri-save-line align-middle me-1"></i> {{ __('models.create') }}
                        </button>
                        <a href="{{ route('admin.admins.index') }}" class="btn btn-light">{{ __('models.cancel') }}</a>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
@endsection
