/* ============================================================
   WordPress 增强评论模块 — comments.css
   配色：#fff（主背景）+ #c8102e（主题红）
   文件位置：主题目录 /wpcm/comments.css
   ============================================================ */

/* ── CSS 自定义属性 ── */
:root {
    --wpcm-red:        #c8102e;
    --wpcm-red-dark:   #a00d25;
    --wpcm-red-light:  #f9e5e8;
    --wpcm-white:      #ffffff;
    --wpcm-gray-50:    #f8f8f8;
    --wpcm-gray-100:   #f1f1f1;
    --wpcm-gray-200:   #e4e4e4;
    --wpcm-gray-400:   #9ca3af;
    --wpcm-gray-600:   #4b5563;
    --wpcm-gray-800:   #1f2937;
    --wpcm-radius:     10px;
    --wpcm-radius-sm:  6px;
    --wpcm-shadow:     0 2px 12px rgba(0, 0, 0, 0.07);
    --wpcm-shadow-md:  0 4px 24px rgba(0, 0, 0, 0.10);
    --wpcm-transition: 0.2s ease;
}

/* ── 整体区块 ── */
.wpcm-section {
    font-family: var(--wpcm-font);
    color: var(--wpcm-gray-800);
    max-width: 100%;
    margin: 40px auto;
    padding: 0 16px;
}

/* ── 区块标题 ── */
.wpcm-section__header {
    display: flex;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--wpcm-red);
}

.wpcm-section__title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--wpcm-gray-800);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wpcm-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    background: var(--wpcm-red);
    color: var(--wpcm-white);
    border-radius: 14px;
    font-size: 0.875rem;
    font-weight: 700;
}

/* ── 无评论提示 ── */
.wpcm-empty {
    text-align: center;
    color: var(--wpcm-gray-400);
    padding: 32px 0;
    font-size: 0.95rem;
    font-style: italic;
}

/* ════════════════════════════════════════
   评论列表 & 单条评论
   ════════════════════════════════════════ */

.wpcm-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* 单条评论卡片 */
.wpcm-comment {
    display: flex;
    gap: 14px;
    padding: 20px 0;
    border-bottom: 1px solid var(--wpcm-gray-100);
    animation: wpcm-fade-in 0.3s ease both;
}

.wpcm-comment:last-child {
    border-bottom: none;
}

@keyframes wpcm-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── 左侧头像 ── */
.wpcm-comment__avatar {
    flex-shrink: 0;
    position: relative;
}

.wpcm-comment__avatar .wpcm-avatar,
.wpcm-comment__avatar img {
    width: 48px !important;
    height: 48px !important;
    border-radius: 50%;
    border: 2.5px solid var(--wpcm-white);
    box-shadow: 0 0 0 2px var(--wpcm-red);
    object-fit: cover;
    display: block;
}

/* ── 右侧主体 ── */
.wpcm-comment__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 第一行：评论内容 */
.wpcm-comment__content {
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--wpcm-gray-800);
    word-break: break-word;
}

.wpcm-comment__content p {
    margin: 0;
}

/* 图片行 */
.wpcm-comment__images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.wpcm-comment__img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--wpcm-radius-sm);
    border: 2px solid var(--wpcm-gray-200);
    cursor: pointer;
    transition: transform var(--wpcm-transition), border-color var(--wpcm-transition);
}

.wpcm-img-link:hover .wpcm-comment__img {
    transform: scale(1.04);
    border-color: var(--wpcm-red);
}

/* 第二行：作者 + 时间 + Reply */
.wpcm-comment__meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8125rem;
    color: var(--wpcm-gray-400);
}

.wpcm-comment__author {
    font-weight: 600;
    color: var(--wpcm-gray-600);
}

.wpcm-comment__date {
    flex: 1; /* 撑开，让 Reply 右对齐 */
}

/* Reply 按钮 */
.wpcm-reply-btn {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 12px;
    border: 1.5px solid var(--wpcm-red);
    border-radius: 20px;
    background: transparent;
    color: var(--wpcm-red);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--wpcm-transition), color var(--wpcm-transition);
    white-space: nowrap;
}

.wpcm-reply-btn:hover {
    background: var(--wpcm-red);
    color: var(--wpcm-white);
}

/* ── 子评论（嵌套） ── */
.wpcm-replies {
    margin-left: 62px; /* avatar(48) + gap(14) */
    border-left: 2px solid var(--wpcm-red-light);
    padding-left: 16px;
}

.wpcm-comment--child {
    padding: 14px 0;
}

.wpcm-comment--child .wpcm-comment__avatar img,
.wpcm-comment--child .wpcm-comment__avatar .wpcm-avatar {
    width: 36px !important;
    height: 36px !important;
}

/* 深层子评论缩进限制 */
.wpcm-depth-3 .wpcm-replies,
.wpcm-depth-4 .wpcm-replies {
    margin-left: 24px;
}

/* ════════════════════════════════════════
   评论表单
   ════════════════════════════════════════ */

.wpcm-form-wrap {
    margin-top: 40px;
    background: var(--wpcm-white);
    border: 1.5px solid var(--wpcm-gray-200);
    border-radius: var(--wpcm-radius);
    padding: 28px;
    box-shadow: var(--wpcm-shadow);
}

/* 表单标题行 */
.wpcm-form__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--wpcm-red);
}

.wpcm-form__title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--wpcm-gray-800);
    margin: 0;
}

/* 正在回复提示 */
.wpcm-cancel-reply {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--wpcm-gray-600);
    background: var(--wpcm-red-light);
    padding: 6px 12px;
    border-radius: 20px;
    animation: wpcm-fade-in 0.2s ease both;
}

.wpcm-replying-to strong {
    color: var(--wpcm-red);
}

.wpcm-cancel-reply-btn {
    color: var(--wpcm-red);
    text-decoration: none;
    font-weight: 600;
    transition: opacity var(--wpcm-transition);
}

.wpcm-cancel-reply-btn:hover {
    opacity: 0.75;
}

/* WP 原生 form 重置 */
.wpcm-form .comment-form,
#commentform.wpcm-form {
    margin: 0;
    padding: 0;
}

/* 评论文本框 */
.wpcm-field {
    margin-bottom: 14px;
}

.wpcm-field textarea,
.wpcm-field input[type="text"],
.wpcm-field input[type="email"],
.wpcm-field input[type="url"] {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--wpcm-gray-200);
    border-radius: var(--wpcm-radius-sm);
    font-size: 0.9rem;
    font-family: var(--wpcm-font);
    color: var(--wpcm-gray-800);
    background: var(--wpcm-gray-50);
    transition: border-color var(--wpcm-transition), box-shadow var(--wpcm-transition);
    box-sizing: border-box;
    outline: none;
}

.wpcm-field textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.6;
}

.wpcm-field textarea:focus,
.wpcm-field input:focus {
    border-color: var(--wpcm-red);
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.12);
    background: var(--wpcm-white);
}

/* 三字段横排 */
.wpcm-fields-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

/* ── 图片上传区 ── */
.wpcm-upload-area {
    margin-bottom: 16px;
}

.wpcm-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1.5px dashed var(--wpcm-gray-200);
    border-radius: var(--wpcm-radius-sm);
    color: var(--wpcm-gray-600);
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color var(--wpcm-transition), color var(--wpcm-transition), background var(--wpcm-transition);
    user-select: none;
    background: var(--wpcm-gray-50);
}

.wpcm-upload-label:hover {
    border-color: var(--wpcm-red);
    color: var(--wpcm-red);
    background: var(--wpcm-red-light);
}

.wpcm-upload-label em {
    font-style: normal;
    color: var(--wpcm-gray-400);
    font-size: 0.78rem;
}

.wpcm-upload-icon {
    flex-shrink: 0;
}

.wpcm-file-input {
    display: none;
}

/* 上传错误提示 */
.wpcm-upload-error {
    margin-top: 6px;
    color: var(--wpcm-red);
    font-size: 0.82rem;
    min-height: 0;
    transition: all var(--wpcm-transition);
}

/* 图片预览行 */
.wpcm-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.wpcm-preview-item {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: var(--wpcm-radius-sm);
    overflow: hidden;
    box-shadow: var(--wpcm-shadow);
    animation: wpcm-fade-in 0.25s ease both;
}

.wpcm-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.wpcm-preview-remove {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--wpcm-red);
    color: var(--wpcm-white);
    border: none;
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--wpcm-transition);
}

.wpcm-preview-item:hover .wpcm-preview-remove {
    opacity: 1;
}

/* ── 表单底部（提交按钮区） ── */
.wpcm-form__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 4px;
}

/* 隐藏 WP 原生 cookies 复选框 */
.comment-form .comment-form-cookies-consent {
    display: none !important;
}

/* 提交按钮 */
.wpcm-submit {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 32px;
    background: var(--wpcm-red);
    color: var(--wpcm-white);
    border: none;
    border-radius: var(--wpcm-radius-sm);
    font-size: 0.95rem;
    font-weight: 700;
    font-family: var(--wpcm-font);
    cursor: pointer;
    transition: background var(--wpcm-transition), transform var(--wpcm-transition), box-shadow var(--wpcm-transition);
    letter-spacing: 0.02em;
}

.wpcm-submit:hover {
    background: var(--wpcm-red-dark);
    box-shadow: 0 4px 16px rgba(200, 16, 46, 0.35);
    transform: translateY(-1px);
}

.wpcm-submit:active {
    transform: translateY(0);
    box-shadow: none;
}

.wpcm-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

/* 加载旋转圈 */
.wpcm-submit__spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2.5px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: wpcm-spin 0.7s linear infinite;
}

.wpcm-submit.loading .wpcm-submit__spinner {
    display: inline-block;
}

.wpcm-submit.loading .wpcm-submit__text {
    opacity: 0.7;
}

@keyframes wpcm-spin {
    to { transform: rotate(360deg); }
}

/* ── 灯箱（点击大图） ── */
.wpcm-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 0;
    animation: wpcm-lb-in 0.2s ease forwards;
}

@keyframes wpcm-lb-in {
    to { opacity: 1; }
}

.wpcm-lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--wpcm-radius-sm);
    box-shadow: 0 8px 48px rgba(0,0,0,0.6);
}

.wpcm-lightbox-close {
    position: absolute;
    top: 20px;
    right: 24px;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    transition: opacity var(--wpcm-transition);
}

.wpcm-lightbox-close:hover {
    opacity: 1;
}

/* ════════════════════════════════════════
   响应式
   ════════════════════════════════════════ */
@media ( max-width: 640px ) {
    .wpcm-fields-row {
        grid-template-columns: 1fr;
    }

    .wpcm-replies {
        margin-left: 32px;
        padding-left: 12px;
    }

    .wpcm-comment__meta {
        flex-wrap: wrap;
        gap: 6px;
    }

    .wpcm-comment__date {
        flex: none;
    }

    .wpcm-reply-btn {
        margin-left: 0;
    }

    .wpcm-form-wrap {
        padding: 20px 16px;
    }

    .wpcm-form__header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ── 后台评论图片样式（已在 functions.php admin_head 注入，此处备用） ── */
.wpcm-comment-images {
    margin-top: 8px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.wpcm-comment-images a img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 4px;
    border: 2px solid var(--wpcm-red, #c8102e);
}