/**
 * 消息样式优化
 * 为AI对话内容展示提供更流畅、合理的布局
 */

/* 消息容器 */
.messages {
    max-width: 900px;
    margin: 0 auto;
    padding-bottom: 120px;
}

/* 消息框架 */
.message {
    margin-bottom: 28px;
    animation: fadeIn 0.3s ease;
    display: flex;
    align-items: flex-start;
    position: relative;
}

.user-message {
    flex-direction: row-reverse;
}

/* 头像样式 */
.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin: 0 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--accent-blue);
    color: white;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.user-message .message-avatar {
    background-color: rgba(128, 128, 128, 0.2);
    color: var(--text-color);
}

.avatar-icon {
    width: 22px;
    height: 22px;
    color: white;
}

.avatar-text {
    font-size: 14px;
    font-weight: bold;
}

/* 消息内容包装器 */
.message-content-wrapper {
    max-width: 85%;
    min-width: 50px;
}

/* 消息头部 */
.message-header {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-size: 13px;
}

.message-sender {
    font-weight: 500;
    color: var(--text-color);
}

.message-time {
    color: var(--secondary-text);
    margin-left: 8px;
}

/* 消息主体内容 */
.message-content {
    position: relative;
    white-space: pre-wrap;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--input-bg);
    padding: 14px 18px;
    border-radius: 14px;
    font-size: 15px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow-wrap: break-word;
    word-break: break-word;
}

.user-message .message-content {
    background-color: rgba(58, 141, 255, 0.12);
}

.light-theme .user-message .message-content {
    background-color: rgba(58, 141, 255, 0.1);
}

.ai-message .message-content {
    background-color: transparent;
}

/* Markdown内容格式优化 */
.message-content > *:first-child {
    margin-top: 0 !important;
}

.message-content > *:last-child {
    margin-bottom: 0 !important;
}

/* 段落样式 */
.message-content p {
    margin: 12px 0;
    line-height: 1.6;
}

/* 标题样式 */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5 {
    margin-top: 20px;
    margin-bottom: 12px;
    font-weight: 600;
    line-height: 1.4;
}

.message-content h1 {
    font-size: 1.8em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.message-content h2 {
    font-size: 1.5em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
}

.message-content h3 {
    font-size: 1.3em;
}

.message-content h4 {
    font-size: 1.2em;
}

.message-content h5 {
    font-size: 1.1em;
}

/* 表格样式 */
.message-content table {
    border-collapse: collapse;
    margin: 16px 0;
    width: 100%;
    max-width: 100%;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.message-content table th,
.message-content table td {
    padding: 10px 12px;
    text-align: left;
    border: 1px solid var(--border-color);
}

.message-content table th {
    background-color: rgba(128, 128, 128, 0.08);
    font-weight: 600;
}

.message-content table tr:nth-child(even) {
    background-color: rgba(128, 128, 128, 0.04);
}

/* 列表样式 */
.message-content ul,
.message-content ol {
    margin: 12px 0 12px 20px;
    padding-left: 15px;
}

.message-content li {
    margin: 6px 0;
    line-height: 1.5;
}

.message-content ul {
    list-style-type: disc;
}

.message-content ol {
    list-style-type: decimal;
}

/* 代码块样式 */
.message-content pre {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 16px 16px 16px 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 16px 0;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 14px;
    line-height: 1.6;
    border: 1px solid rgba(128, 128, 128, 0.15);
    position: relative;
}

.message-content code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    background-color: rgba(0, 0, 0, 0.15);
    padding: 3px 5px;
    border-radius: 4px;
    font-size: 14px;
}

.light-theme .message-content pre {
    background-color: rgba(0, 0, 0, 0.05);
    color: #333;
}

.light-theme .message-content code {
    background-color: rgba(0, 0, 0, 0.05);
}

/* 代码语言标签 */
.message-content pre::before {
    content: attr(data-language);
    position: absolute;
    top: 0;
    right: 10px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    background-color: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 0 0 4px 4px;
    opacity: 0.8;
}

.light-theme .message-content pre::before {
    color: rgba(0, 0, 0, 0.6);
    background-color: rgba(0, 0, 0, 0.1);
}

/* 引用块样式 */
.message-content blockquote {
    padding: 12px 15px;
    margin: 16px 0;
    border-left: 4px solid var(--accent-blue);
    background-color: rgba(128, 128, 128, 0.08);
    color: var(--text-color);
    border-radius: 0 6px 6px 0;
}

/* 水平线样式 */
.message-content hr {
    border: none;
    height: 1px;
    background-color: var(--border-color);
    margin: 20px 0;
}

/* 复制按钮 */
.copy-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    min-width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(128, 128, 128, 0.15);
    color: var(--text-color);
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 20;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: scale(0.9);
    padding: 0 10px;
    cursor: pointer;
}

.message-content:hover .copy-btn {
    opacity: 1;
    transform: scale(1);
}

/* 触摸操作时显示复制按钮 */
.message-content:active .copy-btn,
.message-content:focus .copy-btn,
.message-content:focus-within .copy-btn {
    opacity: 1;
    transform: scale(1);
}

.copy-btn:hover {
    background-color: rgba(128, 128, 128, 0.25);
    transform: scale(1.05);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.copy-btn .copy-text {
    margin-left: 5px;
    font-size: 12px;
}

/* 思考动画优化 */
.thinking {
    opacity: 1;
    margin-bottom: 20px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.thinking-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 12px;
    height: 16px;
    background-color: rgba(74, 123, 255, 0.15);
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    width: auto;
    max-width: 90px;
    margin-left: 10px;
    border: 1px solid rgba(74, 123, 255, 0.2);
}

.thinking-dots::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 1.5s infinite;
    z-index: 1;
}

@keyframes shimmer {
    0% {
        transform: translateX(0%);
    }
    100% {
        transform: translateX(400%);
    }
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--accent-blue);
    margin: 0 2px;
    opacity: 0.85;
    animation: dot-pulse 1.2s infinite ease-in-out;
    position: relative;
    z-index: 2;
}

.dot:nth-child(2) {
    animation-delay: 0.2s;
}

.dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dot-pulse {
    0%, 100% {
        transform: scale(0.8);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
        box-shadow: 0 0 4px rgba(74, 123, 255, 0.6);
    }
}

/* 响应式设计优化 */
@media (max-width: 768px) {
    .messages {
        max-width: 100%;
    }
    
    .message-content-wrapper {
        max-width: 90%;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        margin: 0 8px;
    }
    
    .message-content {
        padding: 12px 14px;
        font-size: 14px;
    }
    
    .copy-btn {
        opacity: 0;
        bottom: 8px;
        right: 8px;
        min-width: 28px;
        height: 28px;
    }
    
    .copy-btn:hover .copy-text {
        display: none;
    }
}

/* 平板和中等屏幕设备 */
@media (min-width: 769px) and (max-width: 1200px) {
    .messages {
        max-width: 800px;
    }
}

/* 大屏幕设备 */
@media (min-width: 1201px) {
    .messages {
        max-width: 900px;
    }
}

/* 超宽屏幕 */
@media (min-width: 1600px) {
    .messages {
        max-width: 1000px;
    }
    
    .message-content {
        font-size: 16px;
    }
}

/* 响应进度显示 */
.response-progress {
    margin: 4px 0;
    padding: 2px 4px;
    border-radius: 8px;
    background-color: rgba(74, 123, 255, 0.03);
    animation: fadeInUp 0.4s ease;
    border: 1px solid rgba(74, 123, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

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

.progress-bar {
    width: 100%;
    min-height: 8px;
    background-color: transparent;
    border-radius: 4px;
    margin-bottom: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 新的动态加载动画 */
.animation-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 8px;
}

.anim-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #4a7bff;
    animation: anim-dot-pulse 1.4s infinite ease-in-out;
}

.anim-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.anim-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes anim-dot-pulse {
    0%, 80%, 100% { 
        transform: scale(0.6);
        opacity: 0.6;
    }
    40% { 
        transform: scale(1.2);
        opacity: 1;
        box-shadow: 0 0 8px rgba(74, 123, 255, 0.6);
    }
}

.progress-status {
    font-size: 13px;
    color: #4a7bff;
    text-align: center;
    margin-top: 5px;
    position: relative;
    font-weight: 500;
    letter-spacing: 0.2px;
    animation: status-pulse 2s infinite;
}

@keyframes status-pulse {
    0%, 100% {
        opacity: 0.8;
        transform: scale(0.98);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 思考过程显示 */
.thinking-process {
    margin: 10px 0;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.thinking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
}

.thinking-title {
    font-weight: 600;
    color: #555;
}

.thinking-toggle {
    background: none;
    border: none;
    color: #4a7bff;
    cursor: pointer;
    font-size: 13px;
}

.thinking-content {
    padding: 10px;
    max-height: 300px;
    overflow-y: auto;
    background-color: rgba(0, 0, 0, 0.02);
    font-size: 0.9em;
    color: #555;
}

/* 目录导航 */
.response-toc {
    margin: 10px 0 15px;
    border: 1px solid rgba(128, 128, 128, 0.15);
    border-radius: 8px;
    background-color: rgba(0, 0, 0, 0.02);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    transition: all 0.3s ease;
}

.toc-title {
    font-weight: 600;
    margin-bottom: 0;
    color: #333;
    padding: 12px 15px;
    background-color: rgba(74, 123, 255, 0.08);
    border-bottom: 1px solid rgba(128, 128, 128, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.toc-title i {
    color: #4a7bff;
}

.toc-list {
    list-style-type: none;
    padding: 12px 15px;
    margin: 0;
    max-height: 250px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.toc-list::-webkit-scrollbar {
    width: 6px;
}

.toc-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 3px;
}

.toc-list::-webkit-scrollbar-thumb {
    background-color: rgba(128, 128, 128, 0.3);
    border-radius: 3px;
}

.toc-item {
    margin: 4px 0;
    position: relative;
}

.toc-item a {
    color: #555;
    text-decoration: none;
    display: block;
    padding: 5px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 14px;
    line-height: 1.4;
}

.toc-item a:hover {
    color: #4a7bff;
    background-color: rgba(74, 123, 255, 0.1);
    padding-left: 12px;
}

.toc-level-1 { padding-left: 0; font-weight: 600; }
.toc-level-2 { padding-left: 15px; }
.toc-level-3 { padding-left: 30px; }
.toc-level-4 { padding-left: 45px; }
.toc-level-5 { padding-left: 60px; }
.toc-level-6 { padding-left: 75px; }

/* 标题高亮动画 */
.highlight-heading {
    background-color: rgba(74, 123, 255, 0.2);
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

/* 长文本导航和折叠 */
.message-section-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.collapse-all-btn,
.expand-all-btn {
    background-color: rgba(128, 128, 128, 0.08);
    border: 1px solid rgba(128, 128, 128, 0.15);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    color: #555;
}

.collapse-all-btn:hover,
.expand-all-btn:hover {
    background-color: rgba(74, 123, 255, 0.15);
    color: #4a7bff;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.collapse-all-btn:active,
.expand-all-btn:active {
    transform: translateY(0);
}

.collapse-all-btn i,
.expand-all-btn i {
    color: #4a7bff;
    font-size: 12px;
}

.collapse-section-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0 8px;
    margin-left: 8px;
    font-size: 12px;
    opacity: 0.7;
    transition: all 0.2s ease;
}

.collapse-section-btn:hover {
    opacity: 1;
    color: #4a7bff;
}

/* 重试按钮 */
.retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background-color: #f0f0f0;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    margin-top: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.retry-btn:hover {
    background-color: #e0e0e0;
}

.error-message {
    color: #f44336;
    margin: 10px 0;
    padding: 8px 12px;
    background-color: rgba(244, 67, 54, 0.1);
    border-radius: 4px;
}

.error-recovery {
    color: #555;
    font-style: italic;
    margin: 5px 0;
}

/* 模式指示器 */
.mode-indicator {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 15px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.mode-indicator.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.mode-indicator i {
    font-size: 16px;
}

.mode-indicator.chat-mode i {
    color: #4a7bff;
}

.mode-indicator.deep-mode i {
    color: #ff9800;
}

.mode-indicator.think-mode i {
    color: #9c27b0;
}

/* 等待消息提示 */
.waiting-message {
    background-color: rgba(0, 0, 0, 0.05);
    border-left: 3px solid #4a7bff;
    margin: 10px 0;
    padding: 10px 15px;
    border-radius: 0 4px 4px 0;
    font-size: 13px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
    animation: pulse-bg 2s infinite;
}

.waiting-message i {
    color: #4a7bff;
    font-size: 16px;
}

@keyframes pulse-bg {
    0%, 100% {
        background-color: rgba(0, 0, 0, 0.05);
    }
    50% {
        background-color: rgba(74, 123, 255, 0.08);
    }
}

/* 提交按钮处理中状态 */
.submit-btn.processing {
    opacity: 0.7;
    cursor: wait;
}

.submit-btn.processing:hover {
    background-color: var(--accent-blue);
}

/* 长文本内容导航和信息展示 */
.content-info {
    background-color: rgba(74, 123, 255, 0.05);
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 6px;
    margin-bottom: 15px;
    color: rgba(50, 50, 50, 0.7);
    border-left: 3px solid rgba(74, 123, 255, 0.4);
}

.content-progress-info {
    background-color: rgba(255, 193, 7, 0.1);
    padding: 4px 12px;
    font-size: 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    color: rgba(50, 50, 50, 0.7);
    border-left: 3px solid rgba(255, 193, 7, 0.7);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.7;
    }
}

/* 错误信息样式优化 */
.error-message {
    background-color: rgba(255, 87, 87, 0.1);
    padding: 10px 15px;
    border-radius: 6px;
    margin: 15px 0;
    color: #e53935;
    border-left: 3px solid #e53935;
    font-size: 14px;
}

/* 内容恢复按钮样式 */
.check-complete-btn,
.show-full-content-btn,
.recovery-btn {
    background-color: rgba(74, 123, 255, 0.1);
    color: #4a7bff;
    border: 1px solid rgba(74, 123, 255, 0.2);
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 13px;
    margin: 10px 0;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.check-complete-btn:hover,
.show-full-content-btn:hover,
.recovery-btn:hover {
    background-color: rgba(74, 123, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.check-complete-btn:before {
    content: "\f021";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    margin-right: 6px;
}

.show-full-content-btn:before {
    content: "\f06e";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    margin-right: 6px;
}

.recovery-btn:before {
    content: "\f2ea";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    margin-right: 6px;
}

/* 完整内容存储器样式 */
.full-content-store {
    display: none;
}

/* 内容块样式 */
.content-chunk {
    position: relative;
}

.content-chunk:not(:first-child):before {
    content: '';
    height: 1px;
    background: rgba(74, 123, 255, 0.1);
    width: 100%;
    display: block;
    margin: 10px 0;
}

/* 原始内容显示 */
.raw-content {
    white-space: pre-wrap;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 14px;
    line-height: 1.5;
    overflow-x: auto;
    color: #333;
}

.dark-theme .raw-content {
    background-color: rgba(255, 255, 255, 0.05);
    color: #ddd;
}

/* 兼容深色模式的按钮样式 */
.dark-theme .check-complete-btn,
.dark-theme .show-full-content-btn,
.dark-theme .recovery-btn {
    background-color: rgba(74, 123, 255, 0.15);
    color: #7aa3ff;
    border-color: rgba(74, 123, 255, 0.3);
}

.dark-theme .check-complete-btn:hover,
.dark-theme .show-full-content-btn:hover,
.dark-theme .recovery-btn:hover {
    background-color: rgba(74, 123, 255, 0.25);
}

/* 完整内容包装器样式 */
.complete-content-wrapper {
    width: 100%;
} 