/* ==========================================================================
   NVFX Markdown Render - 独立内容渲染样式系统
   来源: NewVFX LLM Chat 2.1
   用途: 为独立渲染的 Markdown 内容提供完全隔离、一致且美观的视觉表现
   核心策略: 使用 all: initial 彻底重置，配合 !important 防御主题污染
   ========================================================================== */

/* ==========================================================================
   1. 容器级强力重置 (Container Reset)
   ========================================================================== */
.nvfx-markdown-rendered {
  all: initial !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  align-items: flex-start !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  contain: layout style paint !important;
  box-sizing: border-box !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
  font-size: 14px !important;
  line-height: 1.7 !important;
  color: #1d1d1f !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  text-align: left !important;
  letter-spacing: normal !important;
  font-weight: 400 !important;
  text-decoration: none !important;
}
.nvfx-markdown-rendered *,
.nvfx-markdown-rendered *::before,
.nvfx-markdown-rendered *::after {
  box-sizing: border-box !important;
}

/* ==========================================================================
   2. 基础排版 (Typography)
   ========================================================================== */
/* 段落与文本修饰 */
.nvfx-markdown-rendered p { display: block !important; width: 100% !important; margin: 0 0 10px !important; padding: 0 !important; }
.nvfx-markdown-rendered p:last-child { margin-bottom: 0 !important; }
.nvfx-markdown-rendered strong, .nvfx-markdown-rendered b { font-weight: 700 !important; color: #1d1d1f !important; }
.nvfx-markdown-rendered em, .nvfx-markdown-rendered i { font-style: italic !important; color: inherit !important; }
.nvfx-markdown-rendered del, .nvfx-markdown-rendered s, .nvfx-markdown-rendered strike { text-decoration: line-through !important; color: #86868b !important; }

/* 标题系统 (合并通用属性，差异化尺寸) */
.nvfx-markdown-rendered h1, .nvfx-markdown-rendered h2, .nvfx-markdown-rendered h3,
.nvfx-markdown-rendered h4, .nvfx-markdown-rendered h5, .nvfx-markdown-rendered h6 {
  display: block !important; width: 100% !important; margin-top: 8px !important;
  color: #1d1d1f !important; font-family: inherit !important; line-height: 1.35 !important;
  font-weight: 700 !important; text-align: left !important;
}
.nvfx-markdown-rendered h1 { margin-bottom: 10px !important; font-size: 24px !important; }
.nvfx-markdown-rendered h2 { margin-bottom: 9px  !important; font-size: 21px !important; }
.nvfx-markdown-rendered h3 { margin: 7px 0 8px !important; font-size: 18px !important; }
.nvfx-markdown-rendered h4 { margin: 6px 0 7px !important; font-size: 16px !important; }
.nvfx-markdown-rendered h5 { margin: 6px 0    !important; font-size: 14px !important; }
.nvfx-markdown-rendered h6 { margin: 5px 0 6px !important; font-size: 13px !important; color: #6e6e73 !important; }

/* 链接 */
.nvfx-markdown-rendered a { color: #ff5f33 !important; text-decoration: none !important; border: 0 !important; background: transparent !important; box-shadow: none !important; }
.nvfx-markdown-rendered a:hover { color: #d9471f !important; text-decoration: underline !important; }

/* ==========================================================================
   3. 列表与引用 (Lists & Blockquotes)
   ========================================================================== */
.nvfx-markdown-rendered ul, .nvfx-markdown-rendered ol {
  display: block !important; width: 100% !important; margin: 0 0 10px !important;
  padding: 0 0 0 24px !important; font-size: 14px !important; line-height: 1.7 !important; color: #1d1d1f !important;
}
.nvfx-markdown-rendered ul { list-style: disc !important; }
.nvfx-markdown-rendered ol { list-style: decimal !important; }
.nvfx-markdown-rendered li { display: list-item !important; margin: 2px 0 !important; padding: 0 !important; }
.nvfx-markdown-rendered li > ul, .nvfx-markdown-rendered li > ol { margin-top: 2px !important; margin-bottom: 2px !important; }

.nvfx-markdown-rendered blockquote {
  display: block !important; width: 100% !important; margin: 10px 0 !important; padding: 8px 14px !important;
  background: #f8fafc !important; border: 0 !important; border-left: 4px solid #cbd5e1 !important;
  border-radius: 0 8px 8px 0 !important; color: #334155 !important; font-size: 14px !important; line-height: 1.7 !important; box-shadow: none !important;
}
.nvfx-markdown-rendered blockquote *, .nvfx-markdown-rendered blockquote p { color: #334155 !important; }

/* ==========================================================================
   4. 媒体与表格 (Media & Tables)
   ========================================================================== */
/* 图片 */
.nvfx-markdown-rendered img {
  max-width: 280px !important; max-height: 280px !important; width: auto !important; height: auto !important;
  object-fit: contain !important; border-radius: 8px !important; display: block !important; margin: 0 !important; padding: 0 !important;
  background-color: #f5f5f5 !important; border: 1px solid #e5e5ea !important; box-shadow: none !important; cursor: zoom-in !important;
}
.nvfx-markdown-rendered p img, .nvfx-markdown-rendered a img { margin: 0 !important; border: 1px solid #e5e5ea !important; }

/* 表格 */
.nvfx-markdown-rendered table {
  display: table !important; width: auto !important; max-width: 100% !important; margin: 10px 0 !important; padding: 0 !important;
  border-collapse: collapse !important; border-spacing: 0 !important; font-size: 13px !important; line-height: 1.5 !important;
  color: #1d1d1f !important; background: #fff !important; border: 0 !important; box-shadow: none !important; overflow: hidden !important;
}
.nvfx-markdown-rendered thead { display: table-header-group !important; }
.nvfx-markdown-rendered tbody { display: table-row-group !important; }
.nvfx-markdown-rendered tr { display: table-row !important; }
.nvfx-markdown-rendered th, .nvfx-markdown-rendered td {
  display: table-cell !important; border: 1px solid #e1e4e8 !important; padding: 6px 10px !important;
  text-align: left !important; vertical-align: top !important; background: #fff !important;
}
.nvfx-markdown-rendered th { font-weight: 600 !important; background: #fafafa !important; }
.nvfx-markdown-rendered tr:nth-child(even) td { background: #fafafa !important; }

/* ==========================================================================
   5. 代码块与语法高亮 (Code & Syntax Highlighting)
   ========================================================================== */
.nvfx-markdown-rendered code { font-family: 'Fira Code', Consolas, Monaco, monospace !important; }

/* 行内代码 */
.nvfx-markdown-rendered :not(pre) > code {
  display: inline !important; padding: 2px 5px !important; margin: 0 !important;
  background: #f1f5f9 !important; color: #d6336c !important; border-radius: 4px !important;
  font-size: 12.5px !important; line-height: 1.5 !important; white-space: normal !important; border: 0 !important;
}

/* 代码块容器 */
.nvfx-markdown-rendered pre {
  display: block !important; width: 100% !important; max-width: 100% !important; min-width: 0 !important;
  position: relative !important; margin: 10px 0 !important; padding: 12px !important;
  background: #0f172a !important; color: #e2e8f0 !important; border-radius: 8px !important;
  border: 0 !important; box-shadow: none !important; overflow-x: auto !important; overflow-y: hidden !important;
  font-size: 12.5px !important; line-height: 1.6 !important; white-space: pre !important; text-align: left !important;
}

/* 代码块内部强力重置 (防止高亮插件注入多余样式) */
.nvfx-markdown-rendered pre code {
  display: block !important; width: auto !important; max-width: none !important; min-width: 0 !important;
  padding: 0 72px 0 0 !important; margin: 0 !important; background: transparent !important; color: inherit !important;
  border: 0 !important; border-radius: 0 !important; box-shadow: none !important; white-space: pre !important; word-break: normal !important;
}
.nvfx-markdown-rendered pre code * {
  background: transparent !important; color: inherit !important; padding: 0 !important; margin: 0 !important;
  border: 0 !important; border-radius: 0 !important; box-shadow: none !important; font-size: inherit !important; line-height: inherit !important;
}

/* 复制按钮 */
.nvfx-markdown-rendered .nvfx-md-copy {
  position: absolute !important; top: 0 !important; right: 0 !important; z-index: 2 !important;
  padding: 3px 8px !important; margin: 0 !important; border: 0 !important; border-radius: 4px !important;
  background: rgba(255,255,255,.12) !important; color: #fff !important; font-family: inherit !important;
  font-size: 11px !important; line-height: 1.4 !important; cursor: pointer !important;
  box-shadow: none !important; text-shadow: none !important; appearance: none !important; -webkit-appearance: none !important;
}
.nvfx-markdown-rendered .nvfx-md-copy:hover { background: rgba(255,255,255,.2) !important; }
.nvfx-markdown-rendered .nvfx-md-copy:active { background: rgba(255,255,255,.28) !important; }
.nvfx-markdown-rendered .nvfx-md-copy:focus { outline: none !important; box-shadow: none !important; }

/* Highlight.js 语法高亮配色 (限定在 pre 内部) */
.nvfx-markdown-rendered pre .hljs { background: transparent !important; color: #e2e8f0 !important; }
.nvfx-markdown-rendered .hljs-keyword, .nvfx-markdown-rendered .hljs-selector-tag { color: #ff7b72 !important; }
.nvfx-markdown-rendered .hljs-string, .nvfx-markdown-rendered .hljs-attr, .nvfx-markdown-rendered pre .hljs-attribute { color: #a5d6ff !important; }
.nvfx-markdown-rendered .hljs-comment, .nvfx-markdown-rendered .hljs-quote, .nvfx-markdown-rendered pre .hljs-meta { color: #8b949e !important; }
.nvfx-markdown-rendered .hljs-number, .nvfx-markdown-rendered .hljs-literal, .nvfx-markdown-rendered pre .hljs-symbol, .nvfx-markdown-rendered pre .hljs-bullet { color: #79c0ff !important; }
.nvfx-markdown-rendered .hljs-title, .nvfx-markdown-rendered .hljs-function .hljs-title { color: #d2a8ff !important; }
.nvfx-markdown-rendered .hljs-built_in, .nvfx-markdown-rendered .hljs-type, .nvfx-markdown-rendered pre .hljs-variable, .nvfx-markdown-rendered pre .hljs-template-variable { color: #ffa657 !important; }
.nvfx-markdown-rendered pre .hljs-function, .nvfx-markdown-rendered pre .hljs-params { color: #e2e8f0 !important; }

/* ==========================================================================
   6. 交互组件与滚动条 (Components & Scrollbars)
   ========================================================================== */
/* 任务列表 (Task Lists) */
.nvfx-markdown-rendered ul.contains-task-list { list-style: none !important; padding-left: 4px !important; }
.nvfx-markdown-rendered li.task-list-item { list-style: none !important; position: relative !important; }
.nvfx-markdown-rendered input[type="checkbox"] {
  appearance: none !important; -webkit-appearance: none !important; width: 14px !important; height: 14px !important;
  min-width: 14px !important; margin: 0 6px 0 0 !important; padding: 0 !important; vertical-align: -2px !important;
  border: 1px solid #d1d5da !important; border-radius: 4px !important; background: #fff !important; cursor: default !important;
}
.nvfx-markdown-rendered input[type="checkbox"]:checked { background: #ff5f33 !important; border-color: #ff5f33 !important; }
.nvfx-markdown-rendered input[type="checkbox"]:checked::after {
  content: "✓" !important; display: block !important; color: #fff !important; font-size: 10px !important;
  line-height: 12px !important; text-align: center !important;
}

/* 自定义滚动条 (仅限代码块) */
.nvfx-markdown-rendered pre::-webkit-scrollbar { height: 8px !important; }
.nvfx-markdown-rendered pre::-webkit-scrollbar-track { background: #0f172a !important; }
.nvfx-markdown-rendered pre::-webkit-scrollbar-thumb { background: #475569 !important; border-radius: 4px !important; }
.nvfx-markdown-rendered pre::-webkit-scrollbar-thumb:hover { background: #64748b !important; }

/* ==========================================================================
   7. 防御性覆盖 (Defense Overrides)
   防止 WordPress 核心或主题注入的伪元素、默认表单样式破坏布局
   ========================================================================== */
.nvfx-markdown-rendered h1::before, .nvfx-markdown-rendered h2::before, .nvfx-markdown-rendered h3::before,
.nvfx-markdown-rendered h4::before, .nvfx-markdown-rendered h5::before, .nvfx-markdown-rendered h6::before,
.nvfx-markdown-rendered li::before { content: none !important; display: none !important; }

.nvfx-markdown-rendered button, .nvfx-markdown-rendered input, .nvfx-markdown-rendered textarea, .nvfx-markdown-rendered select {
  font-family: inherit !important;
}

.nvfx-markdown-rendered::selection, .nvfx-markdown-rendered *::selection {
  background: rgba(255, 95, 51, 0.18) !important;
}

/* ==========================================================================
   8. 响应式适配 (Responsive)
   ========================================================================== */
@media (max-width: 782px) {
  .nvfx-markdown-rendered { font-size: 14px !important; line-height: 1.7 !important; }
  .nvfx-markdown-rendered h1 { font-size: 22px !important; }
  .nvfx-markdown-rendered h2 { font-size: 19px !important; }
  .navfx-markdown-rendered h3 { font-size: 17px !important; } /* 修正了原代码可能的拼写遗漏，保持统一 */
  .nvfx-markdown-rendered h3 { font-size: 17px !important; }
  
  .nvfx-markdown-rendered table { display: block !important; width: 100% !important; overflow-x: auto !important; }
  .nvfx-markdown-rendered pre, .nvfx-markdown-rendered pre code { font-size: 12px !important; }
  .nvfx-markdown-rendered img { max-width: 100% !important; max-height: 400px !important; }
}