/* 富文本排版（P8 M17 · v1.59.0）
 * 单一物理文件，同时服务「后台编辑器」与「门户展示端」—— 这是「编辑端与展示端样式一致」的**唯一保证**：
 *   后台：web/index.html 以 /assets/richtext.css 引入
 *   门户：render.js 以 /assets/richtext.css 引入（由 portal/routes.js 映射到本文件，避免两份拷贝漂移）
 * 结构：
 *   ① .rt-content —— 内容排版（**两端共用**，编辑器的可编辑区也挂这个类）
 *   ② .rt-editor / .rt-toolbar 等 —— 编辑器外壳（仅后台用到，门户加载无副作用）
 * Copyright © 2026 云南紫鸟信息技术有限公司
 */

/* ==================== ① 内容排版（两端共用） ==================== */
.rt-content {
  font-size: 15.5px;
  line-height: 1.85;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.rt-content > :first-child { margin-top: 0; }
.rt-content > :last-child { margin-bottom: 0; }

.rt-content p { margin: 0 0 14px; }
.rt-content div { margin: 0; }                     /* 编辑器换行产生的 div 不占额外间距 */
.rt-content br { line-height: 1.85; }

.rt-content h2 { font-size: 22px; line-height: 1.4; font-weight: 600; margin: 26px 0 12px; }
.rt-content h3 { font-size: 17.5px; line-height: 1.45; font-weight: 600; margin: 22px 0 10px; }
.rt-content h4 { font-size: 15.5px; line-height: 1.5; font-weight: 600; margin: 18px 0 8px; }
.rt-content h2:first-child, .rt-content h3:first-child, .rt-content h4:first-child { margin-top: 0; }

.rt-content ul, .rt-content ol { margin: 8px 0 14px; padding-left: 24px; }
.rt-content ul { list-style: disc; }
.rt-content ol { list-style: decimal; }
.rt-content li { margin: 6px 0; }
.rt-content li > ul, .rt-content li > ol { margin: 6px 0; }

.rt-content blockquote {
  margin: 16px 0; padding: 10px 16px;
  border-left: 3px solid var(--pt-primary, #1f6feb);
  border-radius: 0 8px 8px 0;
  background: var(--pt-soft, #f5f7fb);
  color: var(--pt-muted, #5a6370);
  font-size: 15px;
}
.rt-content blockquote > :last-child { margin-bottom: 0; }

.rt-content a { color: var(--pt-primary, #1f6feb); text-decoration: underline; text-underline-offset: 2px; }
.rt-content a:hover { opacity: .85; }

.rt-content img { max-width: 100%; height: auto; border-radius: 10px; margin: 8px 0; display: block; }

.rt-content code {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: .92em; background: var(--pt-soft, #f1f3f7); border-radius: 4px; padding: 1px 5px;
}
.rt-content pre {
  background: var(--pt-soft, #f1f3f7); border-radius: 8px; padding: 12px 14px;
  overflow-x: auto; margin: 14px 0; white-space: pre;
}
.rt-content pre code { background: none; padding: 0; }
.rt-content hr { border: 0; border-top: 1px solid var(--pt-line, #e6e9ef); margin: 22px 0; }
.rt-content mark { background: #fff3bf; padding: 0 2px; }
.rt-content strong, .rt-content b { font-weight: 600; }

/* ==================== ② 编辑器外壳（后台） ==================== */
.rt-wrap { border: 1px solid var(--line, #e6e9ef); border-radius: 10px; overflow: hidden; background: #fff; }
.rt-toolbar {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 6px 8px; background: var(--soft, #f7f8fa);
  border-bottom: 1px solid var(--line, #e6e9ef);
}
.rt-btn {
  min-width: 30px; height: 30px; padding: 0 8px;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  font: inherit; font-size: 13px; line-height: 1; color: #333; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
}
.rt-btn:hover { background: #eaeef5; }
.rt-btn.is-on { background: #e3ecff; border-color: #b9cdfa; color: #1f4fd8; }
.rt-btn:disabled { opacity: .45; cursor: default; }
.rt-sep { width: 1px; height: 18px; background: var(--line, #e6e9ef); margin: 0 4px; }
.rt-spacer { flex: 1 1 auto; }

.rt-editor {
  min-height: 220px; max-height: 60vh; overflow-y: auto;
  padding: 14px 16px; outline: none;
}
.rt-editor:focus { box-shadow: inset 0 0 0 2px rgba(31, 111, 235, .12); }
.rt-editor:empty::before,
.rt-editor[data-empty="1"]::before { content: attr(data-ph); color: #9aa4b2; }
.rt-editor.is-drag { box-shadow: inset 0 0 0 2px var(--pt-primary, #1f6feb); }

.rt-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 6px 10px; border-top: 1px solid var(--line, #e6e9ef);
  background: #fcfcfd; font-size: 12.5px; color: #6b7280;
}
.rt-hint { margin-left: auto; }

/* 链接输入条（无需 window.prompt，移动端也能用） */
.rt-linkbar { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line, #e6e9ef); background: #fff; }
.rt-linkbar input { flex: 1 1 auto; min-width: 0; border: 1px solid var(--line, #e6e9ef); border-radius: 6px; padding: 6px 8px; font: inherit; font-size: 13px; }

/* 区块编辑器（产品 / 单页） */
.be-list { display: flex; flex-direction: column; gap: 10px; }
.be-card { border: 1px solid var(--line, #e6e9ef); border-radius: 10px; background: #fff; }
.be-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: var(--soft, #f7f8fa); border-bottom: 1px solid var(--line, #e6e9ef); border-radius: 10px 10px 0 0; }
.be-head .be-type { font-size: 13px; font-weight: 600; }
.be-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.be-body .field { margin: 0; }
.be-hint { font-size: 12.5px; color: #6b7280; }

/* ==================== ③ 移动端适配 ==================== */
@media (max-width: 767px) {
  .rt-toolbar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 6px; }
  .rt-toolbar::-webkit-scrollbar { display: none; }
  .rt-btn { min-width: 36px; height: 36px; flex: 0 0 auto; }
  .rt-spacer, .rt-sep { display: none; }
  .rt-editor { min-height: 180px; max-height: none; padding: 12px; font-size: 16px; } /* 16px 防 iOS 聚焦缩放 */
  .rt-content { font-size: 16px; }
  .rt-content h2 { font-size: 20px; }
  .rt-content h3 { font-size: 17px; }
}
