/**
 * MWLib 评论系统样式
 * 复刻自 macwr.com
 */

/* ========================================
   弹窗式留言板样式
   ======================================== */

/* 留言触发按钮 */
.comment-trigger-btn {
    position: fixed;
    bottom: 40px;
    right: 40px;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(74, 144, 226, 0.4);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 999;
    font-family: inherit;
}

.comment-trigger-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 144, 226, 0.5);
}

.comment-trigger-btn:active {
    transform: translateY(0);
}

.comment-count {
    background: rgba(255, 255, 255, 0.3);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 14px;
}

/* 模态框遮罩 */
.comment-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    animation: fadeIn 0.3s;
}

.comment-modal-overlay.active {
    display: block;
}

/* 留言模态框容器 */
.comment-modal-container {
    position: fixed;
    right: 20px;
    bottom: -100%;
    width: 90%;
    max-width: 500px;
    height: 80vh;
    background: var(--card-bg, #ffffff);
    z-index: 9999;
    transition: bottom 0.3s ease-in-out;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
}

.comment-modal-container.active {
    bottom: 20px;
}

/* 模态框头部 */
.comment-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.comment-modal-title {
    font-size: 16px;
    font-weight: 600;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.comment-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.comment-policy-link {
    color: white;
    font-size: 12px;
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.15);
    transition: all 0.3s;
    white-space: nowrap;
}

.comment-policy-link:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.comment-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
    font-family: Arial, sans-serif;
}

.comment-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 模态框主体 */
.comment-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    background: var(--bg-primary, #ffffff);
}

.comment-modal-body::-webkit-scrollbar {
    width: 6px;
}

.comment-modal-body::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 3px;
}

.comment-modal-body::-webkit-scrollbar-track {
    background: #f5f5f5;
}

/* 模态框主体内的评论样式 */
.comment-modal-body .comments-list {
    margin: 0;
}

.comment-modal-body .comment-item {
    background: transparent;
    padding: 16px 0;
    border-radius: 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-light, #f0f0f0);
}

.comment-modal-body .comment-item:last-child {
    border-bottom: none;
}

/* 空状态 */
.empty-comment-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary, #8492a6);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

/* 加载状态 */
.loading-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary, #8492a6);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 12px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 模态框底部 */
.comment-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light, #f0f0f0);
    background: var(--bg-tertiary, #fafafa);
    flex-shrink: 0;
}

.comment-hint {
    color: var(--text-tertiary, #8492a6);
    font-size: 12px;
    margin-bottom: 12px;
    line-height: 1.5;
}

/* ========================================
   留言区域通用样式
   ======================================== */

/* 最新留言区域 */
.latest-comment {
    margin-top: 10px;
}

/* 单条评论 */
.comment-item {
    background: var(--bg-tertiary, #f8f9fa);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 15px;
    transition: all 0.3s;
}

.comment-item:hover {
    background: var(--hover-bg, #f0f2f5);
}

/* 评论头部 */
.comment-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.comment-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

/* 评论操作按钮 */
.comment-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.comment-action-btn {
    font-size: 13px;
    color: var(--text-tertiary, #8492a6);
    cursor: pointer;
    transition: color 0.3s;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
}

.comment-action-btn:hover {
    color: #667eea;
}

.comment-action-btn.delete:hover {
    color: #ff4444;
}

/* 置顶标识 */
.comment-pin-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: linear-gradient(135deg, #ffd89b 0%, #ffa500 100%);
    color: white;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
}

/* 评论头像 */
.comment-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    overflow: hidden;
}

.comment-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 评论用户信息 */
.comment-user-info {
    flex: 1;
}

.comment-username {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #2c3e50);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* 用户等级标签 */
.user-level-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.user-level-badge .level-icon {
    font-size: 10px;
}

.user-level-badge .level-name {
    font-size: 10px;
}

.user-level-admin {
    font-weight: 600;
}

/* 评论等级标签 */
.comment-level-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 500;
}

.comment-level-badge .level-icon {
    font-size: 9px;
}

.comment-level-badge .level-name {
    font-size: 9px;
}

.comment-meta {
    font-size: 12px;
    color: var(--text-tertiary, #8492a6);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.comment-time {
    color: var(--text-tertiary, #8492a6);
}

.comment-meta-sep {
    color: var(--border-color, #d0d0d0);
    margin: 0 1px;
}

.comment-location,
.comment-os,
.comment-browser {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: #666;
    font-size: 11px;
}

.comment-location {
    background: rgba(102, 126, 234, 0.08);
    color: #667eea;
    padding: 2px 8px;
    border-radius: 10px;
}

.comment-os {
    background: rgba(40, 167, 69, 0.08);
    color: #28a745;
    padding: 2px 8px;
    border-radius: 10px;
}

.comment-browser {
    background: rgba(255, 193, 7, 0.1);
    color: #d39e00;
    padding: 2px 8px;
    border-radius: 10px;
}

.os-icon,
.browser-icon {
    font-size: 12px;
}

/* 评论内容 */
.comment-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary, #5f6368);
    padding-left: 52px;
    word-wrap: break-word;
    word-break: break-word;
}

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

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

/* ========================================
   回复区域
   ======================================== */

.comment-replies {
    margin-top: 15px;
    padding-left: 52px;
    border-left: 2px solid var(--border-light, #e9ecef);
}

.comment-reply-item {
    background: var(--card-bg, #ffffff);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.comment-reply-item:last-child {
    margin-bottom: 0;
}

.comment-reply-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.comment-reply-user {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #2c3e50);
}

.comment-reply-time {
    font-size: 11px;
    color: var(--text-tertiary, #8492a6);
}

.comment-reply-content {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary, #5f6368);
}

/* 回复表单 */
.reply-form {
    display: none;
    margin-top: 15px;
    padding-left: 52px;
}

.reply-form.active {
    display: block;
}

.reply-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    font-size: 13px;
    resize: vertical;
    font-family: inherit;
    margin-bottom: 8px;
    background: var(--input-bg, white);
    color: var(--text-primary, #333);
    min-height: 60px;
}

.reply-input:focus {
    outline: none;
    border-color: #667eea;
}

.reply-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.reply-submit-btn, .reply-cancel-btn {
    padding: 6px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    font-family: inherit;
}

.reply-submit-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.reply-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.reply-cancel-btn {
    background: var(--bg-tertiary, #f0f2f5);
    color: var(--text-secondary, #666);
}

.reply-cancel-btn:hover {
    background: var(--hover-bg, #e0e0e0);
}

/* ========================================
   留言输入区
   ======================================== */

.comment-form {
    margin-bottom: 30px;
    background: var(--bg-tertiary, #f8f9fa);
    padding: 20px;
    border-radius: 8px;
}

.comment-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    font-family: inherit;
    margin-bottom: 12px;
    transition: border-color 0.3s;
    background: var(--input-bg, white);
    color: var(--text-primary, #333);
    min-height: 80px;
}

.comment-input:focus {
    outline: none;
    border-color: #667eea;
}

/* 验证码和按钮同一行 */
.comment-form-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.captcha-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.captcha-input {
    width: 150px;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
    font-family: inherit;
}

.captcha-input:focus {
    outline: none;
    border-color: #667eea;
}

.captcha-image {
    height: 38px;
    width: 130px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid #e0e0e0;
}

.captcha-image:hover {
    opacity: 0.8;
    transform: scale(1.02);
}

.comment-submit-btn {
    background: linear-gradient(135deg, #007AFF 0%, #0051D5 100%);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.comment-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
}

/* ========================================
   模态框输入区
   ======================================== */

.comment-input-wrapper {
    margin-bottom: 12px;
    position: relative;
}

.modal-comment-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
    min-height: 80px;
    resize: vertical;
    background: var(--input-bg, white);
    color: var(--text-primary, #333);
    font-family: inherit;
    line-height: 1.6;
}

.modal-comment-input:focus {
    border-color: #667eea;
}

.comment-submit-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
}

.comment-submit-row .captcha-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 0;
    margin-right: auto; /* 验证码行占据左侧 */
}

.modal-submit-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 28px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    font-family: inherit;
}

.modal-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.modal-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ========================================
   游客信息输入
   ======================================== */

.guest-info-row {
    display: none;
    gap: 12px;
    margin-bottom: 12px;
    opacity: 0;
    animation: slideDown 0.3s ease forwards;
}

.guest-info-row.show {
    display: flex;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.guest-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
    font-family: inherit;
}

.guest-input:focus {
    outline: none;
    border-color: #667eea;
}

.guest-hint {
    display: none;
    font-size: 12px;
    color: #ff9800;
    margin-bottom: 12px;
    padding-left: 4px;
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

.guest-hint.show {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========================================
   留言列表
   ======================================== */

.comments-list {
    margin-top: 0;
}

/* ========================================
   动画
   ======================================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========================================
   响应式设计
   ======================================== */

@media (max-width: 768px) {
    .comment-trigger-btn {
        bottom: 20px;
        right: 20px;
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .comment-modal-container {
        right: 10px;
        width: calc(100% - 20px);
        max-height: 85vh;
    }
    
    .comment-modal-container.active {
        bottom: 10px;
    }
    
    .comment-modal-header {
        padding: 10px 16px;
    }
    
    .comment-modal-body {
        padding: 16px;
    }
    
    .comment-modal-footer {
        padding: 12px 16px;
    }
    
    .comment-content {
        padding-left: 0;
        margin-top: 8px;
    }
    
    .comment-replies {
        padding-left: 20px;
    }
    
    .reply-form {
        padding-left: 20px;
    }
    
    .comment-form-bottom {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .comment-submit-btn {
        width: 100%;
    }
    
    .comment-submit-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .captcha-row {
        width: 100%;
    }
    
    .captcha-input {
        flex: 1;
    }
    
    .captcha-image {
        width: 100px;
        height: 34px;
    }
    
    .modal-submit-btn {
        width: 100%;
        margin-top: 8px;
    }
    
    .guest-info-row {
        flex-direction: column;
        gap: 8px;
    }
}

/* ========================================
   暗色模式支持（可选）
   ======================================== */

@media (prefers-color-scheme: dark) {
    .comment-modal-container {
        --card-bg: #1e1e1e;
        --bg-primary: #1e1e1e;
        --bg-tertiary: #2d2d2d;
        --text-primary: #e0e0e0;
        --text-secondary: #b0b0b0;
        --text-tertiary: #808080;
        --border-light: #404040;
        --border-color: #404040;
        --input-bg: #2d2d2d;
        --hover-bg: #363636;
    }
}

/* ========================================
   点赞功能
   ======================================== */

.comment-actions-bottom {
    padding-left: 52px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.like-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border: none;
    background: rgba(0,0,0,0.05);
    border-radius: 16px;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    transition: all 0.2s;
}

.like-btn:hover {
    background: rgba(255,107,107,0.1);
}

.like-btn.liked {
    background: rgba(255,107,107,0.15);
    color: #ff6b6b;
}

.like-btn .like-icon {
    font-size: 14px;
}

.like-btn .like-count {
    font-size: 11px;
    font-weight: 500;
}

@keyframes likeAnim {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* ========================================
   表情面板
   ======================================== */

.emoji-trigger {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.emoji-trigger:hover {
    background: rgba(0,0,0,0.1);
    transform: scale(1.1);
}

.emoji-panel {
    position: absolute;
    bottom: 50px;
    right: 12px;
    width: 280px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 100;
    overflow: hidden;
}

.emoji-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #f5f5f5;
    font-size: 12px;
    color: #666;
}

.emoji-panel-close {
    border: none;
    background: none;
    font-size: 18px;
    cursor: pointer;
    color: #999;
    padding: 0;
    line-height: 1;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    padding: 8px;
}

.emoji-item {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 6px;
    font-size: 18px;
    transition: all 0.15s;
}

.emoji-item:hover {
    background: #f0f0f0;
    transform: scale(1.2);
}

/* ========================================
   加载状态
   ======================================== */

.loading-comments {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary, #8492a6);
    font-size: 14px;
}

.loading-comments::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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