/* QR scan viewer: view-only (no annotation editing or local file open). */

#editorModeButtons,
#editorModeSeparator,
#editorUndoBar,
#secondaryOpenFile,
#altTextSettingsButton,
#altTextSettingsSeparator,
#imageAltTextSettingsButton,
#imageAltTextSettingsSeparator {
  display: none !important;
}

.annotationEditorLayer,
.editToolbar {
  display: none !important;
  pointer-events: none !important;
}

/* Dashboard mobile preview (?compact=1): hide non-essential chrome; keep nav, zoom, download. */
html.pdfjs-compact #sidebarToggleButton,
html.pdfjs-compact #viewFindButton,
html.pdfjs-compact #scaleSelectContainer,
html.pdfjs-compact .toolbarButtonSpacer {
  display: none !important;
}

/* Compact: show download only from the right toolbar group. */
html.pdfjs-compact #toolbarViewerRight #printButton,
html.pdfjs-compact #toolbarViewerRight #secondaryToolbarToggle,
html.pdfjs-compact #toolbarViewerRight .verticalToolbarSeparator {
  display: none !important;
}

html.pdfjs-compact #toolbarViewerRight .hiddenMediumView {
  display: flex !important;
}

html.pdfjs-compact #downloadButton {
  display: inline-block !important;
}

/* PDF.js hides .hiddenSmallView below 690px — override inside narrow preview iframe. */
html.pdfjs-compact .hiddenSmallView {
  display: flex !important;
}

html.pdfjs-compact .hiddenSmallView .toolbarButton,
html.pdfjs-compact .hiddenSmallView .splitToolbarButtonSeparator {
  display: inline-block !important;
}

html.pdfjs-compact #pageNumber {
  width: 2.5rem;
}

html.pdfjs-compact #numPages {
  font-size: 0.75rem;
}

/*
 * Cross-platform compact preview (macOS + Windows):
 * - Same scrollbar behavior (no OS-default gutter eating width/height)
 * - Same light chrome + font metrics in the toolbar
 */
html.pdfjs-compact {
  color-scheme: only light;
  --pdfjs-compact-toolbar-scroll: 6px;
}

html.pdfjs-compact #toolbarContainer,
html.pdfjs-compact #toolbarContainer input,
html.pdfjs-compact #toolbarContainer .toolbarLabel {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  font-size: 12px;
  line-height: 1.2;
}

/* Scrollable toolbar row — PDF content below stays width-clamped. */
html.pdfjs-compact #toolbarContainer {
  max-width: 100% !important;
  height: calc(var(--toolbar-height) + var(--pdfjs-compact-toolbar-scroll));
  box-sizing: border-box;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 23, 42, 0.35) transparent;
  -ms-overflow-style: -ms-autohiding-scrollbar;
}

html.pdfjs-compact #toolbarViewer {
  display: inline-flex;
  justify-content: center;
  flex-wrap: nowrap;
  width: max-content;
  min-width: 100%;
  height: var(--toolbar-height);
  margin-inline: auto;
  gap: 0.375rem;
}

html.pdfjs-compact #toolbarContainer::-webkit-scrollbar {
  height: 6px;
}

html.pdfjs-compact #toolbarContainer::-webkit-scrollbar-track {
  background: transparent;
}

html.pdfjs-compact #toolbarContainer::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.35);
  border-radius: 999px;
}

/* Hide vertical scrollbars in the PDF pane so page width matches on Windows. */
html.pdfjs-compact #viewerContainer {
  inset-block-start: calc(var(--toolbar-height) + var(--pdfjs-compact-toolbar-scroll));
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html.pdfjs-compact #viewerContainer::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

html.pdfjs-compact #toolbarViewerLeft,
html.pdfjs-compact #toolbarViewerMiddle,
html.pdfjs-compact #toolbarViewerRight {
  flex: 0 0 auto;
  justify-content: center;
  min-width: 0;
  gap: 0.125rem;
}

html.pdfjs-compact #toolbarViewerMiddle .splitToolbarButtonSeparator {
  margin-inline: 0.125rem;
}

/* Dashboard preview mockup (~300px): clip horizontal overflow on PDF pages only. */
html.pdfjs-compact,
html.pdfjs-compact body {
  overflow-x: hidden !important;
  max-width: 100%;
}

html.pdfjs-compact #outerContainer,
html.pdfjs-compact #mainContainer,
html.pdfjs-compact #viewerContainer {
  max-width: 100% !important;
  overflow-x: hidden !important;
}

html.pdfjs-compact #mainContainer {
  min-width: 0 !important;
}

html.pdfjs-compact #viewerContainer .page {
  max-width: 100% !important;
  margin-inline: auto;
}

/* Scan page on mobile: stable viewport + toolbar when PDF.js runs in iframe (tablet). */
@media (max-width: 768px) {
  html:not(.pdfjs-compact),
  html:not(.pdfjs-compact) body {
    height: 100%;
    height: 100dvh;
  }

  html:not(.pdfjs-compact) body {
    overflow: hidden;
    width: 100%;
  }

  html:not(.pdfjs-compact) #outerContainer {
    height: 100%;
    height: 100dvh;
  }

  html:not(.pdfjs-compact) #mainContainer {
    min-width: 0;
  }

  html:not(.pdfjs-compact) #toolbarContainer {
    position: sticky;
    top: 0;
    z-index: 10;
  }

  /* PDF.js moves download into the Tools menu below 750px — keep it on the bar. */
  html:not(.pdfjs-compact) #toolbarViewerRight .hiddenMediumView {
    display: flex !important;
  }

  html:not(.pdfjs-compact) #downloadButton {
    display: inline-block !important;
  }

  html:not(.pdfjs-compact) #printButton {
    display: none !important;
  }
}
