/* ========== 评论区 ========== */
.comments-section {
  margin-top: 48px;
  padding-top: 0;
  border-top: 1px solid rgb(var(--mdui-color-outline-variant));
  max-width: var(--content-max-width, 860px);
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

/* ---- 标题 ---- */
.comments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 0 16px;
}

.comments-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.comments-title-count {
  font-size: 0.75rem;
  font-weight: 400;
  color: rgb(var(--mdui-color-on-surface-variant));
  background: rgb(var(--mdui-color-surface-container-highest));
  padding: 0 8px;
  border-radius: 10px;
  line-height: 1.6;
}

/* ---- 评论列表 ---- */
.comment-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* 子评论容器 - 完全透明化使其不产生视觉容器感 */
.comment-children {
  margin: 0;
  padding: 0;
  background: none;
  border: none;
}

.comment-children > .comment-list {
  margin: 0;
  padding: 0;
}

.comment-item {
  position: relative;
}

.comment-card {
  position: relative;
  padding: 18px 20px;
  margin: 10px 0;
  background: rgb(var(--mdui-color-surface-container-low));
  border: 1px solid rgb(var(--mdui-color-outline-variant));
  border-radius: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.comment-card:hover {
  border-color: rgb(var(--mdui-color-outline));
}

/* ---- 评论头部（作者+回复按钮） ---- */
.comment-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

/* ---- 回复按钮 ---- */
.reply-btn {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  color: rgb(var(--mdui-color-primary));
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.15s;
  white-space: nowrap;
  margin-left: auto;
}

.reply-btn:hover {
  background: rgb(var(--mdui-color-primary-container));
  color: rgb(var(--mdui-color-on-primary-container));
}

/* ---- 回复表单在评论内部时 ---- */
.comment-card .respond {
  margin-top: 16px;
  margin-bottom: 0;
  padding: 16px;
  background: rgb(var(--mdui-color-surface-container));
  border-radius: 8px;
  border: 1px solid rgb(var(--mdui-color-outline-variant));
}

.comment-card .respond .respond-header {
  margin-bottom: 12px;
}

.comment-card .respond .respond-title {
  font-size: 0.9375rem;
}

.comment-card .respond .form-footer {
  margin-top: 8px;
}

/* ---- 嵌套评论（纯 border-left 方案，无伪元素定位） ---- */
.comment-item.comment-child > .comment-card {
  margin-left: 40px;
  border-left: 2px solid rgb(var(--mdui-color-outline-variant));
  border-radius: 2px 12px 12px 2px;
}

.comment-item.comment-child.comment-by-author > .comment-card {
  border-left-color: rgb(var(--mdui-color-primary));
  opacity: 0.55;
}

/* ---- 评论作者栏 ---- */
.comment-author {
  display: flex;
  align-items: center;
  gap: 12px;
}

.comment-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgb(var(--mdui-color-surface-container-highest));
}

.comment-author-info {
  min-width: 0;
}

.comment-author-name {
  font-weight: 600;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.comment-author-name a {
  color: inherit;
  text-decoration: none;
}

.comment-author-name a:hover {
  color: rgb(var(--mdui-color-primary));
}

.comment-author-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  background: rgb(var(--mdui-color-primary-container));
  color: rgb(var(--mdui-color-on-primary-container));
  border-radius: 10px;
  font-size: 0.625rem;
  font-weight: 500;
  line-height: 1.6;
}

.comment-time {
  font-size: 0.6875rem;
  color: rgb(var(--mdui-color-on-surface-variant));
  margin-top: 1px;
}

.comment-time a {
  color: inherit;
  text-decoration: none;
}

.comment-time a:hover {
  color: rgb(var(--mdui-color-primary));
}

/* ---- 评论内容 ---- */
.comment-content {
  margin: 0 0 10px;
  line-height: 1.75;
  font-size: 0.875rem;
  word-break: break-word;
}

.comment-content p {
  margin: 0 0 6px;
}

.comment-content p:last-child {
  margin-bottom: 0;
}

.comment-content blockquote {
  margin: 8px 0;
  padding: 6px 12px;
  border-left: 3px solid rgb(var(--mdui-color-primary));
  background: rgb(var(--mdui-color-surface-container));
  border-radius: 0 6px 6px 0;
  font-size: 0.8125rem;
  color: rgb(var(--mdui-color-on-surface-variant));
}

.comment-content code {
  padding: 1px 5px;
  background: rgb(var(--mdui-color-surface-container-highest));
  border-radius: 4px;
  font-size: 0.8125rem;
}

/* ---- 分页 ---- */
.comments-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin: 28px 0 12px;
}

.comments-pagination a,
.comments-pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 0.8125rem;
  text-decoration: none;
  transition: all 0.15s;
}

.comments-pagination a {
  color: rgb(var(--mdui-color-on-surface));
  background: rgb(var(--mdui-color-surface-container));
}

.comments-pagination a:hover {
  background: rgb(var(--mdui-color-surface-container-highest));
}

.comments-pagination .current {
  background: rgb(var(--mdui-color-primary));
  color: rgb(var(--mdui-color-on-primary));
}

.comments-pagination .prev,
.comments-pagination .next {
  color: rgb(var(--mdui-color-on-surface-variant));
}

/* ========== 发表评论表单 ========== */
.respond {
  margin-top: 32px;
  padding: 24px;
  background: rgb(var(--mdui-color-surface-container-low));
  border: 1px solid rgb(var(--mdui-color-outline-variant));
  border-radius: 12px;
}

.respond-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.respond-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.respond .cancel-comment-reply a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.75rem;
  color: rgb(var(--mdui-color-on-surface-variant));
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.15s;
}

.respond .cancel-comment-reply a:hover {
  background: rgb(var(--mdui-color-surface-container-highest));
  color: rgb(var(--mdui-color-primary));
}

.comment-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.comment-form .form-group {
  margin-bottom: 14px;
}

.comment-form label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgb(var(--mdui-color-on-surface-variant));
  margin-bottom: 4px;
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid rgb(var(--mdui-color-outline-variant));
  border-radius: 8px;
  background: rgb(var(--mdui-color-surface));
  color: rgb(var(--mdui-color-on-surface));
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.comment-form input:focus,
.comment-form textarea:focus {
  border-color: rgb(var(--mdui-color-primary));
  box-shadow: 0 0 0 3px rgba(var(--mdui-color-primary), 0.12);
}

.comment-form textarea {
  resize: vertical;
  min-height: 110px;
}

.comment-form .form-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.comment-form .form-hint {
  font-size: 0.75rem;
  color: rgb(var(--mdui-color-on-surface-variant));
  margin-right: auto;
}

.comment-form button[type="submit"] {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  background: rgb(var(--mdui-color-primary));
  color: rgb(var(--mdui-color-on-primary));
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}

.comment-form button[type="submit"]:hover {
  opacity: 0.9;
}

.comment-form button[type="submit"]:active {
  opacity: 0.8;
}

/* ---- 登录身份提示 ---- */
.respond-logged-in {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  background: rgb(var(--mdui-color-surface-container));
  border: 1px solid rgb(var(--mdui-color-outline-variant));
  border-radius: 8px;
  font-size: 0.8125rem;
  color: rgb(var(--mdui-color-on-surface-variant));
}

.respond-logged-in .user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.respond-logged-in .user-name {
  flex: 1;
  font-weight: 500;
  color: rgb(var(--mdui-color-on-surface));
}

.respond-logged-in .logout-link {
  color: rgb(var(--mdui-color-on-surface-variant));
  text-decoration: none;
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
}

.respond-logged-in .logout-link:hover {
  background: rgb(var(--mdui-color-surface-container-highest));
  color: rgb(var(--mdui-color-primary));
}

/* ---- 评论已关闭 ---- */
.comments-closed {
  margin-top: 24px;
  padding: 24px;
  text-align: center;
  background: rgb(var(--mdui-color-surface-container-low));
  border: 1px solid rgb(var(--mdui-color-outline-variant));
  border-radius: 12px;
  color: rgb(var(--mdui-color-on-surface-variant));
  font-size: 0.875rem;
}

.comments-closed .material-icons-round {
  font-size: 2rem;
  margin-bottom: 8px;
  opacity: 0.5;
}

.comments-closed p {
  margin: 0;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .comment-item.comment-child > .comment-card {
    margin-left: 16px;
    border-left-width: 2px;
  }

  .comment-card {
    padding: 14px 14px;
  }

  .comment-content {
    margin-left: 0;
  }

  .comment-form .form-row {
    grid-template-columns: 1fr;
  }

  .respond {
    padding: 18px 16px;
  }

  .comment-form .form-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .comment-form .form-hint {
    margin-right: 0;
    text-align: center;
  }

  .comment-form button[type="submit"] {
    justify-content: center;
  }
}
