/* =========================================================
   OFFICINA60 PDF Viewer v1.2 — © Riva Mario · by OFFICINA60
   Tutti i colori sono variabili CSS sovrascrivibili da Elementor.
   ========================================================= */

.o60pdf {
  /* palette di default (contrasto: testo primario bianco, secondario ≥ #c8d0e0) */
  --o60-bar-bg: #1d2026;
  --o60-bar-fg: #ffffff;
  --o60-bar-fg2: #c8d0e0;
  --o60-field-bg: #2b2f37;
  --o60-accent: #4c8dff;
  --o60-stage-bg: #3a3f48;
  --o60-side-bg: #23262d;
  --o60-hover: rgba(255, 255, 255, 0.12);

  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: var(--o60pdf-h, var(--o60pdf-h-fallback, 700px));
  min-height: 240px;
  overflow: hidden;
  background: var(--o60-stage-bg);
  color: var(--o60-bar-fg);
  font: 400 14px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  container-type: inline-size;
  container-name: o60pdf;
  box-sizing: border-box;
  isolation: isolate;
}
.o60pdf *, .o60pdf *::before, .o60pdf *::after { box-sizing: border-box; }
.o60pdf.o60pdf--bar-bottom { flex-direction: column-reverse; }

/* ---------- stato iniziale / no-JS ---------- */
.o60pdf__boot {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}
.o60pdf__boot-title { font-size: 15px; font-weight: 600; color: var(--o60-bar-fg); word-break: break-word; }
.o60pdf__spinner {
  width: 34px; height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--o60-accent);
  border-radius: 50%;
  animation: o60pdf-spin 0.9s linear infinite;
}
@keyframes o60pdf-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .o60pdf__spinner { animation-duration: 3s; } }

.o60pdf a.o60pdf__btn-link,
.o60pdf a.o60pdf__btn-link:visited {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 6px;
  background: var(--o60-accent);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.o60pdf a.o60pdf__btn-link:hover { filter: brightness(1.1); }

/* ---------- barra strumenti ---------- */
.o60pdf__bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 46px;
  padding: 5px 8px;
  background: var(--o60-bar-bg);
  color: var(--o60-bar-fg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.35);
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  z-index: 3;
}
.o60pdf--bar-bottom .o60pdf__bar { border-bottom: 0; border-top: 1px solid rgba(0, 0, 0, 0.35); }
.o60pdf__grp { display: flex; align-items: center; gap: 2px; }
.o60pdf__grp--left { flex: 1 1 0; justify-content: flex-start; min-width: 0; }
.o60pdf__grp--mid { flex: 0 0 auto; justify-content: center; }
.o60pdf__grp--right { flex: 1 1 0; justify-content: flex-end; min-width: 0; }
.o60pdf__sep { width: 1px; height: 22px; margin: 0 4px; background: rgba(255, 255, 255, 0.18); }

.o60pdf button.o60pdf__ib {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  color: var(--o60-bar-fg);
  cursor: pointer;
  flex: 0 0 auto;
  -webkit-tap-highlight-color: transparent;
}
.o60pdf button.o60pdf__ib svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.o60pdf button.o60pdf__ib:hover { background: var(--o60-hover); }
.o60pdf button.o60pdf__ib:focus-visible { outline: 2px solid var(--o60-accent); outline-offset: 1px; }
.o60pdf button.o60pdf__ib[aria-pressed="true"] { background: var(--o60-accent); color: #ffffff; }
.o60pdf button.o60pdf__ib:disabled { opacity: 0.4; cursor: default; background: none; }

.o60pdf__pageinfo { display: flex; align-items: center; gap: 6px; margin: 0 4px; color: var(--o60-bar-fg2); font-size: 13px; white-space: nowrap; }
.o60pdf input.o60pdf__page,
.o60pdf input.o60pdf__find-input,
.o60pdf select.o60pdf__zoomsel,
.o60pdf input.o60pdf__pw-input {
  all: unset;
  box-sizing: border-box;
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--o60-field-bg);
  color: var(--o60-bar-fg);
  font: 500 14px/32px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.o60pdf input.o60pdf__page { width: 52px; text-align: center; padding: 0 4px; }
.o60pdf select.o60pdf__zoomsel {
  width: 132px;
  cursor: pointer;
  padding-right: 24px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 13px) 14px, calc(100% - 8px) 14px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.o60pdf select.o60pdf__zoomsel option { background: #1d2026; color: #ffffff; }
.o60pdf input:focus-visible,
.o60pdf select:focus-visible { outline: 2px solid var(--o60-accent); outline-offset: 0; }

.o60pdf__credit { margin: 0 6px; color: var(--o60-bar-fg2); font-size: 12px; white-space: nowrap; }

/* ---------- barra di ricerca ---------- */
.o60pdf__find {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--o60-bar-bg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.35);
  position: relative;
  z-index: 2;
}
.o60pdf__find.is-open { display: flex; }
.o60pdf input.o60pdf__find-input { flex: 1 1 auto; min-width: 0; max-width: 360px; }
.o60pdf__find-count { color: var(--o60-bar-fg2); font-size: 13px; min-width: 80px; padding: 0 6px; white-space: nowrap; }

/* ---------- barra di avanzamento ---------- */
.o60pdf__progress { height: 3px; background: transparent; flex: 0 0 auto; position: relative; z-index: 2; }
.o60pdf__progress i { display: block; height: 100%; width: 0; background: var(--o60-accent); transition: width 0.2s; }
.o60pdf__progress.is-done { visibility: hidden; }

/* ---------- corpo: miniature + documento ---------- */
.o60pdf__body { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }
.o60pdf__side {
  flex: 0 0 168px;
  display: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--o60-side-bg);
  border-right: 1px solid rgba(0, 0, 0, 0.35);
  padding: 10px 0;
}
.o60pdf.is-thumbs .o60pdf__side { display: block; }
.o60pdf button.o60pdf__thumb {
  all: unset;
  box-sizing: border-box;
  display: block;
  width: 124px;
  margin: 0 auto 12px;
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
}
.o60pdf button.o60pdf__thumb:hover { background: var(--o60-hover); }
.o60pdf button.o60pdf__thumb:focus-visible { outline: 2px solid var(--o60-accent); }
.o60pdf button.o60pdf__thumb.is-active { background: var(--o60-accent); }
.o60pdf__thumb-img { display: block; width: 100%; min-height: 60px; background: #ffffff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); }
.o60pdf__thumb-img canvas { display: block; width: 100%; height: auto; }
.o60pdf__thumb-n { display: block; margin-top: 4px; font-size: 12px; color: var(--o60-bar-fg2); }
.o60pdf button.o60pdf__thumb.is-active .o60pdf__thumb-n { color: #ffffff; font-weight: 600; }

.o60pdf__stage { position: relative; flex: 1 1 auto; min-width: 0; }
/* PDF.js richiede un contenitore con position:absolute */
.o60pdf__scroll {
  position: absolute;
  inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  outline: none;
}
.o60pdf__scroll:focus-visible { box-shadow: inset 0 0 0 2px var(--o60-accent); }
.o60pdf .pdfViewer { padding: 14px 0; }
.o60pdf .pdfViewer.removePageBorders .page { margin: 0 auto 14px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45); }
.o60pdf .pdfViewer.removePageBorders.scrollHorizontal .page,
.o60pdf .pdfViewer.removePageBorders.scrollWrapped .page,
.o60pdf .pdfViewer.removePageBorders .spread .page { margin: 0 7px 14px; }
.o60pdf .pdfViewer.scrollHorizontal { padding: 14px 7px; }
/* evidenziazione risultati di ricerca coerente con l'accento */
.o60pdf .textLayer .highlight.selected { background-color: var(--o60-accent); }

/* ---------- overlay messaggi / password ---------- */
.o60pdf__msg {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--o60-stage-bg);
  z-index: 4;
  text-align: center;
}
.o60pdf__msg.is-open { display: flex; }
.o60pdf__msg-box { max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.o60pdf__msg-text { color: var(--o60-bar-fg); font-size: 15px; line-height: 1.45; margin: 0; }
.o60pdf__msg-sub { color: var(--o60-bar-fg2); font-size: 13px; margin: 0; }
.o60pdf__pw-row { display: flex; gap: 8px; width: 100%; }
.o60pdf input.o60pdf__pw-input { flex: 1; min-width: 0; }
.o60pdf button.o60pdf__btn {
  all: unset;
  box-sizing: border-box;
  height: 32px;
  padding: 0 16px;
  border-radius: 6px;
  background: var(--o60-accent);
  color: #ffffff;
  font: 600 14px/32px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  cursor: pointer;
}
.o60pdf button.o60pdf__btn:focus-visible { outline: 2px solid #ffffff; outline-offset: 2px; }

/* avviso fallback (lettore del browser) */
.o60pdf__note { flex: 0 0 auto; padding: 6px 10px; background: var(--o60-bar-bg); color: var(--o60-bar-fg2); font-size: 12px; }
.o60pdf__native { flex: 1 1 auto; width: 100%; border: 0; display: block; background: #ffffff; }

/* ---------- schermo intero ---------- */
.o60pdf:fullscreen { width: 100vw; height: 100vh; border-radius: 0; }
.o60pdf.is-pseudo-fs {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: none !important;
  margin: 0 !important;
  border-radius: 0 !important;
  z-index: 2147483000 !important;
}
html.o60pdf-lock, html.o60pdf-lock body { overflow: hidden !important; }

/* ---------- placeholder editor Elementor ---------- */
.o60pdf-placeholder {
  padding: 40px 20px;
  border: 2px dashed #c8d0e0;
  border-radius: 8px;
  background: #1d2026;
  color: #ffffff;
  text-align: center;
  font: 500 14px/1.4 system-ui, sans-serif;
}

/* ---------- responsive (container query: larghezza del viewer, non della pagina) ---------- */
@container o60pdf (max-width: 899px) {
  .o60pdf__credit { display: none; }
}
@container o60pdf (max-width: 719px) {
  .o60pdf select.o60pdf__zoomsel { width: 96px; }
  .o60pdf .o60pdf__hide-md { display: none !important; }
  /* miniature sopra il documento, non affiancate */
  .o60pdf__side { position: absolute; top: 0; bottom: 0; left: 0; z-index: 3; box-shadow: 4px 0 16px rgba(0, 0, 0, 0.45); }
}
@container o60pdf (max-width: 519px) {
  .o60pdf .o60pdf__hide-sm { display: none !important; }
  .o60pdf__bar { gap: 0; padding: 4px; }
  .o60pdf button.o60pdf__ib { width: 34px; height: 34px; }
  .o60pdf__pageinfo { margin: 0 2px; gap: 4px; }
  .o60pdf input.o60pdf__page { width: 44px; }
  .o60pdf__find-count { min-width: 0; }
  .o60pdf select.o60pdf__zoomsel { width: 84px; }
}
/* smartphone: lo zoom si fa con il pinch, la barra tiene solo l'essenziale */
@container o60pdf (max-width: 439px) {
  .o60pdf__grp--mid { display: none; }
}
