/* ============================================================
   WF 富文本编辑器（自研，替换原 Tiptap 界面）
   方案：新编辑器接管界面 → 内容变化时通过 paste 事件同步给隐藏的原编辑器
        → ProseMirror 更新 state → Vue modelValue 同步（已验证可行）
   ============================================================ */

.wf-editor {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.wf-editor:focus-within {
  border-color: #bfd3ff;
  box-shadow: 0 0 0 3px rgba(47, 107, 255, .08);
}

/* ---------- 工具栏 ---------- */
.wf-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: #f8fafc;
  border-bottom: 1px solid #eef2f7;
  min-height: 42px;
  position: relative;
}
.wf-btn {
  height: 28px;
  min-width: 28px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #4b5563;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s, border-color .12s;
  white-space: nowrap;
  font-family: inherit;
}
.wf-btn:hover { background: #e9eef6; color: #111827; }
.wf-btn.active {
  background: #e8f0ff;
  color: #2f6bff;
  border-color: #d6e4ff;
  font-weight: 600;
}
.wf-btn.wf-wide { min-width: 44px; }
.wf-btn.wf-accent { color: #e8590c; font-weight: 600; }
.wf-btn.wf-accent:hover { background: #fff7ed; border-color: #fed7aa; }
.wf-btn svg { width: 14px; height: 14px; display: block; }

.wf-sep {
  width: 1px;
  height: 16px;
  background: #e2e8f0;
  margin: 0 4px;
  flex: none;
}

.wf-select {
  height: 28px;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  background: #fff;
  color: #374151;
  font-size: 12px;
  padding: 0 4px;
  cursor: pointer;
  outline: none;
  font-family: inherit;
}
.wf-select:hover { border-color: #cbd5e1; }
.wf-select:focus { border-color: #2f6bff; box-shadow: 0 0 0 2px rgba(47,107,255,.1); }

/* 颜色按钮 */
.wf-color-wrap {
  position: relative;
  display: inline-flex;
}
.wf-color-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 28px;
  width: 26px;
  border-radius: 5px;
  border: 1px solid transparent;
  cursor: pointer;
  color: #4b5563;
  font-size: 13px;
  font-weight: 700;
  position: relative;
}
.wf-color-label:hover { background: #e9eef6; }
.wf-color-bar {
  position: absolute;
  left: 4px; right: 4px; bottom: 3px;
  height: 3px;
  border-radius: 1px;
  background: #111827;
}

/* ---------- 正文 ---------- */
.wf-body {
  min-height: 300px;
  max-height: 480px;
  overflow-y: auto;
  padding: 16px 18px;
  font-size: 14px;
  line-height: 1.85;
  color: #1f2937;
  outline: none;
  word-break: break-word;
}
.wf-body:empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
  font-size: 13px;
  pointer-events: none;
}
.wf-body p { margin: 0 0 8px; }
.wf-body p:last-child { margin-bottom: 0; }
.wf-body h1 { font-size: 22px; font-weight: 700; margin: 16px 0 10px; }
.wf-body h2 { font-size: 19px; font-weight: 700; margin: 14px 0 9px; }
.wf-body h3 { font-size: 16px; font-weight: 700; margin: 12px 0 8px; }
.wf-body blockquote {
  border-left: 3px solid #d6e4ff;
  padding: 2px 0 2px 12px;
  color: #4b5563;
  margin: 8px 0;
}
.wf-body img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  cursor: pointer;
}
/* 图片选中态 */
.wf-body img.wf-selected {
  outline: 2px solid #2f6bff;
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(47,107,255,.12);
}
.wf-body a { color: #2f6bff; text-decoration: underline; }
.wf-body hr { border: 0; border-top: 1px solid #e5e7eb; margin: 14px 0; }
.wf-body table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.wf-body table td, .wf-body table th {
  border: 1px solid #e5e7eb;
  padding: 6px 10px;
  font-size: 13px;
}
.wf-body table th { background: #f8fafc; font-weight: 600; }

/* 滚动条 */
.wf-body::-webkit-scrollbar { width: 8px; }
.wf-body::-webkit-scrollbar-thumb { background: #dbe1ea; border-radius: 4px; }
.wf-body::-webkit-scrollbar-thumb:hover { background: #c3ccd9; }

/* ---------- 图片浮动操作条 ---------- */
.wf-imgbar {
  position: absolute;
  z-index: 9999;
  display: none;
  gap: 2px;
  padding: 3px;
  background: #1f2937;
  border-radius: 7px;
  box-shadow: 0 6px 20px rgba(0,0,0,.28);
}
.wf-imgbar.show { display: flex; }
.wf-imgbar button {
  height: 24px;
  padding: 0 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #e5e7eb;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.wf-imgbar button:hover { background: #374151; color: #fff; }
.wf-imgbar button.on { background: #2f6bff; color: #fff; }

/* ---------- 源码模式 ---------- */
.wf-source {
  width: 100%;
  min-height: 300px;
  max-height: 480px;
  padding: 14px 16px;
  border: 0;
  outline: none;
  resize: vertical;
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  line-height: 1.7;
  color: #1f2937;
  display: none;
}
.wf-editor.source-mode .wf-body { display: none; }
.wf-editor.source-mode .wf-source { display: block; }

/* ---------- 提示条 ---------- */
.wf-tip {
  padding: 4px 10px;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  font-size: 11px;
  color: #92400e;
}

/* 隐藏原编辑器（保留可交互，仅视觉隐藏） */
.wf-original-hidden {
  position: absolute !important;
  left: -99999px !important;
  top: 0 !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
