/* 知识库文章详情页样式优化 */

/* 文章包装器 */
.kb-article-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 文章头部 */
.kb-article-header {
  padding: 20px;
  margin-bottom: 0;
}

.kb-article-header__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.kb-article-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--color-text);
  margin: 0;
  flex: 1;
  min-width: 0;
}

.kb-article-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* 文章元信息 */
.kb-article-meta {
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

.kb-article-meta__items {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.kb-article-meta__item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.kb-article-meta__label {
  font-weight: 500;
  color: var(--color-text);
}

/* 文章内容区域包装器 */
.kb-article-content-wrapper {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}

/* 目录样式 */
.kb-article-toc {
  background: var(--color-bg-elev);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow-card);
  display: none; /* 移动端默认隐藏 */
}

.kb-article-toc:not(:empty) {
  display: block;
}

.kb-article-toc .link {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--color-text);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.5;
  transition: background-color 0.2s ease, color 0.2s ease;
  margin-bottom: 4px;
  cursor: pointer;
}

.kb-article-toc .link:hover,
.kb-article-toc .link:active {
  background: var(--color-primary-weak);
  color: var(--color-primary);
}

.kb-article-toc .muted {
  padding: 12px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 13px;
}

/* 文章正文内容 */
.kb-article-content {
  background: var(--color-bg-elev);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 24px 20px;
  box-shadow: var(--shadow-card);
  line-height: 1.8;
  font-size: 16px;
  color: var(--color-text);
}

/* 文章章节 */
.kb-article-section {
  margin-bottom: 32px;
}

.kb-article-section:last-child {
  margin-bottom: 0;
}

.kb-article-section__title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--color-text);
  margin: 0 0 16px 0;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--color-border);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.kb-article-section__title:hover {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.kb-article-section__title--highlight {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  animation: highlight-fade 2s ease;
}

@keyframes highlight-fade {
  0%, 100% {
    background-color: transparent;
  }
  50% {
    background-color: var(--color-primary-weak);
  }
}

.kb-article-section__content {
  padding-left: 4px;
}

.kb-article-section__content p {
  margin: 0 0 16px 0;
  line-height: 1.8;
  color: var(--color-text);
  text-align: justify;
  word-wrap: break-word;
  word-break: break-word;
}

.kb-article-section__content p:last-child {
  margin-bottom: 0;
}

/* 相关推荐 */
.kb-article-related {
  margin-top: 0;
  padding: 20px;
}

.kb-article-related .card__title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}

/* 桌面端布局优化 */
@media (min-width: 768px) {
  .kb-article-content-wrapper {
    grid-template-columns: 240px 1fr;
    gap: 24px;
  }

  .kb-article-toc {
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    display: block;
  }

  .kb-article-content {
    padding: 32px 28px;
    font-size: 17px;
  }

  .kb-article-section__title {
    font-size: 22px;
    margin-bottom: 20px;
  }

  .kb-article-section {
    margin-bottom: 40px;
  }

  .kb-article-section__content p {
    margin-bottom: 18px;
    line-height: 1.9;
  }
}

/* 大屏幕优化 */
@media (min-width: 1024px) {
  .kb-article-content {
    padding: 40px 36px;
    font-size: 18px;
    max-width: 800px;
    margin: 0 auto;
  }

  .kb-article-title {
    font-size: 26px;
  }

  .kb-article-section__title {
    font-size: 24px;
  }
}

/* 关怀模式适配 */
[data-care-enabled="1"] .kb-article-content {
  font-size: 18px;
  line-height: 2;
}

[data-care-enabled="1"] .kb-article-section__title {
  font-size: 22px;
  margin-bottom: 20px;
}

[data-care-enabled="1"] .kb-article-section__content p {
  margin-bottom: 20px;
}

/* 深色模式适配 */
[data-theme="dark"] .kb-article-section__title {
  border-bottom-color: var(--color-border);
}

[data-theme="dark"] .kb-article-section__title:hover {
  border-bottom-color: var(--color-primary);
}

/* 移动端优化 */
@media (max-width: 767px) {
  .kb-article-header {
    padding: 16px;
  }

  .kb-article-header__top {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .kb-article-title {
    font-size: 20px;
  }

  .kb-article-actions {
    justify-content: flex-end;
  }

  .kb-article-content {
    padding: 20px 16px;
    font-size: 15px;
  }

  .kb-article-section {
    margin-bottom: 28px;
  }

  .kb-article-section__title {
    font-size: 18px;
    margin-bottom: 14px;
    padding-bottom: 10px;
  }

  .kb-article-section__content p {
    margin-bottom: 14px;
    line-height: 1.75;
  }

  .kb-article-meta__items {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

