{{-- Bed create/edit modal form. --}}
@php $isEdit = $bed->exists; @endphp
<div class="modal-dialog" role="document">
  <div class="modal-content">
    <form class="medward-form"
        action="{{ $isEdit ? route('medward.beds.update', $bed->id) : route('medward.beds.store') }}"
        method="POST">
      {{ csrf_field() }}
      @if($isEdit) {{ method_field('PUT') }} @endif
      <input type="hidden" name="ward_id" value="{{ $ward->id }}">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">{{ $isEdit ? __('medward::lang.edit_bed') : __('medward::lang.add_bed') }} — {{ $ward->name }}</h4>
      </div>
      <div class="modal-body">
        <div class="row">
          <div class="col-md-6 form-group">
            <label>@lang('medward::lang.bed_number') *</label>
            <input type="text" name="bed_number" class="form-control" required value="{{ $bed->bed_number }}">
          </div>
          <div class="col-md-6 form-group">
            <label>@lang('medward::lang.bed_type') *</label>
            <select name="bed_type" class="form-control" required>
              @foreach($bedTypes as $type)
                <option value="{{ $type }}" @selected($bed->bed_type === $type)>@lang('medward::lang.bed_type_' . $type)</option>
              @endforeach
            </select>
          </div>
        </div>
        <div class="row">
          <div class="col-md-6 form-group">
            <label>@lang('medward::lang.status') *</label>
            <select name="status" class="form-control" required @if($isEdit && $bed->status === 'occupied') disabled @endif>
              @foreach($statuses as $st)
                <option value="{{ $st }}" @selected(($bed->status ?: 'available') === $st)>@lang('medward::lang.bed_status_' . $st)</option>
              @endforeach
            </select>
            @if($isEdit && $bed->status === 'occupied')
              <input type="hidden" name="status" value="occupied">
              <small class="text-muted">@lang('medward::lang.bed_occupied_locked')</small>
            @endif
          </div>
          <div class="col-md-6 form-group">
            <label>@lang('medward::lang.cleaning_status')</label>
            <select name="cleaning_status" class="form-control">
              @foreach(['clean','dirty','cleaning'] as $cs)
                <option value="{{ $cs }}" @selected(($bed->cleaning_status ?: 'clean') === $cs)>@lang('medward::lang.clean_' . $cs)</option>
              @endforeach
            </select>
          </div>
        </div>
        <div class="form-group">
          <label>@lang('medward::lang.notes')</label>
          <textarea name="notes" class="form-control" rows="2">{{ $bed->notes }}</textarea>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">@lang('medward::lang.cancel')</button>
        <button type="submit" class="btn btn-primary">@lang('medward::lang.save')</button>
      </div>
    </form>
  </div>
</div>
