/* Offline mode (static/offline.js, core/offline.py).

   While there is no connection the page carries html.nf-offline, and:
   - buttons that need the internet are hidden: forms that cannot be sent later (.nf-needs-online), anything marked
     data-needs-online, and the design studios' uploads, PDF previews, Lock and "Use this design";
   - every menu item and link stays; one whose page cannot open now is faded (.nf-unavailable) and says why;
   - the banner across the top says offline mode is on and how many changes are waiting.
   A page opened from this device's copy starts with a strip saying when it was saved. */

html.nf-offline [data-needs-online],
html.nf-offline .nf-needs-online,
html.nf-offline .idd-upload,
html.nf-offline [data-preview],
html.nf-offline [data-idd-lock],
html.nf-offline form:has(> [data-use-btn]) {
  display: none !important;
}

/* Every menu item and link stays in place offline. One whose page cannot open now (never opened on this device, or
   never available offline) is faded; pressing it, or pointing at it, says which. */
html.nf-offline .nf-unavailable {
  opacity: .5;
  cursor: help;
}

/* The banner (the element static/connectivity.js shows; offline.js writes into it while offline mode is on). */
.connectivity-banner.nf-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 14px;
}
.connectivity-banner.nf-banner--offline { background: #7a4b00; color: #fff; }
.connectivity-banner.nf-banner--syncing { background: #1d4f91; color: #fff; }
.connectivity-banner.nf-banner--synced { background: #146c43; color: #fff; }
.connectivity-banner.nf-banner--review { background: #8a1c1c; color: #fff; }
.nf-banner__count { font-weight: 600; }
.nf-banner__button {
  font: inherit;
  font-weight: 600;
  padding: 2px 10px;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.nf-banner__button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* The banner sits above the page, never over it: while it shows, everything moves down by its height (offline.js
   measures it into --nf-banner-height), so the school's logo, the menu and the header stay in view. */
html.nf-banner-on body { padding-top: var(--nf-banner-height, 0px); }
html.nf-banner-on .rail,
html.nf-banner-on .ws-rail-sk { top: var(--nf-banner-height, 0px); }
html.nf-banner-on .ui-header { top: var(--nf-banner-height, 0px); }
/* The design studios fill the whole window (static/id-card-designer.css, .idd--app): they start below the banner too. */
html.nf-banner-on .idd--app,
html.nf-banner-on .studio-small { top: var(--nf-banner-height, 0px); }
.connectivity-banner.nf-banner { transition: none; }

/* "Saved on this device on ..." at the top of a page opened from its copy. */
.nf-copy-note {
  margin: 0 0 12px;
  padding: 8px 12px;
  border: 1px solid #e3c98f;
  border-radius: 8px;
  background: #fff8e6;
  color: #5c3d00;
  font-size: 14px;
}
.nf-copy-note strong { font-weight: 600; }

/* A short message that comes and goes ("Saved on this device", "This page is not on this device yet"). */
.nf-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 2147483001;
  max-width: min(92vw, 520px);
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 10px;
  background: #1c2533;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}

/* Dialogs: the password prompt after a while unused offline, and the list of changes that need a look. */
.nf-dialog {
  max-width: min(94vw, 560px);
  padding: 0;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .3);
}
.nf-dialog::backdrop { background: rgba(15, 26, 43, .55); }
.nf-dialog__body { display: grid; gap: 12px; padding: 20px; }
.nf-dialog__body h2 { margin: 0; font-size: 18px; }
.nf-dialog__body p { margin: 0; }
.nf-dialog__body label { display: grid; gap: 4px; font-weight: 600; font-size: 14px; }
.nf-dialog__body input { font: inherit; padding: 9px 11px; border: 1px solid #c8cfda; border-radius: 8px; }
.nf-dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.nf-dialog__actions button {
  font: inherit;
  padding: 7px 14px;
  border: 1px solid #c8cfda;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.nf-dialog__actions button.nf-primary { border-color: #1d4f91; background: #1d4f91; color: #fff; }
.nf-dialog__error { color: #b42318; }
.nf-review-list { display: grid; gap: 10px; max-height: 60vh; margin: 0; padding: 0; overflow: auto; list-style: none; }
.nf-review-list li { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid #e1e5ec; border-radius: 8px; }
.nf-review-list small { color: #5a6577; }

/* Offline on your devices (templates/offline_devices.html). */
.offline-devices { display: grid; gap: 14px; max-width: 760px; }
.offline-devices__title { margin: 0; font-size: 22px; }
.offline-devices h2 { margin: 6px 0 0; font-size: 16px; }
.offline-devices p { margin: 0; }
.offline-devices__here { display: grid; gap: 8px; padding: 14px; border: 1px solid #e1e5ec; border-radius: 10px; }
.offline-devices__list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.offline-devices__list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid #e1e5ec; border-radius: 8px; }
.offline-devices__list small { display: block; color: #5a6577; }
.offline-devices__note { color: #5a6577; font-size: 14px; }

/* Offline work to review (templates/admin_offline_work.html). */
.offline-review-list { display: grid; gap: 12px; }
.offline-review { display: grid; gap: 8px; padding: 14px; border: 1px solid #e1e5ec; border-radius: 10px; background: #fff; }
.offline-review header { display: grid; gap: 2px; }
.offline-review header small { color: #5a6577; }
.offline-review__page { margin: 0; font-size: 13px; color: #5a6577; }
.offline-review__fields { border-collapse: collapse; font-size: 13px; }
.offline-review__fields th, .offline-review__fields td { padding: 4px 8px; border-top: 1px solid #eef1f5; text-align: left; vertical-align: top; }
.offline-review__fields th { font-weight: 600; white-space: nowrap; }
.offline-review form { justify-self: start; }

@media (prefers-color-scheme: dark) {
  .nf-copy-note { border-color: #6b5520; background: #2b2410; color: #f3dfae; }
}

/* "Remove..." on Offline on your devices: a second press, with what it means, instead of a pop-up. */
.offline-devices__remove { justify-self: end; }
.offline-devices__remove summary { list-style: none; cursor: pointer; }
.offline-devices__remove summary::-webkit-details-marker { display: none; }
.offline-devices__remove[open] form { display: grid; gap: 8px; max-width: 320px; margin-top: 8px; }
.offline-devices__remove p { font-size: 13px; color: #5a6577; }

/* A change made offline and waiting to be sent, shown where it was made (static/offline.js, markPending). */
.nf-pending {
  outline: 2px dashed #c27c0e;
  outline-offset: 1px;
  background-color: #fff8e6;
}
td.nf-pending { position: relative; }
td.nf-pending::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c27c0e;
}

/* The choice when someone else changed the same thing meanwhile (static/offline.js, reviewRow). */
.nf-conflict { width: 100%; border-collapse: collapse; font-size: 13px; }
.nf-conflict th, .nf-conflict td { padding: 5px 8px; border-top: 1px solid #eef1f5; text-align: left; vertical-align: top; }
.nf-conflict tr:first-child th { border-top: 0; color: #5a6577; font-weight: 600; font-size: 12px; }
.nf-conflict__was { color: #5a6577; text-decoration: line-through; }
.nf-conflict__school { font-weight: 600; }
.nf-conflict__mine { font-weight: 600; color: #1d4f91; }

/* The review dialog: wide enough for the choice table, the portal's own table styles reset, buttons always in view. */
.nf-dialog { width: min(94vw, 720px); max-width: none; }
.nf-dialog .nf-review-list { overflow-x: hidden; }
.nf-dialog .nf-review-list li { min-width: 0; }
.nf-dialog .nf-dialog__actions { justify-content: flex-start; }
.nf-dialog .nf-review-list .nf-dialog__actions { margin-top: 2px; }
.nf-dialog table.nf-conflict { table-layout: fixed; margin: 0; }
.nf-dialog table.nf-conflict th,
.nf-dialog table.nf-conflict td {
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  overflow-wrap: anywhere;
  background: transparent;
}
.nf-dialog table.nf-conflict tr:first-child th:first-child,
.nf-dialog table.nf-conflict tr th:first-child { width: 34%; }
.nf-dialog table.nf-conflict tr:not(:first-child) th { font-weight: 600; color: inherit; }

/* Signing out with changes not yet sent: two clear choices (static/offline.js, chooseOnSignOut). */
.nf-signout { width: min(94vw, 520px); }
.nf-signout__options { display: grid; gap: 10px; }
.nf-signout__option {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid #c8cfda;
  border-radius: 10px;
  background: #fff;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.nf-signout__option strong { font-size: 15px; }
.nf-signout__option span { font-size: 13px; color: #5a6577; line-height: 1.45; }
.nf-signout__option:hover, .nf-signout__option:focus-visible { border-color: #1d4f91; outline: none; box-shadow: 0 0 0 3px rgba(29, 79, 145, .15); }
.nf-signout__option--primary { border-color: #1d4f91; background: #f3f7fc; }

/* The password card after a while unused offline (static/offline.js, askForPassword): the school's mark and name,
   who is signed in, one stacked password field with Show/Hide, a full-width Unlock, and a way to sign out instead.
   In the school's own colours (--brand, set on every page by core/theme.py), like the offline sign-in page. */
.nf-dialog.nf-unlock { width: min(94vw, 400px); border-radius: 16px; overflow: hidden; }
.nf-unlock .nf-dialog__body { gap: 0; padding: 0; }
.nf-unlock__school {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--brand, var(--navy, #0d2b52));
  color: #fff;
}
.nf-unlock__mark { flex: none; width: 40px; height: 40px; border-radius: 10px; background: #fff; object-fit: contain; }
.nf-unlock__mark.school-mark--mono {
  display: grid;
  place-items: center;
  color: var(--brand, var(--navy, #0d2b52));
  font-weight: 700;
  font-size: 15px;
}
.nf-unlock__school-text { display: grid; gap: 2px; min-width: 0; }
.nf-unlock .nf-unlock__school-name { margin: 0; font-weight: 600; font-size: 15px; line-height: 1.25; overflow-wrap: anywhere; }
.nf-unlock .nf-unlock__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 12px;
  letter-spacing: .02em;
  opacity: .85;
}
.nf-unlock__icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nf-unlock__who { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 4px; }
.nf-unlock__avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #eef2f8;
  color: var(--brand, var(--navy, #0d2b52));
  font-weight: 700;
  font-size: 15px;
}
.nf-unlock__who-text { display: grid; gap: 4px; min-width: 0; }
.nf-unlock .nf-unlock__title { margin: 0; font-size: 19px; line-height: 1.25; }
.nf-unlock .nf-unlock__reason { margin: 0; color: #4a5568; font-size: 14px; line-height: 1.45; }
.nf-unlock__form { display: grid; gap: 8px; padding: 16px 20px 0; }
.nf-unlock .nf-unlock__label { display: block; font-weight: 600; font-size: 13px; color: #2d3748; }
.nf-unlock__field { position: relative; }
.nf-unlock .nf-unlock__input {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 10px 64px 10px 12px;
  border: 1px solid #c8cfda;
  border-radius: 10px;
  font: inherit;
  font-size: 16px;   /* phones do not zoom into the field */
}
.nf-unlock .nf-unlock__input:focus {
  outline: none;
  border-color: var(--brand, var(--navy, #0d2b52));
  box-shadow: 0 0 0 3px rgba(29, 79, 145, .18);
}
.nf-unlock__reveal {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--brand, var(--navy, #0d2b52));
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.nf-unlock__reveal:hover { background: #eef2f8; }
.nf-unlock .nf-unlock__error { margin: 0; color: #b42318; font-size: 13px; }
.nf-unlock__submit {
  min-height: 44px;
  margin-top: 4px;
  border: 0;
  border-radius: 10px;
  background: var(--brand, var(--navy, #0d2b52));
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
.nf-unlock__submit:hover { background: var(--brand-dark, var(--navy-deep, #081c35)); }
.nf-unlock__submit:disabled { opacity: .7; cursor: progress; }
.nf-unlock__submit:focus-visible,
.nf-unlock__reveal:focus-visible,
.nf-unlock__signout:focus-visible { outline: 2px solid var(--brand, var(--navy, #0d2b52)); outline-offset: 2px; }
.nf-unlock__signout {
  justify-self: center;
  margin: 12px 20px 0;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  color: #4a5568;
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.nf-unlock__signout:hover { color: #1a202c; }
.nf-unlock .nf-unlock__foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 14px 0 0;
  padding: 12px 20px;
  border-top: 1px solid #edf0f5;
  background: #f8fafc;
  color: #5a6577;
  font-size: 12px;
}
