{{-- アラート --}}
@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">

    {{-- ▼ ゾーンID（編集時のみ表示） --}}
    @if($isEdit && isset($record->zone_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="zone_id"
                    class="form-control form-control-lg"
                    value="{{ $record->zone_id }}"
                    readonly>
            </div>
        </div>
    @endif


    {{-- ▼ 駐輪場 --}}
    <div class="form-group row">
        <label class="col-sm-2 col-form-label required">駐輪場</label>
        <div class="col-sm-10">
            <select name="park_id" class="form-control form-control-lg" required>
                <option value="" disabled {{ old('park_id', $record->park_id ?? '') == '' ? 'selected' : '' }}>
                    駐輪場
                </option>
                @foreach($parkList as $id => $name)
                    <option value="{{ $id }}" {{ old('park_id', $record->park_id ?? '') == $id ? 'selected' : '' }}>
                        {{ $name }}
                    </option>
                @endforeach
            </select>
        </div>
    </div>

    {{-- ▼ 駐輪分類 --}}
    <div class="form-group row">
        <label class="col-sm-2 col-form-label required">駐輪分類</label>
        <div class="col-sm-10">
            <select name="ptype_id" class="form-control form-control-lg" required>
                <option value="" disabled {{ old('ptype_id', $record->ptype_id ?? '') == '' ? 'selected' : '' }}>
                    駐輪分類
                </option>
                @foreach($ptypeList as $id => $name)
                    <option value="{{ $id }}" {{ old('ptype_id', $record->ptype_id ?? '') == $id ? 'selected' : '' }}>
                        {{ $name }}
                    </option>
                @endforeach
            </select>
        </div>
    </div>



    {{-- ▼ 車種区分 --}}
    <div class="form-group row">
        <label class="col-sm-2 col-form-label required">
            車種区分
        </label>
        <div class="col-sm-10">
            <select name="psection_id" class="form-control form-control-lg" required>
                <option value="" disabled {{ old('psection_id', $record->psection_id ?? '') == '' ? 'selected' : '' }}>
                    車種区分
                </option>
                @foreach($psectionList as $id => $name)
                    <option value="{{ $id }}" {{ old('psection_id', $record->psection_id ?? '') == $id ? 'selected' : '' }}>
                        {{ $name }}
                    </option>
                @endforeach
            </select>
        </div>
    </div>


    {{-- ▼ ゾーン名 --}}
    <div class="form-group row">
        <label class="col-sm-2 col-form-label required">ゾーン名</label>
        <div class="col-sm-10">
            <input type="text"
                name="zone_name"
                class="form-control form-control-lg"
                value="{{ old('zone_name', $record->zone_name ?? '') }}"
                placeholder="ゾーン名"
                required>
        </div>
    </div>



    {{-- ▼ ゾーン内現在契約台数 --}}
    <div class="form-group row">
        <label class="col-sm-2 col-form-label">ゾーン内現在契約台数</label>
        <div class="col-sm-10">
            <input type="number"
                name="zone_number"
                class="form-control form-control-lg"
                value="{{ old('zone_number', $record->zone_number ?? '') }}"
                placeholder="ゾーン内現在契約台数">
        </div>
    </div>

    {{-- ▼ ゾーン内標準台数 --}}
    <div class="form-group row">
        <label class="col-sm-2 col-form-label">ゾーン内標準台数</label>
        <div class="col-sm-10">
            <input type="number"
                name="zone_standard"
                class="form-control form-control-lg"
                value="{{ old('zone_standard', $record->zone_standard ?? '') }}"
                placeholder="ゾーン内標準台数">
        </div>
    </div>

    {{-- ▼ ゾーン内許容台数 --}}
    <div class="form-group row">
        <label class="col-sm-2 col-form-label">ゾーン内許容台数</label>
        <div class="col-sm-10">
            <input type="number"
                name="zone_tolerance"
                class="form-control form-control-lg"
                value="{{ old('zone_tolerance', $record->zone_tolerance ?? '') }}"
                placeholder="ゾーン内許容台数">
        </div>
    </div>

    {{-- ▼ ゾーン順 --}}
    <div class="form-group row">
        <label class="col-sm-2 col-form-label">ゾーン順</label>
        <div class="col-sm-10">
            <input type="number"
                name="zone_sort"
                class="form-control form-control-lg"
                value="{{ old('zone_sort', $record->zone_sort ?? '') }}"
                placeholder="ゾーン順">
        </div>
    </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>
