/* ============================== PDF VIEWER (S7) ==============================
 * Dark-theme adapted port of the v2 pdf-viewer.css. The viewer mounts a
 * .pdf-container in each pdf-ref block; this file styles the toolbar,
 * canvas wrapper, page info, and overlay layers for the v3 dark palette
 * (var(--surface), var(--border), var(--text-muted)).
 * ============================================================================ */

/* ─── Container chrome ──────────────────────────────────────────── */
.sf-block-card-type-pdf-ref .pdf-container,
.sf-td-block-body .pdf-container {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface, #1c1f2b);
  margin: 6px 0;
}

/* ─── Toolbar ───────────────────────────────────────────────────── */
.pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-secondary, #2a2f3e);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  flex-wrap: wrap;
}
.pdf-tb-left,
.pdf-tb-center,
.pdf-tb-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pdf-tb-left  { flex: 0 0 auto; }
.pdf-tb-center { flex: 1; justify-content: center; }
.pdf-tb-right { flex: 0 0 auto; }
.pdf-toolbar button {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface, #1c1f2b);
  color: var(--text, #e0e0e0);
  cursor: pointer;
  font-size: 12px;
  line-height: 1.4;
  transition: background .15s, opacity .15s;
}
.pdf-toolbar button:hover { background: var(--primary-light, #2d3561); }
.pdf-toolbar button:active { opacity: .7; }
.pdf-toolbar button:disabled { opacity: .4; cursor: default; }
.pdf-toolbar select {
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface, #1c1f2b);
  font-size: 11px;
  color: var(--text, #e0e0e0);
  cursor: pointer;
}
.pdf-sep {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 2px;
}
.pdf-page-info {
  font-size: 12px;
  color: var(--text-muted, #8b95a8);
  white-space: nowrap;
}
.pdf-open-external {
  display: inline-block;
  padding: 3px 8px;
  background: var(--primary, #4f46e5);
  color: #fff;
  border: none;
  border-radius: 4px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  line-height: 1.4;
}
.pdf-open-external:hover { background: var(--primary-dark, #4338ca); }
.pdf-text-toggle.active {
  background: var(--primary, #4f46e5);
  color: #fff;
  border-color: var(--primary, #4f46e5);
}
.pdf-save-status {
  font-size: 10px;
  color: var(--text-muted, #8b95a8);
  margin-left: 4px;
  min-width: 60px;
}

/* ─── Canvas wrapper ────────────────────────────────────────────── */
.pdf-canvas-wrap {
  position: relative;
  overflow: auto;
  max-height: 70vh;
  background: #2a2f3e;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 8px;
}
.pdf-render-canvas {
  display: block;
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
  background: #fff;
}
.pdf-text-overlay {
  position: absolute;
  pointer-events: none;
  z-index: 10;
}
.pdf-text-overlay.active { pointer-events: auto; }

/* ─── Per-page text annotation (S7 minimal) ───────────────────── */
.pdf-text-item {
  position: absolute;
  min-width: 40px;
  min-height: 24px;
  padding: 4px 6px;
  font-family: sans-serif;
  background: rgba(255, 255, 102, .85);
  color: #1f1f1f;
  border: 1px dashed var(--primary, #4f46e5);
  border-radius: 3px;
  cursor: move;
  z-index: 11;
  outline: none;
  word-break: break-word;
  line-height: 1.3;
  box-sizing: border-box;
  font-size: 13px;
  max-width: 280px;
}
.pdf-text-item:focus {
  background: rgba(255,255,255,.96);
  border-style: solid;
  cursor: text;
}

/* ─── Loading / error overlays ──────────────────────────────────── */
.pdf-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  color: var(--text-muted, #8b95a8);
  background: rgba(28, 31, 43, .92);
  padding: 10px 18px;
  border-radius: 6px;
  z-index: 5;
}
.pdf-loading.is-error {
  color: #ef4444;
}

/* ─── Empty / "no URL" fallback ─────────────────────────────────── */
.pdf-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px;
  background: var(--surface, #1c1f2b);
  border-radius: 5px;
  text-align: center;
  color: var(--text-muted, #8b95a8);
  font-size: 12px;
}

/* ─── Annotation list panel ─────────────────────────────────────── */
.pdf-annots-panel {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary, #2a2f3e);
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-muted, #8b95a8);
}
.pdf-annots-panel summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text, #e0e0e0);
  margin-bottom: 4px;
}
.pdf-annots-list {
  margin: 0;
  padding: 0 0 0 12px;
  max-height: 120px;
  overflow: auto;
}
.pdf-annots-list li { margin-bottom: 2px; word-break: break-word; }
/* ── SCORM import pseudo-terminal (S7b-A: SSE progress stream) ────── */
.sf-pdfi-term {
  margin: 8px 0 0;
  padding: 8px 10px;
  max-height: 180px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #c9d1d9;
  font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
.sf-pdfi-term > div { margin: 0; }
.sf-pdfi-term-err  { color: #ff7b72; }
.sf-pdfi-term-ok   { color: #56d364; font-weight: 600; }
.sf-pdfi-term-info { color: #8b949e; }
.sf-pdfi-term-dim  { color: #6e7681; }
