/* Styles for the PDF editor page only (edit-pdf/). Loaded after style.css. */

/* style.css gives .drop `display: grid`, which overrides the UA's
   [hidden] { display: none } — restate it so hiding the drop zone works. */
#drop-edit[hidden] { display: none; }

.ed-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 0 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.ed-toolbar .sep { width: 1px; align-self: stretch; background: var(--line); margin: 2px 4px; }
.ed-toolbar button {
  font: inherit;
  font-size: 14px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.ed-toolbar button[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.ed-toolbar .primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .ed-toolbar .primary { color: #17110f; } }
.ed-toolbar .ghost { background: none; color: var(--muted); }
.ed-toolbar .ghost:hover { color: var(--accent); border-color: var(--accent); }
.ed-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
}
.ed-toolbar input[type="number"] {
  width: 58px;
  min-height: 40px;
  padding: 6px 8px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.ed-toolbar input[type="color"] {
  width: 40px;
  height: 40px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

/* pages */
.ed-pages {
  position: relative; /* offsetParent for .page, so offsetTop is scroller-relative */
  margin-top: 12px;
  max-height: 76vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
  display: grid;
  gap: 14px;
  justify-items: center;
}
.page {
  position: relative;
  background: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .18);
  flex: none;
}
.page canvas { display: block; position: absolute; inset: 0; }
.ed-pages.tool-text .page { cursor: text; }
.ed-pages.tool-check .page, .ed-pages.tool-cross .page, .ed-pages.tool-sign .page { cursor: copy; }
.ed-pages.tool-highlight .page, .ed-pages.tool-replace .page { cursor: crosshair; touch-action: none; }

/* placed elements */
.el {
  position: absolute;
  touch-action: none;
  cursor: grab;
  z-index: 2;
  user-select: none;
  -webkit-user-select: none;
}
.el-text.editing .txt, .el-replace.editing .txt { user-select: text; -webkit-user-select: text; }
.el.sel { outline: 1.5px solid #2f6fed; outline-offset: 1px; }
.el-highlight { background: #ffe400; mix-blend-mode: multiply; opacity: .85; z-index: 1; }
.el-check svg, .el-cross svg { width: 100%; height: 100%; display: block; }
.el-image img { width: 100%; height: 100%; display: block; user-select: none; }
.el-text .txt, .el-replace .txt {
  font-family: Arial, Helvetica, sans-serif;
  white-space: pre;
  min-width: 8px;
  min-height: 1em;
  padding: 2px;
  outline: none;
  caret-color: #2f6fed;
}
.el-text, .el-replace { cursor: grab; }
.el-replace { background: #fff; }
.el-text.editing, .el-replace.editing { cursor: text; }
.el-text.editing .txt, .el-replace.editing .txt { cursor: text; }

.el .rz, .el .del { display: none; }
.el.sel .rz {
  display: block;
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: #2f6fed;
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: nwse-resize;
}
.el.sel .del {
  display: block;
  position: absolute;
  top: -30px;
  right: -10px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #d33a2c;
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

/* signature dialog */
#sig-dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  padding: 18px;
  width: min(92vw, 520px);
}
#sig-dialog::backdrop { background: rgba(0, 0, 0, .45); }
#sig-dialog h3 { margin: 0 0 10px; font-size: 16px; }
.sig-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.sig-tabs button {
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.sig-tabs button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); font-weight: 600; }
#sig-pad {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 0.38;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  touch-action: none;
  cursor: crosshair;
}
#sig-type-panel input[type="text"] {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
#sig-preview {
  margin-top: 10px;
  min-height: 64px;
  display: flex;
  align-items: center;
  padding: 6px 12px;
  font-size: 38px;
  background: #fff;
  color: #111;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.sig-colors { display: flex; gap: 14px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.sig-colors label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.sig-actions { display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end; }
.sig-actions button {
  font: inherit;
  font-size: 15px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
}
.sig-actions .primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .sig-actions .primary { color: #17110f; } }

@media (max-width: 480px) {
  .ed-toolbar button { padding: 8px 9px; font-size: 13px; }
  .ed-pages { padding: 8px; }
}
