<div class="card">
    <div class="card-body">
        <!-- バリデーションエラー表示 -->
        @if ($errors->any())
            <div class="form-group col-12">
                <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.jurisdiction_parking_id') }}</label>
                </div>
                <div class="form-group col-10">
                    <input type="text" class="form-control form-control-lg" readonly
                        value="{{ $record->jurisdiction_parking_id ?? '' }}">
                </div>
            </div>
        @endif

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

        <!-- オペレータ -->
        <div class="row align-items-center mb-3">
            <div class="form-group col-2">
                <label class="required">{{ __('オペレーター(エリアマネージャ)') }}</label>
            </div>
            <div class="form-group col-10">
                <select class="form-control form-control-lg" name="ope_id">
                    <option value="">{{ __('validation.attributes.ope_name') }}</option>
                    @foreach($opes as $key => $item)
                        <option value="{{ $key }}" @if($key == ($record->ope_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.park_name') }}</label>
            </div>
            <div class="form-group col-10">
                <select class="form-control form-control-lg" name="park_id">
                    <option value="">{{ __('validation.attributes.park_name') }}</option>
                    @foreach($parks as $key => $item)
                        <option value="{{ $key }}" @if($key == ($record->park_id ?? '')) selected @endif>{{ $item }}</option>
                    @endforeach
                </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->jurisdiction_parking_id))
                <button type="button" id="delete_edit" class="btn btn-lg btn-danger">
                    {{ __('削除') }}
                </button>
            @endif
        </div>
    </div>
</div>
