/* ==========================================================================
   Edit PDF — module styles
   ========================================================================== */

/* --- Toolbar --- */
.edit-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tool-btn {
  background: var(--bs-tertiary-bg, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--bs-border-color, rgba(255, 255, 255, 0.12));
  color: var(--bs-body-color, #eee);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.tool-btn:hover {
  border-color: var(--bs-primary, #6c8eff);
}

.tool-btn.active {
  background: rgba(108, 142, 255, 0.15);
  border-color: var(--bs-primary, #6c8eff);
  font-weight: 600;
}

/* --- Contextual property bar --- */
.edit-props {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--bs-tertiary-bg, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--bs-border-color, rgba(255, 255, 255, 0.08));
  border-radius: 8px;
  font-size: 0.88rem;
}

.edit-props .prop-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.edit-props label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--bs-secondary-color, #bbb);
}

.edit-props input[type="color"] {
  width: 34px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--bs-border-color, rgba(255, 255, 255, 0.2));
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.edit-props .input-sm {
  padding: 3px 8px;
  font-size: 0.85rem;
}

.mini-toggle {
  width: 30px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--bs-border-color, rgba(255, 255, 255, 0.15));
  background: transparent;
  color: var(--bs-body-color, #eee);
  cursor: pointer;
}

.mini-toggle.on {
  background: rgba(108, 142, 255, 0.2);
  border-color: var(--bs-primary, #6c8eff);
}

/* --- PDF viewer (shared look with Sign tool) --- */
.pdf-viewer {
  margin-top: 14px;
  background: var(--bs-tertiary-bg, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--bs-border-color, rgba(255, 255, 255, 0.08));
  border-radius: 10px;
  padding: 14px;
  max-height: 75vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.pdf-page-wrap {
  position: relative;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.pdf-page-canvas { display: block; }

.pdf-page-overlay {
  position: absolute;
  inset: 0;
}

.pdf-page-label {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  pointer-events: none;
  font-family: system-ui, -apple-system, sans-serif;
  z-index: 5;
}

/* Cursor per tool */
.pdf-viewer[data-tool="text"] .pdf-page-overlay   { cursor: text; }
.pdf-viewer[data-tool="whiteout"] .pdf-page-overlay,
.pdf-viewer[data-tool="highlight"] .pdf-page-overlay,
.pdf-viewer[data-tool="rect"] .pdf-page-overlay,
.pdf-viewer[data-tool="ellipse"] .pdf-page-overlay,
.pdf-viewer[data-tool="line"] .pdf-page-overlay,
.pdf-viewer[data-tool="arrow"] .pdf-page-overlay,
.pdf-viewer[data-tool="draw"] .pdf-page-overlay   { cursor: crosshair; }
.pdf-viewer[data-tool="image"] .pdf-page-overlay  { cursor: copy; }

/* --- Placed elements (box types) --- */
.edit-el {
  position: absolute;
  box-sizing: border-box;
  user-select: none;
  transform-origin: 50% 50%;
}

.edit-el .el-content {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.edit-el[data-type="text"] { cursor: move; }
.edit-el[data-type="text"] .el-content {
  padding: 2px 3px;
  line-height: 1.25;
  word-break: break-word;
  white-space: pre-wrap;
  outline: none;
  cursor: inherit;
}
.edit-el[data-type="text"].editing { cursor: text; }
.edit-el[data-type="text"].editing .el-content { cursor: text; user-select: text; }

.edit-el[data-type="whiteout"] .el-content { background: #ffffff; }
.edit-el[data-type="whiteout"] {
  outline: 1px dashed rgba(0, 0, 0, 0.18);   /* editing aid only, not exported */
}

.edit-el[data-type="ellipse"] .el-content { border-radius: 50%; }

.edit-el[data-type="check"] .el-content,
.edit-el[data-type="cross"] .el-content {
  background: transparent;
  border: none;
  overflow: visible;
}
.edit-el[data-type="check"],
.edit-el[data-type="cross"] {
  outline: 1px dashed rgba(0, 0, 0, 0.12);  /* editing aid only, not exported */
}

.edit-el:not(.editing) { cursor: move; }

.edit-el.selected {
  outline: 1.5px dashed var(--bs-primary, #6c8eff);
  outline-offset: 1px;
}

.edit-el .el-remove {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e94e4e;
  color: #fff;
  border: none;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 4;
}

.edit-el .el-resize {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: var(--bs-primary, #6c8eff);
  border: 2px solid #fff;
  border-radius: 3px;
  cursor: nwse-resize;
  display: none;
  z-index: 4;
}

.edit-el .el-rotate {
  position: absolute;
  top: -28px;
  left: 50%;
  width: 16px;
  height: 16px;
  background: var(--bs-primary, #6c8eff);
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: grab;
  display: none;
  z-index: 4;
  transform: translateX(-50%);
}

.edit-el .el-rotate::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  width: 2px;
  height: 12px;
  background: var(--bs-primary, #6c8eff);
  transform: translateX(-50%);
}

.edit-el.selected .el-remove,
.edit-el.selected .el-resize,
.edit-el.selected .el-rotate { display: flex; }

/* --- Lines / arrows --- */
.edit-line-wrap {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.edit-line-wrap svg { position: absolute; inset: 0; overflow: visible; }

.edit-line-wrap line.body {
  pointer-events: stroke;
  cursor: move;
}

.line-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bs-primary, #6c8eff);
  border: 2px solid #fff;
  transform: translate(-50%, -50%);
  cursor: grab;
  pointer-events: auto;
  display: none;
  z-index: 4;
}

.line-remove {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e94e4e;
  color: #fff;
  border: none;
  font-size: 12px;
  transform: translate(-50%, -140%);
  cursor: pointer;
  pointer-events: auto;
  display: none;
  z-index: 4;
}

.edit-line-wrap.selected .line-handle,
.edit-line-wrap.selected .line-remove { display: block; }

/* Rubber-band while creating */
.rubber {
  position: absolute;
  border: 1.5px dashed var(--bs-primary, #6c8eff);
  background: rgba(108, 142, 255, 0.08);
  pointer-events: none;
  z-index: 3;
}

/* Temp freehand canvas */
.draw-temp {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}
