@php
    $selectedFnb = isset($hall) ? ($hall->fnb_levels ?? []) : [];
    $selectedFeatures = isset($hall) ? array_keys($hall->features ?? []) : [];
    $selectedManagers = isset($hall) ? ($hall->hall_manager_ids ?? array_filter([$hall->hall_manager_id])) : [];
@endphp

<div class="row">
  <div class="col-md-6">
    <div class="form-group">
      {!! Form::label('venue_id', __('bms::lang.venue') . ':*') !!}
      {!! Form::select('venue_id', $venues, null, ['class' => 'form-control', 'required', 'placeholder' => __('messages.please_select')]) !!}
    </div>
  </div>
  <div class="col-md-6">
    <div class="form-group">
      {!! Form::label('name', __('bms::lang.hall') . ':*') !!}
      {!! Form::text('name', null, ['class' => 'form-control', 'required']) !!}
    </div>
  </div>
</div>

<div class="row">
  <div class="col-md-4">
    <div class="form-group">
      {!! Form::label('name_ar', __('bms::lang.hall') . ' (AR):') !!}
      {!! Form::text('name_ar', null, ['class' => 'form-control', 'dir' => 'rtl']) !!}
    </div>
  </div>
  <div class="col-md-4">
    <div class="form-group">
      {!! Form::label('code', __('bms::lang.code') . ':') !!}
      {!! Form::text('code', null, ['class' => 'form-control']) !!}
    </div>
  </div>
  <div class="col-md-4">
    <div class="form-group">
      {!! Form::label('venue_type', __('bms::lang.venue_type') . ':*') !!}
      {!! Form::select('venue_type', $venueTypes, null, ['class' => 'form-control', 'required']) !!}
    </div>
  </div>
</div>

<div class="row">
  <div class="col-md-3">
    <div class="form-group">
      {!! Form::label('capacity_min', __('bms::lang.capacity_min') . ':') !!}
      {!! Form::number('capacity_min', null, ['class' => 'form-control', 'min' => 0]) !!}
    </div>
  </div>
  <div class="col-md-3">
    <div class="form-group">
      {!! Form::label('capacity_max', __('bms::lang.capacity_max') . ':') !!}
      {!! Form::number('capacity_max', null, ['class' => 'form-control', 'min' => 0]) !!}
    </div>
  </div>
  <div class="col-md-3">
    <div class="form-group">
      {!! Form::label('area_sqm', __('bms::lang.area_sqm') . ':') !!}
      {!! Form::number('area_sqm', null, ['class' => 'form-control', 'min' => 0, 'step' => '0.01']) !!}
    </div>
  </div>
  <div class="col-md-3">
    <div class="form-group">
      <label class="tw-mt-7">
        {!! Form::checkbox('is_active', 1, isset($hall) ? null : true, ['class' => 'input-icheck']) !!}
        @lang('bms::lang.active')
      </label>
    </div>
  </div>
</div>

<div class="form-group">
  {!! Form::label('hall_manager_ids', __('bms::lang.hall_manager') . ':') !!}
  {!! Form::select('hall_manager_ids[]', $managers, $selectedManagers, ['class' => 'form-control bms-select2', 'multiple', 'data-placeholder' => __('messages.please_select')]) !!}
  <span class="help-block">@lang('bms::lang.pricing_from_packages')</span>
</div>

<div class="form-group">
  {!! Form::label('fnb_levels', __('bms::lang.fnb_level') . ':') !!}
  <div class="row">
    @foreach($fnbLevels as $key => $label)
      <div class="col-md-4 col-sm-6">
        <label class="tw-font-normal">
          {!! Form::checkbox('fnb_levels[]', $key, in_array($key, $selectedFnb), ['class' => 'input-icheck']) !!}
          {{ $label }}
        </label>
      </div>
    @endforeach
  </div>
</div>

<div class="form-group">
  {!! Form::label('features', __('bms::lang.features') . ':') !!}
  <div class="row">
    @foreach($features as $key => $label)
      <div class="col-md-4 col-sm-6">
        <label class="tw-font-normal">
          {!! Form::checkbox('features[]', $key, in_array($key, $selectedFeatures), ['class' => 'input-icheck']) !!}
          {{ $label }}
        </label>
      </div>
    @endforeach
  </div>
</div>

<div class="row">
  <div class="col-md-6">
    <div class="form-group">
      {!! Form::label('description', __('bms::lang.description') . ' (EN):') !!}
      {!! Form::textarea('description', null, ['class' => 'form-control', 'rows' => 2]) !!}
    </div>
  </div>
  <div class="col-md-6">
    <div class="form-group">
      {!! Form::label('description_ar', __('bms::lang.description') . ' (AR):') !!}
      {!! Form::textarea('description_ar', null, ['class' => 'form-control', 'rows' => 2, 'dir' => 'rtl']) !!}
    </div>
  </div>
</div>
