<div class="card">
    <div class="card-body">
        <!-- バリデーションエラー表示 -->
        @if ($errors->any())
            <div class="form-group col-12">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                <div class="alert alert-danger">
                    <ul>
                        @foreach ($errors->all() as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            </div>
        @endif

        @if($isEdit)
            <div class="row align-items-center mb-3">
                <!-- 許容市区ID -->
                <div class="form-group col-2">
                    <label>{{ __('validation.attributes.contract_allowable_city_id') }}</label>
                </div>
                <div class="form-group col-10">
                    <input type="text" class="form-control form-control-lg" readonly
                        value="{{ $record->contract_allowable_city_id ?? '' }}">
                </div>
            </div>
        @endif

        <!-- 市区ID -->
        <div class="row align-items-center mb-3">
            <div class="form-group col-2">
                <label class="required">{{ __('validation.attributes.city_id') }}</label>
            </div>
            <div class="form-group col-10">
                <select class="form-control form-control-lg" name="city_id" required>
                    <option value="">{{ __('validation.attributes.city_id') }}</option>
                    @foreach($cityList as $key => $item)
                        <option value="{{ $key }}" @if($key == old('city_id', $record->city_id ?? '')) selected @endif>{{ $item }}</option>
                    @endforeach
                </select>
            </div>
        </div>

        <!-- 許容市区名 -->
        <div class="row align-items-center mb-3">
            <div class="form-group col-2">
                <label class="required">{{ __('validation.attributes.contract_allowable_city_name') }}</label>
            </div>
            <div class="form-group col-10">
                <input type="text" class="form-control form-control-lg"
                    name="contract_allowable_city_name"
                    value="{{ old('contract_allowable_city_name', $record->contract_allowable_city_name ?? '') }}"
                    placeholder="{{ __('validation.attributes.contract_allowable_city_name') }}"
                    maxlength="50"
                    required
                >
            </div>
        </div>

        <!-- 駐輪場 -->
        <div class="row align-items-center mb-3">
            <div class="form-group col-2">
                <label class="required">{{ __('validation.attributes.park_id') }}</label>
            </div>
            <div class="form-group col-10">
                <select class="form-control form-control-lg" name="park_id" required>
                    <option value="">{{ __('validation.attributes.park_id') }}</option>
                    @foreach($parkList as $key => $item)
                        <option value="{{ $key }}" @if($key == old('park_id', $record->park_id ?? '')) selected @endif>{{ $item }}</option>
                    @endforeach
                </select>
            </div>
        </div>

        <!-- 隣接区フラグ -->
        <div class="row align-items-center mb-3">
            <div class="form-group col-2">
                <label class="required">{{ __('validation.attributes.same_district_flag') }}</label>
            </div>
            <div class="form-group col-10">
                <select class="form-control form-control-lg" name="same_district_flag" required>
                    <option value="">{{ __('validation.attributes.same_district_flag') }}</option>
                    <option value="0" @if(old('same_district_flag', $record->same_district_flag ?? '') == 0) selected @endif>隣接市</option>
                    <option value="1" @if(old('same_district_flag', $record->same_district_flag ?? '') == 1) selected @endif>その他</option>
                </select>
            </div>
        </div>

        {{-- ▼ 下部ボタン --}}
        <div class="col-3"></div>
        <div class="form-group col-9 d-flex align-items-center gap-2 mt-4">
            {{-- 登録ボタン --}}
            @if($isEdit)
                <button type="submit" id="register_edit" class="btn btn-lg btn-success mr-2">
                    {{ __('登録') }}
                </button>
            @else
                <button type="submit" id="register" class="btn btn-lg btn-success mr-2 register">
                    {{ __('登録') }}
                </button>
            @endif

            {{-- 削除ボタン（編集時のみ表示） --}}
            @if($isEdit && !empty($record->contract_allowable_city_id))
                <button type="button" id="delete_edit" class="btn btn-lg btn-danger">
                    {{ __('削除') }}
                </button>
            @endif
        </div>
    </div>
</div>
