<x-layout bodyClass="g-sidenav-show  bg-gray-200">

  <x-navbars.student_sidebar
    activePage='subjects'
    studentId="{{ $current_student->id }}"
  ></x-navbars.student_sidebar>

  <main
    class="main-content position-relative max-height-vh-100 h-100 border-radius-lg"
  >

    <!-- Navbar -->
    <x-navbars.navs.auth
      titlePage="Apply subjects"
      role="{{ $request->user()->role }}"
      firstName="{{ $current_student->firstName }}"
      last_name="{{ $current_student->lastName }}"
    >
    </x-navbars.navs.auth>
    <!-- End Navbar -->

    <div class="container-fluid py-4">

      @if ($message = Session::get('success'))
        <div
          class="alert alert-success"
          style="display: flex; align-items: center; gap: 0.5rem; color: white; opacity: 0.9;"
        >
          <!-- <p>{{ $message }}</p> -->
          <i class="material-icons opacity-10">check</i>
          <p style="padding: 0; margin: 0;">{{ $message }}</p>
        </div>
      @endif

      <form
        action="{{ route('studentShowSubjects', $current_student->id) }}"
        method="POST"
        enctype="multipart/form-data"
      >
        @csrf
        @method('PUT')

        @foreach ($schedules as $schedule)
          <div class="form-check">
            <input
              class="form-check-input"
              id="flexCheckDefault"
              name="schedules.schedule_id_{{ $schedule->id }}"
              type="checkbox"
              {{ in_array($schedule->id, $student_selected_subject_id) ? 'checked' : '' }}
            />

            @if ($schedule->subject)
              <label
                class="form-check-label"
                for="flexCheckDefault"
              >
                <b>{{ $schedule->subject }}</b>
                (course duration: {{ $schedule->startTime }} ~
                {{ $schedule->endTime }})
              </label>
            @else
              <label
                class="form-check-label"
                for="flexCheckDefault"
              >
                <b>{{ 'no subject assigned' }}</b>
                (course duration: {{ $schedule->startTime }} ~
                {{ $schedule->endTime }})
              </label>
            @endif

          </div>
        @endforeach

        <button
          class="btn bg-gradient-dark"
          type="submit"
        >
          <i class="material-icons opacity-10">save</i>
          Save
        </button>
        <a
          class="btn bg-gradient-dark"
          href="{{ route('studentShowDashboard') }}"
        >
          Cancel
        </a>
      </form>

      <x-footers.auth></x-footers.auth>
    </div>
  </main>

</x-layout>
