@props([
    'action',
    'method' => 'POST',
    'module' => null,
    'submitLabel',
])

<form method="POST" action="{{ $action }}" novalidate>
    @csrf
    @if (strtoupper($method) !== 'POST')
        @method($method)
    @endif

    <div class="card">
        <div class="card-body">
            <div class="row g-3">
                <div class="col-md-6">
                    <x-ui.form.input
                        name="name"
                        :label="__('modules.fields.name')"
                        :value="$module?->name"
                        :placeholder="__('modules.placeholders.name')"
                        required
                    />
                </div>

                <div class="col-md-6">
                    <x-ui.form.input
                        name="slug"
                        :label="__('modules.fields.slug')"
                        :value="$module?->slug"
                        :placeholder="__('modules.placeholders.slug')"
                        required
                    />
                </div>

                <div class="col-12">
                    <x-ui.form.input
                        name="description"
                        :label="__('modules.fields.description')"
                        :value="$module?->description"
                        :placeholder="__('modules.placeholders.description')"
                        optional
                    />
                </div>

                <div class="col-md-6">
                    <x-ui.form.input
                        name="icon"
                        :label="__('modules.fields.icon')"
                        :value="$module?->icon"
                        placeholder="fe fe-grid"
                    />
                </div>

                <div class="col-md-6">
                    <x-ui.form.input
                        name="route_name"
                        :label="__('modules.fields.route_name')"
                        :value="$module?->route_name"
                        :placeholder="__('modules.placeholders.route_name')"
                    />
                </div>

                <div class="col-md-6">
                    <x-ui.form.input
                        name="category"
                        :label="__('modules.fields.category')"
                        :value="$module?->category"
                        :placeholder="__('modules.placeholders.category')"
                    />
                </div>

                <div class="col-md-6 d-flex align-items-end gap-4">
                    <x-ui.form.checkbox
                        name="is_core"
                        :label="__('modules.fields.is_core')"
                        :checked="$module?->is_core ?? false"
                    />
                    <x-ui.form.checkbox
                        name="is_active"
                        :label="__('modules.fields.is_active')"
                        :checked="$module?->is_active ?? true"
                    />
                </div>
            </div>
        </div>

        <div class="card-footer d-flex justify-content-end gap-2 bg-white">
            <x-ui.buttons.secondary :href="route('admin.modules.index')">
                {{ __('common.cancel') }}
            </x-ui.buttons.secondary>
            <x-ui.buttons.primary type="submit" icon="fe fe-save">
                {{ $submitLabel }}
            </x-ui.buttons.primary>
        </div>
    </div>
</form>
