/* ===== PDF + Dynamic Stamp viewer (IDE) ===== */
.pdf-stamp-wrap {
  display: flex; flex-direction: column; height: 100%; width: 100%;
  background: var(--editor, #1A1815); overflow: hidden;
}

/* Toolbar */
.ps-toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  height: auto; min-height: 46px; padding: 7px 10px; flex-shrink: 0;
  background: var(--bg-sidebar, #201D18); border-bottom: 0.5px solid var(--border);
  font-family: 'Inter', -apple-system, sans-serif;
}
.ps-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px;
  background: transparent; border: 0.5px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; -webkit-tap-highlight-color: transparent; white-space: nowrap;
}
.ps-btn:hover { background: var(--hover); border-color: var(--border-hover); }
.ps-btn:active { transform: scale(0.98); }
.ps-btn svg { width: 14px; height: 14px; stroke: currentColor; }
.ps-btn.ps-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.ps-btn.ps-primary:hover { background: var(--accent-light, #DA7756); }
.ps-sep { width: 0.5px; height: 22px; background: var(--border); margin: 0 2px; }
.ps-pageinfo, .ps-zoominfo { font-size: 12px; color: var(--text-dim); min-width: 52px; text-align: center; font-family: 'Inter', sans-serif; }
.ps-icon-btn {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0.5px solid var(--border); border-radius: 7px; color: var(--text-dim);
  cursor: pointer; line-height: 1; transition: all 0.15s;
}
.ps-icon-btn:hover { background: var(--hover); color: var(--text); }
.ps-spacer { flex: 1; }

/* Stage (scrollable pages) */
.ps-stage {
  flex: 1; overflow: auto; padding: 20px; display: flex; flex-direction: column;
  align-items: center; gap: 18px; background: #2a2722;
}
.ps-page {
  position: relative; box-shadow: 0 2px 14px rgba(0,0,0,0.35); background: #fff;
  border-radius: 2px; flex-shrink: 0;
}
.ps-page canvas { display: block; border-radius: 2px; }
.ps-overlay { position: absolute; inset: 0; overflow: hidden; }

/* A stamp on the page */
.ps-stamp {
  position: absolute; cursor: move; user-select: none; -webkit-user-select: none;
  box-sizing: border-box; will-change: transform;
}
.ps-stamp img { width: 100%; height: 100%; display: block; pointer-events: none; -webkit-user-drag: none; }
.ps-stamp.sel { outline: 1.5px dashed var(--accent); outline-offset: 2px; }
.ps-handle {
  position: absolute; width: 12px; height: 12px; background: #fff; border: 1.5px solid var(--accent);
  border-radius: 50%; display: none; z-index: 3;
}
.ps-stamp.sel .ps-handle { display: block; }
.ps-handle.se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.ps-handle.rot { left: 50%; top: -22px; margin-left: -6px; cursor: grab; background: var(--accent); }
.ps-del {
  position: absolute; right: -10px; top: -10px; width: 18px; height: 18px; border-radius: 50%;
  background: #c0392b; color: #fff; border: none; display: none; align-items: center; justify-content: center;
  font-size: 12px; cursor: pointer; z-index: 4; line-height: 1;
}
.ps-stamp.sel .ps-del { display: flex; }

.ps-hint {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: var(--text-dim); background: var(--bg-input);
  border: 0.5px solid var(--border); border-radius: 20px; padding: 5px 14px;
  pointer-events: none; font-family: 'Inter', sans-serif; white-space: nowrap; z-index: 5; opacity: 0.9;
}
.ps-loading { margin: auto; color: var(--text-dim); font-size: 13px; font-family: 'Inter', sans-serif; }
.pdf-stamp-wrap.ps-busy { pointer-events: none; opacity: 0.72; }
.pdf-stamp-wrap.ps-busy .ps-toolbar::after {
  content: '處理中…'; margin-left: 8px; font-size: 12px; color: var(--accent); font-weight: 600;
}

/* Text-seal dialog */
.ps-dialog-back {
  position: absolute; inset: 0; background: rgba(0,0,0,0.4); z-index: 20;
  display: flex; align-items: center; justify-content: center;
}
.ps-dialog {
  width: 320px; max-width: 90%; background: var(--bg, #2B2A27); border: 0.5px solid var(--border);
  border-radius: 16px; padding: 18px; font-family: 'Inter', sans-serif;
}
.ps-dialog h4 { margin: 0 0 12px; font-size: 14px; font-weight: 700; color: var(--text); }
.ps-dialog label { display: block; font-size: 11px; color: var(--text-dim); margin: 10px 0 4px; }
.ps-dialog input[type=text] {
  width: 100%; box-sizing: border-box; background: var(--bg-input); border: 0.5px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px; padding: 8px 10px; outline: none;
}
.ps-dialog input[type=text]:focus { border-color: var(--accent); }
.ps-dialog .ps-row { display: flex; gap: 10px; align-items: center; }
.ps-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.ps-preview { display: flex; justify-content: center; margin: 12px 0 4px; }
.ps-preview canvas { border-radius: 8px; }

@media (max-width: 768px) {
  .ps-toolbar { gap: 4px; padding: 6px; }
  .ps-btn { padding: 0 8px; font-size: 11px; }
  .ps-stage { padding: 10px; }
}
