/* === MDMS comment-tree.css ===
   职责: 楼中楼评论嵌套连接线 + fold-btn (在 action-bar 行最左)
   版本: v3.0.0-alpha.7 fold-btn inline (跟其他 icon 同排同大小)
   
   工程方法 借鉴 iamkate.com:
     - 父级竖线 = li.border-left + .media::after (Kate trick)
     - L 弯角 = li::before, 跟 border-left 共享 left:-2 完美 overlap
     - 2px 线 + .10 透明度 (整数像素中心, 无亚像素错位)
     - fold-btn absolute 在 action-bar 行最左, 中心 X = li:20
*/

.comment-tree {
  --c-line-color: rgb(255 255 255 / .10);
  --c-line-width: 2px;
  --c-avatar-size: 40px;
  --c-avatar-half: 20px;
  --c-padding-top: 14px;
  --c-radius: 12px;
  --c-indent: 36px;

  list-style: none;
  padding: 0;
  margin: 0;
}

.comment-tree-item {
  position: relative;
  list-style: none;
}

/* ═══ fold-btn: 在 action-bar 行最左, 跟其他 icon 同大小 ═══ */
.comment-fold-btn {
  position: absolute;
  /* 中心 X = action-bar.start (52, 头像 40 + gap 12) - 32 = 20 (= 头像中线) */
  left: -32px;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 18px;                                /* 缩小到 18, 跟其他 icon 协调 */
  height: 18px;
  border-radius: 50%;
  background-color: #1f1f1f;
  border: var(--c-line-width) solid var(--c-line-color);
  color: rgb(255 255 255 / .65);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 5;
  flex-shrink: 0;
  transition: background-color .15s, border-color .15s;
}

.comment-fold-btn:hover {
  background-color: #2d2d2d;
  border-color: rgb(255 255 255 / .25);
  color: rgb(255 255 255 / .9);
}

.comment-fold-btn .fold-icon-fa {
  font-size: 9px;                             /* icon 字号 9, 跟其他 13px icon 视觉等大 (圆 18 vs icon 13 视觉补偿) */
  line-height: 1;
}

/* ═══ 父级竖线: 头像底→.media 底, fold-btn 覆盖中段 ═══ */
.comment-tree-item.has-children > .media {
  position: relative;
}

.comment-tree-item.has-children > .media::after {
  content: "";
  position: absolute;
  top: calc(var(--c-padding-top) + var(--c-avatar-size));   /* 54px 头像底 */
  bottom: 0;
  left: calc(var(--c-avatar-half) - var(--c-line-width) / 2);
  width: var(--c-line-width);
  background: var(--c-line-color);
  pointer-events: none;
}

/* ═══ .comment-children 容器 ═══ */
.comment-children {
  margin: 0 0 0 calc(var(--c-avatar-half) - var(--c-line-width) / 2);
  padding: 0;
  list-style: none;
}

/* ═══ 子级竖线 (Kate trick) ═══ */
.comment-children > .comment-tree-item {
  border-left: var(--c-line-width) solid var(--c-line-color);
  padding-left: var(--c-indent);
  list-style: none;
  margin: 0;
}

.comment-children > .comment-tree-item:last-child {
  border-left-color: transparent;
}

/* ═══ L 弯角 (跟 border-left 共享 left:-2) ═══ */
.comment-children > .comment-tree-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: calc(-1 * var(--c-line-width));
  width: calc(var(--c-indent) + var(--c-line-width));
  height: calc(var(--c-padding-top) + var(--c-avatar-half));
  border-style: solid;
  border-color: var(--c-line-color);
  border-width: 0 0 var(--c-line-width) var(--c-line-width);
  border-bottom-left-radius: var(--c-radius);
  pointer-events: none;
}

/* ═══ 折叠态 ═══ */
.comment-tree-item.is-folded > .comment-children {
  display: none;
}

.comment-tree-item.is-folded > .media::after {
  bottom: 26px;
}

.comment-tree-item.is-folded .comment-fold-btn {
  border-color: rgb(255 255 255 / .15);
  color: rgb(255 255 255 / .45);
}

/* ═══ reply form ═══ */
.comment-reply-form {
  margin: 8px 0 12px 52px;
  padding: 10px 12px;
  background: var(--ae-glass-bg);
  border: none;
  border-radius: 8px;
}
.comment-reply-form textarea {
  width: 100%;
  min-height: 60px;
  padding: 6px 8px;
  background: transparent;
  border: 1px solid var(--ae-glass-border);
  border-radius: 4px;
  color: var(--ae-text-1);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  box-sizing: border-box;
}
.comment-reply-form textarea:focus {
  outline: none;
  border-color: var(--ae-glass-border);
}
.comment-reply-form-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 12px;
}
.comment-reply-count { color: var(--ae-text-3); }
.comment-reply-actions { display: flex; gap: 8px; }
.comment-reply-cancel,
.comment-reply-submit {
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--ae-glass-border);
  transition: all var(--ae-transition);
}
.comment-reply-cancel { background: transparent; color: var(--ae-text-3); }
.comment-reply-cancel:hover { background: var(--ae-glass-bg); color: var(--ae-text-2); }
.comment-reply-submit { background: var(--ae-text-1); color: #000; border-color: var(--ae-text-1); }
.comment-reply-submit:hover { opacity: 0.85; }
.comment-reply-submit:disabled { opacity: 0.4; cursor: not-allowed; }

.comment-action-btn[data-action="reply"][disabled],
.comment-action-btn[data-action="reply"].is-disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

@media (max-width: 600px) {
  .comment-tree {
    --c-indent: 24px;
    --c-radius: 10px;
  }
  .comment-fold-btn {
    width: 16px;
    height: 16px;
    left: -26px;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   展开态分割线缩进: 父评论有 children 且未折叠时,
   把 inline border-bottom 替换成 left:52px 起的自定义线, 避开父级竖线压线
   ═══════════════════════════════════════════════════════════════════ */

.comment-tree-item.has-children:not(.is-folded) > .media {
  border-bottom: none !important;     /* 干掉 inline border-bottom */
}

.comment-tree-item.has-children:not(.is-folded) > .media::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 52px;                          /* 头像 width 40 + gap 12 = 评论内容 X 起点 */
  right: 0;
  height: 1px;
  background: var(--ae-glass-border);
  pointer-events: none;
}
