/* The document a page is about, kept beside it (common\widgets\DocumentPane, js/document-pane.js).
 *
 * html.doc-pane-on: the page has a pane; html.doc-pane-open: it is shown. Both are on <html>, the
 * second put there before the page is drawn. From 1200px up the pane takes the left half of the
 * window in place of the menu; below, it comes over the whole page.
 *
 * It is never display:none: the PDF viewer in it measures its room, and a viewer that started
 * without any draws its pages wrong. Put away, it waits beside the screen. */

:root {
  --doc-pane-width: 50vw;
}

.doc-pane {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  /* over the page's own bars, under pop-ups (1050 and up) so a row is added without leaving it */
  z-index: 1040;
  display: flex;
  flex-direction: column;
  width: var(--doc-pane-width);
  background: #fff;
  border-right: 1px solid #d5dceb;
  box-shadow: 10px 0 28px -18px rgba(15, 23, 42, 0.45);
  transform: translateX(-102%);
  visibility: hidden;
  transition: transform 0.2s ease, visibility 0s linear 0.2s;
}

.doc-pane:focus {
  outline: none;
}

html.doc-pane-open .doc-pane {
  transform: none;
  visibility: visible;
  transition: transform 0.2s ease;
}

.doc-pane-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid #d5dceb;
  background: #f6f8fb;
}

.doc-pane-heading {
  flex: 1 1 auto;
  min-width: 0;
}

.doc-pane-kicker {
  color: #5b6b82;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.3;
  text-transform: uppercase;
}

.doc-pane-title {
  overflow: hidden;
  color: #1d2f49;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-pane-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.doc-pane-actions:empty {
  display: none;
}

.doc-pane-action,
.doc-pane-close,
.doc-pane-download {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 4px 11px;
  border: 1px solid #c3cee0;
  border-radius: 6px;
  background: #fff;
  color: #1d2f49;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.doc-pane-action {
  max-width: 16rem;
  border-color: #198754;
  background: #198754;
  color: #fff;
}

.doc-pane-action span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-pane-action:hover,
.doc-pane-action:focus-visible {
  border-color: #146c43;
  background: #146c43;
  color: #fff;
}

.doc-pane-close:hover,
.doc-pane-close:focus-visible,
.doc-pane-download:hover,
.doc-pane-download:focus-visible {
  border-color: #245f8f;
  background: #eef4fb;
  color: #173f65;
}

.doc-pane-action:focus-visible,
.doc-pane-close:focus-visible,
.doc-pane-download:focus-visible,
.doc-pane-tab:focus-visible {
  outline: 2px solid #6db3ff;
  outline-offset: 1px;
}

.doc-pane-download[hidden] {
  display: none;
}

.doc-pane-tabs {
  display: flex;
  gap: 4px;
  padding: 6px 10px 0;
  overflow-x: auto;
  overflow-y: hidden;
  border-bottom: 1px solid #d5dceb;
  background: #f6f8fb;
}

.doc-pane-tab {
  flex: 0 0 auto;
  padding: 6px 14px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: #47566b;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.doc-pane-tab:hover {
  color: #173f65;
}

.doc-pane-tab.is-active {
  border-color: #d5dceb;
  background: #fff;
  color: #173f65;
}

.doc-pane-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #eef1f6;
}

/* the documents lie over each other and only one is seen: each keeps its room, so its viewer
   keeps its page and zoom while another is read */
.doc-pane-doc {
  position: absolute;
  inset: 0;
  visibility: hidden;
  pointer-events: none;
}

.doc-pane-doc.is-active {
  pointer-events: auto;
}

html.doc-pane-open .doc-pane-doc.is-active {
  visibility: visible;
}

.doc-pane-doc iframe {
  display: block;
  width: 100%;
  height: 100% !important;
  border: 0;
}

.doc-pane-image {
  height: 100%;
  padding: 12px;
  overflow: auto;
  text-align: center;
}

.doc-pane-image img {
  max-width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.2);
}

.doc-pane-empty {
  max-width: 28rem;
  margin: 0 auto;
  padding: 48px 20px;
  color: #47566b;
  text-align: center;
}

/* a field filled from the document: the way to take it again, under the field */
.doc-pane-fill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: #245f8f;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.doc-pane-fill:hover,
.doc-pane-fill:focus-visible {
  color: #173f65;
  text-decoration: underline;
}

.doc-pane-fill-note {
  margin-left: 8px;
  color: #8a5a00;
  font-size: 12.5px;
}

/* what a page shows only while the pane is put away (the button that brings it), or only while it is shown */
html.doc-pane-open .doc-pane-when-closed,
html:not(.doc-pane-open) .doc-pane-when-open {
  display: none !important;
}

@media (min-width: 1200px) {
  .doc-pane-close-narrow {
    display: none;
  }

  /* the document takes the room of the menu, and the page the other half */
  html.doc-pane-open .app-sidebar,
  html.doc-pane-open [data-lte-toggle="sidebar"] {
    display: none !important;
  }

  html.doc-pane-open .app-wrapper {
    display: block;
    margin-left: var(--doc-pane-width);
  }

  /* pop-ups open over the page's half: what is added in one is read from the document beside it */
  html.doc-pane-open .modal,
  html.doc-pane-open .modal-backdrop {
    left: var(--doc-pane-width);
    width: calc(100% - var(--doc-pane-width));
  }
}

@media (max-width: 1199.98px) {
  :root {
    --doc-pane-width: 100vw;
  }

  .doc-pane {
    border-right: 0;
    box-shadow: none;
  }

  .doc-pane-close-wide {
    display: none;
  }

  /* the way back to the page comes first */
  .doc-pane-close {
    order: -1;
  }

  /* the page under the document is not the one scrolled */
  html.doc-pane-open,
  html.doc-pane-open body {
    overflow: hidden;
  }
}

/* a phone: the way back first, then what is read; what can be added gets a row of its own */
@media (max-width: 575.98px) {
  .doc-pane-head {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .doc-pane-heading {
    flex: 1 1 0;
  }

  .doc-pane-kicker {
    display: none;
  }

  .doc-pane-actions {
    flex: 1 1 100%;
    order: 2;
  }

  .doc-pane-action {
    flex: 1 1 auto;
    justify-content: center;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .doc-pane,
  html.doc-pane-open .doc-pane {
    transition: none;
  }
}

@media print {
  .doc-pane {
    display: none;
  }

  html.doc-pane-open .app-wrapper {
    margin-left: 0;
  }
}
