/**
 * HTML内容样式模块
 * 专门用于渲染评估结果中的HTML标签
 * 解决Tailwind样式重置导致的HTML标签无样式问题
 */

/* 基础HTML标签样式重置 */
.html-content {
  /* 标题样式 */
  h1, h2, h3, h4, h5, h6 {
    margin: 1.5em 0 0.8em 0;
    font-weight: 600;
    line-height: 1.3;
    color: #1f2937;
  }

  h1 {
    font-size: 2rem;
    color: #2563eb;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.5em;
  }

  h2 {
    font-size: 1.5rem;
    color: #1e40af;
    margin-top: 2em;
  }

  h3 {
    font-size: 1.25rem;
    color: #374151;
    margin-top: 1.8em;
  }

  h4 {
    font-size: 1.125rem;
    color: #4b5563;
    margin-top: 1.5em;
  }

  h5, h6 {
    font-size: 1rem;
    color: #6b7280;
    margin-top: 1.2em;
  }

  /* 段落样式 */
  p {
    margin: 1em 0;
    line-height: 1.7;
    color: #374151;
    text-align: justify;
  }

  /* 列表样式 */
  ul, ol {
    margin: 1em 0;
    padding-left: 2em;
  }

  li {
    margin: 0.5em 0;
    line-height: 1.6;
  }

  ul li {
    list-style-type: disc;
  }

  ol li {
    list-style-type: decimal;
  }

  /* 强调和加粗 */
  strong, b {
    font-weight: 600;
    color: #1f2937;
  }

  em, i {
    font-style: italic;
    color: #4b5563;
  }

  /* 链接样式 */
  a {
    color: #2563eb;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
  }

  a:hover {
    color: #1d4ed8;
    border-bottom-color: #1d4ed8;
  }

  /* 代码样式 */
  code {
    background: #f3f4f6;
    color: #ef4444;
    padding: 0.2em 0.4em;
    border-radius: 0.25rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875em;
  }

  pre {
    background: #1f2937;
    color: #f9fafb;
    padding: 1em;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1em 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    line-height: 1.5;
  }

  pre code {
    background: none;
    color: inherit;
    padding: 0;
    border-radius: 0;
  }

  /* 引用样式 */
  blockquote {
    margin: 1.5em 0;
    padding: 1em 1.5em;
    border-left: 4px solid #2563eb;
    background: #f8fafc;
    color: #4b5563;
    font-style: italic;
  }

  blockquote p:last-child {
    margin-bottom: 0;
  }

  /* 表格样式 */
  table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 0.875em;
  }

  th, td {
    padding: 0.75em;
    text-align: left;
    border: 1px solid #e5e7eb;
  }

  th {
    background: #f8fafc;
    font-weight: 600;
    color: #374151;
  }

  tr:nth-child(even) {
    background: #f9fafb;
  }

  /* 水平线 */
  hr {
    border: none;
    height: 1px;
    background: #e5e7eb;
    margin: 2em 0;
  }

  /* 定义列表 */
  dl {
    margin: 1.5em 0;
  }

  dt {
    font-weight: 600;
    color: #374151;
    margin-top: 1em;
  }

  dd {
    margin: 0.5em 0 0.5em 2em;
    color: #6b7280;
  }

  /* 标记和高亮 */
  mark {
    background: #fef3c7;
    color: #92400e;
    padding: 0.1em 0.2em;
  }

  /* 小号文本 */
  small {
    font-size: 0.875em;
    color: #6b7280;
  }

  /* 删除线和下划线 */
  del {
    text-decoration: line-through;
    color: #6b7280;
  }

  ins {
    text-decoration: underline;
    color: #059669;
  }

  /* 上标和下标 */
  sup, sub {
    font-size: 0.75em;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
  }

  sup {
    top: -0.5em;
  }

  sub {
    bottom: -0.25em;
  }

  /* 图片样式 */
  img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    margin: 1em 0;
  }

  /* 特殊样式：评估报告专用 */
  .legal-report {
    /* 法律报告标题样式 */
    h1 {
      text-align: center;
      font-size: 2.25rem;
      color: #1e40af;
      margin: 2em 0 1em 0;
      border-bottom: 3px solid #2563eb;
      padding-bottom: 0.8em;
    }

    h2 {
      color: #1e40af;
      font-size: 1.75rem;
      margin-top: 2.5em;
      margin-bottom: 1em;
      border-left: 4px solid #2563eb;
      padding-left: 1em;
      background: #f8fafc;
      padding: 1em 1em 1em 1.5em;
      border-radius: 0 0.5rem 0.5rem 0;
    }

    h3 {
      color: #374151;
      font-size: 1.375rem;
      margin-top: 2em;
      margin-bottom: 0.8em;
      position: relative;
      padding-left: 1.2em;
    }

    h3::before {
      content: '';
      position: absolute;
      left: 0;
      top: 50%;
      transform: translateY(-50%);
      width: 8px;
      height: 8px;
      background: #2563eb;
      border-radius: 50%;
    }

    /* 法律条款引用 */
    .legal-provision {
      background: #f0f9ff;
      border: 1px solid #0ea5e9;
      border-left: 4px solid #0ea5e9;
      padding: 1em 1.5em;
      margin: 1.5em 0;
      border-radius: 0 0.5rem 0.5rem 0;
      font-size: 0.95em;
    }

    /* 风险警示 */
    .risk-warning {
      background: #fef2f2;
      border: 1px solid #ef4444;
      border-left: 4px solid #ef4444;
      padding: 1em 1.5em;
      margin: 1.5em 0;
      border-radius: 0 0.5rem 0.5rem 0;
      color: #dc2626;
    }

    /* 建议框 */
    .recommendation {
      background: #f0fdf4;
      border: 1px solid #22c55e;
      border-left: 4px solid #22c55e;
      padding: 1em 1.5em;
      margin: 1.5em 0;
      border-radius: 0 0.5rem 0.5rem 0;
      color: #15803d;
    }

    /* 证据列表 */
    .evidence-list {
      background: #fafafa;
      border: 1px solid #d1d5db;
      border-radius: 0.5rem;
      padding: 1.5em;
      margin: 1.5em 0;
    }

    .evidence-list h4 {
      color: #374151;
      margin-top: 0;
      margin-bottom: 1em;
      font-size: 1.125rem;
    }

    /* 步骤列表 */
    .step-list {
      counter-reset: step-counter;
    }

    .step-list li {
      counter-increment: step-counter;
      position: relative;
      padding-left: 3em;
      margin: 1em 0;
      list-style: none;
    }

    .step-list li::before {
      content: counter(step-counter);
      position: absolute;
      left: 0;
      top: 0;
      background: #2563eb;
      color: white;
      width: 2em;
      height: 2em;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 600;
      font-size: 0.875em;
    }
  }

  /* 响应式调整 */
  @media (max-width: 640px) {
    h1 {
      font-size: 1.75rem;
    }

    h2 {
      font-size: 1.375rem;
    }

    h3 {
      font-size: 1.125rem;
    }

    p {
      font-size: 0.95em;
      line-height: 1.6;
    }

    .legal-report h1 {
      font-size: 1.875rem;
    }

    .legal-report h2 {
      font-size: 1.5rem;
      padding: 0.8em 0.8em 0.8em 1em;
    }

    table {
      font-size: 0.8em;
    }

    th, td {
      padding: 0.5em;
    }
  }

  /* 打印样式 */
  @media print {
    background: white !important;
    color: black !important;

    h1, h2, h3, h4, h5, h6 {
      color: black !important;
      page-break-after: avoid;
    }

    p {
      orphans: 3;
      widows: 3;
    }

    table {
      page-break-inside: avoid;
    }

    blockquote {
      page-break-inside: avoid;
    }
  }
}

/* 针对模态框的特殊样式 */
.modal-body .html-content {
  /* 确保在模态框中有适当的间距 */
  padding: 0;
  
  /* 模态框内的特殊调整 */
  h1:first-child {
    margin-top: 0;
  }

  /* 长内容时的滚动优化 */
  max-width: 100%;
  word-wrap: break-word;
}

/* 暗色模式支持（可选） */
@media (prefers-color-scheme: dark) {
  .html-content {
    h1, h2, h3, h4, h5, h6 {
      color: #f9fafb;
    }

    p, li, td {
      color: #d1d5db;
    }

    blockquote {
      background: #374151;
      color: #d1d5db;
      border-left-color: #60a5fa;
    }

    code {
      background: #374151;
      color: #f87171;
    }

    pre {
      background: #1f2937;
      color: #f9fafb;
    }

    table {
      th {
        background: #374151;
        color: #f9fafb;
      }

      tr:nth-child(even) {
        background: #374151;
      }

      td {
        border-color: #4b5563;
      }
    }

    hr {
      background: #4b5563;
    }
  }
}