@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>
@elseif(Session::has('error'))
    <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>
        {!! Session::get('error') !!}
    </div>
@elseif(isset($errorMsg))
    <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>
        {!! $errorMsg !!}
    </div>
@endif

<div class="card-body">
    {{-- 車室区分ID --}}
    <div class="form-group row">
        <label class="col-sm-2 col-form-label">車室区分ID</label>
        <div class="col-sm-10">
            <input type="text" name="psection_id" class="form-control"
                value="{{ old('psection_id', $psection->psection_id ?? '') }}"
                @if(isset($psection)) readonly @endif>
        </div>
    </div>

    {{-- 車室区分名 --}}
    <div class="form-group row">
        <label class="col-sm-2 col-form-label">車室区分名<span class="text-danger">*</span></label>
        <div class="col-sm-10">
            <input type="text" name="psection_subject" class="form-control"
                value="{{ old('psection_subject', $psection->psection_subject ?? '') }}" required>
        </div>
    </div>

    {{-- ▼ 下部ボタン --}}
    <div class="form-group row">
        <div class="form-group col-12 d-flex gap-2 mt-4">
            {{-- 登録ボタン --}}
            <button type="submit"
                    class="btn btn-lg btn-success mr-2"
                    onclick="return confirm('登録してよろしいですか？');">
                {{ __('登録') }}
            </button>

            {{-- 削除ボタン（編集画面のみ表示） --}}
            @if(!empty($psection->psection_id))
                </form>
                <form method="POST" action="{{ route('psections_delete') }}"
                    onsubmit="return confirm('本当に削除しますか？')" class="d-inline-block mr-2">
                    @csrf
                    <input type="hidden" name="pk" value="{{ $psection->psection_id }}">
                    <button type="submit" class="btn btn-lg btn-danger">{{ __('削除') }}</button>
                </form>
            @endif
        </div>
    </div>

</div>