/* Viewer CSS - Based on PDF.js original viewer */

:root {
  --sidebar-width: 200px;
  --sidebar-transition-duration: 200ms;
  --sidebar-transition-timing-function: ease;
}

* {
  padding: 0;
  margin: 0;
}

html {
  height: 100%;
  width: 100%;
  font-size: 10px;
}

body {
  height: 100%;
  width: 100%;
  background-color: #404040;
}

body,
input,
button,
select {
  font: message-box;
  outline: none;
}

.hidden {
  display: none !important;
}

[hidden] {
  display: none !important;
}

/* Outer Container */
#outerContainer {
  width: 100%;
  height: 100%;
  position: relative;
}

/* Sidebar */
#sidebarContainer {
  position: absolute;
  top: 32px;
  bottom: 0;
  width: var(--sidebar-width);
  visibility: hidden;
  z-index: 100;
  border-top: 1px solid #333;
  transition-duration: var(--sidebar-transition-duration);
  transition-timing-function: var(--sidebar-transition-timing-function);
  left: calc(0px - var(--sidebar-width));
  transition-property: left;
}

#outerContainer.sidebarOpen #sidebarContainer {
  visibility: visible;
  left: 0px;
}

#toolbarSidebar {
  width: 100%;
  height: 32px;
  background-color: #424242;
  background-image: linear-gradient(#4d4d4d 0%, #404040 100%);
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.25),
              inset 0 -1px 0 rgba(255, 255, 255, 0.05),
              0 1px 0 rgba(0, 0, 0, 0.15),
              0 0 1px rgba(0, 0, 0, 0.1);
}

#toolbarSidebar .toolbarButton svg.icon {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
}

#sidebarContent {
  top: 32px;
  bottom: 0;
  overflow: auto;
  position: absolute;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.1);
  left: 0;
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.25);
}

#thumbnailView,
#outlineView,
#attachmentsView {
  position: absolute;
  width: 95%;
  top: 0;
  bottom: 0;
  overflow: auto;
}

#thumbnailView {
  display: flex;
  flex-direction: column;
  padding: 4px;
  gap: 4px;
}

#outlineView,
#attachmentsView {
  display: none;
}

/* Main Container */
#mainContainer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  min-width: 320px;
}

#viewerContainer {
  overflow: auto;
  position: absolute;
  top: 32px;
  right: 0;
  bottom: 0;
  left: 0;
  outline: none;
  background-color: #525659;
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.05);
  transition-duration: var(--sidebar-transition-duration);
  transition-timing-function: var(--sidebar-transition-timing-function);
}

#outerContainer.sidebarOpen #viewerContainer:not(.pdfPresentationMode) {
  transition-property: left;
  left: var(--sidebar-width);
}

/* Toolbar */
.toolbar {
  position: relative;
  left: 0;
  right: 0;
  z-index: 9999;
  cursor: default;
}

#toolbarContainer {
  width: 100%;
}

#toolbarContainer, .findbar, .secondaryToolbar {
  position: relative;
  height: 32px;
  background-color: #474747;
  background-image: linear-gradient(#525252 0%, #454545 100%);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.15),
              inset 0 -1px 0 rgba(255, 255, 255, 0.05),
              0 1px 0 rgba(0, 0, 0, 0.15),
              0 1px 1px rgba(0, 0, 0, 0.1);
}

#toolbarViewer {
  height: 32px;
}

#toolbarViewerMiddle {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

#toolbarViewerLeft {
  float: left;
}

#toolbarViewerRight {
  float: right;
}

#toolbarViewerLeft > *,
#toolbarViewerMiddle > *,
#toolbarViewerRight > *,
.findbar * {
  position: relative;
  float: left;
}

/* Toolbar Buttons */
.toolbarButton {
  border: 0 none;
  background: none;
  width: 32px;
  height: 25px;
  min-width: 16px;
  padding: 2px 6px 0;
  border: 1px solid transparent;
  border-radius: 2px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  line-height: 14px;
  user-select: none;
  cursor: default;
  margin: 3px 2px 4px 0;
}

.toolbarButton > span {
  display: inline-block;
  width: 0;
  height: 0;
  overflow: hidden;
}

.toolbarButton:hover,
.toolbarButton:focus {
  background-color: rgba(0, 0, 0, 0.12);
  background-image: linear-gradient(rgba(255, 255, 255, 0.05), transparent);
  background-clip: padding-box;
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-color: rgba(0, 0, 0, 0.32) rgba(0, 0, 0, 0.38) rgba(0, 0, 0, 0.42);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset,
              0 0 1px rgba(255, 255, 255, 0.15) inset,
              0 1px 0 rgba(255, 255, 255, 0.05);
}

.toolbarButton[disabled] {
  opacity: 0.5;
}

.splitToolbarButton {
  margin: 3px 2px 4px 0;
  display: inline-block;
}

.splitToolbarButton > .toolbarButton {
  border-radius: 0;
  float: left;
  margin: 0;
}

.splitToolbarButton > .toolbarButton:first-child {
  margin-right: -1px;
  border-top-left-radius: 2px;
  border-bottom-left-radius: 2px;
  border-right-color: transparent;
}

.splitToolbarButton > .toolbarButton:last-child {
  margin-left: -1px;
  border-top-right-radius: 2px;
  border-bottom-right-radius: 2px;
  border-left-color: transparent;
}

.splitToolbarButtonSeparator {
  padding: 8px 0;
  width: 1px;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 99;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
  display: inline-block;
  margin: 5px 0;
  float: left;
}

.splitToolbarButton:hover > .toolbarButton,
.splitToolbarButton:focus > .toolbarButton,
.splitToolbarButton.toggled > .toolbarButton {
  background-color: rgba(0, 0, 0, 0.12);
  background-image: linear-gradient(rgba(255, 255, 255, 0.05), transparent);
  background-clip: padding-box;
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-color: rgba(0, 0, 0, 0.32) rgba(0, 0, 0, 0.38) rgba(0, 0, 0, 0.42);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset,
              0 0 1px rgba(255, 255, 255, 0.15) inset,
              0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Toolbar Icons - Using SVG inline */
.toolbarButton::before {
  position: absolute;
  display: none;
}

.toolbarButton svg.icon,
.secondaryToolbarButton svg.icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
  display: inline-block;
  vertical-align: middle;
}

#sidebarToggle::before {
  content: '';
}

#viewFind::before {
  content: '';
  font-size: 14px;
}

.pageUp::before {
  content: '';
  font-size: 14px;
}

.pageDown::before {
  content: '';
  font-size: 14px;
}

#zoomOut::before {
  content: '';
  font-size: 18px;
}

#zoomIn::before {
  content: '';
  font-size: 18px;
}

#download::before,
.download::before {
  content: '';
  font-size: 14px;
}

#print::before,
.print::before {
  content: '';
  font-size: 14px;
}

#openFile::before,
.openFile::before {
  content: '';
  font-size: 14px;
}

#presentationMode::before,
.presentationMode::before {
  content: '⛶';
  font-size: 16px;
}

#secondaryToolbarToggle::before {
  content: '⚙';
  font-size: 16px;
}

#viewBookmark::before,
.bookmark::before {
  content: '🔖';
  font-size: 14px;
}

/* Toolbar Fields */
.toolbarField {
  padding: 3px 6px;
  margin: 4px 0;
  border-radius: 2px;
  background-color: rgba(255, 255, 255, 0.09);
  background-image: linear-gradient(rgba(255, 255, 255, 0.05), transparent);
  background-clip: padding-box;
  border: 1px solid;
  border-color: rgba(0, 0, 0, 0.32) rgba(0, 0, 0, 0.38) rgba(0, 0, 0, 0.42);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05) inset,
              0 1px 0 rgba(255, 255, 255, 0.05);
  color: #f2f2f2;
  font-size: 12px;
  line-height: 14px;
  outline-style: none;
}

.toolbarField.pageNumber {
  -moz-appearance: textfield;
  min-width: 16px;
  text-align: right;
  width: 40px;
}

.toolbarField:hover {
  background-color: rgba(255, 255, 255, 0.11);
  border-color: rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.43) rgba(0, 0, 0, 0.45);
}

.toolbarLabel {
  min-width: 16px;
  padding: 3px 6px 3px 2px;
  margin: 4px 2px 4px 0;
  border: 1px solid transparent;
  border-radius: 2px;
  color: #d9d9d9;
  font-size: 12px;
  line-height: 14px;
  text-align: left;
  user-select: none;
  cursor: default;
}

.toolbarButtonSpacer {
  width: 30px;
  display: inline-block;
  height: 1px;
}

/* Dropdown */
.dropdownToolbarButton {
  width: 140px;
  padding: 0;
  overflow: hidden;
  background-color: rgba(0, 0, 0, 0.12);
  background-image: linear-gradient(rgba(255, 255, 255, 0.05), transparent);
  margin: 3px 2px 4px 0;
}

.dropdownToolbarButton > select {
  width: 162px;
  height: 23px;
  font-size: 12px;
  color: #f2f2f2;
  margin: 0;
  padding: 3px 2px 2px;
  border: none;
  background: transparent;
}

.dropdownToolbarButton > select > option {
  background: #3d3d3d;
}

#scaleSelect {
  min-width: 140px;
}

/* Vertical Separator */
.verticalToolbarSeparator {
  display: block;
  padding: 8px 0;
  margin: 8px 4px;
  width: 1px;
  background-color: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
  margin-left: 2px;
}

/* Secondary Toolbar */
.secondaryToolbar {
  top: 32px;
  position: absolute;
  z-index: 30000;
  height: auto;
  padding: 6px;
  right: 4px;
  border: 1px solid rgba(0, 0, 0, 0.5);
  border-radius: 2px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.secondaryToolbar.hidden {
  display: none;
}

.secondaryToolbarButton {
  position: relative;
  margin: 0 0 4px 0;
  padding: 3px 0 1px 24px;
  height: auto;
  min-height: 25px;
  width: auto;
  min-width: 100%;
  white-space: normal;
  border: 0;
  background: none;
  border-radius: 2px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  text-align: left;
  cursor: default;
}

.secondaryToolbarButton {
  width: 100%;
  height: 32px;
  margin: 0;
  padding: 0 8px;
  border: 0;
  background-color: transparent;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  text-align: left;
  cursor: default;
  display: flex;
  align-items: center;
}

.secondaryToolbarButton:hover {
  background-color: rgba(0, 0, 0, 0.12);
}

.secondaryToolbarButton::before {
  content: '';
  display: none;
}

.secondaryToolbarButton svg.icon {
  width: 16px;
  height: 16px;
  margin-right: 12px;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
  flex-shrink: 0;
}

.secondaryToolbarButton span {
  flex: 1;
}

.horizontalToolbarSeparator {
  display: block;
  margin: 0 0 4px 0;
  height: 1px;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* Findbar */
.findbar {
  top: 32px;
  position: absolute;
  z-index: 10000;
  height: auto;
  min-width: 300px;
  padding: 0 6px;
  margin: 4px 2px;
  color: #d9d9d9;
  font-size: 12px;
  line-height: 14px;
  text-align: left;
  cursor: default;
  left: 68px;
  border: 1px solid rgba(0, 0, 0, 0.5);
  border-radius: 2px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.findbar.hidden {
  display: none;
}

.findbar > div {
  height: 32px;
}

#findInput {
  width: 200px;
}

/* Findbar Icons */
#findPrevious svg.icon,
#findNext svg.icon {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
}

/* Search Highlights */
.textLayer ::selection {
  background: #f0ad4e;
  color: black;
}

.textLayer .highlight {
  background: #f0ad4e;
  color: black;
  margin: 0;
  padding: 2px 0;
}

.textLayer .selected {
  background: #3498db;
  color: white;
}

/* Ensure text layer is always selectable and copyable. Some environments
   add restrictive rules or overlays; force the text layer to be selectable
   and allow pointer events so copying works reliably. */
.textLayer,
.textLayer * {
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  user-select: text !important;
  pointer-events: auto !important;
  white-space: pre !important;
}

.page .canvasWrapper {
  background: white;
}

.page canvas[data-page-number] {
  display: block;
}

/* PDF Viewer */
.pdfViewer {
  padding: 10px;
}

.pdfViewer .page {
  direction: ltr;
  margin: 10px auto;
  position: relative;
  overflow: visible;
  border: 9px solid transparent;
  background-clip: content-box;
  border-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAA1ElEQVQ4jbXSzw2CMBDH8S/a0AdHYAI3gI0YwQ1kBDdwBEZghJJq0dTaIn9+yUvTXu/ab9ILSQy+5pVKqHIw7YPZzNFX1qFXbeBKpPohQ3JXCMl9ogCxOhwxpEX+LQqeZ0EBuJMgQ5YLMFQlIFb7KGCEi7GCIUG2pwBykwiBRGPLGMCiWxnPEGJEe0zhH6CX4yxTXNK5Y0qSrqIYzqDsKHSHymeBLl5o6F36h5BJ7z+hZwUMXIKNAGnqo8K5j7TY0zxnHdPy/PzYPL36jvL+6yVTcQGg0Cy0cLCnQAAAAABJRU5ErkJggg==) 9 9 repeat;
  background-color: white;
}

.pdfViewer .page canvas {
  margin: 0;
  display: block;
}

/* Loading Bar */
#loadingBar {
  position: relative;
  width: 100%;
  height: 4px;
  background-color: #333;
  border-bottom: 1px solid #333;
}

#loadingBar .progress {
  position: absolute;
  top: 0;
  left: 0;
  width: 0%;
  height: 100%;
  background-color: #ddd;
  overflow: hidden;
  transition: width 200ms;
}

@keyframes progressIndeterminate {
  0% { left: -142px; }
  100% { left: 0; }
}

#loadingBar .progress.indeterminate {
  background-color: #999;
  transition: none;
}

#loadingBar .progress.indeterminate .glimmer {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: calc(100% + 150px);
  background: repeating-linear-gradient(135deg,
                                        #bbbbbb 0, #999999 5px,
                                        #999999 45px, #dddddd 55px,
                                        #dddddd 95px, #bbbbbb 100px);
  animation: progressIndeterminate 950ms linear infinite;
}

#loadingBar.hidden {
  display: none;
}

/* Error Wrapper */
#errorWrapper {
  background: #ff5555;
  color: white;
  left: 0;
  position: absolute;
  right: 0;
  z-index: 1000;
  padding: 3px;
  font-size: 0.8em;
}

#errorMessageLeft {
  float: left;
}

#errorMessageRight {
  float: right;
}

#errorMoreInfo {
  background-color: white;
  color: black;
  padding: 3px;
  margin: 3px;
  width: 98%;
}

/* Overlays */
#overlayContainer {
  display: table;
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.2);
  z-index: 40000;
}

#overlayContainer.hidden {
  display: none;
}

#overlayContainer > .container {
  display: table-cell;
  vertical-align: middle;
  text-align: center;
}

#overlayContainer > .container > .dialog {
  display: inline-block;
  padding: 15px;
  border-spacing: 4px;
  color: #d9d9d9;
  font-size: 12px;
  line-height: 14px;
  background-color: #474747;
  background-image: linear-gradient(#525252, #454545);
  border: 1px solid rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* Small full-screen overlay used during print preparation */
.print-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
  z-index: 60000;
}

.print-progress-container {
  background: white;
  border-radius: 8px;
  padding: 30px;
  min-width: 350px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.print-spinner {
  width: 50px;
  height: 50px;
  margin: 0 auto 20px;
  border: 4px solid #f0f0f0;
  border-top: 4px solid #27ae60;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.print-status-text {
  color: #333;
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 20px;
}

.print-progress-bar {
  width: 100%;
  height: 6px;
  background-color: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}

.print-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #27ae60, #2ecc71);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.print-progress-text {
  color: #666;
  font-size: 13px;
  margin: 0;
}

.dialog > .row {
  display: table-row;
}

.dialog > .row > * {
  display: table-cell;
}

.dialog .separator {
  display: block;
  margin: 4px 0;
  height: 1px;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.dialog .buttonRow {
  text-align: center;
  vertical-align: middle;
  margin-top: 10px;
}

.overlayButton {
  width: auto;
  margin: 3px 4px 2px !important;
  padding: 2px 6px 3px;
}

#documentPropertiesOverlay .row > span {
  width: 125px;
  word-wrap: break-word;
}

#documentPropertiesOverlay .row > p {
  max-width: 225px;
  word-wrap: break-word;
}

/* Warning Banner */
#warningBanner {
  position: absolute;
  top: 32px;
  left: 0;
  right: 0;
  background-color: #f39c12;
  color: white;
  padding: 12px;
  text-align: center;
  z-index: 1000;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  font-size: 14px;
  font-weight: 500;
}

#warningBanner.hidden {
  display: none;
}

/* Fullscreen Loading State */
#warningBanner.fullscreen-loading {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 0;
  background-color: white;
  box-shadow: none;
  z-index: 10000;
}

/* Loading Container Styles */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
}

.spinner-svg {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.loading-text {
  text-align: center;
}

.loading-text h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.loading-text p {
  margin: 0;
  font-size: 14px;
  color: #999;
  font-weight: 400;
}

/* Progress Bar Styles */
.progress-container {
  width: 100%;
  max-width: 300px;
  margin-top: 16px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background-color: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #27ae60 0%, #2ecc71 100%);
  width: 0%;
  transition: width 300ms ease;
  border-radius: 3px;
}

.progress-text {
  margin-top: 8px;
  text-align: center;
  font-size: 13px;
  color: #27ae60;
  font-weight: 600;
}

/* Spinner animation */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

#warningBanner .spinner-svg circle:nth-child(2) {
  animation: spin 1.5s ease-in-out infinite;
}

/* Responsive - Default visibility for large screens */
.visibleLargeView,
.visibleMediumView,
.visibleSmallView {
  display: none;
}

/* Responsive */
@media all and (max-width: 900px) {
  #toolbarViewerMiddle {
    display: table;
    margin: auto;
    left: auto;
    position: inherit;
    transform: none;
  }
}

@media all and (max-width: 840px) {
  #outerContainer.sidebarOpen #viewerContainer {
    left: 0 !important;
  }

  .hiddenLargeView,
  .hiddenMediumView {
    display: inherit;
  }
  
  .visibleLargeView,
  .visibleMediumView {
    display: none;
  }
}

@media all and (max-width: 770px) {
  .hiddenLargeView {
    display: none;
  }
  
  .visibleLargeView {
    display: inherit;
  }
}

@media all and (max-width: 700px) {
  .hiddenMediumView {
    display: none;
  }
  
  .visibleMediumView {
    display: inherit;
  }
}

@media all and (max-width: 640px) {
  .hiddenSmallView,
  .hiddenSmallView * {
    display: none;
  }
  
  .visibleSmallView {
    display: inherit;
  }
  
  .toolbarButtonSpacer {
    width: 0;
  }
  
  .findbar {
    left: 38px;
  }
}

@media all and (max-width: 535px) {
  #scaleSelectContainer {
    display: none;
  }
}

/* Thumbnail Viewer Styles */
.thumbnail-page {
  direction: ltr;
  margin: 4px auto;
  position: relative;
  border: 1px solid #3a3d40;
  border-radius: 4px;
  background-color: #424242;
  cursor: pointer;
  transition: all 150ms ease;
  max-width: 180px;
  width: 69%;
  overflow: visible;
}

.thumbnail-page:hover {
  background-color: #4a4d50;
  border-color: #27ae60;
  box-shadow: 0 2px 4px rgba(39, 174, 96, 0.2);
}

.thumbnail-page.selected {
  border: 2px solid #27ae60;
  box-shadow: 0 0 6px rgba(39, 174, 96, 0.4);
}

.thumbnail-page canvas {
  display: block;
  width: 100%;
  height: auto;
  background-color: white;
}

/* Outline Styles */
.outline-list {
  list-style: none;
  padding: 8px 0;
  margin: 0;
}

.outline-item {
  padding: 4px 0;
  list-style: none;
}

.outline-item a {
  display: block;
  padding: 6px 8px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 13px;
  transition: background-color 150ms ease;
  border-left: 2px solid transparent;
}

.outline-item a:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-left-color: #3498db;
}

.outline-item a:active {
  color: #3498db;
  background-color: rgba(52, 152, 219, 0.1);
}

/* Attachments Styles */
.attachments-list {
  list-style: none;
  padding: 8px 0;
  margin: 0;
}

.attachment-item {
  padding: 4px 0;
  list-style: none;
}

.attachment-item a {
  display: block;
  padding: 6px 8px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 13px;
  transition: all 150ms ease;
  border-left: 2px solid transparent;
}

.attachment-item a:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-left-color: #2ecc71;
}

.attachment-item a:active {
  color: #2ecc71;
  background-color: rgba(46, 204, 113, 0.1);
}

/* Print Container - Hidden by default, shown during printing */
#printContainer {
  display: none !important;
  position: absolute;
  top: -9999px;
  left: -9999px;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* Show print container during printing */
body[data-pdfjsprinting] #printContainer {
  display: block !important;
  position: static !important;
  top: auto !important;
  left: auto !important;
  width: 100% !important;
  height: auto !important;
  overflow: visible !important;
}

/* Print Styles */
@media print {
  /* CRITICAL: Reset everything for print */
  * {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
  }

  html, body {
    width: 100%;
    height: auto;
    background: white;
    color: black;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
  }

  /* Hide main viewer when printing from print container */
  body[data-pdfjsprinting] #outerContainer {
    display: none !important;
  }

  /* Show print container content */
  body[data-pdfjsprinting] #printContainer {
    display: block !important;
  }

  /* Hide UI elements during print */
  #sidebarContainer,
  #secondaryToolbar,
  #toolbarContainer,
  .findbar,
  .warning {
    display: none !important;
  }

  /* Hide the on-screen print overlay when printing */
  .print-overlay {
    display: none !important;
  }

  /* Print container - NO margins, NO padding */
  #printContainer {
    width: 100%;
    height: auto;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    display: block;
  }

  /* Canvas elements - STRICT sizing */
  #printContainer > canvas.printedPageCanvas {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    line-height: 0 !important;
    font-size: 0 !important;
    page-break-inside: avoid;
    page-break-after: always;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Image elements for print (converted from canvas) */
  #printContainer > img.printedPageImage {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    line-height: 0 !important;
    font-size: 0 !important;
    page-break-inside: avoid;
    page-break-after: always;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    max-width: 100%;
  }

  /* NO page break after last element */
  #printContainer > canvas.printedPageCanvas:last-child,
  #printContainer > img.printedPageImage:last-child {
    page-break-after: avoid !important;
  }

  @page {
    margin: 0 !important;
    padding: 0 !important;
    size: auto;
    orphans: 0;
    widows: 0;
  }
}

/* ============================================
   AI FLOATING WINDOW - CHAT ASSISTANT
   ============================================ */

:root {
  --ai-window-width: 420px;
  --ai-window-height: 600px;
  --ai-primary-color: #2563eb;
  --ai-secondary-color: #1e40af;
  --ai-bg-light: #f8fafc;
  --ai-border-color: #e2e8f0;
  --ai-text-primary: #1e293b;
  --ai-text-secondary: #64748b;
}

/* Floating Window */
.ai-floating-window {
  position: fixed;
  right: 20px;
  top: 50%;
  width: var(--ai-window-width);
  height: var(--ai-window-height);
  max-height: calc(100vh - 40px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  user-select: none;
  transform: translateY(-50%);
}

.ai-floating-window.hidden {
  transform: translateY(calc(100% + 20px));
  opacity: 0;
  pointer-events: none;
}

.ai-floating-window.minimized {
  height: 56px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Floating Button */
.ai-floating-btn {
  position: fixed;
  top: 50%;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--ai-border-color);
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  z-index: 999;
  user-select: none;
  touch-action: none;
  right: 24px;
}

.ai-floating-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.ai-floating-btn:hover:not(.dragging) {
  background: linear-gradient(135deg, var(--ai-primary-color) 10%, white 100%);
  color: white;
}

.ai-floating-btn.dragging {
  cursor: grabbing;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
  transform: none;
}

/* Button is always visible - never hide */
.ai-floating-btn.hidden {
  display: flex !important;
  visibility: visible !important;
}

.ai-floating-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
}

.ai-floating-content {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.ai-floating-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ai-text-primary);
  margin-bottom: 4px;
}

.ai-floating-message {
  font-size: 12px;
  color: var(--ai-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.ai-floating-btn .icon {
  width: 28px;
  height: 28px;
  stroke: white;
  stroke-width: 2.5;
}

.ai-floating-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: white;
  font-size: 11px;
  font-weight: 600;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: none; /* Hidden by default, shown via JS when there are notifications */
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* Floating Tooltip Message */
.ai-floating-tooltip {
  position: fixed;
  right: 100px;
  top: 50%;
  transform: translateY(-50%);
  background: white;
  color: var(--ai-text-primary);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--ai-border-color);
  max-width: 250px;
  z-index: 998;
  animation: slideInRight 0.3s ease-out;
  transition: opacity 0.3s ease;
}

.ai-floating-tooltip.hidden {
  display: none;
}

.ai-floating-tooltip::after {
  content: '';
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 8px 0 8px 8px;
  border-color: transparent transparent transparent white;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Window Header */
.ai-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 20px 10px 20px;
  background: linear-gradient(135deg, var(--ai-primary-color) 0%, var(--ai-secondary-color) 100%);
  color: white;
  border-radius: 16px 16px 0 0;
  cursor: grab;
  user-select: none;
  gap: 12px;
  transition: all 0.2s ease;
}

.ai-sidebar-header:hover {
  box-shadow: inset 0 0 0 1000px rgba(0, 0, 0, 0.05);
}

.ai-sidebar-header.grabbing {
  cursor: grabbing;
  box-shadow: inset 0 0 0 1000px rgba(0, 0, 0, 0.1);
}

.ai-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.ai-sidebar-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  flex: 1;
}

.ai-header-buttons {
  display: flex;
  gap: 8px;
}

.ai-header-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  width: 28px;
  height: 28px;
}

.ai-header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.ai-header-btn .icon {
  width: 16px;
  height: 16px;
  stroke: white;
}

.ai-section {
  border-bottom: 1px solid var(--ai-border-color);
  display: flex;
  flex-direction: column;
}

.ai-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: var(--ai-bg-light);
  border-bottom: 1px solid var(--ai-border-color);
}

.ai-section-header .icon {
  width: 20px;
  height: 20px;
  stroke: var(--ai-primary-color);
  flex-shrink: 0;
}

.ai-section-header h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--ai-text-primary);
  margin: 0;
}

.ai-content {
  padding: 20px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ai-text-primary);
  overflow-y: auto;
  max-height: 300px;
}

.ai-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--ai-text-secondary);
}

.ai-placeholder .icon {
  width: 48px;
  height: 48px;
  stroke: var(--ai-text-secondary);
  margin-bottom: 12px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.ai-placeholder p {
  margin: 0;
  font-size: 13px;
}

/* Chat Section */
.ai-chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-bottom: none;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--ai-bg-light);
}

.ai-chat-message {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  max-width: 85%;
  word-wrap: break-word;
}

.ai-chat-message.user {
  align-self: flex-end;
  background: var(--ai-primary-color);
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-chat-message.assistant {
  align-self: flex-start;
  background: white;
  color: var(--ai-text-primary);
  border: 1px solid var(--ai-border-color);
  border-bottom-left-radius: 4px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.ai-profile-image {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--ai-border-color);
}

.ai-message-text {
  flex: 1;
  min-width: 0;
}

.ai-chat-message.summary-message {
  max-width: 95%;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  font-size: 12.5px;
}

/* Markdown styling inside chat messages */
.ai-chat-message h1,
.ai-chat-message h2,
.ai-chat-message h3 {
  margin-top: 12px;
  margin-bottom: 8px;
  font-weight: 600;
}

.ai-chat-message h1 { font-size: 16px; }
.ai-chat-message h2 { font-size: 15px; }
.ai-chat-message h3 { font-size: 14px; }

.ai-chat-message p {
  margin: 8px 0;
}

.ai-chat-message ul,
.ai-chat-message ol {
  margin: 8px 0;
  padding-left: 20px;
}

.ai-chat-message li {
  margin: 4px 0;
}

.ai-chat-message code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
}

.ai-chat-message pre {
  background: rgba(0, 0, 0, 0.05);
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 8px 0;
}

.ai-chat-message pre code {
  background: none;
  padding: 0;
}

.ai-chat-message blockquote {
  border-left: 3px solid var(--ai-primary-color);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--ai-text-secondary);
  font-style: italic;
}

.ai-chat-message strong {
  font-weight: 600;
}

.ai-chat-message em {
  font-style: italic;
}

.ai-chat-message a {
  color: var(--ai-primary-color);
  text-decoration: underline;
}

/* AI Summary Button */
.ai-summary-btn {
  margin-top: 12px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.ai-summary-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  transform: translateY(-1px);
}

.ai-summary-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.ai-summary-btn:disabled {
  background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.7;
}
/* End AI Summary Button */

.ai-chat-message.thinking {
  opacity: 0.7;
  font-style: italic;
}

.ai-welcome-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  color: var(--ai-text-secondary);
}

.ai-welcome-message .icon {
  width: 36px;
  height: 36px;
  stroke: var(--ai-text-secondary);
  margin-bottom: 8px;
  animation: pulse 2s ease-in-out infinite;
}

.ai-welcome-message p {
  margin: 0;
  font-size: 13px;
}

.ai-chat-input-container {
  display: flex;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid var(--ai-border-color);
  background: white;
}

.ai-chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--ai-border-color);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.ai-chat-input:focus {
  border-color: var(--ai-primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.ai-chat-send-btn {
  background: var(--ai-primary-color);
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.ai-chat-send-btn:hover {
  background: var(--ai-secondary-color);
}

.ai-chat-send-btn:disabled {
  background: var(--ai-border-color);
  cursor: not-allowed;
}

.ai-chat-send-btn .icon {
  width: 18px;
  height: 18px;
  stroke: white;
}

/* Responsive para ventana flotante */
@media (max-width: 768px) {
  :root {
    --ai-window-width: 100%;
    --ai-window-height: 100%;
  }
  
  .ai-floating-window {
    right: 0;
    top: 0;
    transform: none;
    border-radius: 0;
    max-width: 100%;
  }
  
  .ai-floating-btn {
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
  }
}

@media (max-width: 480px) {
  .ai-floating-window {
    width: 100%;
    height: 100%;
  }
}

