/* ═══════════════ 打印模板编辑器 v2 · 2026-07-18 ═══════════════ */

/* 编辑器容器：全屏 flex 列 */
.pt-editor-root {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: #f5f6f8;
  font-family: 'Microsoft YaHei', 'PingFang SC', -apple-system, sans-serif;
}

/* ═══ 顶部工具栏 ═══ */
.pt-editor-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  flex-shrink: 0;
}
.pt-name-input {
  padding: 6px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 14px;
  width: 260px;
  font-weight: 500;
}
.pt-name-input:focus { border-color: #1677ff; outline: none; box-shadow: 0 0 0 2px rgba(22,119,255,0.15); }
.pt-editor-toolbar select {
  padding: 6px 8px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
}
.pt-toolbar-spacer { flex: 1; }

/* 纵向/横向切换按钮组 */
.pt-orient-group {
  display: inline-flex;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  overflow: hidden;
}
.pt-orient-btn {
  padding: 6px 14px;
  background: #fff;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: #595959;
  border-right: 1px solid #d9d9d9;
  transition: all 0.15s;
}
.pt-orient-btn:last-child { border-right: none; }
.pt-orient-btn:hover { background: #f0f0f0; }
.pt-orient-btn.active {
  background: #1677ff;
  color: #fff;
}

/* ═══ 主体：左字段面板 + 中编辑区 + 右AI/预览抽屉 ═══ */
.pt-editor-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* ═══ 左侧字段面板 ═══ */
.pt-field-panel {
  width: 300px;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  display: flex; flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

/* 顶部关联对象 Tab（横排） */
.pt-object-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 8px 8px 0;
  background: #fafafa;
  border-bottom: 1px solid #e5e7eb;
}
.pt-object-tab {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  color: #595959;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
  white-space: nowrap;
}
.pt-object-tab:hover { color: #1677ff; }
.pt-object-tab.active {
  color: #1677ff;
  border-bottom-color: #1677ff;
  font-weight: 500;
}

.pt-field-hint {
  padding: 8px 14px;
  font-size: 12px;
  color: #8c8c8c;
  background: #fafafa;
  border-bottom: 1px solid #f0f0f0;
}
.pt-field-groups {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.pt-field-group {
  margin-bottom: 8px;
}
.pt-field-group-title {
  padding: 6px 14px;
  font-size: 12px;
  color: #262626;
  font-weight: 600;
  background: #f5f5f5;
  border-left: 3px solid #1677ff;
  margin-bottom: 4px;
}
.pt-field-list {
  padding: 0 8px;
}
.pt-field-item {
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  color: #262626;
  border-radius: 3px;
  margin-bottom: 2px;
  transition: all 0.1s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.pt-field-item:hover {
  background: #e6f4ff;
  color: #0958d9;
}
.pt-field-item:active {
  background: #bae0ff;
}
.pt-field-detail {
  background: #fffbe6;
  border: 1px dashed #ffa940;
}
.pt-field-detail:hover {
  background: #fff1b8;
}
.pt-field-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 1px 6px;
  background: #ffa940;
  color: #fff;
  border-radius: 8px;
}

/* ═══ 中央编辑区 · A4 白纸样式 ═══ */
.pt-tinymce-wrapper {
  flex: 1;
  background: #e9ecef;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 20px 0;
  min-width: 0;
}
.pt-paper-wrap {
  width: 100%;
  max-width: 100%;
  display: flex;
  justify-content: center;
}
.pt-paper-wrap > .tox-tinymce {
  width: 100% !important;
  border: none !important;
  background: transparent !important;
}
/* TinyMCE 工具栏保持吸顶 */
.pt-paper-wrap .tox-editor-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
/* 编辑区 iframe 边框去掉，让 A4 纸自己带阴影 */
.pt-paper-wrap .tox-edit-area {
  background: #e9ecef !important;
}
.pt-paper-wrap .tox-edit-area__iframe {
  background: transparent !important;
}

/* ═══ 右侧 AI 抽屉 ═══ */
.pt-ai-drawer {
  width: 340px;
  background: #fff;
  border-left: 1px solid #e5e7eb;
  display: flex; flex-direction: column;
  box-shadow: -2px 0 8px rgba(0,0,0,0.05);
  flex-shrink: 0;
  z-index: 20;
}
.pt-ai-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, #722ed1, #9254de);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
}
.pt-ai-close {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 8px;
  border-radius: 3px;
}
.pt-ai-close:hover { background: rgba(255,255,255,0.15); }
.pt-ai-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.pt-ai-hint {
  font-size: 12px;
  color: #8c8c8c;
  margin-bottom: 10px;
}
.pt-ai-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 13px;
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
}
.pt-ai-input:focus { border-color: #722ed1; outline: none; box-shadow: 0 0 0 2px rgba(114,46,209,0.15); }
.pt-ai-actions {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 12px;
}
.pt-ai-actions .wk-btn {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
}
.pt-ai-actions .wk-btn-primary {
  background: linear-gradient(135deg, #722ed1, #9254de);
  border-color: #722ed1;
}
.pt-ai-quick-title {
  font-size: 12px;
  color: #8c8c8c;
  margin: 20px 0 8px;
  padding-top: 12px;
  border-top: 1px solid #f0f0f0;
}
.pt-ai-quick {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.pt-ai-quick-btn {
  padding: 6px 12px;
  background: #f5f0ff;
  color: #722ed1;
  border: 1px solid #d3adf7;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.pt-ai-quick-btn:hover {
  background: #722ed1;
  color: #fff;
  border-color: #722ed1;
}

/* ═══ 半屏预览抽屉 ═══ */
.pt-preview-half {
  width: 50%;
  background: #e9ecef;
  border-left: 1px solid #d9d9d9;
  display: flex; flex-direction: column;
  box-shadow: -2px 0 12px rgba(0,0,0,0.08);
  flex-shrink: 0;
  z-index: 20;
}
.pt-preview-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: #1677ff;
  color: #fff;
  font-size: 15px;
  font-weight: 500;
}
.pt-preview-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.pt-preview-paper {
  background: #fff;
  padding: 20mm;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  border-radius: 2px;
  font-family: simsun, serif;
  line-height: 1.6;
  min-height: 300px;
}
.pt-preview-paper table { border-collapse: collapse; width: 100%; }
.pt-preview-paper table, .pt-preview-paper th, .pt-preview-paper td { border: 1px solid #333; padding: 6px; }

/* ═══ 兼容 wk-btn 若未定义 ═══ */
.wk-btn {
  padding: 6px 14px;
  background: #fff;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: #262626;
  transition: all 0.15s;
  white-space: nowrap;
}
.wk-btn:hover { border-color: #1677ff; color: #1677ff; }
.wk-btn-primary { background: #1677ff; color: #fff; border-color: #1677ff; }
.wk-btn-primary:hover { background: #4096ff; border-color: #4096ff; color: #fff; }
.wk-btn:disabled { opacity: 0.5; cursor: not-allowed; }
