/* School Settings index and single-school editor. */

.nn-school-settings {
  --nn-school-ink: #101820;
  --nn-school-muted: #64748b;
  --nn-school-line: #e2e8f0;
  --nn-school-soft: #f7f8fa;
  --nn-school-teal: #0f9fa8;

  display: grid;
  gap: 18px;
  width: min(100%, 1180px);
  margin: 0 auto;
}

.nn-school-settings *,
.nn-school-settings *::before,
.nn-school-settings *::after {
  box-sizing: border-box;
}

.nn-school-settings .nn-btn-dark,
.nn-school-settings .btn--primary {
  border-color: var(--nn-school-ink);
  background: var(--nn-school-ink);
  color: #fff;
  box-shadow: none;
}

.nn-school-settings .nn-btn-dark:hover,
.nn-school-settings .nn-btn-dark:focus-visible,
.nn-school-settings .btn--primary:hover,
.nn-school-settings .btn--primary:focus-visible {
  border-color: #29333c;
  background: #29333c;
  color: #fff;
}

.nn-school-settings .btn {
  border-radius: 7px;
}

.nn-school-settings .btn i {
  margin-right: 6px;
}


/* Index */

.nn-school-index-actions {
  display: flex;
  justify-content: flex-end;
}

.nn-school-index-list {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--nn-school-line);
  border-radius: 9px;
  background: #fff;
}

.nn-school-index-row {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-width: 0;
  padding: 15px 18px;
  border-bottom: 1px solid #edf0f3;
}

.nn-school-index-row:last-child {
  border-bottom: 0;
}

.nn-school-index-row__logo {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  overflow: hidden;
  border: 1px solid var(--nn-school-line);
  border-radius: 8px;
  background: #f8fafc;
}

.nn-school-index-row__logo img {
  width: 100%;
  height: 100%;
  padding: 5px;
  object-fit: contain;
}

.nn-school-index-row__logo span {
  color: #475569;
  font-size: 1rem;
  font-weight: 850;
}

.nn-school-index-row__copy {
  min-width: 0;
}

.nn-school-index-row__copy h2 {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--nn-school-ink);
  font-size: 0.98rem;
  font-weight: 800;
}

.nn-school-index-row__copy p {
  margin: 4px 0 0;
  color: var(--nn-school-muted);
  font-size: 0.78rem;
}

.nn-school-index-row__edit {
  min-width: 102px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--nn-school-ink);
  font-size: 0.8rem;
  font-weight: 750;
  text-decoration: none;
}

.nn-school-index-row__edit:hover,
.nn-school-index-row__edit:focus-visible {
  border-color: #94a3b8;
  background: #f8fafc;
  color: var(--nn-school-ink);
}

.nn-school-index-empty {
  padding: 28px;
  border: 1px dashed #cbd5e1;
  border-radius: 9px;
  background: #fafbfc;
  text-align: center;
}

.nn-school-index-empty h2 {
  margin: 0;
  font-size: 1rem;
}

.nn-school-index-empty p {
  margin: 7px 0 0;
  color: var(--nn-school-muted);
  font-size: 0.84rem;
}


/* Editor shell */

.nn-school-settings--editor {
  width: min(100%, 1120px);
}

.nn-school-editor-header {
  display: grid;
  gap: 20px;
  padding-bottom: 4px;
}

.nn-school-editor-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  color: #475569;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
}

.nn-school-editor-back:hover,
.nn-school-editor-back:focus-visible {
  color: var(--nn-school-teal);
}

.nn-school-editor-header__main {
  display: flex;
  align-items: center;
  gap: 15px;
}

.nn-school-editor-header__main img {
  width: 52px;
  height: 52px;
  padding: 4px;
  border: 1px solid var(--nn-school-line);
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}

.nn-school-editor-header__main h1 {
  margin: 0;
  color: var(--nn-school-ink);
  font-size: clamp(1.55rem, 3vw, 2.15rem);
  font-weight: 850;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.nn-school-editor-header__main p {
  margin: 5px 0 0;
  color: var(--nn-school-muted);
  font-size: 0.86rem;
}

.nn-school-editor-sections,
.nn-school-settings-form,
.nn-terms-page {
  display: grid;
  gap: 14px;
  min-width: 0;
}


/* Shared sections */

.nn-settings-section {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--nn-school-line);
  border-radius: 9px;
  background: #fff;
  scroll-margin-top: 20px;
}

.nn-settings-section__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 62px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.nn-settings-section__summary::-webkit-details-marker {
  display: none;
}

.nn-settings-section__summary::marker {
  content: "";
}

.nn-settings-section__summary:hover {
  background: #fafbfc;
}

.nn-settings-section__heading {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.nn-settings-section__heading > i {
  display: inline-flex;
  justify-content: center;
  width: 22px;
  color: #687584;
  font-size: 0.88rem;
}

.nn-settings-section__heading > span {
  display: grid;
  gap: 2px;
}

.nn-settings-section__heading strong {
  color: var(--nn-school-ink);
  font-size: 0.92rem;
  font-weight: 850;
}

.nn-settings-section__heading small {
  color: var(--nn-school-muted);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
}

.nn-settings-section__chevron {
  flex: 0 0 auto;
  color: #94a3b8;
  font-size: 0.68rem;
  transition: transform 0.18s ease;
}

.nn-settings-section:not([open]) .nn-settings-section__chevron {
  transform: rotate(-90deg);
}

.nn-settings-section__body {
  padding: 16px;
  border-top: 1px solid #edf0f3;
}


/* School details */

.nn-school-details-layout {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.nn-school-logo-panel {
  display: grid;
  justify-items: center;
  gap: 7px;
}

.nn-school-logo-panel img,
.nn-school-logo-panel__fallback {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.nn-school-logo-panel__fallback {
  display: grid;
  place-items: center;
  border: 1px solid var(--nn-school-line);
  border-radius: 9px;
  background: #f8fafc;
  color: #475569;
  font-size: 1.7rem;
  font-weight: 850;
}

.nn-school-logo-panel span {
  color: #94a3b8;
  font-size: 0.7rem;
}

.nn-school-form--workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px 15px;
}

.nn-school-form--workspace .nn-field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.nn-school-form--workspace .nn-field--contact-email {
  grid-column: 1 / -1;
}

.nn-school-form--workspace .nn-field label {
  color: #334155;
  font-size: 0.76rem;
  font-weight: 800;
}

.nn-school-form--workspace .nn-field > small {
  color: var(--nn-school-muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.nn-school-form--workspace input,
.nn-school-form--workspace select {
  width: 100%;
  min-width: 0;
  min-height: 39px;
  padding: 0 10px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  font-size: 0.85rem;
}

.nn-school-form--workspace input:focus,
.nn-school-form--workspace select:focus,
.nn-feature-setting__control select:focus {
  outline: 2px solid rgba(15, 159, 168, 0.14);
  border-color: var(--nn-school-teal);
}

.nn-field__suffix {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
}

.nn-field__suffix:focus-within {
  outline: 2px solid rgba(15, 159, 168, 0.14);
  border-color: var(--nn-school-teal);
}

.nn-field__suffix input {
  border: 0;
  border-radius: 0;
  outline: 0 !important;
}

.nn-field__suffix span {
  padding: 0 10px;
  color: #94a3b8;
  font-size: 0.72rem;
}


/* Student Features */

.nn-feature-settings-list {
  display: grid;
}

.nn-feature-setting {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  align-items: center;
  gap: 18px;
  padding: 12px 0;
  border-bottom: 1px solid #edf0f3;
}

.nn-feature-setting:last-child {
  border-bottom: 0;
}

.nn-feature-setting__copy strong {
  display: block;
  color: #0f172a;
  font-size: 0.85rem;
  font-weight: 800;
}

.nn-feature-setting__copy p {
  margin: 3px 0 0;
  color: var(--nn-school-muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

.nn-feature-setting__control select {
  width: 100%;
  min-height: 37px;
  padding: 0 9px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
}

.nn-practice-subsettings {
  margin: -1px 0 0;
  padding: 4px 16px 10px 34px;
  border-bottom: 1px solid var(--nn-school-line);
  background: #f8fafc;
}

.nn-feature-setting--subsetting {
  padding: 10px 0;
  background: transparent;
}


/* Save and danger actions */

.nn-school-save-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.nn-school-save-bar > span {
  margin-right: auto;
  color: #94a3b8;
  font-size: 0.72rem;
}

.nn-school-save-bar .btn {
  min-height: 39px;
}

.nn-settings-section--danger {
  border-color: #efd1d1;
}

.nn-settings-section--danger .nn-settings-section__heading > i,
.nn-settings-section--danger .nn-settings-section__heading strong {
  color: #a61b1b;
}

.nn-danger-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.nn-danger-action strong {
  color: #991b1b;
  font-size: 0.85rem;
}

.nn-danger-action p {
  margin: 3px 0 0;
  color: var(--nn-school-muted);
  font-size: 0.76rem;
}

.nn-danger-action form {
  margin: 0;
}

.nn-btn-danger {
  border-color: #b42318 !important;
  background: #b42318 !important;
  color: #fff !important;
}

.nn-btn-danger:hover,
.nn-btn-danger:focus-visible {
  border-color: #8f1b13 !important;
  background: #8f1b13 !important;
}


/* Teaching Week */

.nn-teaching-week-card {
  position: relative;
}

.nn-teaching-week-card > .nn-terms-notice {
  margin: 0 16px 12px;
}

.nn-teaching-week-form {
  display: grid;
  gap: 14px;
}

.nn-teaching-week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.nn-teaching-week-row {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--nn-school-line);
  border-radius: 7px;
  background: #fafbfc;
}

.nn-teaching-week-row > span:first-child {
  color: #334155;
  font-size: 0.73rem;
  font-weight: 850;
}

.nn-teaching-week-choice {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  color: #475569;
  font-size: 0.72rem;
  font-weight: 700;
}

.nn-teaching-week-choice input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--nn-school-ink);
}

.nn-teaching-week-row > small {
  color: #9a6700;
  font-size: 0.65rem;
  line-height: 1.3;
}

.nn-teaching-week-actions {
  display: flex;
  justify-content: flex-end;
}

.nn-teaching-week-actions .btn {
  min-height: 38px;
}


/* Terms and closures */

.nn-terms-page {
  margin: 0;
}

.nn-terms-section__body {
  display: grid;
  gap: 11px;
}

.nn-terms-section__actions {
  display: flex;
  justify-content: flex-end;
}

.nn-terms-section__actions .btn {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.77rem;
  font-weight: 750;
}

.nn-terms-notice {
  margin: 0;
  padding: 9px 11px;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 750;
}

.nn-terms-notice--success {
  border: 1px solid #b7dfc6;
  background: #f3fbf6;
  color: #166534;
}

.nn-terms-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--nn-school-line);
  border-radius: 8px;
}

.nn-terms-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.nn-terms-table th,
.nn-terms-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #edf0f3;
  text-align: left;
  vertical-align: middle;
}

.nn-terms-table th {
  background: #fafbfc;
  color: var(--nn-school-muted);
  font-size: 0.7rem;
  font-weight: 850;
}

.nn-terms-table td {
  color: #334155;
  font-size: 0.78rem;
}

.nn-terms-table td strong {
  color: #0f172a;
}

.nn-terms-table tr:last-child td {
  border-bottom: 0;
}

.nn-terms-status {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
}

.nn-terms-status.is-current {
  background: #e8f6ee;
  color: #166534;
}

.nn-terms-status.is-past {
  background: #f1f5f9;
  color: #64748b;
}

.nn-terms-status.is-future {
  background: #eef6fb;
  color: #315f76;
}

.nn-terms-actions-head,
.nn-terms-actions {
  text-align: right;
}

.nn-terms-actions form {
  display: inline-flex;
  margin: 0;
}

.nn-terms-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid #d5dce4;
  border-radius: 6px;
  background: #fff;
  color: #64748b;
  cursor: pointer;
}

.nn-terms-icon-btn--danger {
  color: #b91c1c;
}

.nn-terms-icon-btn--danger:hover,
.nn-terms-icon-btn--danger:focus-visible {
  border-color: #fecaca;
  background: #fff5f5;
  color: #991b1b;
}

.nn-terms-empty {
  padding: 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #fafbfc;
  color: var(--nn-school-muted);
  font-size: 0.78rem;
  font-weight: 650;
}


/* Dialogs */

.nn-terms-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 10px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.nn-terms-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.nn-terms-dialog__form {
  margin: 0;
}

.nn-terms-dialog__head,
.nn-terms-dialog__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 18px;
}

.nn-terms-dialog__head {
  border-bottom: 1px solid var(--nn-school-line);
}

.nn-terms-dialog__foot {
  justify-content: flex-end;
  border-top: 1px solid var(--nn-school-line);
}

.nn-terms-dialog__head h3 {
  margin: 0;
  color: #0f172a;
  font-size: 1rem;
  font-weight: 850;
}

.nn-terms-dialog__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 7px;
  background: #f1f5f9;
  color: #0f172a;
  cursor: pointer;
  font-size: 20px;
}

.nn-terms-dialog__body {
  display: grid;
  gap: 13px;
  padding: 18px;
}

.nn-terms-field {
  display: grid;
  gap: 5px;
}

.nn-terms-field span {
  color: #334155;
  font-size: 0.78rem;
  font-weight: 800;
}

.nn-terms-field input,
.nn-terms-field select {
  width: 100%;
  min-height: 39px;
  padding: 0 10px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: #0f172a;
  font: inherit;
}


/* iPad and phone layouts */

@media (max-width: 900px) {
  .nn-teaching-week-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .nn-school-settings {
    gap: 14px;
  }

  .nn-school-index-actions .btn {
    width: 100%;
  }

  .nn-school-index-row {
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
  }

  .nn-school-index-row__logo {
    width: 42px;
    height: 42px;
  }

  .nn-school-index-row__edit {
    grid-column: 2;
    justify-self: start;
    min-height: 38px;
  }

  .nn-settings-section__summary {
    min-height: 56px;
    padding: 11px 12px;
  }

  .nn-settings-section__heading small {
    display: none;
  }

  .nn-settings-section__body {
    padding: 12px;
  }

  .nn-school-details-layout,
  .nn-school-form--workspace {
    grid-template-columns: 1fr;
  }

  .nn-school-logo-panel {
    grid-template-columns: auto 1fr;
    align-items: center;
    justify-items: start;
  }

  .nn-school-logo-panel img,
  .nn-school-logo-panel__fallback {
    width: 58px;
    height: 58px;
  }

  .nn-school-form--workspace .nn-field--contact-email {
    grid-column: auto;
  }

  .nn-feature-setting {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .nn-practice-subsettings {
    padding-left: 14px;
  }

  .nn-school-save-bar,
  .nn-danger-action {
    align-items: stretch;
    flex-direction: column;
  }

  .nn-school-save-bar > span {
    display: none;
  }

  .nn-school-save-bar .btn,
  .nn-danger-action .btn,
  .nn-teaching-week-actions .btn,
  .nn-terms-section__actions .btn {
    width: 100%;
  }

  .nn-teaching-week-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nn-terms-table-wrap {
    overflow: visible;
    border: 0;
  }

  .nn-terms-table,
  .nn-terms-table tbody {
    display: grid;
    gap: 10px;
  }

  .nn-terms-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
  }

  .nn-terms-table tr {
    display: grid;
    gap: 7px;
    padding: 12px;
    border: 1px solid var(--nn-school-line);
    border-radius: 8px;
  }

  .nn-terms-table td {
    display: grid;
    grid-template-columns: minmax(90px, 0.45fr) minmax(0, 1fr);
    gap: 10px;
    padding: 0;
    border: 0;
    font-size: 0.76rem;
  }

  .nn-terms-table td::before {
    color: #94a3b8;
    font-size: 0.67rem;
    font-weight: 800;
    text-transform: uppercase;
  }

  details[id^="term-dates-"] td:nth-child(1)::before { content: "Name"; }
  details[id^="term-dates-"] td:nth-child(2)::before { content: "Academic year"; }
  details[id^="term-dates-"] td:nth-child(3)::before { content: "Start"; }
  details[id^="term-dates-"] td:nth-child(4)::before { content: "End"; }
  details[id^="term-dates-"] td:nth-child(5)::before { content: "Status"; }
  details[id^="term-dates-"] td:nth-child(6)::before { content: "Actions"; }

  details[id^="school-closures-"] td:nth-child(1)::before { content: "Name"; }
  details[id^="school-closures-"] td:nth-child(2)::before { content: "Type"; }
  details[id^="school-closures-"] td:nth-child(3)::before { content: "Start"; }
  details[id^="school-closures-"] td:nth-child(4)::before { content: "End"; }
  details[id^="school-closures-"] td:nth-child(5)::before { content: "Notes"; }
  details[id^="school-closures-"] td:nth-child(6)::before { content: "Actions"; }

  .nn-terms-actions {
    justify-content: start;
    text-align: left;
  }

  .nn-terms-dialog {
    width: calc(100% - 20px);
    max-height: calc(100% - 20px);
  }
}

@media (max-width: 420px) {
  .nn-teaching-week-grid {
    grid-template-columns: 1fr;
  }

  .nn-school-editor-header__main img {
    width: 44px;
    height: 44px;
  }
}
