@props([
    'label' => null,           // The group heading/question
    'name' => null,            // Input name attribute
    'options' => [],           // ['value' => 'Label']
    'selected' => null,        // Pre-checked value
    'inline' => false,         // Horizontal layout toggle
    'idPrefix' => 'radio-' . \Illuminate\Support\Str::random(4),
    'required' => false
])

{{-- Fixed: Do not merge raw attributes onto the wrapper. Livewire attributes like wire:model must only attach to inputs. --}}
<div class="mb-3 {{ $attributes->get('class') }}">
    {{-- Group Label/Question --}}
    @if($label || $slot->isNotEmpty())
        <label class="form-label d-block fw-bold mb-2">
            {{ $label ?? $slot }}
            @if($required) <span class="text-danger">*</span> @endif
        </label>
    @endif

    <div class="radio-group-container">
        @foreach($options as $value => $optionLabel)
            @php $uniqueId = $idPrefix . '-' . $loop->index; @endphp

            <div class="form-check {{ $inline ? 'form-check-inline' : '' }}">
                {{-- Valid attributes automatically drop down onto this input --}}
                <input
                        wire:model="{{ $name }}"
                        class="form-check-input @error($name) is-invalid @enderror"
                        type="radio"
                        name="{{ $name }}"
                        id="{{ $uniqueId }}"
                        value="{{ $value }}"
                        {{ (string) $selected === (string) $value ? 'checked' : '' }}
                        {{ $required ? 'required' : '' }}
                        {{ $attributes->whereDoesntStartWith(['class', 'name', 'id']) }}
                >
                <label class="form-check-label" for="{{ $uniqueId }}">
                    {{ $optionLabel }}
                </label>
            </div>
        @endforeach
    </div>

    {{-- Validation Error Support --}}
    @error($name)
    <div class="invalid-feedback d-block mt-1">
        {{ $message }}
    </div>
    @enderror
</div>