/* 流量智囊团样式 - Modern UI 适配 */

.ai-expert-section {
    padding: 0; /* 让卡片 padding 生效 */
    width: 100%;
}

/* 覆盖特定状态下的显示逻辑 */
body:has(.ai-expert-section[style*="block"]) #progressSection,
body:has(.ai-expert-section[style*="block"]) .progress-section {
    display: none !important;
}

.ai-expert-active #progressSection,
.ai-expert-active .progress-section {
    display: none !important;
}

/* 当处于 AI 专家模式时，调整外层卡片样式以适应全屏聊天 */
#replicaCard.ai-expert-active {
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    min-height: auto !important;
}

.ai-expert-header {
    margin-bottom: var(--spacing-md);
}

.ai-expert-header h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.ai-expert-chat-container {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    background: #fafafa;
    margin-bottom: var(--spacing-md);
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
}

.ai-expert-messages {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
}

.ai-expert-message {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    position: relative;
    animation: fadeIn 0.3s ease;
}

.ai-expert-message.user {
    align-items: flex-end;
}

.ai-expert-message.assistant {
    align-items: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.ai-expert-message.user .message-avatar {
    background: linear-gradient(135deg, var(--primary-color), #ff7155);
    color: white;
}

.ai-expert-message.assistant .message-avatar {
    background: white;
    border: 1px solid var(--border-color);
}

.message-content-wrapper {
    width: 100%;
    max-width: 100%;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-text {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    line-height: 1.6;
    font-size: 15px;
    word-wrap: break-word;
    white-space: pre-wrap;
    box-shadow: var(--shadow-sm);
}

/* 复制按钮样式 - 放在文字框下方 */
.message-copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.7;
    align-self: flex-start;
    width: auto;
}

.message-copy-btn:hover {
    background: white;
    color: var(--primary-color);
    border-color: var(--primary-color);
    opacity: 1;
}

/* 移动端：始终显示按钮 */
@media (max-width: 768px) {
    .message-copy-btn {
        opacity: 0.8;
    }
}

/* 桌面端：hover时显示 */
@media (min-width: 769px) {
    .message-copy-btn {
        opacity: 0;
    }
    
    .message-content:hover .message-copy-btn {
        opacity: 1;
    }
}

.message-copy-btn .copy-icon {
    font-size: 14px;
    line-height: 1;
}

.message-copy-btn .copy-text {
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
}

/* Logo头像样式 */
.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* 流量智囊团模式下隐藏发布按钮和开始分析按钮 */
.ai-expert-active #publishBtn,
body.ai-expert-active #publishBtn,
.ai-expert-active #analyzeBtn,
body.ai-expert-active #analyzeBtn {
    display: none !important;
    visibility: hidden !important;
}

/* 额外保护：通过ID直接选择 */
#publishBtn[style*="display: none"],
#analyzeBtn[style*="display: none"] {
    display: none !important;
}

/* 如果aiExpertSection显示，强制隐藏按钮 */
#aiExpertSection:not([style*="display: none"]) ~ * #publishBtn,
#aiExpertSection:not([style*="display: none"]) ~ * #analyzeBtn {
    display: none !important;
}