/* ============================================================
   Ironshelf — PDF Reader Styles
   ============================================================ */

/* --- Container --- */
.pdf-reader-container {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  background: #2a2a2a;
  color: #e8e4da;
  font-family: 'Inter', sans-serif;
}

/* --- Toolbar --- */
.pdf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(15, 17, 21, 0.97);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
  flex-shrink: 0;
  gap: 8px;
}

.pdf-toolbar-left,
.pdf-toolbar-center,
.pdf-toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pdf-toolbar-left {
  flex: 1;
  min-width: 0;
}

.pdf-toolbar-center {
  flex-shrink: 0;
}

.pdf-toolbar-right {
  flex: 1;
  justify-content: flex-end;
}

.pdf-toolbar-separator {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.12);
  margin: 0 4px;
}

.pdf-title {
  font-size: 13px;
  font-weight: 500;
  color: rgba(232, 228, 218, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 8px;
  min-width: 0;
}

/* --- Buttons --- */
.pdf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(232, 228, 218, 0.85);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
  flex-shrink: 0;
  padding: 0;
}

.pdf-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #e8e4da;
}

.pdf-btn:focus-visible {
  outline: 2px solid #3BB3C9;
  outline-offset: 2px;
}

.pdf-btn svg {
  width: 18px;
  height: 18px;
}

.pdf-btn-active {
  background: rgba(59, 179, 201, 0.15);
  color: #3BB3C9;
}

.pdf-btn-active:hover {
  background: rgba(59, 179, 201, 0.25);
}

.pdf-zoom-display {
  width: auto;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 500;
  min-width: 48px;
  text-align: center;
}

/* --- Page Navigation --- */
.pdf-page-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pdf-page-input {
  width: 48px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: #e8e4da;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  text-align: center;
  padding: 0 4px;
  -moz-appearance: textfield;
}

.pdf-page-input::-webkit-inner-spin-button,
.pdf-page-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pdf-page-input:focus {
  outline: none;
  border-color: #3BB3C9;
}

.pdf-page-total {
  font-size: 13px;
  color: rgba(232, 228, 218, 0.6);
  white-space: nowrap;
}

/* --- Body (sidebar + viewport) --- */
.pdf-body {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

/* --- Sidebar (Thumbnails) --- */
.pdf-sidebar {
  width: 0;
  overflow: hidden;
  background: rgba(15, 17, 21, 0.95);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  transition: width 250ms ease;
  flex-shrink: 0;
}

.pdf-sidebar-visible {
  width: 160px;
}

.pdf-sidebar-content {
  width: 160px;
  height: 100%;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.pdf-thumbnail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 2px solid transparent;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
  width: 100%;
}

.pdf-thumbnail:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

.pdf-thumbnail:focus-visible {
  outline: 2px solid #3BB3C9;
  outline-offset: 1px;
}

.pdf-thumbnail-active {
  border-color: #3BB3C9;
  background: rgba(59, 179, 201, 0.06);
}

.pdf-thumbnail-canvas {
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  line-height: 0;
}

.pdf-thumbnail-canvas canvas {
  display: block;
}

.pdf-thumbnail-label {
  font-size: 11px;
  color: rgba(232, 228, 218, 0.5);
}

.pdf-thumbnail-active .pdf-thumbnail-label {
  color: #3BB3C9;
  font-weight: 500;
}

/* --- Viewport --- */
.pdf-viewport {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
  outline: none;
}

/* --- Page Container --- */
.pdf-page-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-bottom: 32px;
}

.pdf-page-container.pdf-single-mode {
  gap: 0;
}

/* --- Page Wrapper --- */
.pdf-page-wrapper {
  position: relative;
  background: #fff;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.25),
    0 0 1px rgba(0, 0, 0, 0.3);
  line-height: 0;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.pdf-page-label {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: rgba(232, 228, 218, 0.4);
  white-space: nowrap;
}

/* --- Loading --- */
.pdf-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #2a2a2a;
  z-index: 20;
}

.pdf-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(59, 179, 201, 0.2);
  border-top-color: #3BB3C9;
  border-radius: 50%;
  animation: pdf-spin 0.8s linear infinite;
}

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

.pdf-loading-text {
  font-size: 14px;
  color: rgba(232, 228, 218, 0.7);
}

/* --- Error --- */
.pdf-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 24px;
}

.pdf-error-icon {
  width: 48px;
  height: 48px;
  color: #ef4444;
}

.pdf-error-icon svg {
  width: 100%;
  height: 100%;
}

.pdf-error-title {
  font-size: 16px;
  font-weight: 600;
  color: #e8e4da;
}

.pdf-error-message {
  font-size: 13px;
  color: rgba(232, 228, 218, 0.6);
  max-width: 400px;
}

.pdf-error-btn {
  margin-top: 8px;
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  background: #3BB3C9;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 150ms ease;
}

.pdf-error-btn:hover {
  opacity: 0.85;
}

/* --- Dark Mode (invert content) --- */
.pdf-dark-mode .pdf-page-wrapper {
  filter: invert(1) hue-rotate(180deg);
}

.pdf-dark-mode .pdf-page-wrapper canvas {
  filter: none; /* already inverted by parent */
}

.pdf-dark-mode .pdf-thumbnail-canvas {
  filter: invert(1) hue-rotate(180deg);
}

/* --- Print --- */
@media print {
  .pdf-toolbar,
  .pdf-sidebar,
  .pdf-loading {
    display: none !important;
  }

  .pdf-reader-container {
    position: static;
    background: transparent;
  }

  .pdf-viewport {
    overflow: visible;
    padding: 0;
  }

  .pdf-page-wrapper {
    box-shadow: none;
    page-break-after: always;
  }

  .pdf-page-label {
    display: none;
  }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .pdf-toolbar {
    padding: 4px 8px;
    flex-wrap: wrap;
    gap: 4px;
  }

  .pdf-toolbar-left {
    order: 1;
    flex: 1;
  }

  .pdf-toolbar-center {
    order: 3;
    flex: 1;
    justify-content: center;
  }

  .pdf-toolbar-right {
    order: 2;
    flex: 0;
  }

  .pdf-title {
    display: none;
  }

  .pdf-toolbar-separator {
    display: none;
  }

  .pdf-sidebar-visible {
    width: 120px;
  }

  .pdf-sidebar-content {
    width: 120px;
  }

  .pdf-btn {
    width: 36px;
    height: 36px;
  }

  /* Hide print on mobile */
  #pdf-print-btn {
    display: none;
  }
}

@media (max-width: 480px) {
  .pdf-toolbar-right {
    gap: 2px;
  }

  .pdf-zoom-display {
    display: none;
  }

  .pdf-sidebar-visible {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 15;
    width: 140px;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.3);
  }

  .pdf-sidebar-content {
    width: 140px;
  }
}

/* --- Fullscreen --- */
.pdf-reader-container:fullscreen .pdf-viewport,
.pdf-reader-container:-webkit-full-screen .pdf-viewport {
  background: #2a2a2a;
}
