@if ($insurer)
	<div class="box" id="address-residence-form">
		<div class="box-header">
			<h5 class="box-title">{{ __('forms.BusinessAddress') }}</h5>
		</div>
		<div class="box-body pb-2">
			{{-- We are updating an existing Residence address --}}
			<form action="{{ route('osiguranje.insurers.addresses.update', [$insurer, $insurer->lastActiveResidence->id]) }}"
				method="POST">
				@csrf
				@method('put')

				<input type="hidden" name="type" value="Residence">

				{{-- line_1 --}}
				<div class="grid grid-cols-1 gap-x-6 mb-6">
					<div>
						<label for="residence_line_1" class="ti-form-label @error('residence.line_1') error @enderror">
							@error('residence.line_1')
								{{ $message }}
							@else
								{{ __('forms.Address') }}
							@enderror
						</label>
						<input id="residence_line_1" type="text" name="residence[line_1]"
							value="{{ old('residence.line_1') ?? $insurer->lastActiveResidence?->line_1 }}"
							class="ti-form-input shadow-sm @error('residence.line_1') border-red-500 @enderror"
							placeholder="{{ __('forms.Address') }}" {{ $readonly ? 'disabled' : '' }}>
					</div>
				</div>

				{{-- city_id --}}
				<div class="mb-6">
					<label for="residence_city_id_update" class="ti-form-label @error('residence.city_id') error @enderror">
						@error('residence.city_id')
							{{ $message }}
						@else
							{{ __('forms.Town') }}
						@enderror
					</label>
					<select id="residence_city_id_update"
						class="ti-form-select py-1 @error('residence.city_id') border-red-500 @enderror" name="residence[city_id]"
						{{ $readonly ? 'disabled' : '' }}>
						<!-- City options -->
					</select>
				</div>

				@if (!$readonly)
					<div class="flex justify-between">
						<div></div>
						<button type="submit" class="ti-btn ti-btn-outline-success py-1 px-3 mr-0">
							<span>{{ __('forms.Update') }}</span>
						</button>
					</div>
				@endif
			</form>

		</div>
	</div>
@endif
