/* Azariah PDF Editor */
:root {
  --navy: #1B2A4A;
  --navy-2: #122038;
  --slate: #4A6080;
  --gold: #C2A14E;
  --cream: #F4EFE1;
  --bg: #E6E9EF;
  --panel: #FFFFFF;
  --line: #D8DDE6;
  --text: #1B2A4A;
  --muted: #5B6578;
  --accent: #2F6FED;
  --danger: #C62828;
  --topbar-h: 52px;
  --toolbar-h: 56px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Calibri', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  font-size: 14px;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ── Top bar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--navy);
  color: #fff;
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  white-space: nowrap;
}
.brand { color: #fff; text-decoration: none; font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.brand span { color: var(--gold); }
.filename { max-width: 260px; overflow: hidden; text-overflow: ellipsis; color: rgba(255,255,255,.75); font-size: 13px; }
.tb-group { display: flex; align-items: center; gap: 2px; padding-left: 8px; border-left: 1px solid rgba(255,255,255,.15); }
.spacer { flex: 1; }
.tb {
  background: transparent; border: 1px solid transparent; color: inherit;
  border-radius: 6px; padding: 6px 10px; display: inline-flex; align-items: center; gap: 6px;
  line-height: 1;
}
.topbar .tb:hover:not(:disabled) { background: rgba(255,255,255,.12); }
.tb.icon { padding: 6px 8px; }
.tb.primary { background: var(--gold); color: var(--navy); font-weight: 600; }
.tb.primary:hover:not(:disabled) { background: #d4b462 !important; }
.tb.big { padding: 10px 18px; font-size: 15px; }
.zoomval { min-width: 58px; justify-content: center; font-variant-numeric: tabular-nums; }
.findbox { gap: 4px; }
.findbox input {
  width: 170px; border-radius: 6px; border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.08); color: #fff; padding: 5px 8px; outline: none;
}
.findbox input::placeholder { color: rgba(255,255,255,.55); }
.findbox input:focus { border-color: var(--gold); background: rgba(255,255,255,.14); }
#findCount { font-size: 12px; color: rgba(255,255,255,.7); min-width: 38px; }
.privacy { font-size: 12px; color: #A5D6A7; display: flex; gap: 4px; align-items: center; }

/* ── Tool bar ── */
.toolbar {
  height: var(--toolbar-h);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 2px;
  padding: 0 10px; overflow-x: auto;
}
.tool {
  background: none; border: 1px solid transparent; border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-width: 58px; height: 46px; padding: 2px 6px; color: var(--navy);
}
.tool i { font-size: 18px; }
.tool span { font-size: 11px; color: var(--muted); }
.tool:hover { background: #F1F3F7; }
.tool.active { background: var(--cream); border-color: var(--gold); }
.tool.active span { color: var(--navy); font-weight: 600; }
.toolbar .sep { width: 1px; height: 32px; background: var(--line); margin: 0 4px; flex: none; }

/* ── Layout ── */
.workspace { display: flex; height: calc(100% - var(--topbar-h) - var(--toolbar-h)); }
.sidebar, .props { background: var(--panel); display: flex; flex-direction: column; flex: none; }
.sidebar { width: 190px; border-right: 1px solid var(--line); }
.props { width: 250px; border-left: 1px solid var(--line); }
.sidebar.hidden { display: none; }
.side-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.side-head .mini { margin-left: auto; }
.mini {
  background: none; border: 1px solid transparent; border-radius: 6px;
  padding: 4px 6px; color: var(--navy); line-height: 1;
}
.mini:hover:not(:disabled) { background: #EEF1F6; border-color: var(--line); }
.mini.danger { color: var(--danger); }
.page-actions { display: flex; justify-content: space-between; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.sel-hint { padding: 6px 10px 0; line-height: 1.3; }
.side-reopen { position: fixed; left: 8px; bottom: 12px; z-index: 20; display: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.sidebar.hidden ~ .side-reopen, body.side-hidden .side-reopen { display: block; }

/* ── Thumbnails ── */
.thumbs { flex: 1; overflow-y: auto; padding: 10px 10px 40px; }
.thumb {
  position: relative; margin: 0 auto 14px; width: 130px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.thumb .tcan {
  background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.18); border: 2px solid transparent;
  border-radius: 3px; overflow: hidden; display: flex;
}
.thumb .tcan canvas { display: block; width: 100%; height: 100%; }
.thumb.current .tcan { border-color: var(--slate); }
.thumb.selected .tcan { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,111,237,.25); }
.thumb .tnum { font-size: 12px; color: var(--muted); }
.thumb.selected .tnum { color: var(--accent); font-weight: 600; }
.thumb .tbtns { position: absolute; top: 4px; right: 4px; display: none; gap: 2px; }
.thumb:hover .tbtns { display: flex; }
.thumb .tbtns button { background: rgba(27,42,74,.85); color: #fff; border: none; border-radius: 4px; padding: 3px 5px; font-size: 11px; line-height: 1; }
.thumb .tbtns button:hover { background: var(--navy-2); }
.thumb.drop-before::before, .thumb.drop-after::after {
  content: ''; position: absolute; left: -6px; right: -6px; height: 3px; background: var(--accent); border-radius: 2px;
}
.thumb.drop-before::before { top: -9px; }
.thumb.drop-after::after { bottom: -9px; }
.thumb.dragging { opacity: .4; }

/* ── Viewer ── */
.viewer { flex: 1; overflow: auto; position: relative; }
.pages { padding: 24px 24px 80px; display: flex; flex-direction: column; align-items: center; gap: 18px; min-width: max-content; }
.page {
  position: relative; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.18); flex: none;
}
.page > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.page .forms, .page .overlay { position: absolute; inset: 0; }
.page .overlay { z-index: 2; }
.page .forms { z-index: 3; pointer-events: none; }
body.tool-select .page .forms { pointer-events: auto; }
.page .forms > * { pointer-events: auto; }
body:not(.tool-select) .page .forms > * { pointer-events: none; }
.page .plabel { position: absolute; bottom: -17px; right: 0; font-size: 11px; color: var(--muted); }
body:not(.tool-select) .page .overlay { cursor: crosshair; }
body.tool-edittext .page .overlay { cursor: text; }
body.tool-place .page .overlay { cursor: copy; }

.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; padding: 24px; overflow-y: auto; }
.empty > .drop-card { margin: auto 0; flex: none; }
.drop-card h1 small { display: block; font-size: 14px; font-weight: 400; color: var(--muted); margin-top: 4px; }
.empty.hidden { display: none; }
.drop-card {
  background: var(--panel); border: 2px dashed #B9C2D3; border-radius: 16px;
  padding: 36px 44px; text-align: center; max-width: 560px;
}
.drop-card > i { font-size: 52px; color: var(--gold); }
.drop-card h1 { font-size: 22px; margin: 10px 0 4px; }
.feature-list { list-style: none; padding: 0; margin: 22px 0 10px; text-align: left; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; font-size: 13px; }
.feature-list i { color: var(--slate); margin-right: 6px; }

/* ── Public (lead-magnet) mode ── */
.tb.cta { color: #fff; text-decoration: none; border: 1px solid rgba(194,161,78,.7); font-size: 13px; }
.tb.cta strong { color: var(--gold); }
.tb.cta:hover { background: rgba(194,161,78,.18); }
.seo { max-width: 860px; width: 100%; margin: 40px 0 24px; flex: none; color: var(--text); line-height: 1.55; }
.seo h2 { font-size: 19px; margin: 28px 0 12px; }
.seo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.seo-grid > div { background: var(--panel); border-radius: 10px; padding: 14px 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.seo-grid h3 { font-size: 14.5px; margin: 0 0 6px; }
.seo-grid h3 i { color: var(--gold); margin-right: 4px; }
.seo-grid p { margin: 0; font-size: 13.5px; color: var(--muted); }
.seo details { background: var(--panel); border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; }
.seo summary { cursor: pointer; font-weight: 600; }
.seo details p { margin: 8px 0 2px; color: var(--muted); }
.seo-cta { margin-top: 22px; padding: 14px 16px; background: var(--cream); border-left: 4px solid var(--gold); border-radius: 6px; }
.seo-cta a { color: var(--navy); font-weight: 600; }
.cta-dlg h2 i { color: #2E7D32; }
.dl-app { color: var(--navy); font-weight: 600; }
.pro-tag { display: inline-block; font-size: 8.5px; font-weight: 700; letter-spacing: .06em; line-height: 1; padding: 2px 4px; border-radius: 3px; background: var(--gold); color: var(--navy); vertical-align: middle; }
.pro-tag.big { font-size: 12px; padding: 3px 6px; }
.tool { position: relative; }
.tool .pro-tag { position: absolute; top: 2px; right: 2px; }
.topbar .tb .pro-tag { margin-left: 2px; }
.cta-dlg ul { list-style: none; padding: 0; }
.cta-dlg li { margin: 8px 0; }
.cta-dlg li i { color: var(--gold); margin-right: 8px; }
.cta-dlg a.tb { text-decoration: none; color: var(--navy); }
@media (max-width: 760px) { .seo-grid { grid-template-columns: 1fr; } }

/* ── Form fields ── */
.ff {
  position: absolute; border: none; margin: 0; padding: 0 2px;
  background: rgba(47,111,237,.10); outline: 1px solid rgba(47,111,237,.35);
  font-family: Helvetica, Arial, 'Liberation Sans', sans-serif; color: #000;
}
.ff:focus { background: rgba(47,111,237,.16); outline: 2px solid var(--accent); }
textarea.ff { resize: none; line-height: 1.15; }
.ff.comb { font-family: 'Courier New', Courier, 'Liberation Mono', monospace; padding-right: 0; }
input.ff[type=checkbox], input.ff[type=radio] { accent-color: #111; outline-offset: -1px; cursor: pointer; }
.ff:disabled { background: transparent; outline-color: rgba(0,0,0,.08); }

/* ── Annotations ── */
.annot { position: absolute; }
.annot.sel { outline: 1.5px dashed var(--accent); outline-offset: 2px; }
.annot.box { pointer-events: auto; }
.annot.svgish { pointer-events: none; }
.annot.svgish svg { width: 100%; height: 100%; overflow: visible; display: block; pointer-events: none; }
.annot.svgish .hit { pointer-events: stroke; stroke: transparent; fill: none; cursor: move; }
body.tool-select .annot.box, body.tool-select .annot.text, body.tool-select .annot.image { cursor: move; }
body:not(.tool-select) .annot { pointer-events: none !important; }
body:not(.tool-select) .annot .hit { pointer-events: none !important; }
.annot.text .tx {
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.2; outline: none; min-height: 1em;
}
.annot.text .tx[contenteditable=true], .annot.text .tx[contenteditable=plaintext-only] { cursor: text; }
.annot.text.editing { outline: 1.5px solid var(--accent); outline-offset: 2px; }
.annot.text .tx:empty::before { content: 'Type here'; color: #9AA3B2; }
.annot.image img { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.annot.redact { background: #000; }
.annot.redact::after { content: 'REDACT'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.55); font-size: 10px; letter-spacing: .1em; overflow: hidden; }
.annot.whiteout { background: #fff; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.handle {
  position: absolute; width: 10px; height: 10px; background: #fff; border: 1.5px solid var(--accent);
  border-radius: 2px; pointer-events: auto !important; z-index: 5;
}
.handle.se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.handle.e { right: -7px; top: calc(50% - 5px); cursor: ew-resize; }
.handle.pt { border-radius: 50%; cursor: move; transform: translate(-50%, -50%); }
.preview { position: absolute; pointer-events: none; border: 1.5px dashed var(--accent); background: rgba(47,111,237,.06); }
.textsel-box { position: absolute; pointer-events: none; border: 1.5px dashed var(--gold); background: rgba(194,161,78,.06); }
/* The box being edited must take clicks even while a drawing tool (e.g. Edit text) is active. */
body .page .annot.editing, body .page .annot.editing .tx { pointer-events: auto !important; }
.hover-text { position: absolute; pointer-events: none; outline: 1.5px solid var(--gold); background: rgba(194,161,78,.15); }
.find-hit { position: absolute; pointer-events: none; background: rgba(255,152,0,.35); }
.find-hit.current { background: rgba(255,87,34,.55); outline: 1px solid #E64A19; }

/* ── Properties ── */
.props-body { flex: 1; overflow-y: auto; padding: 12px; }
.props-foot { padding: 10px 12px; border-top: 1px solid var(--line); }
.prop { margin-bottom: 12px; }
.prop > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.prop input[type=number], .prop select, .prop input[type=text] {
  width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
.prop input[type=range] { width: 100%; }
.prop .row { display: flex; gap: 6px; align-items: center; }
.swatches { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); padding: 0; }
.swatch.on { box-shadow: 0 0 0 2px var(--accent); }
.swatch.none { background: linear-gradient(135deg, #fff 45%, #e53935 45%, #e53935 55%, #fff 55%); }
.swatches input[type=color] { width: 26px; height: 26px; border: none; padding: 0; background: none; }
.toggle { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 5px 10px; }
.toggle.on { background: var(--cream); border-color: var(--gold); font-weight: 600; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.btn-row .tb { border: 1px solid var(--line); background: #fff; font-size: 13px; padding: 6px 9px; }
.btn-row .tb:hover { background: #F1F3F7; }
.btn-row .tb.danger { color: var(--danger); }
.props-tip { background: var(--cream); border-left: 3px solid var(--gold); padding: 8px 10px; border-radius: 4px; font-size: 12.5px; line-height: 1.4; margin-bottom: 12px; }

/* ── Dialogs ── */
.dlg { border: none; border-radius: 12px; padding: 0; box-shadow: 0 20px 60px rgba(0,0,0,.3); max-width: 94vw; color: var(--text); }
.dlg::backdrop { background: rgba(18,32,56,.45); }
.dlg-inner { padding: 18px 20px; width: 560px; max-width: 100%; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dlg-head h2 { font-size: 18px; margin: 0; }
.dlg h3 { font-size: 14px; margin: 16px 0 6px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dlg-foot .tb { border: 1px solid var(--line); }
.dlg .field { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.dlg .field input, .dlg .field select { display: block; width: 100%; margin-top: 3px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; color: var(--text); }
.dlg .field input[type=color] { height: 32px; padding: 2px; }
.dlg fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 10px 0; padding: 8px 12px; }
.dlg legend { font-size: 13px; font-weight: 600; padding: 0 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 6px 0; }
.chk.radio input[type=text] { flex: 1; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; }
.chk.radio input[type=number] { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.tab { background: none; border: none; border-bottom: 2px solid transparent; padding: 8px 14px; color: var(--muted); }
.tab.active { border-bottom-color: var(--gold); color: var(--navy); font-weight: 600; }
#sigCanvas { width: 100%; height: 170px; border: 1px dashed #B9C2D3; border-radius: 8px; touch-action: none; cursor: crosshair; background: #FBFBFD; display: block; }
.tabpane .row { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; font-size: 13px; }
.tabpane .row .tb { border: 1px solid var(--line); }
#sigText { width: 100%; padding: 8px 10px; font-size: 16px; border: 1px solid var(--line); border-radius: 6px; }
.font-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.font-choice { border: 1px solid var(--line); background: #fff; border-radius: 8px; height: 64px; font-size: 30px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 10px; }
.font-choice.on { border-color: var(--gold); background: var(--cream); }
.sig-preview { margin-top: 10px; min-height: 80px; border: 1px dashed var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; background: repeating-conic-gradient(#f3f3f3 0 25%, #fff 0 50%) 0 / 16px 16px; }
.sig-preview img { max-width: 100%; max-height: 140px; }
.saved-sigs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.saved-sigs:empty { display: none; }
.saved-sig { position: relative; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 6px; height: 58px; width: 150px; display: flex; align-items: center; justify-content: center; }
.saved-sig:hover { border-color: var(--gold); }
.saved-sig img { max-width: 100%; max-height: 100%; }
.saved-sig .del { position: absolute; top: -7px; right: -7px; background: #fff; border: 1px solid var(--line); border-radius: 50%; width: 20px; height: 20px; font-size: 10px; display: none; padding: 0; }
.saved-sig:hover .del { display: block; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; font-size: 13px; }
kbd { background: #EEF1F6; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; font-size: 11px; font-family: inherit; }
.dlg ul { padding-left: 18px; line-height: 1.5; }

/* ── Overlays ── */
.dropzone { position: fixed; inset: 0; z-index: 50; background: rgba(27,42,74,.6); display: none; align-items: center; justify-content: center; pointer-events: none; }
.dropzone.on { display: flex; }
.dropzone div { background: #fff; border-radius: 16px; padding: 28px 40px; font-size: 18px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.dropzone i { font-size: 40px; color: var(--gold); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; transition: .2s; z-index: 60; pointer-events: none; max-width: 90vw; }
.toast.on { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--danger); }
.busy { position: fixed; inset: 0; z-index: 70; background: rgba(255,255,255,.65); display: none; align-items: center; justify-content: center; flex-direction: column; gap: 12px; font-weight: 600; }
.busy.on { display: flex; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--gold); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Small screens ── */
@media (max-width: 1480px) { .privacy { display: none; } }
@media (max-width: 1400px) { .cta-lead { display: none; } .findbox input { width: 130px; } }
@media (max-width: 1279px) {
  .tb span:not(.cta-lead), .privacy { display: none; }
  .tb.cta strong { white-space: nowrap; }
  .tool span { display: none; }
  .tool { min-width: 40px; }
  .findbox input { width: 110px; }
}
@media (max-width: 860px) {
  .props { position: fixed; right: 0; bottom: 0; top: auto; width: 100%; max-height: 40vh; z-index: 15; border-left: none; border-top: 1px solid var(--line); box-shadow: 0 -4px 14px rgba(0,0,0,.1); }
  .props.empty-props { display: none; }
  .sidebar { position: fixed; left: 0; top: calc(var(--topbar-h) + var(--toolbar-h)); bottom: 0; z-index: 16; box-shadow: 4px 0 14px rgba(0,0,0,.12); }
  .filename, .findbox, .tb-group:has(#btnZoomOut) { display: none; }
}
@media print { body { display: none; } }
@media (max-width: 760px) { .tb.cta { display: none; } }
@media (max-width: 1440px) { .filename { max-width: 130px; } }
@media (max-width: 1040px) { .filename, .tb.cta { display: none; } .findbox input { width: 100px; } }
@media (max-width: 960px) { .findbox { display: none; } }

/* ── Phones & tablets ── */
@media (max-width: 860px) {
  .topbar { overflow-x: auto; gap: 6px; }
  .topbar > * { order: 2; flex: none; }
  .topbar .brand { order: 0; }
  .topbar #btnSave { order: 1; }
  .topbar .spacer { display: none; }
  .props { max-height: 32vh; }
  .side-reopen { bottom: calc(32vh + 12px); }
  body.tool-select .side-reopen { bottom: 12px; }
  .pages { padding: 12px 8px 60px; }
  .empty { padding: 12px; }
  .drop-card { padding: 24px 18px; }
  .feature-list { grid-template-columns: 1fr; }
}
