/* DDKK 文章侧边栏样式 - 基于 Ant Design 5.x 设计规范 */
/* 所有选择器均使用完整前缀，避免样式冲突 */

.ddkk-sidebar-article {
  background: #ffffff;
  border: none;
  padding: 0;
  position: relative;
  flex: 1 1 auto; /* 明确设置 flex 属性：grow、shrink、basis */
  display: flex;
  flex-direction: column;
  min-height: 0; /* 允许 flex 子元素缩小到内容以下 */
  height: 100%; /* 明确设置高度为 100% */
  overflow: hidden; /* 保持隐藏溢出，配合 flex 布局 */
}

/* 头部区域：固定在侧边栏滚动容器顶部 */
.ddkk-sidebar-article-header {
  padding: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  position: sticky;
  /* 父容器顶部无内边距，此处设为 0，避免滚动时产生跳动 */
  top: 0;
  z-index: 2;
  background: #ffffff;
  flex-shrink: 0; /* 防止头部被压缩 */
}

.ddkk-sidebar-article-nav {
  flex: 1 1 auto; /* 明确设置 flex 属性 */
  overflow-y: auto; /* 只在需要时显示滚动条 */
  overflow-x: hidden;
  min-height: 0; /* 允许缩小 */
  height: 0; /* 配合 flex: 1 填充剩余空间 */
  scrollbar-width: thin; /* Firefox 滚动条宽度 */
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent; /* Firefox 滚动条颜色：滑块、轨道（透明） */
  /* 确保滚动容器正确捕获滚动事件，防止滚动穿透 */
  position: relative;
  z-index: 1;
  touch-action: pan-y; /* 允许垂直滚动，防止滚动穿透 */
}

/* 滚动条样式 - Webkit 浏览器（Chrome、Safari、Edge） */
.ddkk-sidebar-article-nav::-webkit-scrollbar {
  width: 8px;
}

.ddkk-sidebar-article-nav::-webkit-scrollbar-track {
  background: transparent; /* 轨道背景透明，不显示背景 */
  border-radius: 4px;
}

.ddkk-sidebar-article-nav::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  min-height: 40px; /* 确保滚动条滑块有最小高度 */
}

.ddkk-sidebar-article-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

.ddkk-sidebar-article-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ddkk-sidebar-article-title {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.88);
  text-decoration: none;
  margin-bottom: 8px;
  transition: color 0.2s;
  /* 标题单行显示，超出部分省略 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: keep-all;
  word-wrap: normal;
}

.ddkk-sidebar-article-title:hover {
  color: #1677ff;
}

.ddkk-sidebar-article-title-active {
  color: #1677ff !important;
  font-weight: 600;
}

.ddkk-sidebar-article-subtitle {
  display: block;
  font-size: 14px;
  color: rgba(0, 0, 0, 0.88);
  text-decoration: none;
  transition: color 0.2s;
}

.ddkk-sidebar-article-subtitle:hover {
  color: #1677ff;
}

.ddkk-sidebar-article-subtitle-active {
  color: #1677ff !important;
  font-weight: 600;
}


/* 分组 */
.ddkk-sidebar-article-group {
  padding: 0;
}

/* 分组标题 */
.ddkk-sidebar-article-group-title {
  width: 100%;
  padding: 6px 6px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.88);
  background: transparent;
  border: none;
  border-bottom: none; /* 移除分组标题下面的下划线 */
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background-color 0.2s, color 0.2s;
  border-radius: 4px;
  margin: 0;
}

.ddkk-sidebar-article-group-title:hover {
  background: rgba(0, 0, 0, 0.06);
}

.ddkk-sidebar-article-group-title-text {
  flex: 1;
  /* 标题单行显示，超出部分省略 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: keep-all;
  word-wrap: normal;
  font-size: 17px;
  font-weight: 700;
}

/* 分组箭头 */
.ddkk-sidebar-article-group-arrow {
  width: 24px;
  height: 24px;
  margin-left: 8px;
  flex-shrink: 0;
  transition: transform 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M512 714.667L213.333 416l59.733-59.733L512 595.2l238.933-238.933L810.667 416 512 714.667z' fill='rgba(0, 0, 0, 0.65)'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.ddkk-sidebar-article-group-arrow-right {
  transform: rotate(-90deg);
}

.ddkk-sidebar-article-group-arrow-down {
  transform: rotate(0deg);
}

/* 分组内容 */
.ddkk-sidebar-article-group-content {
  list-style: none;
  padding: 2px 0;
  margin: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out, opacity 0.2s;
}

.ddkk-sidebar-article-group-collapsed {
  max-height: 0;
  opacity: 0;
  padding: 0;
}

/* 分组项 */
.ddkk-sidebar-article-group-item {
  margin: 0;
  border-top: none; /* 移除标题间分割线 */
}

/* 确保第一个分组项也没有上边框 */
.ddkk-sidebar-article-group-content > .ddkk-sidebar-article-group-item:first-child {
  border-top: none;
}

/* 链接 */
.ddkk-sidebar-article-link {
  display: block;
  padding: 4px 6px;
  font-size: 14px;
  color: rgba(0, 0, 0, 0.88);
  text-decoration: none;
  transition: color 0.2s, background-color 0.2s;
  border-radius: 0;
  margin: 0 3px;
  border-left: 3px solid transparent; /* 预留选中状态高亮条 */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* 链接文本单行显示，超出部分省略 */
  word-break: keep-all;
  word-wrap: normal;
}

.ddkk-sidebar-article-link:hover {
  color: #1677ff;
  background: #f5f5f5;
}

.ddkk-sidebar-article-link-active {
  color: #1677ff;
  font-weight: 600;
  background: rgba(22, 119, 255, 0.1); /* 激活状态浅蓝色背景 */
  border-left-color: #1677ff; /* 激活状态蓝色高亮条 */
  border-radius: 0;
}

/* 响应式设计 - 移动端适配 */
@media (max-width: 767.98px) {
  /* 移动端抽屉内部列表左侧更紧凑，贴近屏幕边缘约 3px */
  .ddkk-sidebar-article-header {
    padding: 8px 8px 8px 3px;
  }

  .ddkk-sidebar-article-group-title {
    padding-left: 3px;
    padding-right: 6px;
  }

  .ddkk-sidebar-article-link {
    margin-left: 3px;
    margin-right: 6px;
  }
}

