/*
 * pdf-canvas-viewer.css — styles for the shared pdf.js canvas viewer
 * (public/js/pdf-canvas-viewer.js). Used on the contract-preview and
 * download pages inside the existing .prev-pdf-viewer-v2 box.
 */

/* Page containers that host the viewer (match the old iframe's sizing:
   .prev-pdf-iframe-v2 was flex:1 min-height:600px on preview, 400px on
   the download page) */
.prev-pdf-canvas-v2 {
  width: 100%;
  flex: 1 1 auto;
  min-height: 600px;
}

.pcv-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 400px;
  background: #525659; /* matches the dark chrome of native PDF viewers */
  border-radius: inherit;
  overflow: hidden;
}

/* ── Toolbar ── */
.pcv-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: #323639;
  color: #f1f1f1;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
}

.pcv-group { display: inline-flex; gap: 6px; margin-left: 10px; }
.pcv-group-right { margin-left: auto; }

.pcv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: #f1f1f1;
  cursor: pointer;
}
.pcv-btn:hover { background: rgba(255, 255, 255, 0.15); }
.pcv-btn:active { background: rgba(255, 255, 255, 0.25); }
.pcv-btn svg { width: 18px; height: 18px; }

.pcv-page-label {
  font-size: 13px;
  min-width: 92px;
  text-align: center;
  white-space: nowrap;
}

/* ── Scrollable page column ── */
.pcv-pages {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px;
  text-align: center;
}

canvas.pcv-page {
  display: block;
  margin: 0 auto 8px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  max-width: none; /* canvases size themselves; horizontal scroll when zoomed */
}

/* ── Loading spinner ── */
.pcv-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.pcv-root { position: relative; }
.pcv-spinner {
  width: 38px;
  height: 38px;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: #f59e0b;
  border-radius: 50%;
  animation: pcv-spin 0.9s linear infinite;
}
@keyframes pcv-spin { to { transform: rotate(360deg); } }

.pcv-error {
  color: #f1f1f1;
  padding: 40px 20px;
  font-size: 15px;
}

/* ── Print-only container (print button renders pages here) ── */
#pcv-print-box { display: none; }

@media print {
  /* Show only the rendered PDF pages when printing from the viewer */
  body.pcv-printing > *:not(#pcv-print-box) { display: none !important; }
  #pcv-print-box { display: block !important; }
  #pcv-print-box img {
    display: block;
    width: 100%;
    page-break-after: always;
  }
}

/* ── Mobile ── */
@media (max-width: 640px) {
  .pcv-page-label { min-width: 76px; font-size: 12px; }
  .pcv-btn { width: 38px; height: 34px; } /* bigger touch targets */

  /* Cap the viewer height on mobile so it doesn't stretch to the full
     document height. Pages scroll inside .pcv-pages (overflow:auto). */
  .pcv-root { max-height: 700px; }
}
