@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">
    <div class="form-group row">
        <label class="col-sm-2 col-form-label">駐輪分類ID</label>
        <div class="col-sm-10">
            <input type="text" name="ptype_id" class="form-control" value="{{ old('ptype_id', $item->ptype_id ?? '') }}" @if(isset($item->ptype_id)) 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="ptype_subject" class="form-control" value="{{ old('ptype_subject', $item->ptype_subject ?? '') }}" required>
        </div>
    </div>
    <div class="form-group row">
        <label class="col-sm-2 col-form-label">階数ソート順</label>
        <div class="col-sm-10">
            <input type="text" name="floor_sort" class="form-control" value="{{ old('floor_sort', $item->floor_sort ?? '') }}">
        </div>
    </div>
    <div class="form-group row">
        <label class="col-sm-2 col-form-label">備考</label>
        <div class="col-sm-10">
            <input type="text" name="ptype_remarks" class="form-control" value="{{ old('ptype_remarks', $item->ptype_remarks ?? '') }}">
        </div>
    </div>
</div>

{{-- ▼ 下部ボタン --}}
<div class="form-group col-12 d-flex gap-2 mt-4">
    {{-- 登録ボタン --}}
    <button type="submit" class="btn btn-lg btn-success mr-2">{{ __('登録') }}</button>

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