/* Settings for dropdowns, curriculum tables, and schedule previews. */
:root {
  --dropdown-radius: 10px;
  --dropdown-arrow-inset: 14px;
}

/* Every visible dropdown uses the same rounded control and popup menu. */
.custom-select {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  margin-top: 0;
}

.custom-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  padding: 0 !important;
  opacity: 0;
  clip-path: inset(50%);
  pointer-events: none;
}

.custom-select-trigger {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  padding: 9px 36px 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--dropdown-radius);
  background: #0d251e;
  color: var(--text);
  text-align: left;
  font-size: 14px;
  line-height: 20px;
}

.custom-select-trigger:hover:not(:disabled), .is-open > .custom-select-trigger {
  border-color: #7dba93;
  background: #153529;
}

.custom-select-trigger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.custom-select-value {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.custom-select-arrow {
  position: absolute;
  top: 50%;
  right: var(--dropdown-arrow-inset);
  display: flex;
  color: var(--muted);
  transform: translateY(-50%);
  transition: transform 140ms;
}

.is-open .custom-select-arrow {
  transform: translateY(-50%) rotate(180deg);
}

.custom-select-menu {
  position: fixed;
  inset: auto;
  z-index: 1000;
  margin: 0;
  padding: 6px;
  overflow: auto;
  border: 1px solid #4a705b;
  border-radius: var(--dropdown-radius);
  background: #142f25;
  color: var(--text);
  box-shadow: 0 14px 38px #0007;
  font-family: inherit;
  font-size: 14px;
  scrollbar-width: thin;
  scrollbar-color: #52775e transparent;
}

.custom-select-option {
  min-height: 36px;
  padding: 8px 11px;
  border-radius: 6px;
  line-height: 20px;
  cursor: pointer;
  white-space: normal;
  overflow-wrap: anywhere;
}

.custom-select-option[aria-selected="true"] {
  background: #25503a;
  color: #c0f5cf;
  font-weight: 600;
}

.custom-select-option.is-highlighted {
  background: #345f43;
  outline: 1px solid #659c72;
  outline-offset: -1px;
}

.custom-select-option[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
}

.custom-select-group-label {
  padding: 6px 10px;
  color: var(--muted);
  font-size: 11px;
}

.sort-wrap {
  padding: 0;
  border: 0;
  align-items: center;
  justify-content: center;
}

.sort-wrap > span:not(.custom-select) {
  display: none;
}

.sort-wrap .custom-select {
  margin-top: 0;
}

.sort-wrap .custom-select-trigger {
  text-align: center;
  padding-left: 42px;
}

.academic-context {
  align-items: center;
}

.academic-context > .button {
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  text-align: center;
}

.meeting-row .custom-select-trigger {
  padding-left: 8px;
  font-size: 12px;
}

/* Curriculum fills the workspace; units stay left-aligned. */
#curriculum-panel, body[data-view="curriculum"] .tools {
  width: 100%;
  max-width: none;
}

.curriculum-group {
  width: 100%;
  max-width: none;
}

.curriculum-group th:last-child, .curriculum-group td:last-child {
  width: 96px;
  padding-left: 12px;
  padding-right: 20px;
  text-align: left;
}

/* Reserve action space, but reveal the icons only when the row is in use. */
.table-actions, .group-actions, .period-actions {
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms;
}

tbody tr:hover .table-actions, tbody tr:focus-within .table-actions, .group-heading:hover .group-actions, .group-heading:focus-within .group-actions, .period-row:hover .period-actions, .period-row:focus-within .period-actions {
  opacity: 1;
  pointer-events: auto;
}

.table-actions button, .row-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--mint);
  line-height: 1;
}

.table-actions button:hover, .row-icon-button:hover {
  border-color: #416b50;
  background: #254634;
}

.table-actions button.delete {
  color: #f2b3a6;
}

.table-actions button.delete:hover {
  border-color: #805347;
  background: #442c25;
}

.current-period-label {
  color: var(--muted);
  font-size: 11px;
}

/* The weekly chart takes priority over its compact summary header. */
.schedule-dialog > .dialog-heading {
  padding: 10px 16px;
}

.schedule-dialog .dialog-content {
  padding: 12px 16px 16px;
}

.schedule-title-row {
  margin-bottom: 10px;
}

.schedule-title-row h2 {
  font-size: 23px;
  line-height: 1.15;
}

.schedule-title-row p, .schedule-title-row .helper {
  font-size: 10px;
}

.schedule-stats {
  margin: 0 0 12px;
  padding: 8px 0;
  gap: 12px;
}

.schedule-stats dt {
  font-size: 10px;
}

.schedule-stats dd {
  margin-top: 2px;
  font-size: 14px;
  line-height: 1.3;
}

.timeline-body {
  background: repeating-linear-gradient(to bottom,     transparent 0,     transparent calc(var(--hour-height, 60px) - 1px),     #2d4639 calc(var(--hour-height, 60px) - 1px),     #2d4639 var(--hour-height, 60px));
}

/* Switch between section cards and weekly schedule previews. */
.explore-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.explore-toolbar .filter-container {
  flex: 1;
  margin: 0;
}

.schedule-view-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  gap: 10px;
  min-height: 36px;
  margin-left: auto;
  padding: 6px 0 6px 10px;
  font-size: 12px;
  color: var(--muted);
}

.switch-track {
  display: inline-flex;
  align-items: center;
  width: 34px;
  height: 20px;
  padding: 3px;
  border: 1px solid #5b7e65;
  border-radius: 12px;
  background: #19392a;
}

.switch-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #bbd1c1;
  transition: transform 140ms;
}

.schedule-view-switch[aria-checked="true"] {
  color: var(--text);
}

.schedule-view-switch[aria-checked="true"] .switch-track {
  border-color: var(--mint);
  background: #366746;
}

.schedule-view-switch[aria-checked="true"] .switch-thumb {
  transform: translateX(14px);
  background: var(--mint);
}

#section-grid.is-schedule-view {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.section-schedule-preview {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.preview-heading {
  display: grid;
  grid-template-columns: minmax(56px, 1fr) minmax(0, 3fr) minmax(56px, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.preview-heading h2 {
  font-size: 20px;
  line-height: 1.2;
}

.preview-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 348px;
  min-width: 0;
  margin: 0;
  justify-self: center;
  text-align: center;
}

.preview-summary > div {
  display: grid;
  align-content: center;
  justify-items: center;
  min-width: 0;
  min-height: 56px;
  padding: 8px 6px;
  border: 1px solid #a3edba1a;
  border-radius: 8px;
  background: var(--surface-hover);
}

.preview-heading > button {
  justify-self: end;
}

.preview-summary dt {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
}

.preview-summary dd {
  margin: 4px 0 0;
  color: var(--mint);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.section-card .stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Keep native touch, trackpad and keyboard scrolling without a visible bar. */
.week-scroll {
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.week-scroll::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

@media (max-width: 600px) {
  .preview-heading {
    grid-template-columns: minmax(0, 1fr) 32px;
  }

  .preview-summary {
    grid-column: 1 / -1;
    grid-row: 2;
    padding-top: 10px;
    border-top: 1px solid var(--line);
  }

  .preview-heading > button {
    grid-column: 2;
    grid-row: 1;
  }
}

.preview-week .week-grid {
  min-width: calc(44px + var(--days, 6) * 96px);
  grid-template-columns: 44px repeat(var(--days, 6), minmax(96px, 1fr));
}

.preview-week .timeline-day, .preview-week .time-header {
  height: 32px;
}

.preview-week .timeline-event {
  padding: 5px;
}

.preview-week .event-name {
  font-size: 9px;
  line-height: 1.3;
}

.preview-week .event-time {
  display: none;
}

@media (max-width: 1100px) {
  #section-grid.is-schedule-view {
    grid-template-columns: minmax(0, 1fr);
  }

}

@media (max-width: 680px) {
  .academic-context > .button {
    width: auto;
    margin: 12px auto 0;
  }

  .explore-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .explore-toolbar .filter-container {
    flex-basis: 100%;
  }

  .custom-select-trigger {
    font-size: 14px;
  }

  .section-context .custom-select-trigger {
    padding-left: 8px;
    padding-right: 30px;
    font-size: 12px;
  }

  .section-context .custom-select-arrow {
    right: var(--dropdown-arrow-inset);
  }

  .schedule-stats {
    gap: 8px;
  }

  .schedule-stats dd {
    font-size: 13px;
  }

}

@media (hover: none), (pointer: coarse) {
  .table-actions,   .group-actions,   .period-actions {
    opacity: 1;
    pointer-events: auto;
  }

  .custom-select-trigger,   .custom-select-option,   .schedule-view-switch,   .table-actions button,   .row-icon-button {
    min-height: 44px;
  }

  .table-actions button,   .row-icon-button {
    width: 44px;
    min-width: 44px;
  }

}

/* Period selectors share the search toolbar in Explore and Course offerings. */
.tools.has-period-selectors {
  display: grid;
  grid-template-columns: minmax(340px, auto) minmax(0, 1fr) 198px;
  align-items: center;
  gap: 12px;
}

.tools .context-fields {
  min-width: 0;
}

.tools .context-fields label {
  min-width: 84px;
}

.filter-help {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 11px;
}

.view-nav [role="tablist"] {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
}

/* One data workspace owns all file transfers, templates, and scraper actions. */
#backup-panel {
  width: 100%;
}

.data-transfer-section {
  margin: 0 0 18px;
  padding: 16px 0 18px;
  border-bottom: 1px solid var(--line);
}

.data-transfer-section h3 {
  margin-bottom: 10px;
  font-size: 17px;
}

.data-transfer-section h4 {
  font-size: 13px;
  font-weight: 600;
}

.data-transfer-controls {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
}

.data-transfer-controls > label:first-child {
  width: 240px;
}

.data-transfer-controls > label:nth-child(2) {
  width: 210px;
}

.backup-period-target {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.backup-period-target .context-fields {
  margin-top: 10px;
  max-width: 650px;
}

.backup-period-target .helper {
  margin-top: 4px;
}

.template-downloads {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 14px;
}

.template-downloads p {
  margin: 5px 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.data-transfer-section > .button {
  margin-top: 12px;
}

@media (max-width: 680px) {
  .template-downloads {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .data-transfer-controls > label:first-child {
    width: min(100%, 240px);
  }

  .data-transfer-controls > .actions {
    width: 100%;
  }

  .backup-period-target .context-fields {
    flex-wrap: wrap;
  }

  .backup-period-target .context-fields label {
    min-width: 80px;
    flex: 1;
  }
}

#backup-section-field {
  display: block;
  max-width: 280px;
  margin-top: 12px;
}

.tools.has-period-selectors .sort-wrap {
  min-width: 0;
}

/* Value-only dropdowns keep labels available as empty-state placeholders. */
.custom-select-leading-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  color: var(--muted);
}

.has-leading-icon.custom-select-trigger {
  padding-left: 35px;
}

.tools .context-fields {
  flex: none;
  gap: 8px;
}

.tools .context-fields label:first-child {
  min-width: 170px;
}

.tools .search-wrap {
  width: auto;
  min-width: 0;
  height: 40px;
}

.tools .search-wrap input {
  min-width: 0;
  width: 100%;
}

.tools .sort-wrap {
  width: auto;
  min-width: 0;
  height: 40px;
  border: 0;
  padding: 0;
  gap: 0;
}

.sort-wrap .custom-select-value {
  text-align: center;
  font-size: 13px;
}

/* Rooms are visible in compact weekly charts as well as the larger modal. */
.preview-week .timeline-room {
  display: block;
  font-size: 10px;
  line-height: 1.25;
  margin-top: 3px;
  overflow-wrap: anywhere;
  color: #163525;
  font-weight: 650;
}

.preview-heading {
  flex-shrink: 0;
}

.section-schedule-preview {
  display: flex;
  flex-direction: column;
}

.manual-course-fields {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(180px, 2fr) 100px 34px;
  align-items: end;
  gap: 10px;
}

.section-course .remove-course {
  opacity: 1;
  visibility: visible;
  height: 40px;
}

.section-curriculum-tools {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 10px;
}

.section-curriculum-tools label {
  flex: 1 1 190px;
  min-width: 0;
}

.course-matching {
  margin: 10px 0 16px;
}

.match-explanation {
  margin-top: 6px;
}

.curriculum-course-picker {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.curriculum-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 9px 0;
}

.curriculum-choice input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  accent-color: var(--mint);
}

.period-row > div:first-child {
  flex: 1;
  min-width: 0;
}

#open-personal {
  margin: 8px 0 12px;
}

.curriculum-name-label {
  flex: 2;
  min-width: 220px;
}

.danger {
  color: #ffc4be;
  border-color: #a05d59;
}

#reset-confirm-label {
  display: block;
  margin-top: 14px;
}

#confirm-backup {
  margin-top: 12px;
}

@media (max-width: 960px) {
  .tools.has-period-selectors {
    grid-template-columns: minmax(0, 1fr) 198px;
  }

  .tools.has-period-selectors .context-fields {
    grid-column: 1 / -1;
    max-width: none;
  }
}

@media (max-width: 600px) {
  .manual-course-fields {
    grid-template-columns: minmax(0, 1fr) 90px 34px;
  }

  .manual-course-fields label:nth-child(2) {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .tools .context-fields label,
  .tools .context-fields label:first-child {
    flex: 1;
    min-width: 0;
  }

  .tools .context-fields label:first-child {
    flex: 1.6;
  }

  .tools.has-period-selectors .sort-wrap {
    width: 198px;
  }

  .tools.has-period-selectors {
    grid-template-columns: minmax(0, 1fr);
  }

  .tools.has-period-selectors .search-wrap {
    width: 100%;
  }

  .tools.has-period-selectors .sort-wrap {
    justify-self: end;
  }
}

.preview-week .timeline-event {
  display: flex;
  flex-direction: column;
  padding-block: 3px;
}

.preview-week .timeline-event strong {
  flex-shrink: 0;
}

.preview-week .timeline-room {
  order: 1;
  flex-shrink: 0;
  margin-top: 1px;
}

.preview-week .timeline-event .event-name {
  order: 2;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  margin-top: 2px;
}

/* Full-width input rows remain legible with longer curriculum and workspace names. */
.curriculum-context,
.curriculum-toolbar,
.period-create {
  flex-wrap: wrap;
}

@media (max-width: 680px) {
  .section-context .custom-select-trigger {
    padding: 9px 36px 9px 12px;
  }
}

@media (min-width: 601px) {
  .tools.has-period-selectors .sort-wrap {
    width: 100%;
    justify-self: stretch;
  }
}

.section-context {
  grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr));
}

.period-create {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.period-create label:last-of-type {
  grid-column: 1 / 3;
}

.period-create .button {
  grid-column: 3;
  width: 100%;
}

.curriculum-context .curriculum-name-label {
  flex: 2;
}

.period-row .period-actions {
  display: flex;
  flex-shrink: 0;
  gap: 4px;
}

@media (max-width: 600px) {
  .period-create {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .period-create label:first-child,
  .period-create label:last-of-type,
  .period-create .button {
    grid-column: 1 / -1;
  }
}

.preview-heading > div {
  min-width: 0;
}

.preview-heading h2 {
  overflow-wrap: anywhere;
}

#search {
  margin-top: 0;
}

.custom-select-trigger.is-placeholder .custom-select-value {
  color: var(--muted);
}

.group-heading h3 {
  flex: 1;
  min-width: 0;
}

.group-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.group-toggle > svg {
  flex-shrink: 0;
  transition: transform 120ms;
}

.group-toggle[aria-expanded="false"] > svg {
  transform: rotate(-90deg);
}

.group-heading h3 .group-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
  overflow-wrap: anywhere;
}

.group-heading h3 .group-meta {
  margin-left: 10px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

.group-heading:has(.group-toggle[aria-expanded="false"]) {
  border-bottom: 1px solid var(--line);
  border-radius: 7px;
}
