/* ==========================================================================
   DS 高级评论系统 v7.7.0 — 样式
   命名空间:ds-cmt-
   ========================================================================== */

/* 1. 容器 */
.ds-cmt {
    max-width: 920px;
    margin: 32px auto;
    padding: 0 16px;
    font-family: var(--ds-font, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
    color: var(--ds-color-text-1, #1f2937);
}

/* 2. 顶部(标题 + 排序) */
.ds-cmt-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--ds-color-primary, #6366f1);
    margin-bottom: 16px;
}
.ds-cmt-title {
    font-size: var(--ds-fs-md, 18px);
    font-weight: 700;
    margin: 0;
    color: var(--ds-color-text-1, #1f2937);
}
.ds-cmt-total {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    background: var(--ds-color-bg, #f3f4f6);
    color: var(--ds-color-text-2, #4b5563);
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    min-width: 24px;
    text-align: center;
    line-height: 20px;
}
.ds-cmt-sort {
    margin-left: auto;
    display: flex;
    gap: 4px;
}
.ds-cmt-sort button {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--ds-color-border, #e5e7eb);
    border-radius: var(--ds-radius-sm, 4px);
    color: var(--ds-color-text-2, #4b5563);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.ds-cmt-sort button:hover { color: var(--ds-color-primary, #6366f1); border-color: var(--ds-color-primary, #6366f1); }
.ds-cmt-sort button.is-active {
    background: var(--ds-color-primary, #6366f1);
    color: #fff;
    border-color: var(--ds-color-primary, #6366f1);
}

/* 3. 登录提示 */
.ds-cmt-login-tip {
    text-align: center;
    padding: 16px;
    background: var(--ds-color-bg, #f3f4f6);
    border-radius: var(--ds-radius-md, 8px);
    color: var(--ds-color-text-2, #4b5563);
    font-size: var(--ds-fs-sm, 14px);
    margin-bottom: 16px;
}
.ds-cmt-login-tip a {
    color: var(--ds-color-primary, #6366f1);
    font-weight: 600;
    text-decoration: none;
}

/* 4. 评论表单 */
.ds-cmt-form {
    background: var(--ds-color-white, #fff);
    border: 1px solid var(--ds-color-border, #e5e7eb);
    border-radius: var(--ds-radius-md, 8px);
    padding: 12px;
    margin-bottom: 16px;
}
.ds-cmt-form-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.ds-cmt-form .ds-cmt-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
}
.ds-cmt-form-main {
    flex: 1;
    min-width: 0;
    position: relative;
}
.ds-cmt-textarea {
    width: 100%;
    min-height: 80px;
    padding: 8px 10px;
    border: 1px solid var(--ds-color-border, #e5e7eb);
    border-radius: var(--ds-radius-sm, 4px);
    font-size: var(--ds-fs-sm, 14px);
    font-family: inherit;
    color: var(--ds-color-text-1, #1f2937);
    resize: vertical;
    transition: border-color 0.15s;
    background: var(--ds-color-white, #fff);
}
.ds-cmt-textarea:focus {
    outline: none;
    border-color: var(--ds-color-primary, #6366f1);
}
.ds-cmt-textarea.is-dragover {
    border-color: var(--ds-color-primary, #6366f1);
    background: var(--ds-color-primary-light, #eef2ff);
    border-style: dashed;
}
.ds-cmt-form-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}
.ds-cmt-tools {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}
.ds-cmt-tool {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--ds-radius-sm, 4px);
    color: var(--ds-color-text-2, #4b5563);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.ds-cmt-tool:hover { background: var(--ds-color-bg, #f3f4f6); color: var(--ds-color-primary, #6366f1); }
.ds-cmt-count {
    margin-left: auto;
    font-size: 11px;
    color: var(--ds-color-text-3, #9ca3af);
}
.ds-cmt-form-actions { display: flex; gap: 6px; }
.ds-cmt-btn {
    padding: 6px 14px;
    border-radius: var(--ds-radius-sm, 4px);
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}
.ds-cmt-btn-primary {
    background: var(--ds-color-primary, #6366f1);
    color: #fff;
}
.ds-cmt-btn-primary:hover { background: var(--ds-color-primary-light, #4f46e5); }
.ds-cmt-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.ds-cmt-btn-ghost {
    background: var(--ds-color-bg, #f3f4f6);
    color: var(--ds-color-text-2, #4b5563);
}
.ds-cmt-btn-ghost:hover { background: var(--ds-color-border, #e5e7eb); }

/* 5. 表情选择器 */
.ds-cmt-emoji-pop {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    padding: 8px;
    background: var(--ds-color-white, #fff);
    border: 1px solid var(--ds-color-border, #e5e7eb);
    border-radius: var(--ds-radius-md, 8px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}
.ds-cmt-emoji-pop button {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--ds-radius-sm, 4px);
    font-size: 18px;
    cursor: pointer;
    transition: background 0.15s;
}
.ds-cmt-emoji-pop button:hover { background: var(--ds-color-bg, #f3f4f6); transform: scale(1.15); }

/* 6. @ 提醒 */
.ds-cmt-mention-pop {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 4px;
    min-width: 200px;
    max-height: 200px;
    overflow-y: auto;
    background: var(--ds-color-white, #fff);
    border: 1px solid var(--ds-color-border, #e5e7eb);
    border-radius: var(--ds-radius-md, 8px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 50;
}
.ds-cmt-mention-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    transition: background 0.15s;
}
.ds-cmt-mention-item:hover, .ds-cmt-mention-item.is-active { background: var(--ds-color-primary-light, #eef2ff); }
.ds-cmt-mention-item img {
    width: 24px; height: 24px;
    border-radius: 50%;
}
.ds-cmt-mention-item strong { font-size: 13px; color: var(--ds-color-text-1, #1f2937); }
.ds-cmt-mention-item span { font-size: 11px; color: var(--ds-color-text-3, #9ca3af); }

/* 7. 图片预览 */
.ds-cmt-image-preview {
    position: relative;
    margin-top: 8px;
    display: inline-block;
    max-width: 200px;
    border: 1px solid var(--ds-color-border, #e5e7eb);
    border-radius: var(--ds-radius-sm, 4px);
    overflow: hidden;
}
.ds-cmt-image-preview img {
    max-width: 200px;
    max-height: 200px;
    display: block;
}
.ds-cmt-image-remove {
    position: absolute;
    top: 4px; right: 4px;
    width: 22px; height: 22px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

/* 8. 列表 */
.ds-cmt-list { margin-top: 8px; }
.ds-cmt-empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--ds-color-text-3, #9ca3af);
    background: var(--ds-color-white, #fff);
    border: 1px dashed var(--ds-color-border, #e5e7eb);
    border-radius: var(--ds-radius-md, 8px);
    font-size: var(--ds-fs-sm, 14px);
}

/* 9. 单条评论 */
.ds-cmt-item {
    display: flex;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--ds-color-border, #e5e7eb);
}
.ds-cmt-item:last-child { border-bottom: none; }
.ds-cmt-item .ds-cmt-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--ds-color-bg, #f3f4f6);
}
.ds-cmt-body { flex: 1; min-width: 0; }
.ds-cmt-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.ds-cmt-author {
    font-size: 13px;
    color: var(--ds-color-text-1, #1f2937);
    font-weight: 600;
}
.ds-cmt-meta time {
    font-size: 11px;
    color: var(--ds-color-text-3, #9ca3af);
}
.ds-cmt-reply-to {
    font-size: 11px;
    color: var(--ds-color-text-3, #9ca3af);
}
.ds-cmt-reply-to strong {
    color: var(--ds-color-primary, #6366f1);
    font-weight: 600;
}
.ds-cmt-content {
    font-size: var(--ds-fs-sm, 14px);
    line-height: 1.6;
    color: var(--ds-color-text-1, #1f2937);
    word-break: break-word;
    white-space: pre-wrap;
}
.ds-cmt-content p { margin: 0 0 6px; }
.ds-cmt-content p:last-child { margin: 0; }
.ds-cmt-mention {
    color: var(--ds-color-primary, #6366f1);
    font-weight: 600;
    text-decoration: none;
}
.ds-cmt-mention:hover { text-decoration: underline; }
.ds-cmt-image {
    margin-top: 8px;
}
.ds-cmt-image img {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--ds-radius-sm, 4px);
    cursor: zoom-in;
    border: 1px solid var(--ds-color-border, #e5e7eb);
}

/* 10. 操作区(反应 + 按钮) */
.ds-cmt-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.ds-cmt-reactions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.ds-cmt-react {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--ds-color-text-3, #9ca3af);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
}
.ds-cmt-react:hover { background: var(--ds-color-bg, #f3f4f6); }
.ds-cmt-react.is-active {
    background: var(--ds-color-primary-light, #eef2ff);
    border-color: var(--ds-color-primary, #6366f1);
    color: var(--ds-color-primary, #6366f1);
}
.ds-cmt-react-emoji { font-size: 13px; }
.ds-cmt-react-num { font-weight: 600; }

.ds-cmt-buttons {
    margin-left: auto;
    display: flex;
    gap: 4px;
}
.ds-cmt-action {
    padding: 2px 8px;
    background: transparent;
    border: none;
    color: var(--ds-color-text-3, #9ca3af);
    font-size: 12px;
    cursor: pointer;
    transition: color 0.15s;
}
.ds-cmt-action:hover { color: var(--ds-color-primary, #6366f1); }
.ds-cmt-action-danger:hover { color: #ef4444; }

/* 11. 嵌套子评论 */
.ds-cmt-children {
    margin-top: 8px;
    padding-left: 16px;
    border-left: 2px solid var(--ds-color-border, #e5e7eb);
}
.ds-cmt-depth-1 .ds-cmt-avatar { width: 32px; height: 32px; }
.ds-cmt-depth-1 .ds-cmt-body { font-size: 13px; }
.ds-cmt-depth-1 .ds-cmt-content { font-size: 13px; }

/* 12. 加载更多 */
.ds-cmt-more {
    text-align: center;
    margin-top: 16px;
}
.ds-cmt-more .ds-cmt-btn-ghost {
    min-width: 200px;
}

/* 13. 响应式 */
@media (max-width: 768px) {
    .ds-cmt { padding: 0 12px; }
    .ds-cmt-head { flex-wrap: wrap; }
    .ds-cmt-sort { margin-left: 0; width: 100%; justify-content: flex-end; }
    .ds-cmt-form-row { gap: 8px; }
    .ds-cmt-form .ds-cmt-avatar { width: 32px; height: 32px; }
    .ds-cmt-item .ds-cmt-avatar { width: 32px; height: 32px; }
    .ds-cmt-children { padding-left: 8px; }
    .ds-cmt-reactions { flex: 1 1 100%; }
    .ds-cmt-buttons { margin-left: 0; }
    .ds-cmt-meta { font-size: 12px; }
}

/* ================================================================
 * v7.14: 展开更多回复按钮 + 锚点高亮
 * ================================================================ */
.ds-cmt-load-more {
    display: inline-block;
    margin: 8px 0 4px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    color: #3a8ee6;
    background: #f0f7ff;
    border: 1px dashed #93c5fd;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.18s;
    font-family: inherit;
}
.ds-cmt-load-more:hover {
    color: #fff;
    background: #3a8ee6;
    border-color: #3a8ee6;
    border-style: solid;
    transform: translateX(2px);
}
.ds-cmt-load-more:active {
    transform: scale(0.97);
}

/* 锚点高亮(2 秒动画) */
@keyframes ds-cmt-highlight-pulse {
    0%   { background: rgba(58, 142, 230, 0); }
    20%  { background: rgba(58, 142, 230, 0.18); }
    60%  { background: rgba(58, 142, 230, 0.12); }
    100% { background: rgba(58, 142, 230, 0); }
}
.ds-cmt-item.ds-cmt-highlight {
    animation: ds-cmt-highlight-pulse 2.4s ease-in-out;
    border-radius: 8px;
    position: relative;
}
.ds-cmt-item.ds-cmt-highlight::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: #3a8ee6;
    border-radius: 2px;
    animation: ds-cmt-highlight-bar 2.4s ease-in-out;
}
@keyframes ds-cmt-highlight-bar {
    0%, 100% { opacity: 0; transform: scaleY(0); }
    20%, 80% { opacity: 1; transform: scaleY(1); }
}

/* 暗色模式 */
@media (prefers-color-scheme: dark) {
    .ds-cmt-load-more {
        color: #60a5fa;
        background: #1e3a5f;
        border-color: #60a5fa;
    }
    .ds-cmt-load-more:hover {
        color: #fff;
        background: #3a8ee6;
        border-color: #3a8ee6;
    }
}
