/* ══ PDF SPLIT-SCREEN STYLES ══════════════════════════════════════ */

/*
 * Split view works by adding classes to .proj-body and .left-panel.
 * No floating overlay — the real pub-detail stays in place and is
 * fully interactive. The PDF pane is injected as a sibling inside
 * .proj-body.
 */

/* ── Hide left panel when split is active ────────────────────────── */
.proj-body .left-panel.psv-hidden {
  display: none !important;
}

/* ── Proj-body split layout ─────────────────────────────────────── */
/*
 * Normal layout is: grid-template-columns: 1fr 295px
 * Split mode: right-panel (pub detail) | 5px divider | pdf pane
 * We switch to flex so the resizer can work freely.
 */
.proj-body.psv-split-mode {
  display: flex !important;
  flex-direction: row;
  align-items: stretch;
  gap: 0px;
  overflow: visible;
  /* fill from topbar to bottom of viewport */
  height: calc(100vh - 80px);
  max-height: calc(100vh - 80px);
}

/* Right-panel (pub detail) stretches to fill its flex share.
   The base stylesheet sets `.right-panel { order: 1; }` for the normal
   (non-split) grid layout — that rule still applies here, which would
   otherwise push the pub-detail panel after the injected divider/PDF
   pane (order defaults to 0, so it would render FIRST/left of the
   pub-detail panel). Pin explicit order values on all three split-mode
   children so the pub detail always stays on the left and the PDF
   pane always opens on the right. */
.proj-body.psv-split-mode #rightPanel {
  order: 1;
  flex: 0 0 50%;
  width: 50%;
  min-width: 320px;
  height: 100%;
  overflow-y: auto;
  border-radius: var(--r-card);
}

/* Scrollbar inside pub detail when in split mode */
.proj-body.psv-split-mode #rightPanel::-webkit-scrollbar { width: 4px; }
.proj-body.psv-split-mode #rightPanel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Draggable resize handle ─────────────────────────────────────── */
.psv-divider {
  order: 2;
  flex: 0 0 5px;
  width: 5px;
  height: 100%;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.14s;
  z-index: 10;
}

.psv-divider-handle {
  width: 3px;
  height: 36px;
  border-radius: 3px;
  background: var(--border-hover, rgba(43,24,23,0.18));
  transition: background 0.14s;
}
.psv-divider:hover .psv-divider-handle,
.psv-divider.dragging .psv-divider-handle {
  background: var(--teal, #0da79a);
}

/* ── PDF pane ────────────────────────────────────────────────────── */
.psv-pdf-pane {
  order: 3;
  flex: 1;
  min-width: 300px;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border, rgba(43,24,23,0.10));
  border-radius: var(--r-card);
  margin-left: 0;
  box-shadow: var(--shadow-card);
}

.psv-pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: 40px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-radius: var(--r-card) var(--r-card) 0 0;
}
.psv-pdf-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
  flex-shrink: 0;
}
.psv-pdf-tab-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  overflow: hidden;
}
.psv-pdf-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.psv-pdf-tab:hover {background: var(--bg-page); color: var(--ink-muted);}
.psv-pdf-tab.active {background: var(--bg-page); color: var(--ink-muted);}
.psv-pdf-tab i { font-size: 0.78rem; flex-shrink: 0; }

.psv-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}
.psv-open-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-page);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.71rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.14s;
  white-space: nowrap;
}
.psv-open-btn:hover { border-color: var(--border-teal); color: var(--teal); background: var(--teal-soft); }
.psv-open-btn i { font-size: 0.8rem; }

.psv-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-page);
  color: var(--ink-muted);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.14s;
}
.psv-close-btn:hover {
  background: var(--red-soft);
  border-color: rgba(220,38,38,0.25);
  color: var(--red);
}

.psv-pdf-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  min-height: 0; /* critical — allows flex child to shrink below content size */
}
.psv-no-pdf {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink-muted);
  font-size: 0.78rem;
}
.psv-no-pdf i { font-size: 2.5rem; opacity: 0.25; }

.psv-pdf-frame {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: #525659;
}

/* ── Button highlight when split is active ───────────────────────── */
#pdfSplitBtn.split-active {
  background: var(--teal-soft);
  border-color: var(--teal);
  color: var(--teal);
}

/* ── Responsive: disable split on narrow screens ─────────────────── */
@media (max-width: 900px) {
  #pdfSplitBtn { display: none !important; }
  .proj-body.psv-split-mode { flex-direction: column; }
  .proj-body.psv-split-mode #rightPanel { flex: 0 0 45%; width: 100%; min-width: unset; }
  .psv-divider { display: none; }
}