/**
 * Zuwad Plugin - Teacher Calendar Styles
 * 
 * This file contains styles for the teacher calendar functionality
 * Organization:
 * - Calendar container and layout
 * - Calendar cells and time slots
 * - Event styling
 * - Interactive elements
 * - Modal components
 * - Status indicators
 */

/* =====================
   Calendar Container
   ===================== */
#teacher-calendar-container {
  max-width: 100%;
  margin: 20px auto;
  padding: 20px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  direction: rtl; /* Right-to-left for Arabic */
}

#student-filter {
  margin-bottom: 20px;
  padding: 5px;
  font-size: 16px;
  width: 100%; /* Full width on mobile */
}

#teacher-calendar {
  width: 100%;
  direction: rtl; /* Right-to-left for Arabic */
}

/* Header toolbar */
.fc-header-toolbar {
  margin-bottom: 10px;
  flex-direction: column; /* Stack header items vertically on mobile */
  align-items: flex-start; /* Align items to the start */
}

.fc-toolbar-title {
  font-size: 1.2em; /* Smaller title on mobile */
  margin-bottom: 10px; /* Add space below the title */
}

.fc-button-group {
  display: flex;
  flex-wrap: wrap; /* Allow buttons to wrap on small screens */
  gap: 5px; /* Add space between buttons */
}

.fc-button {
  font-size: 0.9em; /* Smaller buttons on mobile */
  padding: 5px 10px; /* Adjust button padding */
}

/* Events */
.fc-event {
  cursor: pointer;
  background-color: #4a90e2;
  border: none;
  padding: 5px;
  border-radius: 4px;
  color: #fff;
  font-size: 0.8em; /* Smaller event text on mobile */
  white-space: normal !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Ensure the event content container allows wrapping */
.fc-event-main {
  white-space: normal !important;
  word-wrap: break-word !important;
  text-align: center !important;
}

/* Adjust event height */
.fc-time-grid-event {
  height: auto !important;
  min-height: 30px !important;
}

.fc-timegrid-event .fc-event-main {
  justify-content: center;
  display: flex;
  align-content: center;
  align-items: center;
  white-space: normal !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.fc-event:hover {
  background-color: #357abd;
}

/* Add a small icon or indicator for postponed events */
.fc-event.postponed-event::before {
  content: "⏰ ";
  font-size: 0.9em;
  margin-right: 3px;
}

/* Ensure the hour column is on the right */
.fc-timegrid-axis {
  text-align: right;
  direction: rtl; /* Right-to-left for Arabic */
  font-size: 0.8em; /* Smaller hour labels on mobile */
}

/* Ensure days start from the right */
.fc-timegrid-header {
  direction: rtl; /* Right-to-left for Arabic */
}

/* Align the days correctly */
.fc-col-header-cell {
  text-align: right;
  font-size: 0.9em; /* Smaller day labels on mobile */
}

/* Ensure the time slots are aligned correctly */
.fc-timegrid-slot {
  text-align: right;
}

/* Reverse the order of days */
.fc-col-header {
  direction: rtl; /* Force RTL for the header to reverse the order */
}

/* Move the hour column to the right */
.fc-timegrid-axis-frame {
  direction: rtl; /* Right-to-left for Arabic */
}

/* Ensure the hour labels are aligned to the right */
.fc-timegrid-axis-cushion {
  text-align: right;
}

/* Ensure the calendar body is RTL */
.fc-timegrid-body {
  direction: rtl; /* Right-to-left for Arabic */
}

/* Ensure the time slots are RTL */
.fc-timegrid-slot {
  direction: rtl; /* Right-to-left for Arabic */
}

/* Make the days header take the full width */
.fc-col-header {
  width: 100% !important;
}

.fc-col-header-cell {
  flex: 1; /* Distribute space evenly */
  text-align: center; /* Center the day names */
}

/* Customize event content */
.fc-event-title {
  font-weight: bold;
  margin-bottom: 5px;
}

.fc-event-time {
  font-size: 0.8em; /* Smaller time text on mobile */
}

/* =====================
   Tablet Responsive (max-width: 1024px)
   ===================== */
@media (max-width: 1024px) {
  #teacher-calendar-container {
    padding: 12px;
    margin: 10px auto;
    border-radius: 6px;
  }

  #calender-filter {
    flex-wrap: wrap;
    height: auto;
    gap: 8px;
    margin-bottom: 12px;
  }

  #calender-filter select.searchable-select {
    height: 38px;
    font-size: 13px;
  }

  #calender-filter .select2-container {
    width: 48% !important;
    min-width: 200px;
  }

  #calender-filter .select2-container--default .select2-selection--single {
    height: 38px;
  }

  #calender-filter
    .select2-container--default
    .select2-selection--single
    .select2-selection__rendered {
    line-height: 38px;
    font-size: 13px;
  }

  #calender-filter
    .select2-container--default
    .select2-selection--single
    .select2-selection__arrow {
    height: 36px;
  }

  .fc .fc-toolbar.fc-header-toolbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
  }

  .fc-toolbar-title {
    font-size: 1.1em;
    margin-bottom: 4px;
  }

  .fc-button {
    font-size: 0.85em;
    padding: 6px 10px;
    min-height: 36px;
  }

  .fc-prev-button,
  .fc-next-button {
    min-width: 40px;
    min-height: 40px;
    font-size: 1em;
  }

  .fc-button-group {
    gap: 4px;
  }

  .fc-event {
    font-size: 0.8em;
    padding: 3px 5px;
    min-height: 26px !important;
  }

  .fc-timegrid-axis {
    width: 50px !important;
    font-size: 0.82em;
  }

  .fc-col-header-cell {
    font-size: 0.85em;
    padding: 4px 2px;
  }

  .fc-direction-rtl .fc-timegrid-slot-label-frame {
    font-size: 11px;
  }

  .fc-timegrid-slot {
    height: 40px !important;
  }

  .fc .fc-timegrid-slot-label {
    font-size: 0.82em;
  }

  #hours-select {
    font-size: 13px;
    padding: 6px 10px;
  }

  .button-row {
    gap: 8px;
  }

  .button-row button {
    padding: 10px 6px;
    font-size: 13px;
  }
}

/* =====================
   Mobile Responsive (max-width: 768px)
   ===================== */
@media (max-width: 768px) {
  #teacher-calendar-container {
    padding: 10px 6px;
    margin: 5px auto;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  }

  #calender-filter {
    flex-direction: column;
    height: auto;
    margin-bottom: 10px;
    gap: 6px;
  }

  #calender-filter select.searchable-select {
    width: 100%;
    height: 42px;
    font-size: 15px;
  }

  #calender-filter .select2-container {
    width: 100% !important;
  }

  #calender-filter .select2-container--default .select2-selection--single {
    height: 42px;
  }

  #calender-filter
    .select2-container--default
    .select2-selection--single
    .select2-selection__rendered {
    line-height: 42px;
    font-size: 15px;
  }

  #calender-filter
    .select2-container--default
    .select2-selection--single
    .select2-selection__arrow {
    height: 40px;
  }

  .fc-header-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .fc .fc-toolbar.fc-header-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 8px 0;
  }

  .fc .fc-toolbar.fc-header-toolbar > .fc-toolbar-chunk {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    align-items: center;
    width: 100%;
  }

  .fc-toolbar-title {
    font-size: 1em;
    text-align: center;
    width: 100%;
    order: -1;
    margin-bottom: 4px;
    font-weight: 700;
    color: #333;
  }

  .fc-button {
    font-size: 0.82em;
    padding: 8px 10px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 6px !important;
  }

  .fc-prev-button,
  .fc-next-button {
    min-width: 48px;
    min-height: 44px;
    font-size: 1.1em;
  }

  .fc-today-button {
    min-width: 60px;
    min-height: 44px;
    font-size: 0.85em;
    font-weight: 600;
  }

  .fc-button-group {
    gap: 4px;
  }

  .fc-timeGridDay-button,
  .fc-timeGridWeek-button,
  .fc-dayGridMonth-button {
    min-width: 60px;
    min-height: 40px;
    font-size: 0.82em;
  }

  .fc-event {
    font-size: 0.72em;
    padding: 4px 5px;
    min-height: 28px !important;
    border-radius: 4px !important;
  }

  .fc-timegrid-axis {
    font-size: 0.72em;
    width: 42px !important;
  }

  .fc-col-header-cell {
    font-size: 0.78em;
    padding: 3px 1px;
  }

  .fc-direction-rtl .fc-timegrid-slot-label-frame {
    font-size: 10px;
  }

  .fc .fc-timegrid-slot-label {
    font-size: 0.72em;
  }

  .fc-timegrid-slot {
    height: 36px !important;
  }

  .fc .fc-timegrid-body > table {
    min-width: 500px;
  }

  .fc .fc-timegrid-cols > table {
    min-width: 500px;
  }

  #hours-select {
    width: 100% !important;
    margin: 6px 0 !important;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 500;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    min-height: 44px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 10px center;
    padding-left: 30px;
  }

  .fc-scroller {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .fc-scroller::-webkit-scrollbar {
    height: 4px;
  }

  .fc-scroller::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
  }

  .calendar-loading-overlay {
    border-radius: 4px;
  }

  .calendar-loading-spinner {
    width: 36px;
    height: 36px;
    border-width: 3px;
  }

  .zuwad-modal {
    padding: 10px !important;
  }

  .zuwad-modal-content {
    padding: 16px !important;
    max-height: 90vh;
    width: 96% !important;
    margin: 0 auto;
  }

  .button-row {
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
  }

  .button-row button {
    padding: 14px 10px;
    font-size: 15px;
    border-radius: 8px;
    min-height: 48px;
    font-weight: 600;
  }

  .fc .fc-scrollgrid {
    min-width: 500px;
  }

  .fc .fc-scrollgrid > table {
    min-width: 500px;
  }

  /* Ensure select2 dropdown is usable on mobile */
  .select2-dropdown {
    font-size: 15px;
  }

  .select2-container--default .select2-search--dropdown .select2-search__field {
    padding: 10px 12px;
    font-size: 15px;
    min-height: 44px;
  }

  .select2-results__option {
    padding: 10px 12px;
    font-size: 15px;
    min-height: 44px;
  }
}

/* =====================
   Small Phone Responsive (max-width: 480px)
   ===================== */
@media (max-width: 480px) {
  #teacher-calendar-container {
    padding: 4px 2px;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
  }

  #calender-filter {
    margin-bottom: 6px;
    gap: 4px;
  }

  #calender-filter select.searchable-select {
    height: 40px;
    font-size: 14px;
  }

  #calender-filter .select2-container--default .select2-selection--single {
    height: 40px;
  }

  #calender-filter
    .select2-container--default
    .select2-selection--single
    .select2-selection__rendered {
    line-height: 40px;
    font-size: 14px;
  }

  .fc .fc-toolbar.fc-header-toolbar {
    gap: 6px;
    padding: 4px 0;
  }

  .fc .fc-toolbar.fc-header-toolbar > .fc-toolbar-chunk {
    gap: 3px;
    justify-content: center;
  }

  .fc-toolbar-title {
    font-size: 0.88em;
    font-weight: 700;
  }

  .fc-button {
    font-size: 0.72em;
    padding: 7px 6px;
    min-width: 36px;
    min-height: 40px;
    border-radius: 5px !important;
  }

  .fc-prev-button,
  .fc-next-button {
    min-width: 40px;
    min-height: 40px;
    font-size: 1em;
    padding: 7px 8px;
  }

  .fc-today-button {
    min-width: 50px;
    min-height: 40px;
    font-size: 0.78em;
    padding: 7px 8px;
  }

  .fc-timeGridDay-button,
  .fc-timeGridWeek-button,
  .fc-dayGridMonth-button {
    min-width: 48px;
    min-height: 36px;
    font-size: 0.72em;
    padding: 6px 4px;
  }

  .fc-button-group {
    gap: 2px;
  }

  .fc-event {
    font-size: 0.62em;
    padding: 2px 3px;
    min-height: 24px !important;
    border-radius: 3px !important;
  }

  .fc-timegrid-axis {
    font-size: 0.65em;
    width: 36px !important;
  }

  .fc-col-header-cell {
    font-size: 0.68em;
    padding: 2px 1px;
  }

  .fc-direction-rtl .fc-timegrid-slot-label-frame {
    font-size: 9px;
  }

  .fc .fc-timegrid-slot-label {
    font-size: 0.65em;
  }

  .fc-timegrid-slot {
    height: 32px !important;
  }

  #hours-select {
    padding: 8px 10px;
    font-size: 14px;
    border-radius: 5px;
    min-height: 42px;
  }

  .calendar-loading-overlay {
    border-radius: 0;
  }

  .calendar-loading-spinner {
    width: 30px;
    height: 30px;
    border-width: 3px;
  }

  .zuwad-modal-content {
    padding: 12px !important;
    border-radius: 8px !important;
  }

  .button-row {
    gap: 6px;
  }

  .button-row button {
    padding: 12px 6px;
    font-size: 14px;
    min-height: 46px;
  }

  .fc .fc-scrollgrid {
    min-width: 420px;
  }

  .fc .fc-scrollgrid > table {
    min-width: 420px;
  }

  .fc .fc-timegrid-body > table {
    min-width: 420px;
  }

  .fc .fc-timegrid-cols > table {
    min-width: 420px;
  }
}

/* =====================
   Filter Bar & Select2 (Global)
   ===================== */
#calender-filter{
    display: flex;
    flex-direction: row;
    gap: 10px;
    height: 50px;
    align-items: center;
    margin-bottom: 15px;
}

/* Native select styling */
#calender-filter select.searchable-select {
    height: 40px;
    padding: 5px 10px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: #fff;
}

/* Select2 Searchable Dropdown Styles */
#calender-filter .select2-container {
    width: 250px !important;
}

#calender-filter .select2-container--default .select2-selection--single {
  height: 40px;
  display: flex;
  align-items: center;
  border: 1px solid #ddd;
  border-radius: 6px;
  background-color: #fff;
  direction: rtl;
}

#calender-filter
  .select2-container--default
  .select2-selection--single
  .select2-selection__rendered {
  line-height: 40px;
  padding-right: 12px;
  padding-left: 30px;
  color: #333;
}

#calender-filter
  .select2-container--default
  .select2-selection--single
  .select2-selection__arrow {
  height: 38px;
  left: 5px;
  right: auto;
}

/* Dropdown styles */
.select2-dropdown {
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  direction: rtl;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  direction: rtl;
}

.select2-container--default
  .select2-results__option--highlighted.select2-results__option--selectable {
  background-color: #8f1b2b;
  color: white;
}

.select2-results__option {
  padding: 8px 12px;
  text-align: right;
}

/* Clear button styling */
.select2-container--default
  .select2-selection--single
  .select2-selection__clear {
  margin-left: 5px;
  margin-right: 0;
  color: #999;
}

.select2-container--default
  .select2-selection--single
  .select2-selection__clear:hover {
  color: #8f1b2b;
}

.fc-icon-chevron-left::before {
  content: "\e901";
}
.fc-icon-chevron-right::before {
  content: "\e900";
}

.fc-direction-rtl .fc-timegrid-slot-label-frame {
  text-align: center;
  font-size: 12px;
}

.fc-direction-ltr .fc-timegrid-slot-label-frame {
  font-size: 0.7rem;
  text-align: center;
}

/* RTL specific styles for arrow buttons */
.fc-prev-button,
.fc-next-button {
  transform: rotate(180deg); /* Flip the arrows for RTL */
}

.fc-header-toolbar {
  display: flex;
  justify-content: flex-start; /* Align buttons to the left */
}

.fc-prev-button {
  margin-right: 0;
}

.fc-next-button {
  margin-left: 0;
}

.fc .fc-toolbar.fc-header-toolbar {
  display: flex;
  flex-direction: row;
}

/* Hide scrollbar for the calendar */
.fc-scroller::-webkit-scrollbar {
  display: none; /* Hide scrollbar for WebKit browsers (Chrome, Safari, etc.) */
}

.fc-scroller {
  scrollbar-width: none; /* Hide scrollbar for Firefox */
  -ms-overflow-style: none; /* Hide scrollbar for IE/Edge */
}

.button-row {
  display: flex;
  gap: 10px; /* Space between buttons */
  margin-top: 20px; /* Adjust as needed */
}

.button-row button {
  flex: 1; /* Distribute space evenly */
  padding: 10px 0px;
  font-size: 14px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

#share-report {
  background-color: #4caf50; /* Green */
  color: white;
}

#share-report:hover {
  background-color: #45a049;
}

.remove-report-button {
  background-color: #cc0101; /* Red */
  color: white;
}

.remove-report-button:hover {
  background-color: #e70d0d;
}

/* =====================
   Calendar Grid
   ===================== */

/* =====================
   Events and Appointments
   ===================== */

/* =====================
   Interactive Elements
   ===================== */

/* =====================
   Modal Components
   ===================== */

/* =====================
   Status Indicators
   ===================== */

/* =====================
   Loading Indicators
   ===================== */
.calendar-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  border-radius: 8px;
}

.calendar-loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #8f1b2b;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.slot-loading {
  opacity: 0.6;
  pointer-events: none;
}

.slot-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #8f1b2b;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* FullCalendar v6 injects its base CSS at runtime, so keep key overrides scoped */
#teacher-calendar .fc-header-toolbar {
  margin-bottom: 10px;
}

#teacher-calendar .fc-toolbar-title {
  font-size: 1.2em;
}

#teacher-calendar .fc-button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

#teacher-calendar .fc-button {
  font-size: 0.9em;
  padding: 5px 10px;
}

#teacher-calendar .fc-event {
  cursor: pointer;
  background-color: #4a90e2;
  border: none;
  padding: 5px;
  border-radius: 4px;
  color: #fff;
  font-size: 0.8em;
  white-space: normal !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#teacher-calendar .fc-event-main {
  white-space: normal !important;
  word-wrap: break-word !important;
  text-align: center !important;
}

#teacher-calendar .fc-timegrid-axis {
  text-align: right;
  direction: rtl;
  font-size: 0.8em;
}

#teacher-calendar .fc-timegrid-header,
#teacher-calendar .fc-col-header,
#teacher-calendar .fc-timegrid-axis-frame,
#teacher-calendar .fc-timegrid-body,
#teacher-calendar .fc-timegrid-slot {
  direction: rtl;
}

#teacher-calendar .fc-col-header-cell,
#teacher-calendar .fc-timegrid-axis-cushion {
  text-align: right;
}

#teacher-calendar .fc-col-header {
  width: 100% !important;
}

#teacher-calendar .fc-event-title {
  font-weight: bold;
  margin-bottom: 5px;
}

#teacher-calendar .fc-event-time {
  font-size: 0.8em;
}

@media (max-width: 768px) {
  #teacher-calendar .fc-header-toolbar,
  #teacher-calendar .fc-toolbar.fc-header-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  #teacher-calendar .fc-toolbar-title {
    font-size: 1em;
    text-align: center;
    width: 100%;
    order: -1;
    margin-bottom: 4px;
  }

  #teacher-calendar .fc-button {
    font-size: 0.82em;
    padding: 8px 10px;
    min-width: 44px;
    min-height: 44px;
  }

  #teacher-calendar .fc-button-group {
    gap: 4px;
  }

  #teacher-calendar .fc-event {
    font-size: 0.72em;
    padding: 4px 5px;
    min-height: 28px !important;
  }
}

@media (max-width: 480px) {
  #teacher-calendar .fc-toolbar-title {
    font-size: 0.88em;
  }

  #teacher-calendar .fc-button {
    font-size: 0.72em;
    padding: 7px 6px;
    min-width: 36px;
    min-height: 40px;
  }

  #teacher-calendar .fc-button-group {
    gap: 2px;
  }

  #teacher-calendar .fc-event {
    font-size: 0.62em;
    padding: 2px 3px;
    min-height: 24px !important;
  }
}
