/**
 * 富文本通用样式库
 * 适用场景：文章内容、编辑器输出、评论区等 HTML 富文本渲染
 * 核心特点：高可读性、响应式、美观统一、低侵入性
 */

/* 富文本容器基础样式 */
.rich-text {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  font-size: 16px;
  line-height: 1.8;
  color: #333;
  max-width: 100%;
  padding: 16px;
  box-sizing: border-box;
}

/* 重置基础样式 */
.rich-text * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.rich-text p {
  margin: 12px 0;
  text-align: justify;
}

/* 标题样式 */
.rich-text h1 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.4;
  margin: 24px 0 16px;
  color: #222;
  border-bottom: 1px solid #eee;
  padding-bottom: 8px;
}

.rich-text h2 {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.4;
  margin: 20px 0 12px;
  color: #222;
  border-left: 4px solid #ff4040;
  padding-left: 12px;
}

.rich-text h3 {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
  margin: 16px 0 10px;
  color: #222;
}

.rich-text h4 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
  margin: 14px 0 8px;
  color: #222;
}

.rich-text h5,
.rich-text h6 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  margin: 12px 0 6px;
  color: #222;
}

/* 链接样式 */
.rich-text a {
  color: #ff4040;
  text-decoration: none;
  border-bottom: 1px dotted #ff4040;
  transition: all 0.3s ease;
}

.rich-text a:hover {
  color: #ff1818;
  border-bottom: 1px solid #ff1818;
}

/* 列表样式 */
.rich-text ul,
.rich-text ol {
  margin: 12px 0 12px 24px;
}

.rich-text ul ul,
.rich-text ul ol,
.rich-text ol ul,
.rich-text ol ol {
  margin: 6px 0 6px 20px;
}

.rich-text ul {
  list-style-type: disc;
}

.rich-text ol {
  list-style-type: decimal;
}

.rich-text li {
  margin: 6px 0;
}

/* 图片样式（响应式） */
.rich-text img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 16px auto;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 表格样式 */
.rich-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  background-color: #fff;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.rich-text th,
.rich-text td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.rich-text th {
  background-color: #f8f9fa;
  font-weight: 600;
  color: #222;
}

.rich-text tr:last-child td {
  border-bottom: none;
}

.rich-text tr:hover {
  background-color: #f8f9fa;
}

/* 引用样式 */
.rich-text blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 4px solid #ff4040;
  background-color: #f5f8ff;
  color: #666;
  font-style: italic;
}

/* 行内元素样式 */
.rich-text strong,
.rich-text b {
  font-weight: 700;
  color: #222;
}

.rich-text em,
.rich-text i {
  font-style: italic;
}

.rich-text u {
  text-decoration: underline;
}

.rich-text del,
.rich-text s {
  text-decoration: line-through;
  color: #999;
}

/* 代码样式 */
.rich-text code {
  padding: 2px 6px;
  background-color: #f8f8f8;
  border-radius: 3px;
  font-family: "Consolas", "Monaco", "Courier New", monospace;
  font-size: 14px;
  color: #e53935;
}

.rich-text pre code {
  padding: 0;
  background: none;
  color: #333;
  font-size: 14px;
  line-height: 1.6;
}

.rich-text pre {
  margin: 16px 0;
  padding: 16px;
  background-color: #f8f8f8;
  border-radius: 4px;
  overflow-x: auto;
}

/* 水平线样式 */
.rich-text hr {
  border: none;
  border-top: 1px solid #eee;
  margin: 24px 0;
}

/* 响应式适配（移动端） */
@media (max-width: 768px) {
  .rich-text {
    font-size: 15px;
    padding: 12px 0;
  }

  .rich-text h1 {
    font-size: 20px;
  }

  .rich-text h2 {
    font-size: 19px;
  }

  .rich-text h3 {
    font-size: 18px;
  }

  .rich-text img {
    width: 100%;
  }

  .rich-text table {
    display: block;
    overflow-x: auto;
  }
}