/* SchoolDay v209: compact staff header and whole-workspace Class Calendar scrolling. */

/* Header: remove the second white dashboard strip and keep identity/status in the coloured banner. */
.admin-body .site-header {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas: "brand year actions";
  padding: .58rem clamp(.7rem, 1.35vw, 1.25rem) !important;
  gap: .7rem !important;
  align-items: center !important;
}
.admin-body .site-header .header-brand {
  grid-area: brand;
  justify-self: start;
  align-items: center;
  min-width: 0;
}
.admin-body .site-header > nav {
  grid-area: actions;
  justify-self: end;
  justify-content: flex-end;
  margin-left: 0 !important;
  min-width: 0;
}
.admin-header-title-stack-v209 {
  display: grid;
  gap: .06rem;
  min-width: 0;
}
.admin-header-title-stack-v209 .eyebrow,
.admin-header-title-stack-v209 h1,
.admin-header-user-summary-v209 {
  margin: 0 !important;
}
.admin-header-title-stack-v209 h1 {
  line-height: 1.08 !important;
}
.admin-header-user-summary-v209 {
  display: block !important;
  max-width: min(560px, 42vw);
  font-size: .73rem !important;
  line-height: 1.16 !important;
  white-space: normal;
  overflow-wrap: anywhere;
}
.admin-body .admin-shell {
  padding-top: .55rem !important;
}
#reloadAllButton.hidden {
  display: none !important;
}

/* School year now lives beside the banner year label. */
.admin-school-year-control-v209 {
  grid-area: year;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  flex: 0 0 auto;
  min-width: 0;
}
.admin-school-year-current-v209 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .38rem;
  min-width: 0;
}
.admin-school-year-control-v209 .admin-banner-year {
  margin: 0 !important;
}
.admin-school-year-change-v209 {
  display: none !important;
  min-height: 30px !important;
  padding: .3rem .58rem !important;
  border-radius: 999px !important;
  font-size: .78rem !important;
  line-height: 1 !important;
  white-space: nowrap;
}
.admin-school-year-control-v209.school-year-ready-v209 .admin-school-year-change-v209 {
  display: inline-flex !important;
}
.admin-school-year-chooser-v209 {
  position: absolute;
  top: calc(100% + .5rem);
  left: 50%;
  z-index: 2200;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  gap: .45rem;
  align-items: center;
  width: max-content;
  max-width: min(94vw, 540px);
  padding: .6rem;
  border: 1px solid rgba(20,79,140,.24);
  border-radius: .8rem;
  background: #fff;
  color: #172033;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .2);
}
.admin-school-year-chooser-v209.hidden { display: none !important; }
.admin-school-year-chooser-v209 label {
  color: #334155;
  font-size: .8rem;
  font-weight: 850;
  white-space: nowrap;
}
.admin-school-year-chooser-v209 select {
  min-width: 175px;
  width: 100%;
}
.admin-school-year-chooser-v209 button {
  min-height: 34px !important;
  padding: .35rem .6rem !important;
}

/* The Class Calendars CARD is now the vertical scroll viewport. Its title, notes,
   month jump bar, mobile picker, routine editor, week controls and table all live inside it. */
@media (min-width: 901px) {
  /* The desktop menu is fixed to the viewport. The menu itself scrolls only when
     the available height is shorter than its complete set of visible buttons. */
  .admin-shell-v206-ready #adminContentV206 {
    grid-column: 2;
  }
  .admin-shell-v206-ready #adminSidebarV206.admin-sidebar-v206 {
    position: fixed !important;
    top: calc(var(--admin-header-sticky-height, 82px) + .55rem) !important;
    right: auto !important;
    bottom: .5rem !important;
    left: var(--admin-sidebar-fixed-left-v209, .5rem) !important;
    width: var(--admin-sidebar-width-v206, 248px) !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  body.admin-class-calendar-active-v209 {
    height: 100dvh;
    overflow-y: hidden !important;
  }
  .admin-shell-v206-ready #tab-class-calendars.tab-panel.active {
    height: var(--class-calendar-viewport-height-v209, calc(100dvh - var(--admin-header-sticky-height, 82px) - 1.6rem)) !important;
    min-height: 0 !important;
    max-height: var(--class-calendar-viewport-height-v209, calc(100dvh - var(--admin-header-sticky-height, 82px) - 1.6rem)) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior-y: auto !important;
    scroll-behavior: auto !important;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
  }
}

/* v208's table viewport becomes horizontal-only; vertical movement belongs to the whole calendar card. */
.admin-shell-v206-ready #tab-class-calendars #classCalendarTableWrap.class-calendar-scroll-window {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-x: auto !important;
  overflow-y: visible !important;
  overscroll-behavior-x: auto !important;
  overscroll-behavior-y: auto !important;
  scrollbar-gutter: stable;
  position: relative;
}

/* Fixed context/date widths. */
#tab-class-calendars .responsive-calendar[data-calendar="class"] .date-col {
  min-width: 155px !important;
  width: 155px !important;
  max-width: 155px !important;
}
#tab-class-calendars .responsive-calendar[data-calendar="class"] .school-ks-calendar-col {
  min-width: 285px !important;
  width: 285px !important;
  max-width: 285px !important;
}

/* With up to three classes, share every remaining pixel equally between class columns. */
#tab-class-calendars .responsive-calendar[data-calendar="class"].class-calendar-few-classes-v209 {
  width: 100% !important;
  min-width: 100% !important;
}
#tab-class-calendars .responsive-calendar[data-calendar="class"].class-calendar-few-classes-v209 .class-col {
  width: calc((100% - 440px) / var(--class-calendar-class-count-v209, 1)) !important;
  min-width: 0 !important;
  max-width: none !important;
}

/* Four or more classes: don't compress editing cells below the 285px context-column width. */
#tab-class-calendars .responsive-calendar[data-calendar="class"].class-calendar-many-classes-v209 {
  width: var(--class-calendar-min-table-width-v209) !important;
  min-width: var(--class-calendar-min-table-width-v209) !important;
  max-width: none !important;
}
#tab-class-calendars .responsive-calendar[data-calendar="class"].class-calendar-many-classes-v209 .class-col {
  min-width: 285px !important;
  width: 285px !important;
  max-width: 285px !important;
}

/* Compact School / Key Stage content to the same scale as the weekday/date labels. */
#tab-class-calendars .responsive-calendar[data-calendar="class"] tbody .school-ks-calendar-col,
#tab-class-calendars .responsive-calendar[data-calendar="class"] .class-calendar-context-lines,
#tab-class-calendars .responsive-calendar[data-calendar="class"] .class-calendar-context-event,
#tab-class-calendars .responsive-calendar[data-calendar="class"] .class-calendar-context-time {
  font-size: .78rem !important;
  line-height: 1.18 !important;
}
#tab-class-calendars .responsive-calendar[data-calendar="class"] .class-calendar-context-heading {
  font-size: .82rem !important;
  line-height: 1.15 !important;
}
#tab-class-calendars .class-calendar-context-group {
  gap: .16rem;
  margin-bottom: .48rem;
  padding-bottom: .42rem;
}
#tab-class-calendars .class-calendar-context-lines {
  gap: .14rem;
}

@media (max-width: 1100px) {
  .admin-header-user-summary-v209 { max-width: 34vw; }
}

/* A two-row desktop/tablet header keeps both side groups clear of the centred
   school-year control when the single-row layout becomes too narrow. */
@media (min-width: 901px) and (max-width: 1180px) {
  .admin-body .site-header {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "year year";
  }
  .admin-school-year-control-v209 {
    width: 100%;
  }
  .admin-header-user-summary-v209 {
    max-width: min(50vw, 520px);
  }
}

@media (max-width: 900px) {
  .admin-body .site-header {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      "brand"
      "year"
      "actions" !important;
    justify-items: center;
    align-items: center !important;
    gap: .52rem !important;
    text-align: center;
  }
  .admin-body .site-header .header-brand {
    width: 100%;
    justify-self: center;
    justify-content: center;
  }
  .admin-header-title-stack-v209 {
    justify-items: center;
  }
  .admin-body .site-header > nav {
    width: 100%;
    justify-self: center;
    justify-content: center;
    margin: 0 !important;
  }
  .admin-header-user-summary-v209 { max-width: min(92vw, 620px); }
  .admin-school-year-control-v209 {
    width: 100%;
    justify-self: center;
    justify-content: center;
  }
  .admin-school-year-current-v209 { justify-content: center; }
  .admin-school-year-control-v209 .admin-banner-year {
    min-width: 0 !important;
    white-space: nowrap !important;
    text-align: center !important;
  }
  .admin-school-year-chooser-v209 {
    left: 50%;
    transform: translateX(-50%);
    grid-template-columns: 1fr auto;
    width: min(94vw, 430px);
  }
  .admin-school-year-chooser-v209 label { grid-column: 1 / -1; }

  .admin-shell-v206-ready #tab-class-calendars.tab-panel.active {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
  .admin-shell-v206-ready #tab-class-calendars #classCalendarTableWrap.class-calendar-scroll-window {
    height: auto !important;
    max-height: none !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
  }
}

@media (max-width: 560px) {
  .admin-body .site-header {
    padding: .52rem .6rem !important;
  }
  .admin-body .site-header .header-brand {
    flex-wrap: wrap;
  }
  .admin-header-title-stack-v209 {
    flex: 1 1 100%;
  }
  .admin-body .site-header > nav {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, auto));
    align-items: center;
    justify-content: center;
    gap: .42rem !important;
  }
  .admin-body .site-header > nav #adminZoomControls {
    justify-self: center;
  }
  .admin-school-year-current-v209 {
    flex-wrap: wrap;
    row-gap: .34rem;
  }
  .admin-school-year-control-v209 .admin-banner-year {
    flex: 1 1 auto !important;
    font-size: .86rem !important;
  }
  .admin-school-year-change-v209 {
    min-height: 28px !important;
  }
  .admin-school-year-chooser-v209 {
    grid-template-columns: minmax(0, 1fr);
  }
  .admin-school-year-chooser-v209 label {
    grid-column: auto;
  }
  .admin-school-year-chooser-v209 button {
    width: 100%;
  }
}
