@if(Session::has('success'))
  <div class="alert alert-success alert-dismissible">{{ Session::get('success') }}</div>
@elseif(Session::has('error'))
  <div class="alert alert-danger alert-dismissible">{{ Session::get('error') }}</div>
@endif

<div class="card p-4">

  {{-- 決済情報ID（編集/参照のみ表示、システム自動採番） --}}
  @if($isEdit || $isInfo)
    <div class="row mb-3">
      <label class="col-md-2 col-form-label">決済情報ID</label>
      <div class="col-md-10">
        <input type="text" class="form-control" value="{{ $payment->payment_id ?? '' }}" readonly>
      </div>
    </div>
  @endif

  {{-- 会社名（必須） --}}
  <div class="row mb-3">
    <label class="col-md-2 col-form-label">会社名 <span class="text-danger">*</span></label>
    <div class="col-md-10">
      <input type="text"
             name="payment_companyname"
             class="form-control @error('payment_companyname') is-invalid @enderror"
             value="{{ old('payment_companyname', $payment->payment_companyname ?? '') }}"
             maxlength="255"
             placeholder="例）〇〇駐輪場運営株式会社"
             @if($isInfo) readonly @endif>
      @error('payment_companyname')<div class="invalid-feedback">{{ $message }}</div>@enderror
    </div>
  </div>

  {{-- 住所 --}}
  <div class="row mb-3">
    <label class="col-md-2 col-form-label">住所</label>
    <div class="col-md-10">
      <input type="text"
             name="payment_add"
             class="form-control @error('payment_add') is-invalid @enderror"
             value="{{ old('payment_add', $payment->payment_add ?? '') }}"
             maxlength="255"
             placeholder="例）東京都〇〇区〇〇 1-2-3"
             @if($isInfo) readonly @endif>
      @error('payment_add')<div class="invalid-feedback">{{ $message }}</div>@enderror
    </div>
  </div>

  {{-- 詳細（補足情報） --}}
  <div class="row mb-3">
    <label class="col-md-2 col-form-label">詳細</label>
    <div class="col-md-10">
      <input type="text"
             name="payment_detail"
             class="form-control @error('payment_detail') is-invalid @enderror"
             value="{{ old('payment_detail', $payment->payment_detail ?? '') }}"
             maxlength="255"
             placeholder="例）ビル名・階数など"
             @if($isInfo) readonly @endif>
      @error('payment_detail')<div class="invalid-feedback">{{ $message }}</div>@enderror
    </div>
  </div>

  {{-- 予備項目１ --}}
  <div class="row mb-3">
    <label class="col-md-2 col-form-label">予備項目1</label>
    <div class="col-md-10">
      <input type="text"
             name="payment_space1"
             class="form-control @error('payment_space1') is-invalid @enderror"
             value="{{ old('payment_space1', $payment->payment_space1 ?? '') }}"
             maxlength="255"
             @if($isInfo) readonly @endif>
      @error('payment_space1')<div class="invalid-feedback">{{ $message }}</div>@enderror
    </div>
  </div>

  {{-- 予備項目２ --}}
  <div class="row mb-3">
    <label class="col-md-2 col-form-label">予備項目2</label>
    <div class="col-md-10">
      <input type="text"
             name="payment_space2"
             class="form-control @error('payment_space2') is-invalid @enderror"
             value="{{ old('payment_space2', $payment->payment_space2 ?? '') }}"
             maxlength="255"
             @if($isInfo) readonly @endif>
      @error('payment_space2')<div class="invalid-feedback">{{ $message }}</div>@enderror
    </div>
  </div>

  {{-- タイトル --}}
  <div class="row mb-3">
    <label class="col-md-2 col-form-label">タイトル</label>
    <div class="col-md-10">
      <input type="text"
            name="payment_title"
            class="form-control @error('payment_title') is-invalid @enderror"
            value="{{ old('payment_title', $payment->payment_title ?? '') }}"
            maxlength="255"
            placeholder="例）お支払いのご案内"
            @if($isInfo) readonly @endif>
      @error('payment_title')
        <div class="invalid-feedback">{{ $message }}</div>
      @enderror
    </div>
  </div>

  {{-- 案内文 --}}
  <div class="row mb-3">
    <label class="col-md-2 col-form-label">案内文</label>
    <div class="col-md-10">
      <input type="text"
             name="payment_guide"
             class="form-control @error('payment_guide') is-invalid @enderror"
             value="{{ old('payment_guide', $payment->payment_guide ?? '') }}"
             maxlength="255"
             placeholder="例）お支払い方法につきましては以下をご確認ください。"
             @if($isInfo) readonly @endif>
      @error('payment_guide')<div class="invalid-feedback">{{ $message }}</div>@enderror
    </div>
  </div>

  {{-- 問い合わせ担当者名 --}}
  <div class="row mb-3">
    <label class="col-md-2 col-form-label">問い合わせ担当</label>
    <div class="col-md-10">
      <input type="text"
             name="payment_inquiryname"
             class="form-control @error('payment_inquiryname') is-invalid @enderror"
             value="{{ old('payment_inquiryname', $payment->payment_inquiryname ?? '') }}"
             maxlength="255"
             placeholder="例）山田 太郎"
             @if($isInfo) readonly @endif>
      @error('payment_inquiryname')<div class="invalid-feedback">{{ $message }}</div>@enderror
    </div>
  </div>

  {{-- 問い合わせ電話番号 --}}
  <div class="row mb-3">
    <label class="col-md-2 col-form-label">問い合わせ電話</label>
    <div class="col-md-10">
      <input type="text"
             name="payment_inquirytel"
             class="form-control @error('payment_inquirytel') is-invalid @enderror"
             value="{{ old('payment_inquirytel', $payment->payment_inquirytel ?? '') }}"
             maxlength="255"
             placeholder="例）03-1234-5678"
             @if($isInfo) readonly @endif>
      @error('payment_inquirytel')<div class="invalid-feedback">{{ $message }}</div>@enderror
      <small class="text-muted">半角数字・ハイフンで入力してください。</small>
    </div>
  </div>

  {{-- 受付時間（例：平日9:00〜17:00） --}}
  <div class="row mb-3">
    <label class="col-md-2 col-form-label">受付時間</label>
    <div class="col-md-10">
      <input type="text"
             name="payment_time"
             class="form-control @error('payment_time') is-invalid @enderror"
             value="{{ old('payment_time', $payment->payment_time ?? '') }}"
             maxlength="255"
             placeholder="例）平日 9:00〜17:00"
             @if($isInfo) readonly @endif>
      @error('payment_time')<div class="invalid-feedback">{{ $message }}</div>@enderror
    </div>
  </div>

  {{-- オペレータID（編集/参照のみ表示・自動設定） --}}
  @if($isEdit || $isInfo)
    <div class="row mb-3">
      <label class="col-md-2 col-form-label">更新オペレータID</label>
      <div class="col-md-10">
        <input type="text" class="form-control" value="{{ $payment->operator_id ?? '' }}" readonly>
      </div>
    </div>
  @endif

  {{-- ボタン --}}
  <div class="text-left mt-2">
    @if($isInfo)
      <a href="{{ route('payments_edit', ['id' => $payment->payment_id]) }}" class="btn btn-lg btn-success">編集</a>
    @else
      <button type="submit" class="btn btn-lg btn-success">登録</button>
      @if($isEdit)
        <a href="{{ route('payments_delete', ['id' => $payment->payment_id]) }}"
           class="btn btn-lg btn-danger ms-2"
           onclick="return confirm('削除してよろしいですか？')">削除</a>
      @endif
    @endif
  </div>

</div>
