{{-- Thread modal: message list + staff reply form. --}}
<div class="modal-dialog" role="document">
  <div class="modal-content">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal">&times;</button>
      <h4 class="modal-title">{{ $patientName }} — @lang('medportal::lang.thread')</h4>
    </div>
    <div class="modal-body">
      <div style="max-height:320px;overflow-y:auto;">
        @foreach($messages as $m)
          <div style="margin-bottom:10px;">
            <span class="label {{ $m->sender_type === 'patient' ? 'label-info' : 'label-primary' }}">
              {{ $m->sender_type === 'patient' ? __('medportal::lang.from_patient') : __('medportal::lang.from_staff') }}
            </span>
            <small class="text-muted">{{ optional($m->created_at)->format('Y-m-d H:i') }}</small>
            <div>{{ $m->body }}</div>
          </div>
        @endforeach
      </div>
      <hr>
      <form class="mportal-form" action="{{ route('mportal.messages.reply') }}" method="POST">
        {{ csrf_field() }}
        <input type="hidden" name="thread_id" value="{{ $threadId }}">
        <div class="form-group">
          <label>@lang('medportal::lang.your_reply')</label>
          <textarea name="body" class="form-control" rows="3" required></textarea>
        </div>
        <button type="submit" class="btn btn-primary">@lang('medportal::lang.reply')</button>
      </form>
    </div>
  </div>
</div>
