<h5 class="mb-3">{{ __('store.clientarea_domains_management_contacts_title') }}</h5>
<p class="text-muted">{{ __('store.clientarea_domains_management_contacts_description') }}</p>

@if($groups)
    <form action="{{ route('store.auth.domains.manage.contacts.update', $domain->id) }}" method="POST">
        @csrf

        <!-- Nav tabs -->
        <ul class="nav nav-tabs mb-3" role="tablist">
            @foreach($groups as $groupName => $fields)
                <li class="nav-item" role="presentation">
                    <button class="nav-link @if($loop->first) active @endif"
                            id="{{ Str::slug($groupName) }}-tab"
                            data-bs-toggle="tab"
                            data-bs-target="#{{ Str::slug($groupName) }}-pane"
                            type="button"
                            role="tab"
                            aria-controls="{{ Str::slug($groupName) }}-pane"
                            aria-selected="{{ $loop->first ? 'true' : 'false' }}">
                        {{ $groupName }}
                    </button>
                </li>
            @endforeach
        </ul>

        <!-- Tab content -->
        <div class="tab-content mb-3">
            @foreach($groups as $groupName => $fields)
                <div class="tab-pane fade @if($loop->first) show active @endif"
                     id="{{ Str::slug($groupName) }}-pane"
                     role="tabpanel"
                     aria-labelledby="{{ Str::slug($groupName) }}-tab"
                     tabindex="0">
                    <div class="card">
                        <div class="card-body">
                            <div class="row g-3">
                                @foreach($fields as $fieldName => $fieldValue)
                                    <div class="col-md-6">
                                        <label class="form-label text-capitalize">{{ ucfirst(str_replace('_', ' ', $fieldName)) }}</label>
                                        <input type="text"
                                               class="form-control"
                                               name="groups[{{ $groupName }}][{{ $fieldName }}]"
                                               value="{{ $fieldValue }}">
                                    </div>
                                @endforeach
                            </div>
                        </div>
                    </div>
                </div>
            @endforeach
        </div>

        <button type="submit" class="btn btn-primary">
            <i class="fas fa-save me-2"></i>{{ __('store.common_save') }}
        </button>
    </form>
@else
    <div class="alert alert-info">
        <i class="fas fa-info-circle me-2"></i>{{ $error ?? __('store.clientarea_domains_management_contacts_not_available') }}
    </div>
@endif
