/* ==========================================================================
   套打模板设计器样式
   ========================================================================== */

.tpl-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 128px);
  min-height: 560px;
  background: var(--bg);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

/* ---------------- 顶部工具条 ---------------- */
.tpl-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.tpl-toolbar .btn { white-space: nowrap; }
.tpl-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}
.tpl-lbl { font-size: 12px; color: var(--muted); }
.tpl-zoom {
  min-width: 48px;
  text-align: center;
  font-size: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.tpl-select {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.tpl-papers { display: flex; gap: 3px; flex-wrap: wrap; }
.tpl-pp {
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: .12s;
}
.tpl-pp:hover { border-color: var(--primary); color: var(--text); }
.tpl-pp.on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
/* 「设为默认」按钮的激活态 */
.tpl-toolbar .btn.on {
  background: rgba(240,178,44,.15);
  border-color: #f0b22c;
  color: #b8791a;
}
.tpl-toolbar .btn:disabled {
  opacity: .6;
  cursor: default;
}

/* ---------------- 主体三栏 ---------------- */
.tpl-body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

/* 左侧字段面板 */
.tpl-panel {
  width: 188px;
  flex: 0 0 188px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 10px 9px 24px;
}
.tpl-grp { margin-bottom: 13px; }
.tpl-grp-t {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--border);
}
.tpl-grp-tip {
  margin-top: 5px;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.5;
  padding: 3px 6px;
  background: var(--bg);
  border-radius: 4px;
  border-left: 2px solid var(--primary);
}
.tpl-grp-b { display: flex; flex-wrap: wrap; gap: 4px; }
.tpl-chip {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: .12s;
  user-select: none;
}
.tpl-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft, rgba(47,111,237,.07));
}
.tpl-chip[draggable] { cursor: grab; }

/* 中间画布 */
.tpl-canvas-wrap {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  overflow: hidden;
  background: #eef1f6;
}
.tpl-scroll {
  position: absolute;
  inset: 0;
  overflow: auto;
  padding: 26px 26px 40px 30px;
}
.tpl-page {
  position: relative;
  background: #fff;
  box-shadow: 0 3px 16px rgba(30,45,80,.18);
  margin: 0 auto;
}

/* 标尺 */
.tpl-ruler-h, .tpl-ruler-v {
  position: absolute;
  background: #e2e6ee;
  color: #7a8699;
  font-size: 9px;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}
.tpl-ruler-h {
  top: 0; left: 30px; right: 0; height: 20px;
  border-bottom: 1px solid #cfd6e2;
}
.tpl-ruler-h span {
  position: absolute;
  top: 2px;
  padding-left: 2px;
  border-left: 1px solid #b6bfcd;
  height: 16px;
  line-height: 16px;
}
.tpl-ruler-v {
  top: 20px; left: 0; bottom: 0; width: 30px;
  border-right: 1px solid #cfd6e2;
}
.tpl-ruler-v span {
  position: absolute;
  left: 2px;
  padding-top: 1px;
  border-top: 1px solid #b6bfcd;
  width: 26px;
  height: 1px;
}

/* 画布上的元素 */
.tpl-el {
  position: absolute;
  border: 1px dashed rgba(70,110,170,.55);
  background: rgba(70,110,170,.045);
  cursor: move;
  user-select: none;
  overflow: hidden;
  line-height: 1.25;
  white-space: nowrap;
}
.tpl-el:hover { border-color: var(--primary); background: rgba(70,110,170,.1); }
.tpl-el.sel {
  border: 1px solid var(--primary);
  background: rgba(47,111,237,.12);
  box-shadow: 0 0 0 1px rgba(47,111,237,.35);
}
.tpl-el.hidden-el { opacity: .35; }
.tpl-el.tpl-line { border: none; border-top: 1px solid #4a6ea9; height: 0 !important; }
.tpl-el.tpl-rect { background: transparent; }
.tpl-el.tpl-table { background: rgba(70,110,170,.03); }
.tpl-tag {
  display: inline-block;
  font-size: 9px;
  color: #7a8699;
  vertical-align: top;
  margin-right: 3px;
}
.tpl-val { color: #2b3a52; }
.tpl-thead {
  display: flex;
  background: #e8eef8;
  border-bottom: 1px solid #4a6ea9;
}
.tpl-tc {
  padding: 1px 3px;
  font-size: 10px;
  color: #2b3a52;
  border-right: 1px solid #b9c6dc;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tpl-tbody {
  padding: 3px;
  font-size: 10px;
  color: #8b95a8;
}

/* 右侧属性栏 */
.tpl-props {
  width: 216px;
  flex: 0 0 216px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 11px 11px 26px;
}
.tpl-props-sec { margin-bottom: 16px; }
.tpl-props-t {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}
.tpl-f {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}
.tpl-f > span { flex: 0 0 52px; }
.tpl-f input[type=text],
.tpl-f input[type=number],
.tpl-f select {
  flex: 1 1 auto;
  min-width: 0;
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
}
.tpl-f input[type=checkbox] { flex: 0 0 auto; }
.tpl-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.9;
  padding: 10px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px dashed var(--border);
}
.tpl-col {
  display: flex;
  gap: 3px;
  align-items: center;
  margin-bottom: 5px;
}
.tpl-col input, .tpl-col select {
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 11px;
  padding: 0 4px;
}
.tpl-x {
  width: 20px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
.tpl-x:hover { border-color: #d9534f; color: #d9534f; }

/* ==========================================================================
   打印模板选择器(打印时弹的模板卡片列表)
   ========================================================================== */
.tpl-pick-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 9px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 2px;
}
.tpl-pick {
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
  transition: .12s;
  display: block;
  width: 100%;
}
.tpl-pick:hover {
  border-color: var(--primary);
  background: rgba(47,111,237,.06);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(30,45,80,.10);
}
.tpl-pick:active { transform: translateY(0); }
.tpl-pick-h {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.tpl-pick-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tpl-pick-m {
  font-size: 11px;
  color: var(--muted);
}
.tpl-pick.quick {
  border-style: dashed;
}
.tpl-pick.quick .tpl-pick-name { color: var(--muted); }

/* ---------------- 打印渲染的元素样式 ---------------- */
.tp-el { position: absolute; overflow: hidden; line-height: 1.25; }
.tp-line { border-top: 0.2mm solid #000; height: 0 !important; }
.tp-table { width: 100%; border-collapse: collapse; }
.tp-table th, .tp-table td {
  border: 0.2mm solid #000;
  padding: 0.6mm 1mm;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tp-table th { font-weight: 700; }
