/* ===== Root =====
   Friendly Helper palette (Blue): trust-blue accent, light panels, soft tints.
   Inherits design tokens from site.css (--blue, --ink, --soft, etc.). */
.pdf-fill-tool {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
.pdf-fill-tool .pft-panel { display: none; }
.pdf-fill-tool .pft-panel.active { display: block; }

/* ===== Upload ===== */
.pft-dropzone {
  border: 2.5px dashed #b9cdf3;
  border-radius: 18px;
  padding: 44px 24px;
  text-align: center;
  color: #566479;
  cursor: pointer;
  background: linear-gradient(180deg, #f7faff, #eef4ff);
  max-width: 620px;
  margin: 0 auto;
  transition: border-color .15s, background .15s, transform .15s;
}
.pft-dropzone:hover { transform: translateY(-2px); }
.pft-dropzone.dragover { border-color: #2563eb; background: #e7f0ff; }
.pft-dz-icon {
  width: 64px; height: 64px; border-radius: 20px; background: #dbe8ff;
  display: grid; place-items: center; font-size: 30px; margin: 0 auto 14px;
}
.pft-dz-title { font-size: 19px; font-weight: 700; color: #13243b; }
.pft-dz-sub { font-size: 14px; color: #566479; margin-top: 3px; }
.pft-dz-btn {
  margin-top: 18px; display: inline-block; background: #2563eb; color: #fff;
  font-weight: 700; font-size: 15px; padding: 12px 26px; border-radius: 14px;
  box-shadow: 0 10px 24px -10px rgba(37, 99, 235, .6);
}
.pft-privacy-note { margin-top: 16px; font-size: 13px; color: #566479; text-align: center; }
.pft-error { margin-top: 10px; color: #c0392b; font-size: 13px; text-align: center; }

/* ===== Detecting ===== */
.pft-detecting { text-align: center; padding: 48px 0; color: #566479; }

/* ===== Editor Layout ===== */
.pft-editor-layout {
  display: flex;
  height: 82vh;
  min-height: 500px;
  border: 1px solid #e4eaf2;
  border-radius: 18px;
  overflow: hidden;
  background: #eef2f8;
  box-shadow: 0 24px 60px -34px rgba(19, 36, 59, .35);
}

/* ===== Sidebar (light) ===== */
.pft-sidebar {
  width: 148px;
  min-width: 148px;
  background: #f7f9fc;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e4eaf2;
  user-select: none;
}
.pft-sidebar-header {
  color: #768297;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 14px 8px;
}
.pft-thumbnail-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pft-thumbnail-list::-webkit-scrollbar { width: 5px; }
.pft-thumbnail-list::-webkit-scrollbar-thumb { background: #cbd5e6; border-radius: 3px; }

.pft-thumbnail {
  cursor: pointer;
  border: 2px solid #e4eaf2;
  border-radius: 7px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fff;
  flex-shrink: 0;
}
.pft-thumbnail:hover { border-color: #b9cdf3; }
.pft-thumbnail.active { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37, 99, 235, .15); }
.pft-thumbnail img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}
.pft-thumbnail-label {
  text-align: center;
  font-size: 10px;
  color: #768297;
  padding: 3px 0;
  background: #f7f9fc;
  font-weight: 600;
}
.pft-thumbnail.active .pft-thumbnail-label { color: #2563eb; }

/* ===== Main area ===== */
.pft-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ===== Toolbar ===== */
.pft-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fbfcfe;
  border-bottom: 1px solid #e4eaf2;
  padding: 6px 12px;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 44px;
}
.pft-toolbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pft-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pft-toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pft-toolbar-divider {
  width: 1px;
  height: 22px;
  background: #e4eaf2;
  margin: 0 4px;
}

/* Nav buttons */
.pft-nav-btn {
  width: 28px;
  height: 28px;
  border: 1px solid #d7dfec;
  border-radius: 7px;
  background: #fff;
  color: #13243b;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}
.pft-nav-btn:hover { background: #eef4ff; }
.pft-nav-btn:disabled { opacity: 0.35; cursor: default; }
.pft-nav-btn:disabled:hover { background: #fff; }

.pft-fmt-btn {
  width: 28px; height: 28px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.12s, border-color 0.12s;
}
.pft-fmt-btn:hover { background: #eef4ff; border-color: #93c5fd; }
.pft-fmt-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.pft-page-info {
  font-size: 12px;
  color: #566479;
  display: flex;
  align-items: center;
  gap: 3px;
}
.pft-page-input {
  width: 32px;
  height: 26px;
  border: 1px solid #d7dfec;
  border-radius: 6px;
  text-align: center;
  font-size: 12px;
  color: #13243b;
  background: #fff;
  -moz-appearance: textfield;
}
.pft-page-input::-webkit-inner-spin-button,
.pft-page-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Format controls */
.pft-font-select,
.pft-size-select {
  height: 28px;
  border: 1px solid #d7dfec;
  border-radius: 7px;
  background: #fff;
  color: #13243b;
  font-size: 12px;
  padding: 0 4px;
  cursor: pointer;
}
.pft-font-select { width: 110px; }
.pft-size-select { width: 52px; }

.pft-color-input {
  width: 28px;
  height: 28px;
  border: 1px solid #d7dfec;
  border-radius: 7px;
  padding: 2px;
  cursor: pointer;
  background: #fff;
}

/* Upload New button */
.pft-upload-new-btn {
  background: #fff;
  color: #566479;
  border: 1px solid #d7dfec;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.pft-upload-new-btn:hover { background: #eef4ff; border-color: #93c5fd; color: #1d4ed8; }

/* Download button */
.pft-download-btn {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  white-space: nowrap;
  box-shadow: 0 8px 18px -8px rgba(37, 99, 235, .6);
}
.pft-download-btn:hover { background: #1d4ed8; transform: translateY(-1px); }

/* Zoom controls */
.pft-zoom-label {
  font-size: 12px;
  color: #566479;
  min-width: 40px;
  text-align: center;
  user-select: none;
}
.pft-zoom-fit {
  height: 28px;
  border: 1px solid #d7dfec;
  border-radius: 7px;
  background: #fff;
  color: #13243b;
  font-size: 12px;
  padding: 0 9px;
  cursor: pointer;
}
.pft-zoom-fit:hover { background: #eef4ff; }

/* ===== Page Area ===== */
.pft-page-area {
  flex: 1;
  overflow: auto;
  background: #e3e8f1;
  display: flex;
  justify-content: center;
  padding: 24px;
}
.pft-page-container {
  position: relative;
  display: inline-block;
  cursor: crosshair;
  user-select: none;
  box-shadow: 0 2px 12px rgba(19, 36, 59, 0.18);
  background: #fff;
  flex-shrink: 0;
}
.pft-page-img {
  display: block;
  width: auto;            /* explicit width set by zoom (_applyZoom) */
  height: auto;
  -webkit-user-drag: none;
  user-select: none;
}

/* ===== Field Boxes =====
   Adobe-style: soft highlighted fill at rest with NO visible border; a dashed
   outline appears only on the active (focused) field. The resting border is
   transparent at the same width as the dashed one, so focus causes no reflow —
   fields stay pixel-aligned with the PDF underline. */
.pft-field-box {
  position: absolute;
  box-sizing: border-box;
  border: 1.5px solid transparent;
  background: rgba(37, 99, 235, 0.08);
  border-radius: 1px;
  display: flex;
  align-items: flex-end;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
.pft-field-box:hover {
  background: rgba(37, 99, 235, 0.13);
}
.pft-field-box:focus-within {
  border: 1.5px dashed rgba(220, 38, 38, 0.9);
  background: rgba(220, 38, 38, 0.09);
}

/* Signature / image fields — green tint (kept distinct from blue text fields) */
.pft-field-box.signature-field {
  background: rgba(34, 197, 94, 0.10);
}
.pft-field-box.signature-field:hover {
  background: rgba(34, 197, 94, 0.15);
}
.pft-field-box.signature-field:focus-within {
  border-color: rgba(220, 38, 38, 0.9);
  background: rgba(220, 38, 38, 0.09);
}

/* User-added fields — same as text (no special color) */
.pft-field-box.user-added {
  background: rgba(37, 99, 235, 0.08);
}
.pft-field-box.user-added:hover { background: rgba(37, 99, 235, 0.13); }
.pft-field-box.user-added:focus-within {
  border-color: rgba(220, 38, 38, 0.9);
  background: rgba(220, 38, 38, 0.09);
}
/* User-added signature fields keep green */
.pft-field-box.user-added.signature-field {
  background: rgba(34, 197, 94, 0.10);
}
.pft-field-box.user-added.signature-field:hover { background: rgba(34, 197, 94, 0.15); }
.pft-field-box.user-added.signature-field:focus-within {
  border-color: rgba(220, 38, 38, 0.9);
  background: rgba(220, 38, 38, 0.09);
}

/* Active-field label tag (small pill below the field, like Adobe's) */
.pft-field-tag {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 3px;
  background: #13243b;
  color: #cdd9ec;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
  box-shadow: 0 2px 6px rgba(19, 36, 59, 0.3);
}

.pft-field-box input {
  width: 100%;
  max-height: 100%;
  box-sizing: border-box;
  border: none;
  background: transparent;
  outline: none;
  padding: 0 2px;
  line-height: 1;
  transform: translateY(1px);
  color: #13243b;
  font-family: inherit;
}
.pft-field-box input::placeholder { color: #9ca3af; }

/* Multiline fields (textarea) */
.pft-field-box.multiline {
  align-items: flex-start;
}
.pft-field-box textarea {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  outline: none;
  padding: 2px 3px;
  line-height: 1.3;
  color: #13243b;
  font-family: inherit;
  resize: none;
  overflow: auto;
}
.pft-field-box textarea::placeholder { color: #9ca3af; }

/* ===== Delete Buttons ===== */
.pft-field-box .pft-delete {
  position: absolute;
  top: -6px;
  right: -10px;
  width: 13px;
  height: 13px;
  background: #97a4ba;
  color: #fff;
  border: 1.5px solid #fff;
  border-radius: 50%;
  font-size: 9px;
  line-height: 10px;
  text-align: center;
  cursor: pointer;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.pft-field-box:hover .pft-delete { opacity: 0.6; }
.pft-field-box .pft-delete:hover {
  opacity: 1;
  background: #ef4444;
}

/* ===== Drag Rect ===== */
.pft-drag-rect {
  display: none;
  position: absolute;
  border: 2px dashed #4b5563;
  background: rgba(75, 85, 99, 0.08);
  pointer-events: none;
}

/* ===== Type Picker (light) ===== */
.pft-type-picker {
  display: none;
  position: fixed;
  background: #fff;
  border: 1px solid #e4eaf2;
  border-radius: 10px;
  padding: 12px;
  z-index: 100;
  box-shadow: 0 12px 32px rgba(19, 36, 59, 0.18);
}
.pft-type-picker p { color: #566479; font-size: 12px; margin: 0 0 8px; }
.pft-type-picker .pft-types { display: flex; gap: 6px; flex-wrap: wrap; }
.pft-type-picker button {
  background: #eef4ff; color: #1d4ed8; border: 1px solid #d7e3fb; border-radius: 7px;
  padding: 5px 10px; cursor: pointer; font-size: 12px; font-weight: 600;
}
.pft-type-picker button:hover { background: #dbe8ff; }
.pft-type-picker .pft-cancel {
  margin-top: 8px; display: block; color: #768297; font-size: 11px; cursor: pointer;
  background: none; border: none;
}

/* ===== Checkbox Field (PDF overlay) ===== */
.pft-field-box.checkbox-field {
  background: rgba(245, 158, 11, 0.18);
  cursor: pointer;
}
.pft-field-box.checkbox-field:hover {
  background: rgba(245, 158, 11, 0.26);
}
.pft-field-box.checkbox-field.pft-active-glow {
  border: 1.5px dashed rgba(220, 38, 38, 0.9);
  background: rgba(220, 38, 38, 0.11);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14);
}
.pft-cb-wrap {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.pft-cb-wrap.checked::after {
  content: "\2714";
  color: #13243b;
  font-weight: 700;
  line-height: 1;
}

/* ===== Signature Field ===== */
.pft-sig-wrap {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden;
}
.pft-sig-img {
  max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none;
}
.pft-sig-placeholder {
  color: #94a3b8; font-size: 11px; user-select: none;
}

/* ===== Usage Banner ===== */
.pft-usage-banner {
  display: none;
  background: #eef4ff;
  border: 1px solid #b9cdf3;
  color: #1d4ed8;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 10px;
}
.pft-usage-banner.show { display: block; }

/* ===== Right Field Panel (light) ===== */
.pft-field-panel {
  width: 280px;
  min-width: 280px;
  background: #f7f9fc;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #e4eaf2;
  user-select: none;
}
.pft-field-panel-header {
  padding: 12px 14px 8px;
  border-bottom: 1px solid #e4eaf2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.pft-field-panel-title {
  color: #768297;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pft-field-panel-progress {
  color: #8a96ab;
  font-size: 11px;
  margin-left: auto;
}
.pft-field-panel-nav {
  display: flex;
  gap: 4px;
  width: 100%;
  margin-top: 4px;
}
.pft-field-panel-nav button {
  flex: 1;
  height: 26px;
  border: 1px solid #d7dfec;
  border-radius: 7px;
  background: #fff;
  color: #566479;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
}
.pft-field-panel-nav button:hover { background: #eef4ff; color: #1d4ed8; }
.pft-field-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px 10px;
}
.pft-field-panel-body::-webkit-scrollbar { width: 5px; }
.pft-field-panel-body::-webkit-scrollbar-thumb { background: #cbd5e6; border-radius: 3px; }

/* Page group headers */
.pft-fpanel-page-group { margin-bottom: 4px; }
.pft-fpanel-page-header {
  color: #8a96ab;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 0 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.pft-fpanel-page-header .pft-collapse-icon {
  transition: transform 0.15s;
  font-size: 8px;
}
.pft-fpanel-page-header.collapsed .pft-collapse-icon {
  transform: rotate(-90deg);
}

/* Field entries (white cards) */
.pft-fpanel-field {
  background: #fff;
  border: 1px solid #e4eaf2;
  border-radius: 8px;
  padding: 6px 8px;
  margin-bottom: 5px;
  border-left: 3px solid #2563eb;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.pft-fpanel-field:hover { background: #f4f8ff; }
.pft-fpanel-field.active {
  background: #fef2f2;
  border-color: #fecaca;
  border-left-color: #dc2626;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.18);
}
.pft-fpanel-field.signature-entry { border-left-color: #22c55e; }
.pft-fpanel-field.checkbox-entry { border-left-color: #f59e0b; }
.pft-fpanel-field.signature-entry.active,
.pft-fpanel-field.checkbox-entry.active {
  background: #fef2f2;
  border-color: #fecaca;
  border-left-color: #dc2626;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.18);
}

.pft-fpanel-field-label {
  color: #13243b;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.pft-fpanel-field-type {
  color: #768297;
  font-size: 9px;
  background: #eef2f8;
  padding: 1px 5px;
  border-radius: 4px;
}
.pft-fpanel-field-input {
  width: 100%;
  border: 1px solid #d7dfec;
  border-radius: 6px;
  background: #fff;
  color: #13243b;
  font-size: 11px;
  padding: 3px 5px;
  outline: none;
  box-sizing: border-box;
}
.pft-fpanel-field-input:focus { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37, 99, 235, .12); }
.pft-fpanel-field-input::placeholder { color: #aab4c5; }

/* Signature in panel */
.pft-fpanel-sig-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}
.pft-fpanel-sig-preview img {
  max-width: 48px;
  max-height: 24px;
  border-radius: 3px;
  border: 1px solid #d7dfec;
}
.pft-fpanel-sig-upload-btn {
  font-size: 10px;
  color: #1d4ed8;
  background: #fff;
  border: 1px solid #d7dfec;
  border-radius: 6px;
  padding: 2px 6px;
  cursor: pointer;
}
.pft-fpanel-sig-upload-btn:hover { background: #eef4ff; }

/* Checkbox in panel */
.pft-fpanel-checkbox {
  width: 16px;
  height: 16px;
  accent-color: #2563eb;
}

/* ===== Active glow on PDF field =====
   Used when a field is activated from the side panel (no :focus-within on the
   on-page box). Matches the dashed-active look, plus a brief soft glow so the
   jump is noticeable. Kept consistent with focus-within so the two don't fight. */
.pft-field-box.pft-active-glow,
.pft-field-box.signature-field.pft-active-glow,
.pft-field-box.user-added.signature-field.pft-active-glow {
  border: 1.5px dashed rgba(220, 38, 38, 0.9);
  background: rgba(220, 38, 38, 0.11);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14);
  animation: pft-pulse 0.9s ease-out 1;
}
@keyframes pft-pulse {
  0% { box-shadow: 0 0 0 5px rgba(220, 38, 38, 0.32); }
  100% { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14); }
}

/* ===== Tab hint tooltip ===== */
.pft-tab-hint {
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: #13243b;
  color: #aebdd4;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  animation: pft-hint-fade 3s ease-in-out forwards;
}
@keyframes pft-hint-fade {
  0% { opacity: 0; }
  10% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== Signature Modal (draw or upload) ===== */
.pft-sig-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(19, 36, 59, 0.55);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.pft-sig-modal.show { display: flex; }
.pft-sig-card {
  background: #fff;
  border-radius: 18px;
  padding: 24px;
  width: min(520px, 92vw);
  box-shadow: 0 30px 70px rgba(19, 36, 59, 0.4);
}
.pft-sig-card h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 800;
  color: #13243b;
}
.pft-sig-hint {
  margin: 0 0 12px;
  font-size: 12px;
  color: #566479;
}
.pft-sig-canvas {
  width: 100%;
  height: 180px;
  border: 1.5px dashed #b9cdf3;
  border-radius: 12px;
  background: #f7faff;
  cursor: crosshair;
  touch-action: none;       /* let finger-draw work without scrolling the page */
  display: block;
}
.pft-sig-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.pft-sig-spacer { flex: 1; }
.pft-sig-btn {
  border: 1px solid #d7dfec;
  border-radius: 10px;
  background: #fff;
  color: #13243b;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
}
.pft-sig-btn:hover { background: #eef2f8; }
.pft-sig-btn.primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
.pft-sig-btn.primary:hover { background: #1d4ed8; }
.pft-sig-btn:disabled { opacity: 0.45; cursor: default; }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .pft-field-panel { width: 220px; min-width: 220px; }
}
@media (max-width: 768px) {
  .pft-sidebar { display: none; }
  .pft-field-panel { display: none; }
  .pft-editor-layout { height: 75vh; }
  .pft-toolbar { padding: 6px 8px; }
  .pft-font-select { width: 80px; }
}
