/* ============================================================
   WindX Make 製作臺樣式
   ============================================================ */

.make-section { padding: 26px 0 48px; }
.make-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
@media (max-width: 960px) {
  .make-layout { grid-template-columns: 1fr; }
}

/* ---------- 側欄 ---------- */
.make-side {
  position: sticky;
  top: calc(var(--header-h) + 14px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - var(--header-h) - 28px);
  overflow-y: auto;
  padding-right: 2px;
}
@media (max-width: 960px) {
  .make-side { position: static; max-height: none; }
}
.make-panel-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
}
.make-panel-card h3 {
  font-size: 13.5px;
  color: var(--navy);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.make-panel-card h3 .step {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

/* 模板卡折疊:選中文檔後收起列表,讓購買/字段/導出面板進入視口 */
.make-panel-card.is-folded .tpl-body { display: none; }
.make-panel-card.is-folded { padding-bottom: 12px; }
.tpl-unfold {
  margin-left: auto;
  border: 1px solid var(--line);
  background: #f2f7fa;
  color: var(--navy);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}
.tpl-unfold:hover { background: #e4eef5; }

/* 模板選擇 */
.tpl-pick-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--blue-700);
  margin-bottom: 8px;
}
.tpl-country-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
/* 其他國家下拉:跨滿兩列,緊跟常用按鈕之後 */
.tpl-country-select {
  grid-column: 1 / -1;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--navy);
  padding: 7px 8px;
  font-size: 12px;
  cursor: pointer;
}
.tpl-country-select:focus { border-color: var(--blue-500); outline: none; background: var(--blue-soft); }
.tpl-country {
  display: flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--navy);
  min-width: 0;
}
.tpl-country:hover { border-color: var(--blue-500); background: var(--blue-soft); }
.tpl-country.is-on { border-color: var(--navy); background: var(--blue-soft); font-weight: 700; }
.tpl-country-flag { flex: none; font-size: 14px; line-height: 1; }
.tpl-country b { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; font-weight: inherit; }
.tpl-country i { flex: none; font-style: normal; font-size: 10px; color: var(--muted); }
.tpl-country.is-on i { color: var(--blue-700); }
.tpl-search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  background: var(--bg);
}
.tpl-search:focus { border-color: var(--blue-500); }
.tpl-type-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tpl-type {
  border: 1px solid var(--line); background: #fff; color: var(--navy);
  border-radius: 999px; padding: 3px 10px; font-size: 11.5px; cursor: pointer;
  font-family: inherit; line-height: 1.4;
}
.tpl-type i { font-style: normal; color: var(--muted); margin-left: 4px; font-size: 10.5px; }
.tpl-type.is-on { background: var(--navy); color: #fff; border-color: var(--navy); }
.tpl-type.is-on i { color: rgba(255, 255, 255, 0.75); }
.tpl-list {
  margin-top: 10px;
  max-height: 480px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tpl-group { display: flex; flex-direction: column; gap: 5px; }
.tpl-group-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; font-weight: 700; color: var(--navy);
  background: var(--blue-soft); border: 1px solid var(--line);
  border-radius: 8px; padding: 4px 10px; position: sticky; top: 0; z-index: 1;
}
.tpl-group-head i { font-style: normal; color: var(--muted); font-weight: 400; font-size: 10.5px; }
.tpl-item b em.tpl-tag {
  font-style: normal; font-size: 10px; font-weight: 600; border-radius: 4px;
  padding: 0 5px; margin-left: 6px; vertical-align: 1px;
}
.tpl-tag.pdf { background: rgba(2, 167, 240, 0.12); color: #0273a3; }
.tpl-tag.docx { background: rgba(47, 104, 230, 0.12); color: #2e56d8; }
.tpl-tag.docx-mod { background: rgba(224, 146, 32, 0.15); color: #b07908; }
.tpl-item {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 9px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: #fff;
}
.tpl-item:hover { border-color: var(--blue-500); background: var(--blue-soft); }
.tpl-item.is-active { border-color: var(--navy); background: var(--blue-soft); }
.tpl-item img { width: 40px; height: 52px; object-fit: cover; border-radius: 5px; background: #f3f0e9; flex: none; }
.tpl-item-meta { min-width: 0; }
.tpl-item-meta b { display: block; font-size: 12.5px; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-item-meta span { font-size: 11px; color: var(--muted); }

/* 字段表單 */
.field-row { margin-bottom: 10px; }
.field-row label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--blue-700);
  margin-bottom: 4px;
}
.field-row label small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.field-row input, .field-row select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  background: var(--bg);
}
.field-row input:focus, .field-row select:focus { border-color: var(--blue-500); }
.field-row input:disabled { background: #eef1f5; color: #9aa8b8; }
.field-hint { font-size: 11.5px; color: var(--muted); margin: 8px 0 0; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; white-space: nowrap; }
.btn-outline-blue {
  border: 1px solid var(--blue-500);
  color: var(--blue-700);
  background: #fff;
}
.btn-outline-blue:hover { background: var(--blue-soft); }

/* ---------- 主區(畫布) ---------- */
.make-main {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 520px;
}
.make-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
  flex-wrap: wrap;
}
.make-toolbar .spacer { flex: 1; }
.tool-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tool-btn:hover { border-color: var(--blue-500); color: var(--blue-700); background: var(--blue-soft); }
.tool-btn.is-on { background: var(--navy); border-color: var(--navy); color: #fff; }
.tool-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.tool-zoom {
  min-width: 110px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.make-canvas-wrap {
  flex: 1;
  overflow: auto;
  background: #e8edf2;
  display: flex;
  justify-content: center;
  padding: 22px;
  position: relative;
}
.make-canvas-stack {
  position: relative;
  flex: none;
  box-shadow: 0 10px 40px rgba(26, 44, 64, 0.25);
  background: #fff;
}
.make-canvas-stack canvas { display: block; }
.make-canvas-stack.is-annotating { cursor: crosshair; }
.make-field-box {
  position: absolute;
  border: 2px solid #e35d6a;
  border-radius: 3px;
  box-sizing: border-box;
  cursor: move;
  pointer-events: auto;
}
.make-field-box.is-selected { border-color: var(--blue); border-width: 2.5px; box-shadow: 0 0 0 3px rgba(2, 167, 240, 0.25); }
.make-field-box .fb-tag {
  position: absolute;
  top: -20px;
  left: -2px;
  background: #e35d6a;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 5px 5px 5px 0;
  white-space: nowrap;
}
.make-field-box.is-selected .fb-tag { background: var(--blue); }
.make-statusbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  background: #fbfdff;
  font-size: 12.5px;
  color: var(--muted);
  min-height: 36px;
}
.make-statusbar .progress {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
  display: none;
}
.make-statusbar .progress.is-on { display: block; }
.make-statusbar .progress i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--green));
  transition: width 0.2s;
}
.make-empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  max-width: 420px;
}
.make-empty h2 { color: var(--navy); font-size: 19px; margin-bottom: 10px; }
.make-empty p { font-size: 13.5px; margin: 0 0 18px; }

/* 彈窗(手動標註) */
.make-modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(26, 44, 64, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
}
.make-modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: min(400px, 92vw);
  padding: 18px 20px;
}
.make-modal h3 { margin: 0 0 12px; font-size: 15px; color: var(--navy); }
.make-modal .field-row { margin-bottom: 12px; }
.make-modal .btn-row { margin-top: 14px; }

/* 導出成功提示 */
.make-toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.make-toast.is-on { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* docx 修改對照 */
.mdx-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.mdx-head b { font-size: 13.5px; color: var(--navy); line-height: 1.4; }
.mdx-sub { font-size: 11.5px; color: var(--muted); }
.mdx-lead { font-size: 12.5px; color: var(--navy); margin: 0 0 8px; line-height: 1.55; }
.mdx-table-wrap { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 9px; }
.mdx-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.mdx-table thead th {
  position: sticky; top: 0; background: var(--bg); z-index: 1;
  text-align: left; font-size: 11px; color: var(--muted); font-weight: 600;
  padding: 5px 8px; border-bottom: 1px solid var(--line);
}
.mdx-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; line-height: 1.5; word-break: break-word; }
.mdx-table tr:last-child td { border-bottom: 0; }
.mdx-idx { color: var(--muted); width: 22px; }
.mdx-old { color: #b0483f; background: #fdf3f2; }
.mdx-new { color: #1f7a58; background: #f0f9f4; }
.mdx-kind { font-style: normal; font-size: 10px; font-weight: 700; border-radius: 4px; padding: 1px 5px; white-space: nowrap; }
.mdx-replace { background: rgba(224, 146, 32, 0.15); color: #b07908; }
.mdx-insert { background: rgba(31, 122, 88, 0.13); color: #1f7a58; }
.mdx-delete { background: rgba(176, 72, 63, 0.13); color: #b0483f; }
.mdx-dl { white-space: nowrap; }
