/* -------------------------------------------------------------------------- */
/* Modern PDF Viewer - Notion XT                                              */
/* -------------------------------------------------------------------------- */

.pdf-reader {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #0b0f19;
  border-radius: 14px;
  overflow: hidden;
  color: #f1f5f9;
  position: relative;
}

/* Ensure modal form reset does not bleed into PDF reader forms */
.modal .pdf-reader form,
.pdf-reader form,
.pdf-reader-page-jump {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 4px !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Modal preview body layout for PDF */
.preview-body:has(.pdf-reader),
.modal-preview.preview-pdf-mode .preview-body {
  overflow: hidden !important;
  align-items: stretch !important;
  justify-content: stretch !important;
  padding: 0 !important;
  background: #0b0f19 !important;
}

/* PDF Toolbar */
.pdf-reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex: none;
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  box-sizing: border-box;
}

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

/* Icon Buttons */
.pdf-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #1e293b;
  color: #cbd5e1;
  padding: 0;
  cursor: pointer;
  transition: all 0.14s ease;
  flex-shrink: 0;
}

.pdf-tool-btn svg {
  display: block;
  pointer-events: none;
}

.pdf-tool-btn:hover:not(:disabled) {
  background: #334155;
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
  transform: translateY(-1px);
}

.pdf-tool-btn:active:not(:disabled) {
  transform: translateY(0);
  background: #0f172a;
}

.pdf-tool-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* Page Jump Pill */
.pdf-page-indicator {
  display: inline-flex;
  align-items: center;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  height: 32px;
  padding: 0 8px;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #94a3b8;
}

.pdf-page-indicator:focus-within {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.pdf-page-input {
  width: 36px !important;
  height: 24px !important;
  border: 0 !important;
  border-radius: 4px !important;
  background: #0f172a !important;
  color: #f8fafc !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  text-align: center !important;
  padding: 0 2px !important;
  margin: 0 !important;
  outline: 0 !important;
  -moz-appearance: textfield;
}

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

.pdf-page-sep {
  color: #64748b;
  user-select: none;
}

.pdf-page-total {
  color: #94a3b8;
  user-select: none;
  min-width: 14px;
}

/* Status badge */
.pdf-status-badge {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  background: rgba(30, 41, 59, 0.6);
  padding: 4px 12px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

/* Zoom badge button */
.pdf-zoom-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #1e293b;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.14s ease;
  min-width: 52px;
}

.pdf-zoom-badge:hover {
  background: #334155;
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

.pdf-toolbar-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.12);
  margin: 0 3px;
  flex-shrink: 0;
}

/* PDF Stage / Viewer */
.pdf-reader-stage {
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  padding: 24px 16px;
  text-align: center;
  background: #0b0f19;
  box-sizing: border-box;
}

.pdf-reader-stage::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.pdf-reader-stage::-webkit-scrollbar-track {
  background: rgba(11, 15, 25, 0.8);
}

.pdf-reader-stage::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 6px;
  border: 2px solid #0b0f19;
}

.pdf-reader-stage::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* Page wrapper & canvas */
.pdf-reader-page {
  width: max-content;
  min-width: 0;
  margin: 0 auto 24px;
  position: relative;
  display: flex;
  justify-content: center;
  transition: transform 0.18s ease;
}

.pdf-reader-page:last-child {
  margin-bottom: 28px;
}

.pdf-reader-page canvas {
  display: block;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 6px;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.65), 0 2px 10px rgba(0, 0, 0, 0.4);
  max-width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: box-shadow 0.2s ease;
}

.pdf-reader-page:hover canvas {
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.8), 0 4px 14px rgba(0, 0, 0, 0.5);
}

/* Page badge */
.pdf-page-badge {
  position: absolute;
  bottom: -13px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.pdf-reader-page:hover .pdf-page-badge {
  opacity: 1;
}

/* Loading & Spinner */
.pdf-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: 100%;
  min-height: 280px;
  color: #94a3b8;
}

.pdf-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(56, 189, 248, 0.15);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: pdfSpin 0.75s linear infinite;
}

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

.pdf-loading-text {
  font-size: 14px;
  font-weight: 500;
}

/* Password Protected Card */
.pdf-password-card {
  max-width: 360px;
  margin: 60px auto;
  padding: 28px;
  background: #1e293b;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.45);
}

.pdf-password-icon {
  font-size: 36px;
  margin-bottom: 12px;
  display: block;
}

.pdf-password-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  color: #f8fafc;
}

.pdf-password-card p {
  margin: 0 0 16px;
  font-size: 13px;
  color: #94a3b8;
}

.pdf-password-form {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
}

.pdf-password-form input {
  height: 40px !important;
  border-radius: 10px !important;
  border: 1px solid #334155 !important;
  background: #0f172a !important;
  color: #f8fafc !important;
  padding: 0 12px !important;
  font-size: 13px !important;
}

/* Screen Reader Text */
.pdf-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* Responsive Breakpoints */
@media (max-width: 680px) {
  .pdf-center-group {
    display: none !important;
  }

  .pdf-first-btn,
  .pdf-last-btn {
    display: none !important;
  }

  .pdf-reader-toolbar {
    padding: 6px 10px;
  }

  .pdf-reader-stage {
    padding: 16px 8px;
  }
}

@media (max-width: 440px) {
  .pdf-zoom-badge {
    display: none !important;
  }

  .pdf-toolbar-divider {
    display: none !important;
  }

  .pdf-page-indicator {
    padding: 0 4px;
    height: 30px;
  }

  .pdf-tool-btn {
    width: 30px;
    height: 30px;
  }
}
