/* ── FRAIT Onboarding Document Editor ─────────────────────────────────────── */
/* Shared by ContractEdit, SupplementalDocEdit, ContractPreview, SupplementalDocPreview */

/* ── PDF drop zone ───────────────────────────────────────────────────────────── */
.adm-pdf-drop-zone {
  border: 2px dashed rgba(107,178,206,0.3);
  border-radius: 8px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
  user-select: none;
  position: relative;
}
.adm-pdf-drop-zone:hover,
.adm-pdf-drop-over {
  border-color: rgba(107,178,206,0.65);
  background: rgba(107,178,206,0.05);
}
.adm-pdf-drop-icon {
  font-size: 2.25rem;
  margin-bottom: .5rem;
  line-height: 1;
}

/* ── Editor card — overflow MUST be visible for position:sticky toolbar ─────── */
.adm-card-editor {
  padding: 0 !important;
  overflow: visible !important;
  background: #0d1c2a;
  border: 1px solid rgba(107,178,206,0.1);
  border-radius: 10px;
  margin-bottom: 1.25rem;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────────── */
.adm-doc-toolbar {
  background: #0d1827;
  border-bottom: 1px solid rgba(107,178,206,0.12);
  border-radius: 10px 10px 0 0;
  padding: .45rem .75rem;
  position: sticky;
  top: var(--onb-banner-h, 0px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  box-shadow: 0 2px 10px rgba(0,0,0,.45);
}

.adm-tb-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .18rem;
}

.adm-tb-sep {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,.12);
  margin: 0 .3rem;
  flex-shrink: 0;
}

.adm-tb-select {
  background: #1a2d3e;
  color: #e4e1f0;
  border: 1px solid rgba(107,178,206,0.18);
  border-radius: 4px;
  padding: .22rem .35rem;
  font-size: .8rem;
  cursor: pointer;
  height: 28px;
  outline: none;
}
.adm-tb-select:focus  { border-color: rgba(107,178,206,0.5); }
.adm-tb-select option { background: #0d1c2a; }
.adm-tb-font-sel { min-width: 130px; }
.adm-tb-size-sel { width: 54px; }

.adm-tb-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: rgba(255,255,255,0.6);
  padding: .18rem .45rem;
  font-size: .82rem;
  line-height: 1.3;
  cursor: pointer;
  height: 28px;
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  transition: background .1s, border-color .1s, color .1s;
  white-space: nowrap;
}
.adm-tb-btn:hover {
  background: rgba(107,178,206,0.1);
  border-color: rgba(107,178,206,0.2);
  color: #fff;
}
.adm-tb-btn:active  { background: rgba(107,178,206,0.18); }
.adm-tb-btn:disabled { opacity: .35; cursor: not-allowed; }

.adm-tb-active {
  background: rgba(107,178,206,0.18) !important;
  border-color: rgba(107,178,206,0.4) !important;
  color: #6BB2CE !important;
}

.adm-tb-bold      { font-weight: 700; min-width: 28px; justify-content: center; }
.adm-tb-italic    { font-style: italic; min-width: 28px; justify-content: center; }
.adm-tb-underline { text-decoration: underline; min-width: 28px; justify-content: center; }
.adm-tb-strike    { text-decoration: line-through; min-width: 28px; justify-content: center; }

.adm-tb-btn-initials {
  color: #e6b800;
  border-color: rgba(230,184,0,.2);
}
.adm-tb-btn-initials:hover { background: rgba(230,184,0,.1); color: #ffe033; }

.adm-tb-btn-pagebreak {
  color: rgba(245,158,11,0.85);
  border-color: rgba(245,158,11,.2);
}
.adm-tb-btn-pagebreak:hover { background: rgba(245,158,11,.1); color: #fbbf24; }

.adm-tb-btn-ph-date {
  background: rgba(255,200,50,.09);
  color: #b8960a;
  border-color: rgba(255,200,50,.25);
}
.adm-tb-btn-ph-date:hover   { background: rgba(255,200,50,.18); }
.adm-tb-btn-ph-name {
  background: rgba(107,178,206,.09);
  color: #6BB2CE;
  border-color: rgba(107,178,206,.25);
}
.adm-tb-btn-ph-name:hover   { background: rgba(107,178,206,.18); }

.adm-tb-btn-save {
  background: rgba(107,178,206,.12);
  color: #6BB2CE;
  border-color: rgba(107,178,206,.28);
  font-weight: 600;
}
.adm-tb-btn-save:hover    { background: rgba(107,178,206,.22); color: #9dd3e8; }
.adm-tb-btn-save:disabled { opacity: .45; cursor: not-allowed; }

.adm-tb-btn-preview {
  background: rgba(34,197,94,.09);
  color: rgba(34,197,94,.85);
  border-color: rgba(34,197,94,.2);
}
.adm-tb-btn-preview:hover    { background: rgba(34,197,94,.18); color: #22c55e; }
.adm-tb-btn-preview:disabled { opacity: .35; cursor: not-allowed; }

.adm-tb-btn-activate {
  background: rgba(34,197,94,.85);
  color: #06210f;
  border-color: rgba(34,197,94,.9);
  font-weight: 700;
}
.adm-tb-btn-activate:hover    { background: #22c55e; }
.adm-tb-btn-activate:disabled { opacity: .35; cursor: not-allowed; }

/* Color picker */
.adm-tb-colorpick {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: .1rem .4rem .3rem;
  border: 1px solid transparent;
  border-radius: 4px;
  user-select: none;
  height: 28px;
  gap: 1px;
}
.adm-tb-colorpick:hover       { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.14); }
.adm-tb-colorpick-lbl         { font-size: .8rem; color: #e4e1f0; pointer-events: none; line-height: 1; }
.adm-tb-colorpick-swatch      { width: 18px; height: 3px; border-radius: 1px; pointer-events: none; }
.adm-tb-colorpick input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
  padding: 0; border: none;
}

/* ── Document outer (dark surround) ─────────────────────────────────────────── */
.adm-doc-outer {
  background: #111a25;
  padding: 2rem 1.5rem 3rem;
  min-height: 500px;
  border-radius: 0 0 10px 10px;
  position: relative;
}

#docPageProcessingOverlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(17,26,37,0.88);
  z-index: 20;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: rgba(255,255,255,0.75);
  border-radius: 0 0 10px 10px;
}
#docPageProcessingOverlay .onb-spinner { width: 40px; height: 40px; margin-bottom: 1rem; }
#docPageProcessingOverlay .onb-progress-track { width: 260px; }

/* ── White paper page ─────────────────────────────────────────────────────────── */
.adm-doc-page {
  background: #ffffff;
  color: #111111;
  width: 800px;
  max-width: 100%;
  min-height: 900px;
  margin: 0 auto;
  padding: 40px 52px;
  font-family: Arial, sans-serif;
  font-size: 10.5pt;
  line-height: 1.5;
  box-shadow: 0 4px 40px rgba(0,0,0,.55);
  outline: none;
  border-radius: 2px;
  box-sizing: border-box;
}
.adm-doc-page:focus-visible {
  box-shadow: 0 4px 40px rgba(0,0,0,.55), 0 0 0 2px rgba(107,178,206,.35);
}
.adm-doc-page h1 { font-size: 15pt; font-weight: 700; margin: 1rem 0 .4rem; }
.adm-doc-page h2 { font-size: 13pt; font-weight: 700; margin: .9rem 0 .35rem; }
.adm-doc-page h3 { font-size: 11pt; font-weight: 600; margin: .75rem 0 .3rem; }
/* A heading that opens a fresh page (immediately follows a page-break marker) reads
   as that page's title, so it's centered — same treatment as page 1's own title.
   Ordinary body headings mid-page (e.g. "A. Product Loading:") are untouched. */
.adm-doc-page .ob-page-break + h1,
.adm-doc-page .ob-page-break + h2,
.adm-doc-page .ob-page-break + h3 { text-align: center; }
.adm-doc-page p  { margin-bottom: .55rem; }
.adm-doc-page ul,
.adm-doc-page ol { padding-left: 1.75rem; margin-bottom: .8rem; }
.adm-doc-page blockquote {
  border-left: 3px solid #ccc;
  margin-left: 0;
  padding-left: 1rem;
  color: #444;
  font-style: italic;
}

/* Logo header inside page */
[data-logo-header] {
  text-align: center;
  padding-bottom: 1.5em;
  margin-bottom: 2em;
  border-bottom: 2px solid #e5e7eb;
}
[data-logo-header] img {
  max-height: 90px;
  max-width: 280px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}
[data-logo-header] h1,
[data-logo-header] h2,
[data-logo-header] h3 {
  text-align: center;
  margin-top: .65rem;
  margin-bottom: 0;
  font-size: 13pt;
  font-weight: 700;
  color: #111;
}

/* ── Document markers ─────────────────────────────────────────────────────────── */
.adm-doc-marker {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 6px;
  padding: .55rem 2.8rem .55rem 1rem;
  margin: .9rem 0;
  user-select: none;
}

.adm-doc-page [data-marker="initials"] {
  float: none;
  clear: both;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100px;
  min-height: 62px;
  padding: 0.4rem 0.6rem;
  margin: 1rem 0 1rem auto;
  background: #fffbea;
  border: 2px dashed #d4a000;
  border-radius: 6px;
  color: #6b4400;
  font-size: 7.5pt;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  gap: 0.3rem;
  position: relative;
}
.adm-doc-page [data-marker="initials"] span {
  display: block;
  width: 100%;
  border-bottom: 1px solid #d4a000;
  padding-bottom: 0.5rem;
  margin-bottom: 0.2rem;
}
.ob-initial-right { justify-content: center; padding-right: 0; text-align: center; }

/* Page break — extends to page edges */
.ob-page-break {
  position: relative;
  display: block;
  margin: 1.8em -52px;
  padding: 1.2em 52px .5em;
  background: linear-gradient(to bottom, #d8d8d8 0%, #ececec 30%, #f8f8f8 60%, #fff 100%);
  border-top: 1px solid #bbb;
  box-shadow: 0 -6px 18px -6px rgba(0,0,0,.18), inset 0 4px 10px rgba(0,0,0,.06);
  color: #999;
  font-size: 8pt;
  text-align: center;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.ob-pb-label { display: inline; }

/* Marker remove button */
.adm-marker-remove {
  position: absolute;
  top: 50%;
  right: .55rem;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  background: rgba(0,0,0,.07);
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 50%;
  font-size: 13px;
  cursor: pointer;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background .12s, color .12s;
}
.adm-marker-remove:hover { background: rgba(210,40,40,.12); color: #c00; border-color: rgba(210,40,40,.3); }

/* ── Placeholder spans ────────────────────────────────────────────────────────── */
.ob-ph {
  display: inline;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: .87em;
  font-weight: 600;
  white-space: nowrap;
  cursor: default;
  user-select: none;
}
.ob-ph-date   { background: #fff3cd; color: #664d03; border: 1px solid #ffd666; }
.ob-ph-name   { background: #d2f5f7; color: #055160; border: 1px solid #7ed8de; }
.ob-ph-masked { background: #fde8e8; color: #842029; border: 1px solid #f5c2c7; font-family: monospace; }

/* ── Signature block preview (admin dark-mode card) ─────────────────────────── */
.adm-sig-preview {
  background: #fff;
  border: 1px solid rgba(107,178,206,0.15);
  border-radius: 8px;
  padding: 1.5rem 2rem;
  font-family: Arial, sans-serif;
  font-size: 10.5pt;
  color: #111;
  line-height: 1.5;
}
.ob-sf { margin: .35rem 0; font-size: 10.5pt; }

/* ── Spinner ─────────────────────────────────────────────────────────────────── */
@keyframes onb-spin { to { transform: rotate(360deg); } }
.onb-spinner {
  width: 32px; height: 32px;
  border: 3px solid rgba(107,178,206,0.2);
  border-top-color: #6BB2CE;
  border-radius: 50%;
  animation: onb-spin 0.8s linear infinite;
  margin: 0 auto .75rem;
}

/* ── Processing / error / success banners ────────────────────────────────────── */
#pdfError   { background: rgba(239,68,68,0.1); color: #ef4444; border: 1px solid rgba(239,68,68,0.2); border-radius: 6px; padding: .6rem .9rem; font-size: .82rem; margin-top: .75rem; display: none; }
#pdfSuccess { background: rgba(34,197,94,0.1);  color: #22c55e; border: 1px solid rgba(34,197,94,0.2);  border-radius: 6px; padding: .6rem .9rem; font-size: .82rem; margin-top: .75rem; display: none; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
#pdfProcessing { text-align: center; padding: 2rem 0; display: none; color: rgba(255,255,255,0.6); }
.onb-progress-track {
  width: 220px;
  height: 5px;
  margin: 0.85rem auto 0;
  border-radius: 3px;
  background: rgba(107,178,206,0.15);
  overflow: hidden;
}
@keyframes onb-progress-sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}
.onb-progress-track::after {
  content: '';
  display: block;
  width: 30%;
  height: 100%;
  background: #6BB2CE;
  border-radius: 3px;
  animation: onb-progress-sweep 1.6s ease-in-out infinite;
}
#pdfProcessingMsg { transition: opacity 0.25s ease; }
#pdfProcessingMsg.onb-fade { opacity: 0; }

/* ── Preview page (standalone) ───────────────────────────────────────────────── */
.onb-preview-wrap { max-width: 900px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.onb-preview-bar  {
  background: rgba(13,28,42,0.97);
  border: 1px solid rgba(107,178,206,0.15);
  border-radius: 8px;
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .82rem;
  color: #e8edf2;
  margin-bottom: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.onb-preview-bar a { color: #6BB2CE; text-decoration: none; }
.onb-preview-bar a:hover { text-decoration: underline; }

/* Preview doc page — brighter, for reading */
.onb-doc-preview {
  background: #fff;
  color: #111;
  width: 800px;
  max-width: 100%;
  margin: 0 auto;
  padding: 40px 52px;
  font-family: Arial, sans-serif;
  font-size: 11pt;
  line-height: 1.65;
  border-radius: 4px;
  box-shadow: 0 2px 24px rgba(0,0,0,.18);
}
.onb-doc-preview h1 { font-size: 15pt; font-weight: 700; margin-bottom: .4rem; }
.onb-doc-preview h2 { font-size: 13pt; font-weight: 700; margin: 1.25rem 0 .4rem; }
.onb-doc-preview h3 { font-size: 11pt; font-weight: 600; margin: .9rem 0 .3rem; }
.onb-doc-preview p  { margin-bottom: .55rem; }

/* In preview: hide editor-UI elements; render page breaks as visual separators */
.onb-doc-preview .adm-marker-remove { display: none !important; }
.onb-doc-preview .ob-page-break { background: none; border-top: 1px dashed #ccc; border-bottom: none; box-shadow: none; color: #bbb; margin: 2em -52px; padding: .6em 52px; }
.onb-doc-preview [data-marker="initials"] { background: rgba(59,130,246,.06); border: 1px dashed rgba(59,130,246,.4); color: #1d4ed8; font-size: .85rem; }

@media print {
  .onb-preview-bar { display: none !important; }
  body { background: #fff !important; }
  .onb-preview-wrap { max-width: 100%; padding: 0; margin: 0; }
  .onb-doc-preview { box-shadow: none; padding: 1.5cm 2cm; width: 100%; }
}

/* ── Paginated contract preview ──────────────────────────────────────────────── */
.pvw-pages-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
  padding: 1.5rem 1rem 5rem;
  background: #1a2535;
  min-height: 100vh;
}
.pvw-page {
  /* Matches ContractHtmlBuilder.PageContentWidthPx/PageContentHeightPx and PdfBodyCss
     exactly (0.75in left/right, 0.4in top, 0.9in bottom margins, 13px body font, 1.5
     line-height) — this page previously used its own independent geometry (1in
     margins, 11pt font), so the same heading could wrap here but not in the editor
     or the real signed PDF. */
  background: #fff;
  color: #1a1a1a;
  width: 8.5in;
  max-width: calc(100vw - 2rem);
  min-height: 11in;
  padding: 0.4in 0.75in 0.9in;
  box-sizing: border-box;
  box-shadow: 0 6px 32px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  font-family: Arial, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  position: relative;
}
.pvw-logo-hdr {
  text-align: center;
  padding-bottom: 1.5em;
  margin-bottom: 2em;
  border-bottom: 2px solid #e5e7eb;
  flex-shrink: 0;
}
.pvw-logo-hdr img {
  max-height: 90px;
  max-width: 280px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}
.pvw-page-body          { flex: 1; }
.pvw-page-body h1       { font-size: 15pt; font-weight: 700; margin-bottom: .4rem; }
.pvw-page-body h2       { font-size: 13pt; font-weight: 700; margin: 1.25rem 0 .4rem; }
.pvw-page-body h3       { font-size: 11pt; font-weight: 600; margin: .9rem 0 .3rem; }
.pvw-page-body p        { margin-bottom: .55rem; }
.pvw-page-body ul,
.pvw-page-body ol       { padding-left: 1.75rem; margin-bottom: .8rem; }
.pvw-page-body strong   { font-weight: 700; }
/* The heading that opens a page (first child of the page body) reads as that page's
   title — centered, same treatment as the editor and the real signed PDF. Anything
   further down the page (mid-page section headers) stays left-aligned. */
.pvw-page-body > h1:first-child,
.pvw-page-body > h2:first-child,
.pvw-page-body > h3:first-child { text-align: center; }
.pvw-page-footer {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  color: #aaa;
  padding-top: 0.75rem;
  flex-shrink: 0;
}
.pvw-initials {
  display: flex;
  justify-content: flex-end;
  padding-top: 1.5rem;
  margin-top: auto;
  flex-shrink: 0;
}
.pvw-initials-box       { border: 1.5px solid #999; border-radius: 3px; padding: 0.5rem 2rem; min-width: 140px; text-align: center; }
.pvw-initials-line      { height: 42px; }
.pvw-initials-label     { font-size: 8pt; color: #666; border-top: 1px solid #ccc; padding-top: 0.25rem; margin-top: 0.25rem; text-transform: uppercase; letter-spacing: 0.06em; }
@media print {
  .pvw-pages-wrap        { gap: 0; padding: 0; background: white; }
  .pvw-page              { box-shadow: none; width: 100%; min-height: 100vh; page-break-after: always; break-after: page; }
  .pvw-page:last-child   { page-break-after: auto; break-after: auto; }
}

/* ── Paragraph-hover initials ghost button ───────────────────────────────────── */
.ob-para-ghost {
  position: fixed;
  z-index: 300;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px dashed rgba(212,160,0,0.5);
  background: rgba(255,251,234,0.1);
  color: rgba(212,160,0,0.65);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: background .15s, border-color .15s, color .15s, border-style .1s;
  box-shadow: 0 1px 5px rgba(0,0,0,.3);
}
.ob-para-ghost:hover {
  background: rgba(212,160,0,0.22);
  border-color: #d4a000;
  border-style: solid;
  color: #d4a000;
}
.ob-para-ghost--marked {
  border-style: solid;
  border-color: #d4a000;
  background: rgba(212,160,0,0.16);
  color: #d4a000;
}
.ob-para-ghost--marked:hover {
  background: rgba(239,68,68,0.18);
  border-color: rgba(239,68,68,0.75);
  color: rgba(239,68,68,0.95);
}
@media print { .ob-para-ghost { display: none !important; } }
