/* BillMint PDF editor — page styles. Design tokens come from app.css. */

.editor-main { padding: 34px 20px 60px; }

/* ---------- upload stage ---------- */
.upload-hero { max-width: 720px; margin: 0 auto; text-align: center; padding-top: 22px; }
.upload-hero h1 { font-size: clamp(1.7rem, 4.5vw, 2.6rem); }
.upload-hero .sub { font-size: 1.05rem; max-width: 560px; margin: 0 auto 26px; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 52px 24px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
  user-select: none;
}
.drop-zone:hover, .drop-zone:focus-visible { border-color: var(--brand); }
.drop-zone.dragover { border-color: var(--brand); background: var(--bg-elev2); transform: scale(1.01); }
.drop-zone.loading { pointer-events: none; opacity: .7; }
.drop-zone .dz-icon { font-size: 2.4rem; margin-bottom: 10px; }
.drop-zone .dz-title { font-weight: 700; font-size: 1.08rem; color: var(--text); margin-bottom: 6px; }
.drop-zone .dz-sub { color: var(--text-mut); font-size: .9rem; margin: 0; }

.load-error {
  margin-top: 16px; padding: 12px 16px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--danger); font-weight: 600; font-size: .93rem;
}

.privacy-chips { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 22px; }

.how-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 860px; margin: 40px auto 0; }
.how-cards .card { padding: 18px; text-align: left; }
.how-cards .step { font-size: .78rem; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: .06em; }
.how-cards h3 { font-size: 1rem; margin: 6px 0 4px; }
.how-cards p { font-size: .88rem; margin: 0; color: var(--text-mut); }
@media (max-width: 700px) { .how-cards { grid-template-columns: 1fr; } }

/* ---------- editor toolbar ---------- */
.editor-bar {
  position: sticky; top: 62px; z-index: 40;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 12px;
}
.file-meta { display: flex; flex-direction: column; min-width: 0; max-width: 180px; }
.file-meta .fname { font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta .fpages { font-size: .76rem; color: var(--text-mut); }

.tool-group { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.tool-group::-webkit-scrollbar { display: none; }
.tool-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit; font-size: .87rem; font-weight: 600;
  background: var(--bg-elev2); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 13px; cursor: pointer; white-space: nowrap;
  transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.tool-btn .ti { font-size: 1rem; line-height: 1; }
.tool-btn:hover { color: var(--text); border-color: var(--brand); }
.tool-btn[aria-pressed="true"] {
  background: color-mix(in srgb, var(--brand) 18%, transparent);
  border-color: var(--brand); color: var(--text);
}
.tool-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 2px; }

.bar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.bar-actions .btn { padding: 9px 16px; font-size: .88rem; }
.bar-actions .icon-btn, .bar-actions .btn.is-ghost { padding: 8px 12px; }
.btn.is-ghost {
  background: var(--bg-elev2); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  font-family: inherit; font-weight: 600; font-size: .88rem;
}
.btn.is-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--brand); }
.btn.is-ghost:disabled { opacity: .4; cursor: default; }

/* ---------- status line ---------- */
.status-line {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: .86rem; color: var(--text-mut); margin: 0 2px 12px;
}
.status-line .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.status-line strong { color: var(--text-dim); }
.status-line .status-msg { color: var(--text-dim); font-weight: 600; }

/* scanned-PDF notice */
.scan-banner {
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border-radius: var(--radius-sm); padding: 11px 14px; margin-bottom: 12px;
  font-size: .9rem; color: var(--text-dim);
}
.scan-banner b { color: var(--text); }

/* pro banner — non-blocking nudge */
.pro-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 12px;
  font-size: .9rem; color: var(--text-dim);
}
.pro-banner strong { color: var(--text); }
.pro-banner .btn { padding: 7px 14px; font-size: .84rem; margin-left: auto; }
.pro-banner .banner-close {
  background: none; border: none; color: var(--text-mut); font-size: 1.1rem;
  cursor: pointer; padding: 2px 6px; line-height: 1;
}
.pro-banner .banner-close:hover { color: var(--text); }

/* ---------- pages pane ---------- */
.pages-pane { display: flex; flex-direction: column; align-items: center; gap: 26px; }
.page-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 100%; position: relative; }
.page-num { font-size: .8rem; color: var(--text-mut); }

.page-box {
  position: relative; background: #fff; border-radius: 4px;
  box-shadow: 0 8px 30px -8px rgba(0,0,0,.45);
  border: 1px solid var(--border);
}
.page-box canvas { display: block; border-radius: 4px; }

/* editable text layer sits exactly over the canvas glyphs */
.tlayer { position: absolute; inset: 0; overflow: hidden; z-index: 2; }
.overlay { position: absolute; inset: 0; z-index: 3; }

/* the overlay only grabs pointer events in the placement tools */
body[data-mode="edit"] .overlay { pointer-events: none; }
body[data-mode="edit"] .tlayer { pointer-events: auto; }
body[data-mode="addtext"] .overlay { cursor: text; }
body[data-mode="whiteout"] .overlay { cursor: crosshair; touch-action: none; }
body[data-mode="image"] .overlay { cursor: copy; }
/* in placement tools the text layer must not eat clicks */
body:not([data-mode="edit"]) .tlayer { pointer-events: none; }

/* ---------- editable run spans ---------- */
.trun {
  position: absolute;
  white-space: pre;
  transform-origin: 0 0;
  color: transparent;               /* default: canvas shows the real glyph */
  background: transparent;
  cursor: text;
  border-radius: 2px;
  caret-color: var(--brand);
  line-height: 1;
  outline: none;
  -webkit-user-modify: read-write-plaintext-only;
}
body[data-mode="edit"] .trun:hover {
  background: color-mix(in srgb, var(--brand) 14%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 50%, transparent);
}
/* while editing OR once changed: mask the original glyph + show text opaque */
.trun.editing, .trun.dirty {
  color: var(--run-color, #000);
  background: var(--run-fill, #fff);
  box-shadow: 0 0 0 1.5px var(--run-fill, #fff);
}
.trun.editing {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  box-shadow: 0 0 0 1.5px var(--run-fill, #fff), 0 2px 10px -3px rgba(0,0,0,.4);
  z-index: 6;
}
.trun.bold { font-weight: 700; }
.trun.nofill { background: transparent; box-shadow: none; }

/* ---------- selection popover ---------- */
.sel-pop {
  position: absolute; z-index: 50;
  display: none; align-items: center; gap: 8px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 9px;
  box-shadow: 0 10px 30px -8px rgba(0,0,0,.5);
  font-size: .82rem;
}
.sel-pop.show { display: flex; }
.sel-pop label { display: flex; align-items: center; gap: 5px; margin: 0; font-size: .78rem; color: var(--text-mut); }
.sel-pop input[type="number"] { width: 54px; padding: 5px 6px; font-size: .84rem; }
.sel-pop input[type="color"] {
  width: 30px; height: 28px; padding: 2px; cursor: pointer;
  background: var(--bg-elev2); border: 1px solid var(--border); border-radius: 7px;
}
.sel-pop .pop-btn {
  font-family: inherit; font-weight: 700; font-size: .82rem;
  background: var(--bg-elev2); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 7px;
  padding: 5px 9px; cursor: pointer; line-height: 1;
}
.sel-pop .pop-btn[aria-pressed="true"] {
  background: color-mix(in srgb, var(--brand) 22%, transparent);
  border-color: var(--brand); color: var(--text);
}
.sel-pop .pop-sep { width: 1px; height: 20px; background: var(--border); }

/* ---------- placed edit elements (add-text / whiteout / image) ---------- */
.edit-el { position: absolute; box-sizing: border-box; z-index: 4; }
.edit-el .el-del {
  position: absolute; top: -11px; right: -11px; z-index: 3;
  width: 21px; height: 21px; border-radius: 50%;
  background: var(--danger); color: #fff; border: none; cursor: pointer;
  font-size: 13px; line-height: 1; display: none; place-items: center; padding: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.edit-el:hover .el-del, .edit-el.selected .el-del { display: grid; }
.edit-el .el-grip {
  position: absolute; left: -19px; top: 50%; transform: translateY(-50%); z-index: 3;
  cursor: grab; color: #7a869f; font-size: 13px; line-height: 1;
  padding: 4px 3px; border-radius: 5px; background: rgba(127,127,127,.14);
  display: none; touch-action: none; user-select: none;
}
.edit-el:hover .el-grip, .edit-el.selected .el-grip { display: block; }
.edit-el .el-resize {
  position: absolute; right: -7px; bottom: -7px; z-index: 3;
  width: 15px; height: 15px; border-radius: 4px;
  background: var(--brand); border: 2px solid #fff; cursor: nwse-resize;
  display: none; touch-action: none;
}
.edit-el:hover .el-resize, .edit-el.selected .el-resize { display: block; }

.text-el { border: 1px dashed transparent; border-radius: 3px; }
.text-el:hover, .text-el.selected { border-color: var(--brand); }
.text-el .txt-input {
  display: block; width: auto; min-width: 40px;
  background: transparent; border: none; outline: none; box-shadow: none;
  padding: 0; margin: 0; border-radius: 0;
  font-family: Helvetica, Arial, sans-serif; line-height: 1.25; color: #111;
}
.text-el .txt-input:focus { outline: none; box-shadow: none; border: none; }

.whiteout-el {
  background: #fff; z-index: 1; cursor: move; touch-action: none;
  outline: 1px dashed transparent; border-radius: 1px;
}
.whiteout-el:hover, .whiteout-el.selected { outline-color: var(--brand); }

.image-el { cursor: move; touch-action: none; border: 1px dashed transparent; }
.image-el:hover, .image-el.selected { border-color: var(--brand); }
.image-el img { width: 100%; height: 100%; display: block; pointer-events: none; }

/* ---------- first-load hint arrow ---------- */
.hint-arrow {
  position: fixed; z-index: 60; pointer-events: none;
  display: flex; align-items: center; gap: 8px;
  background: var(--brand); color: #fff; font-weight: 700; font-size: .84rem;
  padding: 8px 12px; border-radius: 10px;
  box-shadow: 0 8px 24px -6px rgba(0,0,0,.5);
  animation: hint-bob 1.3s ease-in-out 3;
}
@media (prefers-reduced-motion: reduce) { .hint-arrow { animation: none; } }
.hint-arrow::after {
  content: ""; position: absolute; left: 18px; bottom: -7px;
  border: 7px solid transparent; border-top-color: var(--brand); border-bottom: 0;
}
@keyframes hint-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .editor-main { padding: 20px 10px 50px; }
  .editor-bar { top: 62px; padding: 8px; gap: 8px; }
  .file-meta { display: none; }
  .tool-group { width: 100%; order: 1; }
  .bar-actions { order: 2; width: 100%; margin-left: 0; }
  .bar-actions .btn-primary { flex: 1; }
  .drop-zone { padding: 38px 14px; }
  .sel-pop { flex-wrap: wrap; max-width: 92vw; }
}
