/* ============================
   SCHEDULING PAGE STYLES
   ============================ */

/* MAIN LAYOUT */
.schedule-container {
  display: flex;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* LEFT COURSE LIST */
.course-search {
  width: 320px;
  max-width: 320px;
  padding: 22px;
  background: var(--bg-card);
  border-right: 2px solid var(--border-warm-strong);
  overflow-y: auto;
  flex-shrink: 0;
}

.course-search h2 {
  color: var(--maroon);
  margin-bottom: 6px;
  font-size: 20px;
}

#data-freshness {
  margin: 0 0 12px;
}

#search-box {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-input);
  margin-bottom: 10px;
  font-size: 14px;
  background: var(--bg-soft);
  box-sizing: border-box;
  font-family: 'Nunito', sans-serif;
}

#search-box:focus {
  outline: var(--focus-ring);
  border-color: var(--maroon);
}

/* FILTERS */
.filter-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.filter-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.semester-data-filter,
.dept-filter {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-input);
  background: var(--bg-soft);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
}

#results-count {
  margin: 0 0 10px;
  font-weight: 600;
}

/* COURSE LIST */
#course-list {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
}

#course-list li {
  margin-bottom: 8px;
}

.course-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px;
  background: var(--bg-cream);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-warm);
  font-size: 13px;
  font-family: 'Nunito', sans-serif;
  color: var(--text-main);
  cursor: pointer;
  transition: 0.15s ease;
}

.course-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: #c6b784;
}

.course-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.course-item-top strong {
  color: var(--maroon);
  font-size: 13px;
}

.course-item-credits {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.course-item-name {
  display: block;
  font-weight: 600;
  margin: 1px 0 2px;
}

.course-item-meta {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
}

.course-item-term {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border-warm);
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

.course-item-extra {
  margin-top: 2px;
  color: var(--warning);
}

.archive-note {
  color: var(--warning);
  background: var(--warning-bg);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin-top: 4px;
}

.prereq-text {
  display: block;
  margin-top: 2px;
  color: var(--gold);
  font-size: 11px;
  font-style: italic;
}

/* Scheduled state */
.scheduled-badge {
  display: none;
  margin-top: 5px;
  padding: 2px 8px;
  background: var(--success-bg);
  color: var(--success);
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
}

.course-item.is-scheduled {
  background: var(--success-bg);
  border-color: var(--success);
}

.course-item.is-scheduled .scheduled-badge {
  display: inline-block;
}

.course-list-message {
  padding: 18px 10px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

/* RIGHT SIDE - SCHEDULE GRID */
.week-grid {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
}

/* SCHEDULE HEADER WITH CREDIT COUNTER */
.schedule-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.schedule-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.schedule-controls .filter-label {
  white-space: nowrap;
}

.semester-select {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-input);
  background: var(--bg-cream);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
}

.title {
  font-size: 24px;
  color: var(--maroon);
  margin: 0;
}

#credit-counter {
  font-size: 1.05em;
  font-weight: 600;
  color: var(--maroon);
  background: white;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-warm);
  white-space: nowrap;
}

/* ACTION BUTTONS */
.schedule-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.schedule-actions .hint-text {
  margin: 0;
  flex-basis: 100%;
}

/* SCHEDULE GRID LAYOUT */

/* Dedicated scroll container: the calendar gets a bounded height and its
   own vertical/horizontal scrolling instead of relying on page scroll. */
.schedule-grid-scroll {
  max-height: min(720px, calc(100vh - 240px));
  overflow-y: auto;
  overflow-x: auto;
  border: 2px solid var(--border-warm);
  border-radius: var(--radius-lg);
  background: white;
  box-shadow: var(--shadow-sm);
}

.schedule-grid {
  display: grid;
  grid-template-columns: 80px repeat(5, 1fr);
  gap: 0;
  background: white;
  min-width: 640px;
}

/* TIME COLUMN (sticky left so labels stay readable while scrolling
   horizontally on narrow screens) */
.time-column {
  background: var(--bg-cream);
  border-right: 2px solid var(--border-warm-strong);
  height: auto;
  position: sticky;
  left: 0;
  z-index: 4;
}

.time-header {
  height: 50px;
  border-bottom: 2px solid var(--border-warm-strong);
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-cream);
}

.time-slot {
  height: 45px;
  min-height: 45px;
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  padding-top: 2px;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid #f5f0e8;
  font-weight: 500;
}

/* DAY COLUMNS */
.day-column {
  position: relative;
  border-right: 1px solid #f5f0e8;
}

.day-column:last-child {
  border-right: none;
}

/* Sticky day headers stay visible while scrolling through the day */
.day-header {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  background: linear-gradient(135deg, var(--maroon), var(--maroon-dark));
  color: #ffffff;
  border-bottom: 2px solid var(--border-warm-strong);
  font-size: 15px;
  font-family: 'Quicksand', sans-serif;
  position: sticky;
  top: 0;
  z-index: 3;
}

.day-slots {
  position: relative;
  /* Height + background set dynamically by buildTimeGrid() */
}

/* COURSE BLOCKS */
.course-block {
  position: absolute;
  left: 4px;
  right: 4px;

  padding: 5px 7px;
  background: #fff8d9;
  border: 1.5px solid #e6d09d;
  border-radius: var(--radius-sm);

  font-size: 10px;
  line-height: 1.2;
  font-weight: 600;
  color: var(--text-soft);

  box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  z-index: 1;
  transition: transform 0.1s ease;
}

.course-block:hover {
  transform: scale(1.02);
  box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.12);
  z-index: 2;
}

.course-block strong {
  display: block;
  font-size: 11px;
  margin-bottom: 1px;
  color: var(--maroon);
}

.course-block-name {
  display: block;
}

.course-block small {
  font-size: 9px;
  color: var(--text-muted);
  opacity: 0.9;
}

/* REMOVE (X) BUTTON */
.remove-btn {
  position: absolute;
  top: 3px;
  right: 5px;

  width: 18px;
  height: 18px;
  padding: 0;
  border: none;

  font-size: 10px;
  color: var(--maroon);
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 3px;
  background: transparent;
  transition: background 0.2s;
}

.remove-btn:hover {
  background: #f2e7d0;
}

/* UNSCHEDULED (NO MEETING TIME) SECTION */
.unscheduled-section {
  margin-top: 20px;
  padding: 16px 20px;
  background: white;
  border: 2px solid var(--border-warm);
  border-radius: var(--radius-lg);
}

.unscheduled-section h3 {
  color: var(--maroon);
  font-size: 16px;
  margin-bottom: 4px;
}

.unscheduled-section .hint-text {
  margin: 0 0 10px;
}

#unscheduled-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.unscheduled-item {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-cream);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-md);
  font-size: 13px;
}

.unscheduled-info strong {
  color: var(--maroon);
  display: block;
  margin-bottom: 2px;
}

.unscheduled-remove {
  position: static;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  font-size: 12px;
}

/* RESPONSIVE - TABLET (≤900px) */
@media (max-width: 900px) {
  .schedule-container {
    flex-direction: column;
    height: auto;
  }

  .course-search {
    width: 100%;
    max-width: 100%;
    border-right: none;
    border-bottom: 2px solid var(--border-warm-strong);
    max-height: 45vh;
  }

  .week-grid {
    padding: 12px;
    overflow: visible;
  }

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

  .schedule-grid-scroll {
    -webkit-overflow-scrolling: touch;
  }
}

/* RESPONSIVE - PHONE (≤640px) */
@media (max-width: 640px) {
  .schedule-container {
    height: auto;
  }

  .course-search {
    max-height: 40vh;
    padding: 14px;
  }

  .course-search h2 {
    font-size: 17px;
    margin-bottom: 10px;
  }

  .title {
    font-size: 18px;
  }

  .schedule-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
  }

  .semester-select {
    width: 100%;
    font-size: 13px;
  }

  #credit-counter {
    font-size: 0.95em;
    padding: 4px 10px;
  }

  .week-grid {
    padding: 8px;
  }

  .schedule-grid {
    min-width: 600px;
  }

  .day-header {
    height: 40px;
    font-size: 0;
  }

  /* Abbreviate day names via CSS (no HTML changes) */
  .day-column:nth-child(2) .day-header::after { content: "Mon"; font-size: 12px; }
  .day-column:nth-child(3) .day-header::after { content: "Tue"; font-size: 12px; }
  .day-column:nth-child(4) .day-header::after { content: "Wed"; font-size: 12px; }
  .day-column:nth-child(5) .day-header::after { content: "Thu"; font-size: 12px; }
  .day-column:nth-child(6) .day-header::after { content: "Fri"; font-size: 12px; }

  .time-header {
    height: 40px;
  }

  .remove-btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .course-block:hover {
    transform: none;
  }
}
