/* ==========================================================================
   Sign PDF — module styles
   These complement the existing styles.css and use the same color tokens.
   ========================================================================== */

/* --- Tabs (Type / Draw / Upload) --- */
.sig-tabs {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  border-bottom: 1px solid var(--bs-border-color, rgba(255, 255, 255, 0.1));
}

.sig-tab {
  background: transparent;
  border: none;
  color: var(--bs-secondary-color, #aaa);
  padding: 10px 16px;
  font-size: 0.95rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.sig-tab:hover {
  color: var(--bs-body-color, #fff);
}

.sig-tab.active {
  color: var(--bs-body-color, #fff);
  border-bottom-color: var(--bs-primary, #6c8eff);
  font-weight: 600;
}

.sig-pane {
  padding-top: 6px;
}


/* --- Type mode font picker --- */
.sig-fontpicker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.sig-font-option {
  border: 2px solid var(--bs-border-color, rgba(255, 255, 255, 0.1));
  background: var(--bs-tertiary-bg, rgba(255, 255, 255, 0.03));
  border-radius: 10px;
  padding: 16px 14px;
  cursor: pointer;
  text-align: center;
  font-size: 1.6rem;
  line-height: 1.2;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bs-body-color, #fff);
  transition: border-color 0.15s, background 0.15s;
  overflow: hidden;
  white-space: nowrap;
}

.sig-font-option:hover {
  border-color: var(--bs-primary, #6c8eff);
}

.sig-font-option.selected {
  border-color: var(--bs-primary, #6c8eff);
  background: rgba(108, 142, 255, 0.08);
}


/* --- Draw mode --- */
.sig-drawwrap {
  margin-top: 10px;
  border: 2px dashed var(--bs-border-color, rgba(255, 255, 255, 0.15));
  border-radius: 10px;
  background: #fff;
  padding: 4px;
  overflow: hidden;
}

.sig-drawcanvas {
  display: block;
  width: 100%;
  height: 220px;
  cursor: crosshair;
  background: #fff;
  border-radius: 6px;
  touch-action: none;
}


/* --- Preview box --- */
.sig-preview-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sig-preview-box {
  border: 1px solid var(--bs-border-color, rgba(255, 255, 255, 0.1));
  border-radius: 8px;
  background:
    repeating-conic-gradient(#f3f3f3 0% 25%, #ffffff 0% 50%) 50% / 16px 16px;
  min-height: 80px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sig-preview-box img {
  max-width: 100%;
  max-height: 120px;
  display: none;
}

.sig-preview-box img[src] {
  display: block;
}


/* --- Floating signature handle (drag source) --- */
.sig-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  background:
    repeating-conic-gradient(#f3f3f3 0% 25%, #ffffff 0% 50%) 50% / 12px 12px;
  border: 2px solid var(--bs-primary, #6c8eff);
  border-radius: 10px;
  cursor: grab;
  user-select: none;
  min-width: 180px;
  min-height: 50px;
  max-width: 320px;
}

.sig-handle:active {
  cursor: grabbing;
}

.sig-handle img {
  max-width: 100%;
  max-height: 80px;
  pointer-events: none;
}


/* --- PDF viewer --- */
.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;
  pointer-events: auto;
}

.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;
}


/* --- Placed signatures --- */
.placed-sig {
  position: absolute;
  border: 1px dashed rgba(108, 142, 255, 0.6);
  cursor: move;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  user-select: none;
}

.placed-sig:hover {
  border-color: rgba(108, 142, 255, 1);
}

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

.placed-sig .placed-sig-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;
  z-index: 2;
}

.placed-sig .placed-sig-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;
  z-index: 2;
  transform: translateX(-50%);
}

.placed-sig .placed-sig-rotate::after {
  /* Connector line from handle down to the signature top edge */
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  width: 2px;
  height: 12px;
  background: var(--bs-primary, #6c8eff);
  transform: translateX(-50%);
}

.placed-sig .placed-sig-rotate:active {
  cursor: grabbing;
}


/* --- Drop highlight --- */
.pdf-page-wrap.dropping {
  outline: 3px solid var(--bs-primary, #6c8eff);
  outline-offset: -3px;
}
