/**
 * 自定义评论系统样式
 */

/* 评论区域容器 */
.uap-comment-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

/* 评论表单 */
.uap-comment-form {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.uap-comment-avatar {
    flex-shrink: 0;
}

.uap-comment-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.uap-comment-input-wrapper {
    flex: 1;
    min-width: 0;
    position: relative;
}

.uap-comment-input {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s;
}

.uap-comment-input:focus {
    outline: none;
    border-color: #1d9bf0;
}

.uap-comment-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.uap-comment-tools {
    display: flex;
    gap: 4px;
}

.uap-comment-tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    color: #6b7280;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.uap-comment-tool-btn:hover {
    background: #f3f4f6;
    color: #1d9bf0;
}

.uap-comment-tool-btn:focus {
    outline: none;
    background: #eff6ff;
    color: #1d9bf0;
    box-shadow: 0 0 0 3px rgba(29, 155, 240, 0.1);
}

.uap-comment-tool-btn:active {
    background: #e5e7eb;
    transform: scale(0.95);
}

.uap-comment-actions {
    display: flex;
    gap: 8px;
}

.uap-comment-submit,
.uap-comment-cancel {
    padding: 6px 16px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.uap-comment-submit {
    background: #1d9bf0;
    color: #ffffff;
}

.uap-comment-submit:hover {
    background: #1a8cd8;
    box-shadow: 0 2px 8px rgba(29, 155, 240, 0.3);
}

.uap-comment-submit:focus {
    outline: none;
    background: #1a8cd8;
    box-shadow: 0 0 0 3px rgba(29, 155, 240, 0.2);
}

.uap-comment-submit:active {
    background: #1570b8;
    transform: scale(0.98);
}

.uap-comment-submit:disabled {
    background: #9ca3af;
    color: #ffffff;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.6;
}

.uap-comment-submit:disabled:hover {
    background: #9ca3af;
    box-shadow: none;
    transform: none;
}

.uap-comment-cancel {
    background: #f3f4f6;
    color: #374151;
}

.uap-comment-cancel:hover {
    background: #e5e7eb;
    color: #1f2937;
}

.uap-comment-cancel:focus {
    outline: none;
    background: #e5e7eb;
    box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.1);
}

.uap-comment-cancel:active {
    background: #d1d5db;
    transform: scale(0.98);
}

/* 图片预览 */
.uap-comment-image-preview {
    margin-top: 12px;
    margin-bottom: 12px;
}

.uap-comment-image-preview-item {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6;
}

.uap-comment-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.uap-comment-image-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 2;
}

.uap-comment-image-remove:hover {
    background: rgba(0, 0, 0, 0.8);
}

.uap-comment-image-remove svg {
    width: 14px;
    height: 14px;
    stroke: #fff;
}

/* 图片上传进度 */
.uap-comment-image-preview-item.uploading .uap-comment-preview-img {
    opacity: 0.5;
}

.uap-comment-image-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: none;
}

.uap-comment-image-preview-item.uploading .uap-comment-image-progress {
    display: block;
}

.uap-comment-image-progress-bar {
    height: 100%;
    background: #1d9bf0;
    width: 0;
    transition: width 0.3s ease;
}

.uap-comment-image-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    z-index: 5;
    display: none;
}

.uap-comment-image-preview-item.uploading .uap-comment-image-progress-text {
    display: block;
}

.uap-comment-image-preview-item.upload-error {
    border: 2px solid #ef4444;
}

.uap-comment-image-preview-item.upload-error::after {
    content: '!';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    background: #ef4444;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.uap-comment-image-preview-item.uploaded .uap-comment-image-progress {
    display: none;
}

.uap-comment-image-preview-item.uploaded .uap-comment-image-progress-text {
    display: none;
}

/* 评论列表 */
.uap-comment-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.uap-comment-item {
    display: flex;
    gap: 12px;
    padding: 0;
    background: unset;
    border: none;
}

.uap-comment-item .uap-comment-avatar img {
    width: 36px;
    height: 36px;
}

.uap-comment-content {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

.uap-comment-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.uap-comment-author {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    text-decoration: none;
}

.uap-comment-author:hover {
    text-decoration: underline;
}

.uap-comment-time {
    font-size: 13px;
    color: #6b7280;
}

.uap-comment-text {
    font-size: 14px;
    line-height: 1.5;
    color: #374151;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

/* @提及链接样式 */
.uap-comment-text .uap-mention {
    color: #1d9bf0;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.uap-comment-text .uap-mention:hover {
    color: #1a8cd8;
    text-decoration: underline;
}

/* 回复链接样式 */
.uap-reply-to {
    color: #1d9bf0;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.uap-reply-to:hover {
    color: #1a8cd8;
    text-decoration: underline;
}

/* 评论高亮效果 */
.uap-comment-highlight {
    background: #fff9e6;
    border-radius: 8px;
    animation: highlight-fade 3s ease-out;
}

@keyframes highlight-fade {
    0% { background: #fff9e6; }
    100% { background: transparent; }
}

.uap-comment-image {
    margin-top: 8px;
    max-width: 300px;
}

.uap-comment-image img {
    width: 76px;
    height: 76px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.uap-comment-image img:hover {
    opacity: 0.9;
}

.uap-comment-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.uap-comment-action-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.uap-comment-action-btn:hover {
    background: #f3f4f6;
    color: #1d9bf0;
}

.uap-comment-action-btn:focus {
    outline: none;
    background: #eff6ff;
    color: #1d9bf0;
    box-shadow: 0 0 0 2px rgba(29, 155, 240, 0.1);
}

.uap-comment-action-btn:active {
    background: #e5e7eb;
    transform: scale(0.95);
}

.uap-comment-like-btn.active {
    color: #ef4444;
}

.uap-comment-like-btn.active:hover {
    background: #fef2f2;
    color: #dc2626;
}

.uap-comment-like-btn.active:focus {
    background: #fee2e2;
    color: #dc2626;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.1);
}

.uap-comment-action-btn svg {
    flex-shrink: 0;
}

/* 回复表单容器 */
.uap-comment-reply-form-wrapper {
    margin-top: 12px;
}

/* 回复列表（二级评论，扁平显示） */
.uap-comment-replies {
    margin-top: 12px;
    padding-left: 12px;
    display: flex;
    flex-direction: column;
    gap: 0;
    border-left: 2px solid #f0f0f0;
}

/* 回复项样式 */
.uap-comment-reply-item {
    display: flex;
    gap: 12px;
}

.uap-comment-reply-item .uap-comment-avatar img {
    width: 32px;
    height: 32px;
}

.uap-comment-reply-item .uap-comment-author {
    font-size: 13px;
}

.uap-comment-reply-item .uap-comment-text {
    font-size: 13px;
}

.uap-comment-reply-item .uap-comment-time {
    font-size: 12px;
}

/* 空状态 */
.uap-comment-empty,
.uap-comment-loading {
    padding: 32px;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
}

/* 查看全部评论 */
.uap-comment-view-all-wrapper {
    margin-top: 16px;
    text-align: center;
}

.uap-comment-view-all {
    display: inline-block;
    padding: 8px 16px;
    color: #1d9bf0;
    font-size: 14px;
    text-decoration: none;
    border-radius: 20px;
    transition: background 0.2s;
}

.uap-comment-view-all:hover {
    background: #eff6ff;
}

/* 响应式 */
@media (max-width: 640px) {
    .uap-comment-form {
        gap: 8px;
    }
    
    .uap-comment-avatar img {
        width: 32px;
        height: 32px;
    }
    
    .uap-comment-item .uap-comment-avatar img {
        width: 32px;
        height: 32px;
    }
    
    .uap-comment-input {
        min-height: 60px;
        font-size: 13px;
    }
    
    .uap-comment-replies {
        padding-left: 6px;
    }
    
    .uap-comment-actions {
        gap: 6px;
    }
}

/* 动画 */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.uap-comment-item {
    animation: slideDown 0.3s ease-out;
}

/* 排序切换器 */
.uap-comment-sort-wrapper {
    display: flex;
    gap: 8px;
    margin: 16px auto 20px;
    padding: 4px;
    background: #f9fafb;
    border-radius: 8px;
    width: fit-content;
}

.uap-comment-sort-btn {
    padding: 6px 16px;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.uap-comment-sort-btn:hover {
    background: #ffffff;
    color: #374151;
}

.uap-comment-sort-btn.active {
    background: #ffffff;
    color: #1d9bf0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.uap-comment-sort-btn:focus {
    outline: none;
}

@media (max-width: 640px) {
    .uap-comment-sort-wrapper {
        width: 100%;
        justify-content: center;
    }
    
    .uap-comment-sort-btn {
        flex: 1;
        padding: 8px 12px;
    }
}

/* 置顶标识 */
.uap-comment-pinned-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    margin-bottom: 6px;
    background: #eff6ff;
    color: #1d9bf0;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
}

.uap-comment-pinned-badge svg {
    flex-shrink: 0;
}

.uap-comment-item.is-pinned {
    background: #f9fafb;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

@media (max-width: 640px) {
    .uap-comment-pinned-badge {
        font-size: 11px;
        padding: 2px 6px;
    }
}


/* 加载更多按钮 */
.uap-comment-load-more-wrapper {
    display: flex;
    justify-content: center;
    padding: 24px 0;
    margin-top: 16px;
}

.uap-comment-load-more-btn {
    padding: 10px 24px;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.uap-comment-load-more-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.uap-comment-load-more-btn:active {
    transform: translateY(0);
}

.uap-comment-load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.uap-comment-no-more {
    text-align: center;
    padding: 16px;
    color: #9ca3af;
    font-size: 14px;
}

/* 分页导航 */
.uap-comment-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 24px 0;
    margin-top: 16px;
}

.uap-pagination-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    background: #ffffff;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.uap-pagination-btn:hover {
    background: #f9fafb;
    border-color: #1d9bf0;
    color: #1d9bf0;
}

.uap-pagination-btn.active {
    background: #1d9bf0;
    color: #ffffff;
    border-color: #1d9bf0;
    cursor: default;
}

.uap-pagination-btn.active:hover {
    background: #1d9bf0;
    color: #ffffff;
}

.uap-pagination-prev,
.uap-pagination-next {
    padding: 0;
    width: 36px;
}

.uap-pagination-ellipsis {
    padding: 0 4px;
    color: #9ca3af;
    font-size: 14px;
}

/* 加载动画 */
.uap-comment-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #6b7280;
    font-size: 14px;
}

.uap-comment-loading::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    border: 2px solid #e5e7eb;
    border-top-color: #1d9bf0;
    border-radius: 50%;
    animation: uap-spin 0.6s linear infinite;
}

@keyframes uap-spin {
    to {
        transform: rotate(360deg);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .uap-comment-pagination {
        gap: 4px;
        padding: 16px 0;
    }
    
    .uap-pagination-btn {
        min-width: 32px;
        height: 32px;
        padding: 0 8px;
        font-size: 13px;
    }
    
    .uap-pagination-prev,
    .uap-pagination-next {
        width: 32px;
    }
    
    .uap-pagination-ellipsis {
        padding: 0 2px;
        font-size: 13px;
    }
    
    .uap-comment-load-more-btn {
        padding: 8px 20px;
        font-size: 13px;
    }
}
