/* Topic 详情页样式 */

.copy-link-btn {
    position: relative;
    overflow: hidden;
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.copy-link-btn.copying {
    transform: scale(0.96);
}

.copy-link-btn.copy-success {
    color: #fff !important;
    background-color: #9CAF88 !important;
    border-color: #9CAF88 !important;
}

.copy-link-btn.copy-success::after {
    content: '';
    position: absolute;
    inset: -6px;
    pointer-events: none;
    background: radial-gradient(circle, rgba(156, 175, 136, 0.4) 0%, rgba(156, 175, 136, 0) 60%);
    animation: copy-pulse 0.6s ease-out;
}

@keyframes copy-pulse {
    from { transform: scale(0.9); opacity: 1; }
    to { transform: scale(1.4); opacity: 0; }
}

.user-hover-card {
    position: absolute;
    min-width: 280px;
    max-width: 400px;
    padding: 16px;
    border-radius: 12px;
    background: linear-gradient(135deg, #FDFCFB 0%, #F7F5F2 100%);
    border: 1px solid rgba(139, 130, 120, 0.1);
    box-shadow: 0 12px 40px rgba(139, 130, 120, 0.15), 0 0 0 1px rgba(139, 130, 120, 0.06);
    opacity: 0;
    transform: translateY(8px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1200;
}

.user-hover-card.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.uhc-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.uhc-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #F0EDE8;
    color: #4A4642;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    letter-spacing: 0.2px;
    overflow: hidden;
    border: 1px solid #D9D4CE;
    text-transform: uppercase;
}

.uhc-avatar.uhc-has-img {
    background-size: cover;
    background-position: center;
    color: transparent;
}

.uhc-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.uhc-name {
    font-weight: 700;
    color: #4A4642;
    line-height: 1.2;
}

.uhc-username {
    font-size: 0.9rem;
    color: #6B6560;
}

.uhc-meta {
    font-size: 0.85rem;
    color: #8B8580;
}

/* 用户悬停浮窗内容区域 */
.uhc-content {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(139, 130, 120, 0.1);
}

.uhc-content-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
    color: #64748b;
    font-size: 0.85rem;
    gap: 8px;
}

.uhc-content-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: ui-fade-in 0.2s ease;
}

.uhc-content-type {
    font-size: 0.7rem;
    font-weight: 700;
    color: #7A8B99;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 2px 8px;
    background: rgba(122, 139, 153, 0.12);
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
}

.uhc-content-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #4A4642;
    line-height: 1.4;
    margin-top: 2px;
}

.uhc-content-preview {
    font-size: 0.875rem;
    color: #5A5652;
    line-height: 1.6;
    max-height: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    background: rgba(247, 245, 242, 0.8);
    padding: 8px 10px;
    border-radius: 6px;
    border-left: 3px solid #A8B5A0;
}

.uhc-content-link {
    margin-top: 6px;
}

.uhc-content-link a {
    font-size: 0.875rem;
    color: #7A8B99;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.uhc-content-link a:hover {
    color: #5A6B7A;
    transform: translateX(2px);
}

/* 淡入动画 */
@keyframes ui-fade-in {
    from { 
        opacity: 0; 
        transform: translateY(-4px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* 回复内容样式 */
.reply-content img {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 8px !important;
    margin: 10px 0 !important;
}

/* 确保所有容器都不限制高度 */
.container, .card, .card-body, .row, .col-md-6, .col-12 {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

/* 确保表单容器不限制高度 */
form, .mb-3, .mt-4 {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

/* 确保回复表单容器不限制高度 */
#replyForm {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

/* 回复文本框样式 - 关键样式 */
#replyContent {
    width: 100% !important;
    min-height: 300px !important;
    resize: none !important;
    overflow-y: hidden !important; /* 隐藏垂直滚动条 */
    height: auto !important;
    /* 统一字体大小、行高和字体族，与预览区域保持一致 */
    font-size: 1rem !important; /* 16px，与预览区域一致 */
    line-height: 1.6 !important; /* 与预览区域一致 */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    padding: 0.75rem !important; /* 与预览区域padding保持一致 */
    max-height: none !important;
    box-sizing: border-box !important;
    display: block !important;
    border-right: none !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

#reply-preview {
    border-left: none !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    /* 统一字体大小、行高和字体族，与编辑框保持一致 */
    font-size: 1rem !important; /* 16px */
    line-height: 1.6 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    padding: 0.75rem !important; /* 与编辑框padding保持一致 */
}

/* 确保按钮区域不限制高度 */
.d-flex, .justify-content-between, .align-items-center {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

/* 小屏幕适配 */
@media (max-width: 768px) {
    #replyContent {
        margin-bottom: 10px !important;
    }

    .row.g-0 .col-md-6 {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
}

/* 确保模态框内容不限制高度 */
.modal-content, .modal-body {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

/* 移除全局字体大小调整，使用编辑器特定的样式 */

/* 推荐话题网格样式 - 一行5个 */
@media (min-width: 992px) {
    .related-topics-grid {
        display: flex;
        flex-wrap: wrap;
    }
    
    .related-topic-item {
        flex: 0 0 20%;
        max-width: 20%;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .related-topics-grid .related-topic-item:nth-child(n+6) {
        margin-top: 1rem;
    }
}

@media (min-width: 1200px) {
    .related-topic-item {
        flex: 0 0 20%;
        max-width: 20%;
    }
}

/* 推荐话题卡片链接样式 - 整个卡片可点击 */
.related-topic-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.related-topic-card-link:hover {
    text-decoration: none;
}

.related-topic-card-link:hover .related-topic-card {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
    border-color: #0d6efd !important;
}

.related-topic-card {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    border-color: #EDE8E2;
    background: linear-gradient(180deg, #FDFCFB 0%, #F7F5F2 100%);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.related-topic-card.related-topic-clicked {
    background: #F5F3F0;
    border-color: #D9D4CE;
    box-shadow: none;
}

.related-topic-card-link:active .related-topic-card {
    transform: translateY(0);
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

.related-topic-card .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.related-topic-badge {
    background: rgba(168, 181, 160, 0.15);
    color: #7A8B8C;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.related-topic-title {
    font-size: 0.95rem;
    line-height: 1.5;
    min-height: 3rem;
    max-height: 3rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* ========== 手机端优化：减少左边留白 ========== */
@media (max-width: 768px) {
    /* 回复列表项减少内边距 */
    #replies-list .list-group-item {
        padding: 0.75rem 0.5rem !important;
    }
    
    /* 回复头像区域减小 margin */
    #replies-list .d-flex.align-items-start > .flex-shrink-0.me-3 {
        margin-right: 0.5rem !important;
    }
    
    /* 回复头像缩小 */
    #replies-list .flex-shrink-0 .rounded-circle,
    #replies-list .avatar-wrapper .rounded-circle {
        width: 32px !important;
        height: 32px !important;
        font-size: 12px !important;
    }
    
    /* 话题头部头像也稍微缩小 */
    .card-header .avatar-wrapper .rounded-circle,
    .card-header .rounded-circle {
        width: 40px !important;
        height: 40px !important;
        font-size: 16px !important;
    }
    
    /* 话题头部减少 margin */
    .card-header .flex-shrink-0.me-3 {
        margin-right: 0.75rem !important;
    }
    
    /* 回复内容区域延伸到边缘 */
    #replies-list .flex-grow-1 {
        min-width: 0; /* 防止 flex item 溢出 */
    }
    
    /* 回复作者信息换行时处理 */
    #replies-list .d-flex.justify-content-between.align-items-center.mb-2 {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    /* 回复操作按钮组在小屏幕下调整 */
    #replies-list .btn-group {
        flex-shrink: 0;
    }
    
    /* 话题正文和回复正文区域减少内边距 */
    .topic-content,
    .reply-content {
        padding: 0 !important;
    }
    
    /* 卡片body减少内边距 */
    .card-body {
        padding: 1rem 0.75rem !important;
    }
    
    /* 回复表单的预览区域在小屏幕下隐藏（可选） */
    #reply-preview {
        display: none !important;
    }
    
    /* 回复编辑框占满宽度 */
    #replyContent {
        border-radius: 0.375rem !important;
        border-right: 1px solid #ced4da !important;
    }
    
    /* 容器减少内边距 */
    .container.py-4 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    /* 返回按钮区域减少 margin */
    .row.mb-3 {
        margin-bottom: 0.5rem !important;
    }
    
    /* 话题卡片减少 margin */
    .row.mb-4 {
        margin-bottom: 1rem !important;
    }
}

/* 更小屏幕的额外优化 */
@media (max-width: 576px) {
    /* 进一步减小内边距 */
    #replies-list .list-group-item {
        padding: 0.5rem 0.375rem !important;
    }
    
    /* 头像更小 */
    #replies-list .flex-shrink-0 .rounded-circle,
    #replies-list .avatar-wrapper .rounded-circle {
        width: 28px !important;
        height: 28px !important;
        font-size: 11px !important;
    }
    
    /* 回复按钮组简化 */
    #replies-list .btn-group .btn {
        padding: 0.2rem 0.4rem !important;
        font-size: 0.75rem !important;
    }
    
    /* 回复作者名字和按钮换行 */
    #replies-list .d-flex.justify-content-between.align-items-center.mb-2 {
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    #replies-list .d-flex.justify-content-between.align-items-center.mb-2 > div:last-child {
        margin-top: 0.25rem;
        width: 100%;
        justify-content: space-between;
    }
}

/* ========== 手机端代码块宽度优化 ========== */
@media (max-width: 768px) {
    /* 代码块宽度占满 */
    .topic-content pre,
    .topic-content .code-block,
    .reply-content pre,
    .reply-content .code-block,
    pre code {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 4px !important;
    }
    
    /* 代码块内部代码 */
    .topic-content pre code,
    .reply-content pre code,
    pre code {
        width: 100% !important;
        max-width: 100% !important;
        display: block !important;
        overflow-x: auto !important;
        white-space: pre !important;
        word-wrap: normal !important;
    }
    
    /* 表格宽度优化 */
    .topic-content table,
    .reply-content table,
    .table-responsive {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* 图片宽度优化 */
    .topic-content img,
    .reply-content img {
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* 引用块宽度优化 */
    .topic-content blockquote,
    .reply-content blockquote {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* 超小屏幕额外优化 */
@media (max-width: 576px) {
    .topic-content pre,
    .topic-content .code-block,
    .reply-content pre,
    .reply-content .code-block {
        font-size: 0.8125rem !important; /* 稍微减小字体 */
        padding: 0.5rem !important;
    }
}
