/* ============================================================
   PDFSTUDIO — 文件编辑 (module 12, HR) — chỉ class RIÊNG module này.
   ============================================================ */

.pdfst-wrap { display: flex; flex-direction: column; gap: var(--sp-3); }

/* — Toolbar — */
.pdfst-toolbar {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  padding: var(--sp-3); border-radius: var(--r-lg);
  background: var(--bg-2); border: 1px solid var(--line-2);
}
.pdfst-toolbar .spacer { flex: 1; }
.pdfst-toolbar label.btn { cursor: pointer; }
.btn.pdfst-on {
  background: var(--purple-soft); border-color: var(--purple-l); color: var(--purple-xl);
  box-shadow: var(--glow-purple);
}

/* — Gợi ý khi bật chế độ Chèn chữ — */
.pdfst-hint {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 9px var(--sp-4); border-radius: var(--r-md);
  background: var(--gold-soft); border: 1px solid var(--gline);
  color: var(--gold-l); font-size: var(--fs-label);
  animation: fadeUp var(--mo-base) var(--ease-out);
}

/* — Layout 2 cột: rail trái + stage giữa — */
.pdfst-layout { display: grid; grid-template-columns: 156px 1fr; gap: var(--sp-4); align-items: start; }
@media (max-width: 720px) { .pdfst-layout { grid-template-columns: 1fr; } }
/* Stage wrap column fills remaining space */
.pdfst-stage-wrap { min-width: 0; }

/* — Rail (danh sách trang) — */
.pdfst-rail {
  display: flex; flex-direction: column; gap: var(--sp-3);
  max-height: 70vh; overflow-y: auto; padding-right: 2px;
}
.pdfst-thumb {
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: var(--card); cursor: pointer; overflow: hidden;
  transition: border-color var(--mo-fast), background var(--mo-fast), transform var(--mo-fast);
}
.pdfst-thumb:hover { border-color: var(--line); background: var(--hover); transform: translateY(-1px); }
.pdfst-thumb.sel { border-color: var(--purple-l); box-shadow: var(--glow-purple); background: var(--purple-soft); }
.pdfst-thumb-surface {
  aspect-ratio: 210 / 297; background: var(--bg-1); position: relative; overflow: hidden;
  display: grid; place-items: center;
}
.pdfst-thumb-rot { position: relative; width: 100%; height: 100%; transition: transform var(--mo-base) var(--ease-out); }
.pdfst-thumb-rot img { width: 100%; height: 100%; object-fit: contain; }
.pdfst-blank-mark { width: 100%; height: 100%; display: grid; place-items: center; color: var(--faint); }
.pdfst-blank-mark .ic { width: 20px; height: 20px; }
.pdfst-thumb-text {
  position: absolute; width: 10px; height: 3px; border-radius: 2px;
  background: var(--gold-l); transform: translate(-50%, -50%);
}
.pdfst-thumb-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px; border-top: 1px solid var(--line-2); background: var(--card-2);
}
.pdfst-thumb-n { font-size: 10.5px; color: var(--faint); font-weight: 700; }
.pdfst-thumb-ord { display: flex; gap: 2px; }
.pdfst-thumb-ord button {
  width: 20px; height: 20px; display: grid; place-items: center; border-radius: 5px;
  color: var(--muted); transition: background var(--mo-fast), color var(--mo-fast);
}
.pdfst-thumb-ord button:hover:not(:disabled) { background: var(--hover-2); color: var(--ink); }
.pdfst-thumb-ord button:disabled { opacity: .3; cursor: not-allowed; }
.pdfst-thumb-ord button .ic { width: 13px; height: 13px; }
.pdfst-thumb-ord button[data-up] .ic { transform: rotate(180deg); }

/* — Stage (trang đang sửa, phóng to) — */
.pdfst-stage { display: flex; flex-direction: column; gap: var(--sp-2); align-items: center; }
.pdfst-stage-hd { display: flex; align-items: center; gap: var(--sp-2); align-self: flex-start; }
.pdfst-stage-n { font-size: var(--fs-label); color: var(--muted); font-weight: 700; }
.pdfst-stage-n .cn { color: var(--faint); font-weight: 400; }

.pdfst-page {
  width: min(520px, 100%); aspect-ratio: 210 / 297; position: relative;
  border-radius: var(--r-lg); overflow: hidden;
  background: var(--bg-1); border: 1px solid var(--line); box-shadow: var(--el-2);
}
.pdfst-page-surface { position: relative; width: 100%; height: 100%; transition: transform var(--mo-base) var(--ease-out); }
.pdfst-page-surface img { width: 100%; height: 100%; object-fit: contain; user-select: none; }
.pdfst-blank-page {
  width: 100%; height: 100%; display: flex; flex-direction: column; gap: var(--sp-2);
  align-items: center; justify-content: center; color: var(--faint);
  background:
    repeating-linear-gradient(135deg, rgba(167,139,250,.05) 0 10px, transparent 10px 20px);
}
.pdfst-blank-page .ic { width: 30px; height: 30px; }
.pdfst-blank-page span { font-size: var(--fs-body); }
.pdfst-blank-page .cn { color: var(--faint); font-size: var(--fs-label); }

.pdfst-text {
  position: absolute; transform: translate(-2px, -50%);
  padding: 3px 8px; border-radius: 5px; font-size: 13px; font-weight: 600;
  background: rgba(243,213,118,.16); color: var(--gold-l);
  border: 1px solid var(--gline); white-space: nowrap; cursor: pointer;
  max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis;
  animation: fadeUp var(--mo-fast) var(--ease-out);
}
.pdfst-text:hover { background: rgba(243,213,118,.28); }

/* — Crosshair cursor khi bật chế độ text/frame — */
#pdfst-canvas { cursor: default; }
#pdfst-canvas.cursor-crosshair { cursor: crosshair; }

/* — Divider trong toolbar — */
.pdfst-tb-divider { width: 1px; height: 22px; background: var(--line-2); margin: 0 2px; flex: none; }

/* — Zoom controls — */
.pdfst-zoom-row { display: flex; align-items: center; gap: 4px; }
.pdfst-zoom-val { font-family: var(--mono); font-size: var(--fs-label); color: var(--muted); min-width: 36px; text-align: center; }

/* — Rail header — */
.pdfst-rail-hd { font-size: 10px; font-weight: 700; letter-spacing: .8px; color: var(--faint); padding: 0 4px 4px; border-bottom: 1px solid var(--line-2); }

/* — Stage wrapper (stage + bottom bar) — */
.pdfst-stage-wrap { display: flex; flex-direction: column; gap: 0; }
.pdfst-stage { display: flex; flex-direction: column; gap: var(--sp-2); align-items: center; }

/* — Bottom hint bar — */
.pdfst-bottombar {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2);
  padding: 8px var(--sp-3); border-radius: 0 0 var(--r-md) var(--r-md);
  background: var(--bg-2); border: 1px solid var(--line-2); border-top: none;
  font-size: 11px; color: var(--faint); margin-top: -1px;
}
.pdfst-bottombar .ic { width: 13px; height: 13px; flex: none; }
.pdfst-bottombar kbd {
  display: inline-block; padding: 1px 5px; border-radius: 4px;
  background: var(--bg-3); color: var(--muted); font-size: 10.5px; font-family: var(--mono);
  border: 1px solid var(--line); margin: 0 2px;
}
.pdfst-mode-hint { color: var(--gold-l); font-weight: 700; background: var(--gold-soft); padding: 2px 8px; border-radius: var(--r-pill); }

/* — Export dropdown — */
.pdfst-export-dd {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 100;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 12px; min-width: 260px; box-shadow: var(--el-4);
  animation: fadeUp var(--mo-fast) var(--ease-out);
}
.pdfst-dd-head { font-size: 10px; font-weight: 700; letter-spacing: .8px; color: var(--faint); margin-bottom: 6px; }
.pdfst-dd-opt {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  padding: 10px; border-radius: var(--r-md); text-align: left; cursor: pointer;
  transition: background var(--mo-fast); background: transparent;
  border: 1px solid transparent; color: var(--ink); margin-bottom: 4px;
}
.pdfst-dd-opt:hover { background: var(--hover); }
.pdfst-dd-opt.sel { background: var(--purple-soft); border-color: var(--purple-l); }
.pdfst-dd-ic { width: 32px; height: 32px; border-radius: var(--r-md); background: var(--bg-3); display: grid; place-items: center; flex: none; }
.pdfst-dd-ic .ic { width: 16px; height: 16px; }
.pdfst-dd-nm { font-weight: 700; font-size: var(--fs-body); }
.pdfst-dd-sub { font-size: 10.5px; color: var(--faint); margin-top: 2px; }
.pdfst-dd-chk { margin-left: auto; color: var(--purple-xl); font-size: 14px; font-weight: 700; flex: none; }
.pdfst-dd-scope { display: flex; gap: 8px; margin-bottom: 4px; }
.pdfst-dd-scope-btn {
  flex: 1; padding: 8px; border-radius: var(--r-md); font-size: var(--fs-label); font-weight: 600;
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--muted); cursor: pointer;
  transition: all var(--mo-fast);
}
.pdfst-dd-scope-btn.sel { background: var(--purple-soft); border-color: var(--purple-l); color: var(--purple-xl); }

/* — Text frame overlay — */
.pdfst-frame {
  position: absolute; transform: translate(-2px, -50%);
  padding: 5px 10px; border-radius: 5px; font-size: 13px; font-weight: 600;
  background: rgba(124,58,237,.14); color: var(--purple-xl);
  border: 1.5px solid var(--purple-l); white-space: nowrap; cursor: pointer;
  max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis;
  animation: fadeUp var(--mo-fast) var(--ease-out);
}
.pdfst-frame:hover { background: rgba(124,58,237,.26); }

/* — Trạng thái rỗng — */
.pdfst-empty {
  width: min(520px, 100%); aspect-ratio: 210 / 297; border-radius: var(--r-lg);
  border: 1px dashed var(--line-2); display: flex; flex-direction: column; gap: var(--sp-2);
  align-items: center; justify-content: center; color: var(--faint);
}
.pdfst-empty .ic { width: 26px; height: 26px; }
