/* ==========================================================================
   WeChat Official Account Compliant Themes & Elements
   Strict adherence to WeChat 2026 Editor Plugin Specification:
   - ZERO !important
   - ZERO redundant nesting (> 10 levels prohibited, kept <= 3)
   - ZERO fixed widths causing horizontal overflow (using data-ignore-width)
   - Proper line-height and contrast in both Light and Dark Modes
   ========================================================================== */

/* Theme Definitions */
.wechat-article-shell.theme-tech-blue {
  --theme-primary: #1e6bb8;
  --theme-primary-light: rgba(30, 107, 184, 0.08);
  --theme-border: #bfdbfe;
  --theme-quote-bg: #f8fafc;
  --theme-table-header: #f1f5f9;
  --theme-code-badge: #1e6bb8;
}

.wechat-article-shell.theme-geek-emerald {
  --theme-primary: #059669;
  --theme-primary-light: rgba(5, 150, 105, 0.08);
  --theme-border: #a7f3d0;
  --theme-quote-bg: #f0fdf4;
  --theme-table-header: #ecfdf5;
  --theme-code-badge: #059669;
}

.wechat-article-shell.theme-enterprise-slate {
  --theme-primary: #334155;
  --theme-primary-light: rgba(51, 65, 85, 0.08);
  --theme-border: #cbd5e1;
  --theme-quote-bg: #f8fafc;
  --theme-table-header: #f1f5f9;
  --theme-code-badge: #475569;
}

.wechat-article-shell.theme-academic-purple {
  --theme-primary: #7c3aed;
  --theme-primary-light: rgba(124, 58, 237, 0.08);
  --theme-border: #ddd6fe;
  --theme-quote-bg: #faf5ff;
  --theme-table-header: #f5f3ff;
  --theme-code-badge: #7c3aed;
}

/* Dark Mode Theme Adjustments */
.preview-container.dark-mode .wechat-article-shell.theme-tech-blue {
  --theme-primary: #60a5fa;
  --theme-primary-light: rgba(96, 165, 250, 0.15);
  --theme-border: #1e3a8a;
  --theme-quote-bg: #1e293b;
  --theme-table-header: #1e293b;
}

.preview-container.dark-mode .wechat-article-shell.theme-geek-emerald {
  --theme-primary: #34d399;
  --theme-primary-light: rgba(52, 211, 153, 0.15);
  --theme-border: #064e3b;
  --theme-quote-bg: #06281e;
  --theme-table-header: #064e3b;
}

.preview-container.dark-mode .wechat-article-shell.theme-enterprise-slate {
  --theme-primary: #94a3b8;
  --theme-primary-light: rgba(148, 163, 184, 0.15);
  --theme-border: #334155;
  --theme-quote-bg: #1e293b;
  --theme-table-header: #1e293b;
}

.preview-container.dark-mode .wechat-article-shell.theme-academic-purple {
  --theme-primary: #a78bfa;
  --theme-primary-light: rgba(167, 139, 250, 0.15);
  --theme-border: #4c1d95;
  --theme-quote-bg: #2e1065;
  --theme-table-header: #3b0764;
}

/* Article Heading 1 (Main Title) */
.wechat-article-shell .wx-h1 {
  margin: 28px 0 20px 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--theme-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid var(--theme-primary);
  padding-bottom: 10px;
}

/* Article Heading 2 (Section Title) */
.wechat-article-shell .wx-h2 {
  margin: 24px 0 16px 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--theme-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.wechat-article-shell .wx-h2-badge {
  display: inline-block;
  width: 4px;
  height: 18px;
  background-color: var(--theme-primary);
  border-radius: 2px;
  flex-shrink: 0;
}

/* Article Heading 3 (Sub Section) */
.wechat-article-shell .wx-h3 {
  margin: 18px 0 12px 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 6px;
}

.preview-container.dark-mode .wechat-article-shell .wx-h3 {
  color: #e2e8f0;
}

.wechat-article-shell .wx-h3-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--theme-primary);
  flex-shrink: 0;
}

/* Article Heading 4 */
.wechat-article-shell .wx-h4 {
  margin: 14px 0 10px 0;
  font-size: 15px;
  font-weight: 600;
  color: #475569;
}

.preview-container.dark-mode .wechat-article-shell .wx-h4 {
  color: #cbd5e1;
}

/* Paragraphs */
.wechat-article-shell .wx-p {
  margin: 16px 0;
  line-height: 1.75;
  letter-spacing: 0.5px;
  font-size: 15px;
  color: inherit;
}

/* Blockquotes */
.wechat-article-shell .wx-blockquote {
  margin: 18px 0;
  padding: 12px 16px;
  background-color: var(--theme-quote-bg);
  border-left: 4px solid var(--theme-primary);
  border-radius: 0 8px 8px 0;
  font-size: 14.5px;
  color: #475569;
  line-height: 1.7;
}

.preview-container.dark-mode .wechat-article-shell .wx-blockquote {
  color: #cbd5e1;
}

/* Bold & Italic */
.wechat-article-shell strong {
  font-weight: 700;
  color: var(--theme-primary);
}

.wechat-article-shell em {
  font-style: italic;
  color: #64748b;
}

/* Inline Code */
.wechat-article-shell code:not(.hljs) {
  background-color: var(--theme-primary-light);
  color: var(--theme-primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: Consolas, Monaco, monospace;
  font-size: 13.5px;
  word-break: break-all;
}

/* Lists */
.wechat-article-shell ul, .wechat-article-shell ol {
  margin: 14px 0;
  padding-left: 20px;
  line-height: 1.75;
}

.wechat-article-shell li {
  margin: 6px 0;
  font-size: 15px;
}

/* Tables (Wrapped in data-ignore-width) */
.wechat-article-shell .wx-table-container {
  width: 100%;
  margin: 18px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.wechat-article-shell table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  line-height: 1.6;
  text-align: left;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
}

.wechat-article-shell th {
  background-color: var(--theme-table-header);
  color: #1e293b;
  font-weight: 600;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
}

.preview-container.dark-mode .wechat-article-shell th {
  color: #f1f5f9;
  border-color: #334155;
}

.wechat-article-shell td {
  padding: 9px 14px;
  border: 1px solid #e2e8f0;
  color: inherit;
}

.preview-container.dark-mode .wechat-article-shell td {
  border-color: #334155;
}

.wechat-article-shell tr:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.015);
}

.preview-container.dark-mode .wechat-article-shell tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Horizontal Rule */
.wechat-article-shell hr {
  margin: 28px 0;
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--theme-border), transparent);
}

/* Footnotes Section */
.wechat-article-shell .wx-footnotes-container {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px dashed #cbd5e1;
}

.preview-container.dark-mode .wechat-article-shell .wx-footnotes-container {
  border-color: #475569;
}

.wechat-article-shell .wx-footnotes-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--theme-primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.wechat-article-shell .wx-footnotes-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
  font-size: 12.5px;
  line-height: 1.8;
  color: #64748b;
}

.preview-container.dark-mode .wechat-article-shell .wx-footnotes-list {
  color: #94a3b8;
}

.wechat-article-shell .wx-footnote-index {
  color: var(--theme-primary);
  font-weight: 600;
  margin-right: 4px;
}

.wechat-article-shell .wx-footnote-url {
  color: var(--theme-primary);
  word-break: break-all;
}

/* Sup footnote badge in body */
.wechat-article-shell .wx-sup-ref {
  font-size: 11px;
  font-weight: 700;
  color: var(--theme-primary);
  margin: 0 2px;
  vertical-align: super;
}

/* Images */
.wechat-article-shell .wx-img-container {
  margin: 20px auto;
  text-align: center;
}

.wechat-article-shell .wx-img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);
  display: block;
  margin: 0 auto;
}

.wechat-article-shell .wx-img-caption {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  margin-top: 8px;
  text-align: center;
}
