{{-- アラート --}}
@if(Session::has('success'))
    <div class="alert alert-success alert-dismissible" role="alert">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
        {{ Session::get('success') }}
    </div>
@endif

@if($errors->any())
    <div class="alert alert-danger alert-dismissible">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
        <h4><i class="icon fa fa-ban"></i> {{ __('入力内容に不備があります:') }}</h4>
        <ul>
            @foreach($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
    </div>
@endif


<div class="card-body">
    <div class="row">
        {{-- ▼ 定期種別ID（自動採番：編集時のみ表示） --}}
        @if($isEdit)
            <div class="col-3">
                <label>{{ __('定期種別ID') }}</label>
            </div>
            <div class="form-group col-9">
                <div class="input-group">
                    <input type="text" name="regular_type_id"
                        class="form-control text-right bg-light"
                        value="{{ old('regular_type_id', $regular_type_id ?? '') }}"
                        maxlength="10" readonly>
                </div>
            </div>
        @endif

        {{-- ▼ 市区名 --}}
        <div class="form-group col-3">
                <label class="form-label required">{{ __('市区名') }}</label>
        </div>
        <div class="col-9">
            <select class="form-control form-control-lg mb10"
                    name="city_id"
                    {{ !$isEdit ? 'required' : '' }}>
                <option value="">{{ __('市区名') }}</option>
                @foreach($cities as $key => $val)
                    <option value="{{ $key }}" {{ (old('city_id', $record->city_id ?? '') == $key) ? 'selected' : '' }}>
                        {{ $val }}
                    </option>
                @endforeach
            </select>
        </div>


        <!-- 定期種別1 -->
         
        <div class="form-group col-3">
            <label>{{ __('定期種別1') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="row">
                <div class="col-2 offset-1 form-check">
                    <input type="radio" class="minimal"
                        name="regular_class_1"
                        value="1"
                        {{-- 新規時デフォルト有効 --}}
                        @if((!$isEdit && !isset($regular_class_1)) || (isset($regular_class_1) && $regular_class_1 == 1)) checked @endif>
                    <label class="form-check-label">{{ __("有効") }}</label>
                </div>
                <div class="col-2 form-check">
                    <input type="radio" class="minimal"
                        name="regular_class_1"
                        value="0"
                        @if(isset($regular_class_1) && $regular_class_1 === 0) checked @endif>
                    <label class="form-check-label">{{ __("無効") }}</label>
                </div>
            </div>
        </div>

        <!-- 定期種別2 -->
        <div class="form-group col-3">
            <label>{{ __('定期種別2') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="row">
                <div class="col-2 offset-1 form-check">
                    <input type="radio" class="minimal"
                        name="regular_class_2"
                        value="1" 
                        @if((!$isEdit && !isset($regular_class_2)) || (isset($regular_class_2) && $regular_class_2 == 1)) checked @endif>
                    <label class="form-check-label">{{ __("有効") }}</label>
                </div>
                <div class="col-2 form-check">
                    <input type="radio" class="minimal"
                        name="regular_class_2"
                        value="0" @if(isset($regular_class_2) && $regular_class_2 === 0) checked @endif>
                    <label class="form-check-label">{{ __("無効") }}</label>
                </div>
            </div>
        </div>

        <!-- 定期種別3 -->
        <div class="form-group col-3">
            <label>{{ __('定期種別3') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="row">
                <div class="col-2 offset-1 form-check">
                    <input type="radio" class="minimal"
                        name="regular_class_3"
                        value="1" @if((!$isEdit && !isset($regular_class_3)) || (isset($regular_class_3) && $regular_class_3 == 1)) checked @endif>
                    <label class="form-check-label">{{ __("有効") }}</label>
                </div>
                <div class="col-2 form-check">
                    <input type="radio" class="minimal"
                        name="regular_class_3"
                        value="0" @if(isset($regular_class_3) && $regular_class_3 === 0) checked @endif>
                    <label class="form-check-label">{{ __("無効") }}</label>
                </div>
            </div>
        </div>

        <!-- 定期種別6 -->
        <div class="form-group col-3">
            <label>{{ __('定期種別6') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="row">
                <div class="col-2 offset-1 form-check">
                    <input type="radio" class="minimal"
                        name="regular_class_6"
                        value="1" 
                        @if((!$isEdit && !isset($regular_class_6)) || (isset($regular_class_6) && $regular_class_6 == 1)) checked @endif>
                    <label class="form-check-label">{{ __("有効") }}</label>
                </div>
                <div class="col-2 form-check">
                    <input type="radio" class="minimal"
                        name="regular_class_6"
                        value="0" @if(isset($regular_class_6) && $regular_class_6 === 0) checked @endif>
                    <label class="form-check-label">{{ __("無効") }}</label>
                </div>
            </div>
        </div>

        <!-- 定期種別12 -->
        <div class="form-group col-3">
            <label>{{ __('定期種別12') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="row">
                <div class="col-2 offset-1 form-check">
                    <input type="radio" class="minimal"
                        name="regular_class_12"
                        value="1" 
                        @if((!$isEdit && !isset($regular_class_12)) || (isset($regular_class_12) && $regular_class_12 == 1)) checked @endif>
                    <label class="form-check-label">{{ __("有効") }}</label>
                </div>
                <div class="col-2 form-check">
                    <input type="radio" class="minimal"
                        name="regular_class_12"
                        value="0" @if(isset($regular_class_12) && $regular_class_12 === 0) checked @endif>
                    <label class="form-check-label">{{ __("無効") }}</label>
                </div>
            </div>
        </div>


        <!-- 備考 -->
        <div class="form-group col-3">
            <label>{{ __('備考') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="input-group">
                <textarea class="form-control form-control-lg"
                    rows="5"
                    placeholder="{{ __('validation.attributes.memo') }}"
                    name="memo">{{ $memo }}</textarea>
            </div>
        </div>
        <!-- /.form group - 備考 -->
    </div>

    {{-- ▼ 下部ボタン --}}
    <div class="row mt-4">
        <div class="form-group col-md-10 d-flex align-items-center gap-2 justify-content-start">

            {{-- 登録ボタン --}}
            @if($isEdit)
                <button type="button" id="register_edit" class="btn btn-lg btn-success mr-2">
                    {{ __('登録') }}
                </button>
            @else
                <button type="button" id="register" class="btn btn-lg btn-success mr-2 register">
                    {{ __('登録') }}
                </button>
            @endif

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

        </div>
    </div>

</div>


