/* ============================================
   PDF Viewer Styles
   Customizable CSS - Edit to match your design
   ============================================ */

/* CSS Variables for easy customization */
:root {
  /* Colors */
  --pdf-primary-color: #1976d2;
  --pdf-primary-hover: #1565c0;
  --pdf-background: #525659;
  --pdf-toolbar-bg: #323639;
  --pdf-toolbar-text: #ffffff;
  --pdf-sidebar-bg: #f5f5f5;
  --pdf-sidebar-text: #333333;
  --pdf-border-color: #e0e0e0;
  --pdf-highlight-color: rgba(255, 235, 59, 0.5);
  --pdf-selection-color: rgba(25, 118, 210, 0.3);
  --pdf-annotation-highlight: rgba(255, 255, 0, 0.4);

  /* Dimensions */
  --pdf-toolbar-height: 48px;
  --pdf-sidebar-width: 280px;

  /* Typography */
  --pdf-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --pdf-font-size: 14px;

  /* Shadows */
  --pdf-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  --pdf-page-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Reset */
.pdf-viewer-wrapper *,
.pdf-viewer-wrapper *::before,
.pdf-viewer-wrapper *::after {
  box-sizing: border-box;
}

/* Hide contents until PDF is loaded (keeps bar background visible) */
.pdf-viewer-wrapper .pdf-not-ready > * {
  visibility: hidden;
  pointer-events: none;
}

/* Main Container */
.pdf-viewer-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 600px;
  min-height: 400px;
  font-family: var(--pdf-font-family);
  font-size: var(--pdf-font-size);
  background: var(--pdf-background);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--pdf-shadow);
  overflow-anchor: none;
}

/* Fullscreen mode */
.pdf-viewer-wrapper:fullscreen,
.pdf-viewer-wrapper:-webkit-full-screen,
.pdf-viewer-wrapper:-moz-full-screen,
.pdf-viewer-wrapper:-ms-fullscreen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
}

/* Toolbar */
.pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--pdf-toolbar-bg);
  color: var(--pdf-toolbar-text);
  height: var(--pdf-toolbar-height);
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toolbar-group:not(:last-child)::after {
  content: '';
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
  margin-left: 8px;
}

/* Hide sidebar toggle when no outline */
.toolbar-group.sidebar-toggle-group {
  display: flex;
}

.toolbar-group.sidebar-toggle-group.hidden {
  display: none;
}

.toolbar-group.sidebar-toggle-group::after {
  display: none;
}

.pdf-toolbar button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: background-color 0.2s;
}

.pdf-toolbar button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.pdf-toolbar button:active {
  background: rgba(255, 255, 255, 0.2);
}

.pdf-toolbar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pdf-toolbar button.active {
  background: var(--pdf-primary-color);
  color: #ffffff;
}

.pdf-toolbar button.active:hover {
  background: var(--pdf-primary-hover);
}

.pdf-toolbar select {
  height: 28px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  font-size: 12px;
  cursor: pointer;
}

.pdf-toolbar select:focus {
  outline: 2px solid var(--pdf-primary-color);
  outline-offset: -2px;
}

.pdf-toolbar select option {
  background: var(--pdf-toolbar-bg);
  color: var(--pdf-toolbar-text);
}

/* Page Info */
.page-info {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
}

.page-info input {
  width: 50px;
  height: 28px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  text-align: center;
  font-size: 13px;
}

.page-info input:focus {
  outline: 2px solid var(--pdf-primary-color);
  outline-offset: -2px;
}

/* View Mode Select */
.view-mode-select {
  display: flex;
  align-items: center;
  gap: 4px;
}

.view-mode-select label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  margin-right: 4px;
}

/* Search Toggle */
.toolbar-search-toggle {
  position: relative;
  margin-left: auto;
}

.toolbar-search-toggle::after {
  display: none !important;
}

/* Search Popout */
.search-popout {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--pdf-toolbar-bg);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  min-width: 280px;
}

.search-popout.visible {
  display: flex;
}

.search-popout input[type="text"] {
  width: 100%;
  height: 32px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--pdf-toolbar-text);
  font-size: 14px;
}

.search-popout input[type="text"]::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.search-popout input[type="text"]:focus {
  outline: 2px solid var(--pdf-primary-color);
  outline-offset: -2px;
  border-color: var(--pdf-primary-color);
}

.search-popout-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.search-results-text {
  flex: 1;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
}

.search-popout button {
  width: 28px;
  height: 28px;
}

.search-close-btn {
  margin-left: auto;
}

[data-pdf-search-results] {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
}

/* Overflow Menu */
.toolbar-overflow-group {
  display: none;
  position: relative;
}

.toolbar-overflow-group::after {
  display: none !important;
}

.overflow-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: none;
  flex-direction: column;
  padding: 4px 0;
  background: var(--pdf-toolbar-bg);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  min-width: 200px;
}

.overflow-menu.visible {
  display: flex;
}

/* Override .pdf-toolbar button with higher specificity */
.overflow-menu .overflow-menu-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  width: 100%;
  height: 40px;
  padding: 8px 16px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--pdf-toolbar-text);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  text-align: left;
}

.overflow-menu .overflow-menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.overflow-menu .overflow-menu-item.active {
  background: rgba(25, 118, 210, 0.2);
  color: var(--pdf-primary-color);
}

.overflow-menu .overflow-menu-item svg {
  flex-shrink: 0;
}

.overflow-menu .overflow-zoom-level {
  justify-content: center;
  cursor: default;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
}

.overflow-menu .overflow-zoom-level:hover {
  background: transparent;
}

.overflow-menu-divider {
  height: 1px;
  margin: 4px 8px;
  background: rgba(255, 255, 255, 0.15);
}

/* Main Content */
.pdf-main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar - Right Side */
.pdf-sidebar {
  order: 2; /* Move to right */
  width: var(--pdf-sidebar-width);
  background: var(--pdf-sidebar-bg);
  color: var(--pdf-sidebar-text);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--pdf-border-color);
  flex-shrink: 0;
  transition: margin-right 0.3s ease, opacity 0.3s ease;
}

.pdf-sidebar.hidden {
  margin-right: calc(-1 * var(--pdf-sidebar-width));
  opacity: 0;
  pointer-events: none;
}

/* Hide sidebar completely when no outline */
.pdf-sidebar.no-outline {
  display: none;
}

.sidebar-header {
  padding: 0;
  font-weight: 600;
  border-bottom: 1px solid var(--pdf-border-color);
  background: #fff;
}

/* Sidebar Tabs */
.sidebar-tabs {
  display: flex;
  gap: 0;
}

.sidebar-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 8px;
  border: none;
  background: #f5f5f5;
  color: #666;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  border-bottom: 2px solid transparent;
}

.sidebar-tab:hover {
  background: #e8e8e8;
  color: #333;
}

.sidebar-tab.active {
  background: #fff;
  color: var(--pdf-primary-color);
  border-bottom-color: var(--pdf-primary-color);
}

.sidebar-tab.hidden {
  display: none;
}

.sidebar-tab svg {
  flex-shrink: 0;
}

.sidebar-tab span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar Content */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  display: none;
}

.sidebar-content.active {
  display: block;
}

/* Thumbnails */
.thumbnail-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
}

.thumbnail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
  border: 2px solid transparent;
}

.thumbnail-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.thumbnail-item.active {
  background: var(--pdf-selection-color);
  border-color: var(--pdf-primary-color);
}

.thumbnail-canvas-wrapper {
  position: relative;
  background: white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  border-radius: 2px;
  overflow: hidden;
}

.thumbnail-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.thumbnail-page-num {
  font-size: 11px;
  color: #666;
  font-weight: 500;
}

.thumbnail-item.active .thumbnail-page-num {
  color: var(--pdf-primary-color);
}

/* Thumbnail placeholder (loading state) */
.thumbnail-placeholder {
  width: 120px;
  height: 160px;
  background: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 12px;
}

.no-outline {
  padding: 16px;
  color: #999;
  font-size: 13px;
  text-align: center;
}

/* Outline Tree */
/* Specificity bumped via `.pdf-sidebar` prefix so external page CSS
   (e.g. `.m-media-pdfGroup ul { margin-left: 24px }`) cannot shift the tree. */
.pdf-sidebar .outline-tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pdf-sidebar .outline-tree .outline-tree {
  padding-left: 16px;
}

.outline-item {
  padding: 8px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.2s;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.outline-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.outline-item.active {
  background: var(--pdf-selection-color);
  color: var(--pdf-primary-color);
}

.outline-toggle {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.outline-toggle svg {
  transition: transform 0.2s;
}

.outline-toggle.expanded svg {
  transform: rotate(90deg);
}

/* Canvas Wrapper - Contains scrollable area and fixed overlays */
.pdf-canvas-wrapper {
  order: 1; /* Left side (before sidebar) */
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--pdf-background);
}

/* Canvas Container - Scrollable area */
.pdf-canvas-container {
  width: 100%;
  height: 100%;
  overflow: auto; /* Enable scroll when content overflows */
  scrollbar-gutter: stable; /* Reserve space for scrollbar to prevent layout shift */
  contain: inline-size; /* Prevent child content from pushing parent width */
  position: relative;
  padding: 16px;
}

/* Drag cursor when zoomed */
.pdf-canvas-container.draggable {
  cursor: grab;
}

.pdf-canvas-container.dragging {
  cursor: grabbing;
  user-select: none;
}

/* Pages Container - Pagination Mode */
.pdf-pages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-shrink: 0;
  margin: 0 auto; /* Center horizontally when smaller than container */
  width: fit-content; /* Shrink to content size */
}

/* Single Page Mode */
.pdf-pages.single-page .pdf-page-wrapper:not(.visible) {
  display: none;
}

/* Spread (Two-Page) Mode */
.pdf-pages.spread-view {
  flex-direction: row;
}

.pdf-pages.spread-view .pdf-page-wrapper:not(.visible) {
  display: none;
}

/* Page Wrapper */
.pdf-page-wrapper {
  position: relative;
  background: white;
  box-shadow: var(--pdf-page-shadow);
  flex-shrink: 0;
}

.pdf-page-wrapper canvas {
  display: block;
}

/* Text Layer */
.pdf-page-text-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  opacity: 0.2;
  line-height: 1.0;
  pointer-events: auto;
}

.pdf-page-text-layer > span {
  color: transparent;
  position: absolute;
  white-space: pre;
  transform-origin: 0% 0%;
  cursor: text;
}

.pdf-page-text-layer ::selection {
  background: var(--pdf-selection-color);
}

/* Annotation Layer */
.pdf-page-annotation-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.pdf-annotation {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
}

.pdf-link-annotation {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  background: transparent;
  border: none;
  text-decoration: none;
}

.pdf-link-annotation:hover {
  background: rgba(0, 100, 255, 0.1);
  outline: 1px solid rgba(0, 100, 255, 0.3);
}

.pdf-annotation.highlight {
  background: var(--pdf-annotation-highlight);
  mix-blend-mode: multiply;
}

.pdf-annotation.highlight.selected {
  outline: 2px solid var(--pdf-primary-color);
}

.pdf-annotation.note {
  width: 24px;
  height: 24px;
  background: #ffeb3b;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Search Highlight Layer */
.pdf-page-search-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.search-highlight {
  position: absolute;
  background: var(--pdf-highlight-color);
  border-radius: 2px;
}

.search-highlight.current {
  background: rgba(255, 152, 0, 0.6);
  outline: 2px solid #ff9800;
}

/* Edge Navigation Overlays */
.pdf-nav-overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 40;
  pointer-events: none;
}

.pdf-nav-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.pdf-nav-prev {
  left: 0;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.3), transparent);
}

.pdf-nav-next {
  right: 0;
  background: linear-gradient(to left, rgba(0, 0, 0, 0.3), transparent);
}

.nav-overlay-btn {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s, background-color 0.2s;
}

.nav-overlay-btn:hover {
  background: #fff;
  transform: scale(1.1);
}

.nav-overlay-btn:active {
  transform: scale(0.95);
}

.nav-overlay-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

/* Minimap Indicator */
.pdf-minimap {
  position: absolute;
  bottom: 16px;
  right: 16px;
  /* Size is set dynamically by JavaScript based on page aspect ratio */
  max-width: 150px;
  max-height: 200px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  overflow: hidden;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: opacity 0.2s;
}

.pdf-minimap.hidden {
  display: none;
}

.minimap-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.minimap-viewport {
  position: absolute;
  border: 2px solid var(--pdf-primary-color);
  background: rgba(25, 118, 210, 0.2);
  pointer-events: none;
  box-sizing: border-box;
}

/* Loading */
.pdf-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(30, 32, 34, 0.85);
  color: white;
  z-index: 100;
}

.pdf-loading.visible {
  display: flex;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--pdf-primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Page Rendering Spinner (for page transitions) */
.pdf-page-spinner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease 0.05s, visibility 0s linear 0.2s;
}

.pdf-page-spinner.visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.15s ease 0.05s, visibility 0s linear 0s;
}

.page-spinner-icon {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--pdf-primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Error */
.pdf-error {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(82, 86, 89, 0.9);
  color: #ff5252;
  z-index: 100;
}

.pdf-error.visible {
  display: flex;
}

/* SEO Direct Link */
.pdf-seo-link-container {
  display: flex;
  justify-content: center;
  padding: 12px 16px;
  margin-top: 12px;
  margin-bottom: 16px;
  background: var(--pdf-toolbar-bg);
  border-radius: 8px;
  box-shadow: var(--pdf-shadow);
}

.pdf-seo-direct-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--pdf-primary-color);
  color: #ffffff;
  text-decoration: none;
  border-radius: 4px;
  font-size: 14px;
  font-family: var(--pdf-font-family);
  transition: background-color 0.2s;
}

.pdf-seo-direct-link:hover {
  background: var(--pdf-primary-hover);
  text-decoration: none;
}

.pdf-seo-direct-link svg {
  flex-shrink: 0;
}

/* SEO Link in Toolbar */
.pdf-toolbar .pdf-seo-direct-link {
  padding: 4px 12px;
  font-size: 12px;
  height: 28px;
}

/* SEO Text Content Section */
.pdf-seo-text-content {
  margin-top: 16px;
  margin-bottom: 16px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: var(--pdf-shadow);
  overflow: hidden;
}

.pdf-seo-text-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 16px 20px;
  border: none;
  background: #f8f9fa;
  color: #333;
  font-size: 15px;
  font-weight: 500;
  font-family: var(--pdf-font-family);
  cursor: pointer;
  transition: background-color 0.2s;
  text-align: left;
}

.pdf-seo-text-toggle:hover {
  background: #e9ecef;
}

.pdf-seo-text-toggle .toggle-icon {
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.pdf-seo-text-toggle[aria-expanded="true"] .toggle-icon {
  transform: rotate(180deg);
}

.pdf-seo-text-content-inner {
  max-height: 600px;
  overflow-y: auto;
  transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
}

.pdf-seo-text-content-inner.collapsed {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
}

.pdf-seo-text-heading {
  padding: 16px 20px;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  background: #f8f9fa;
  border-bottom: 1px solid var(--pdf-border-color);
}

.pdf-seo-text-article {
  padding: 20px;
}

.pdf-seo-text-page {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid #eee;
}

.pdf-seo-text-page:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.pdf-seo-text-page-heading {
  margin: 0 0 12px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--pdf-primary-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pdf-seo-text-page p {
  margin: 0 0 12px 0;
  line-height: 1.7;
  color: #444;
  font-size: 14px;
}

.pdf-seo-text-page p:last-child {
  margin-bottom: 0;
}

/* Page Slider Bar (YouTube-like seek bar) */
.pdf-page-slider-bar {
  position: relative;
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  background: var(--pdf-toolbar-bg);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.pdf-page-slider-bar .page-slider {
  width: 100%;
  height: 16px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  outline: none;
  margin: 0;
  padding: 0;
}

/* Track styling */
.pdf-page-slider-bar .page-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  cursor: pointer;
}

.pdf-page-slider-bar .page-slider::-moz-range-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  cursor: pointer;
  border: none;
}

/* Thumb styling */
.pdf-page-slider-bar .page-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--pdf-primary-color);
  border-radius: 50%;
  cursor: pointer;
  margin-top: -5px; /* Center thumb on track: (16px - 6px) / 2 = 5px */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
}

.pdf-page-slider-bar .page-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--pdf-primary-color);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
}

.pdf-page-slider-bar .page-slider:hover::-webkit-slider-thumb,
.pdf-page-slider-bar .page-slider:active::-webkit-slider-thumb {
  transform: scale(1.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.pdf-page-slider-bar .page-slider:hover::-moz-range-thumb,
.pdf-page-slider-bar .page-slider:active::-moz-range-thumb {
  transform: scale(1.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Page Slider Preview Popup */
.page-slider-preview {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
  pointer-events: none;
  z-index: 100;
}

.page-slider-preview.visible {
  opacity: 1;
  visibility: visible;
}

.page-slider-preview::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
}

.slider-preview-canvas {
  display: block;
  max-width: 150px;
  max-height: 200px;
  background: white;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.slider-preview-page {
  color: white;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* Responsive - Toolbar overflow menu */
@media (max-width: 900px) {
  .pdf-toolbar {
    position: relative;
  }

  .toolbar-group:not(:last-child)::after {
    display: none;
  }

  /* Hide overflow-priority items in toolbar */
  [data-toolbar-priority="overflow"] {
    display: none !important;
  }

  /* Show overflow menu button */
  .toolbar-overflow-group {
    display: flex;
  }

  /* Search popout: hide button but keep popout container in DOM */
  .toolbar-search-toggle[data-toolbar-priority="overflow"] {
    display: block !important;
    position: static;
    width: 0;
    margin: 0;
    margin-left: auto;
    padding: 0;
    overflow: visible;
  }

  .toolbar-search-toggle[data-toolbar-priority="overflow"] > button {
    display: none;
  }

  .toolbar-search-toggle[data-toolbar-priority="overflow"]::after {
    display: none !important;
  }

  /* Position popout relative to toolbar (position: relative above) */
  .toolbar-search-toggle[data-toolbar-priority="overflow"] .search-popout {
    position: absolute;
    top: 100%;
    left: 8px;
    right: 8px;
    min-width: auto;
  }
}

/* Responsive - Mobile layout */
@media (max-width: 768px) {
  .pdf-viewer-wrapper {
    height: 500px;
  }

  .pdf-sidebar {
    position: absolute;
    top: var(--pdf-toolbar-height);
    right: 0;
    bottom: 0;
    z-index: 50;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.2);
  }

  .pdf-sidebar.hidden {
    transform: translateX(100%);
    margin-right: 0;
  }

  /* Adjust canvas container and slider when sidebar is visible (overlay mode) */
  .pdf-canvas-container.sidebar-offset {
    padding-right: calc(280px + 16px);
  }

  .pdf-page-slider-bar.sidebar-offset {
    padding-right: calc(280px + 16px);
  }
}

/* ============================================
   Touch device adjustments (iPad / iPhone / Android)
   - Avoid auto-zoom on input focus (font-size >= 16px)
   - Avoid overlap with iPadOS Safari fullscreen exit "x" button
   Scoped via (hover: none) and (pointer: coarse) so desktop
   layout (incl. PC fullscreen) is unaffected.
   ============================================ */
@media (hover: none) and (pointer: coarse) {
  /* Prevent mobile browser auto-zoom when focusing inputs */
  .pdf-toolbar select,
  .page-info input,
  .search-popout input[type="text"] {
    font-size: 16px;
  }

  /* Reserve space for iPadOS Safari's native exit-fullscreen button
     so it does not cover the page nav / page-number input. */
  .pdf-viewer-wrapper:fullscreen .pdf-toolbar,
  .pdf-viewer-wrapper:-webkit-full-screen .pdf-toolbar {
    padding-left: 60px;
  }
}
