/* 基础样式 */
:root {
    --primary-color: #007bff;
    --background-color: #ffffff;
    --text-color: #333333;
    --border-color: #e0e0e0;
    --message-bg-user: #f0f7ff;
    --message-bg-ai: #f5f5f5;
    --input-bg: #ffffff;
    --button-bg: #007bff;
    --button-text: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --hover-color: #0056b3;
    --transition-speed: 0.3s;
    --input-container-bg: #ffffff;
    --vh: 1vh; /* 动态视口高度变量 */
}

[data-theme="dark"] {
    --primary-color: #4a9eff;
    --background-color: #1a1a1a;
    --text-color: #ffffff;
    --border-color: #333333;
    --message-bg-user: #2a3a4a;
    --message-bg-ai: #2a2a2a;
    --input-bg: #2a2a2a;
    --button-bg: #4a9eff;
    --button-text: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --hover-color: #3a8eff;
    --input-container-bg: #1a1a1a;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: var(--border-color) transparent; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge 隐藏滚动条箭头 */
}

/* 全局过渡效果统一 */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: none; /* 移除过渡效果，避免接缝 */
}

.chat-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    height: 100vh; /* 标准视口高度 */
    height: calc(var(--vh, 1vh) * 100); /* 动态视口高度 */
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--background-color); /* 确保与body背景相同 */
    transition: none; /* 移除过渡效果，避免接缝 */
}

/* 顶部导航栏样式 */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
}

.spacer {
    flex-grow: 1;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.ai-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px; /* 保持顶部LOGO为圆角正方形 */
    transition: transform var(--transition-speed);
}

.ai-avatar:hover {
    transform: scale(1.1);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: var(--background-color);
    box-shadow: 0 2px 10px var(--shadow-color);
    border-radius: 10px;
    margin-bottom: 20px;
    animation: slideDown 0.5s ease-out;
}

.chat-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.top-bar h1 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-color);
}

/* 欢迎界面样式 */
.welcome-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
    animation: fadeIn 1s ease-out;
}

.welcome-content {
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
}

.welcome-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.welcome-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px; /* 圆角正方形 */
    box-shadow: 0 4px 20px var(--shadow-color);
    transition: transform var(--transition-speed);
}

.welcome-logo:hover {
    transform: scale(1.05);
}

.welcome-text-bold {
    font-size: 1.8rem;
    font-weight: 600;
    margin: 0;
    color: var(--primary-color);
}

.welcome-text-normal {
    font-size: 1rem;
    color: var(--text-color);
    opacity: 0.8;
    margin-bottom: 30px;
}

/* 消息区域样式 */
.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 10px; /* 减小底部边距到最小 */
    background-color: var(--background-color); /* 确保与body背景相同 */
    transition: none; /* 移除过渡效果，避免接缝 */
}

.message {
    max-width: 80%;
    padding: 15px 20px;
    border-radius: 20px;
    position: relative;
    animation: fadeIn 0.3s ease-out;
    box-shadow: 0 2px 10px var(--shadow-color);
    transition: none; /* 移除过渡效果，避免接缝 */
    font-size: 14px; /* 减小文字大小 */
    line-height: 1.5;
}

/* 移除消息的悬停效果，保持位置不变 */
.message:hover {
    transform: none;
}

/* 当鼠标悬停到消息上时，显示复制按钮 */
.message:hover .copy-button {
    opacity: 0.7; /* 显示复制按钮 */
}

.message.user {
    align-self: flex-end;
    background-color: var(--message-bg-user);
    border-bottom-right-radius: 5px;
}

.message.ai {
    align-self: flex-start;
    background-color: var(--message-bg-ai);
    border-bottom-left-radius: 5px;
    padding-left: 60px;
}

.message.ai::before {
    content: '';
    position: absolute;
    left: 12px; /* 调整左侧距离为12px */
    top: 12px; /* 调整顶部距离为12px */
    width: 30px;
    height: 30px;
    background-image: url('https://ai.axiaoke.com/images/logo.png');
    background-size: cover;
    border-radius: 50%; /* 恢复为圆形 */
}

/* 复制按钮样式优化 */
.copy-button {
    position: absolute;
    right: 10px;
    bottom: -30px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: none; /* 移除底色 */
    border: none; /* 移除边框 */
    box-shadow: none; /* 移除阴影 */
    color: #9e9e9e; /* 淡灰色 */
    opacity: 0; /* 默认隐藏 */
    transition: color 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

.copy-button:hover {
    color: #616161; /* 加深的灰色 */
    opacity: 1;
    transform: translateY(-2px); /* 轻微上移 */
}

.copy-button.copied {
    color: #4CAF50; /* 复制成功时显示绿色 */
    animation: pulse 0.5s;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* 主题切换按钮样式 */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    transition: all var(--transition-speed);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background-color: var(--border-color);
}

.light-icon,
.dark-icon {
    font-size: 1.2rem;
    color: var(--text-color);
}

[data-theme="light"] .dark-icon,
[data-theme="dark"] .light-icon {
    display: none;
}

/* 输入区域样式 - 统一规格 */
.chat-input-container {
    position: relative; /* 改为相对定位，不再固定在底部 */
    width: 100%;
    padding: 5px 10px;
    background-color: var(--input-container-bg);
    border-radius: 20px;
    box-shadow: none; /* 移除阴影效果 */
    margin-top: 5px; /* 减小顶部边距 */
    z-index: 10;
}

.chat-input-container * {
    transition: background-color var(--transition-speed), color var(--transition-speed), border-color var(--transition-speed);
}

.input-wrapper {
    position: relative;
    margin-top: 20px;
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
}

#user-input, #chat-user-input {
    width: 100%;
    height: 120px;
    padding: 15px 50px 15px 20px;
    border: 2px solid var(--border-color);
    border-radius: 20px;
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 14px; /* 与气泡框文字大小一致 */
    font-family: inherit;
    resize: none;
    transition: all var(--transition-speed);
    box-shadow: 0 2px 10px var(--shadow-color);
    overflow-y: auto;
    line-height: 1.5; /* 与气泡框行高一致 */
    overflow-x: hidden; /* 防止水平溢出 */
    box-sizing: border-box; /* 确保内边距包含在宽度内 */
    padding-right: 8px; /* 为自定义滚动条留出空间 */
    scrollbar-width: thin;
    -ms-overflow-style: none;
}

/* 输入框特殊滚动条样式 */
#user-input::-webkit-scrollbar,
#chat-user-input::-webkit-scrollbar {
    width: 6px;
    margin-right: 4px;
}

#user-input::-webkit-scrollbar-track,
#chat-user-input::-webkit-scrollbar-track {
    background: transparent;
    margin: 10px 0; /* 增大上下边距，移除箭头位置 */
    border-radius: 3px;
    border: none;
}

#user-input::-webkit-scrollbar-thumb,
#chat-user-input::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 3px;
    border: none;
}

#user-input:focus, #chat-user-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 15px var(--primary-color);
}

.input-actions {
    position: absolute;
    right: 15px;
    bottom: 15px;
    display: flex;
    gap: 10px;
}

.file-upload-button,
.send-button {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    transition: all var(--transition-speed);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-upload-button:hover,
.send-button:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .file-upload-button:hover,
[data-theme="dark"] .send-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.send-button.disabled {
    color: var(--border-color);
    cursor: not-allowed;
}

.send-button.disabled:hover {
    background: none;
    transform: none;
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* 复制提示样式 */
.copy-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background-color: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    transition: transform 0.3s ease-out;
}

.copy-toast.show {
    transform: translateX(-50%) translateY(0);
}

/* 处理暗黑模式和亮色模式的特殊样式 */
[data-theme="light"] .chat-input-container,
[data-theme="dark"] .chat-input-container {
    background-color: var(--input-container-bg);
    border-top: none;
}

/* 新对话按钮容器 */
.new-chat-button-container {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-bottom: 5px; /* 减小下方边距 */
    margin-top: 5px; /* 减小上方边距 */
    position: relative; /* 相对定位 */
    z-index: 5;
    height: auto; /* 高度自适应 */
    overflow: hidden; /* 防止内容溢出 */
}

/* 炫酷的新对话按钮 - 更小尺寸和修复溢出 */
.new-chat-button {
    background: linear-gradient(135deg, var(--primary-color), var(--hover-color));
    color: white;
    border: none;
    border-radius: 12px; /* 增加圆角弧度 */
    padding: 8px 16px; /* 减小内边距 */
    font-size: 12px; /* 减小字体大小 */
    font-weight: 500;
    letter-spacing: 0.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px; /* 减小间距 */
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
    overflow: hidden; /* 确保内容不溢出 */
    z-index: 1;
    transform-style: preserve-3d; /* 确保3D效果正常 */
    backface-visibility: hidden; /* 防止闪烁 */
}

/* 背景渐变动画 */
.new-chat-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--hover-color), var(--primary-color));
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
    border-radius: 12px; /* 与按钮保持一致 */
    transform: translateZ(-1px); /* 确保在按钮背后 */
}

/* 波纹效果 - 修复溢出问题 */
.new-chat-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px; /* 减小初始尺寸 */
    height: 5px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    transform: scale(0) translate(-50%, -50%);
    transform-origin: 0 0;
    opacity: 0;
    z-index: -1;
}

.new-chat-button:hover {
    transform: none; /* 不再改变位置 */
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.3);
    letter-spacing: 0.6px; /* 减小字母间距扩大，防止布局变化 */
}

.new-chat-button:hover::before {
    opacity: 1;
}

.new-chat-button:hover::after {
    animation: ripple 0.6s ease-out;
}

.new-chat-button:active {
    transform: none; /* 保持位置不变 */
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
    opacity: 0.9; /* 轻微降低不透明度代替位置变化 */
}

/* 修复亮色模式和暗色模式下的按钮效果 */
[data-theme="light"] .new-chat-button,
[data-theme="dark"] .new-chat-button {
    background: linear-gradient(135deg, var(--primary-color), var(--hover-color));
}

[data-theme="light"] .new-chat-button::before,
[data-theme="dark"] .new-chat-button::before {
    background: linear-gradient(135deg, var(--hover-color), var(--primary-color));
}

.new-chat-button i {
    font-size: 14px; /* 减小图标尺寸 */
    transition: transform 0.3s ease, text-shadow 0.3s ease;
}

.new-chat-button:hover i {
    transform: rotate(15deg); /* 移除缩放效果，只保留旋转 */
    animation: pulse-glow 1.5s infinite;
}

/* 波纹动画 - 确保不会溢出按钮边界 */
@keyframes ripple {
    0% {
        transform: scale(0) translate(-50%, -50%);
        opacity: 0.8;
    }
    100% {
        transform: scale(15) translate(-50%, -50%); /* 控制最大扩散范围 */
        opacity: 0;
    }
}

/* 按钮图标发光动画 */
@keyframes pulse-glow {
    0% { text-shadow: 0 0 0 rgba(255, 255, 255, 0); }
    50% { text-shadow: 0 0 10px rgba(255, 255, 255, 0.8); }
    100% { text-shadow: 0 0 0 rgba(255, 255, 255, 0); }
}

/* 修改加载指示器样式，解决头像溢出问题 */
.message.ai.loading {
    min-height: 60px; /* 增加最小高度 */
    padding: 20px 20px 20px 60px; /* 增加内边距 */
    display: flex;
    align-items: center;
}

.typing-indicator {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
    height: 20px; /* 确保高度合适 */
}

.typing-indicator span {
    height: 6px; /* 减小点的大小 */
    width: 6px;
    margin: 0 2px;
    background-color: var(--text-color);
    border-radius: 50%;
    display: inline-block;
    opacity: 0.6;
}

.typing-indicator span:nth-child(1) {
    animation: loading 1s infinite 0s;
}

.typing-indicator span:nth-child(2) {
    animation: loading 1s infinite 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation: loading 1s infinite 0.4s;
}

@keyframes loading {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px); /* 减小动画幅度 */
    }
}

/* 打字机效果 */
.message.ai.typing {
    width: auto;
}

.message.ai.typing .typing-text {
    visibility: hidden;
    position: absolute;
}

.message.ai.typing .typing-animation {
    white-space: pre-wrap;
    word-break: break-word;
}

.message.ai.typing .typing-cursor {
    display: inline-block;
    width: 8px;
    height: 16px;
    background-color: var(--text-color);
    animation: cursor-blink 0.8s infinite;
    vertical-align: middle;
    margin-left: 1px;
}

@keyframes cursor-blink {
    0%, 100% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
}

/* 聊天底部容器样式 */
.chat-bottom-container {
    width: 100%;
    background-color: var(--background-color);
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px; /* 减少组件间距 */
}

/* 移动端样式优化 */
@media (max-width: 768px) {
    /* 优化移动端容器 */
    .chat-container {
        padding: 10px;
        height: calc(var(--vh, 1vh) * 100); /* 使用动态视口高度 */
    }
    
    /* 调整欢迎页面布局 - 移除左右缩进 */
    .welcome-container {
        padding: 15px 10px; /* 减少左右内边距 */
        height: auto;
        min-height: calc(var(--vh, 1vh) * 80); /* 使用动态视口高度 */
    }
    
    .welcome-content {
        text-align: left; /* 左对齐内容 */
        max-width: 100%;
        padding: 0; /* 移除左右内边距 */
        width: 100%; /* 使用完整宽度 */
        margin: 0 auto;
    }
    
    .welcome-header {
        flex-direction: column;
        gap: 0; /* 移除默认间距 */
        margin-bottom: 0; /* 移除底部边距 */
        align-items: center; /* 居中对齐头部内容 */
        width: 100%; /* 确保宽度占满 */
    }
    
    .welcome-logo {
        width: 60px;
        height: 60px;
        margin-bottom: 20px; /* 统一间距 */
    }
    
    .welcome-text-bold {
        font-size: 1.4rem;
        text-align: center; /* 居中对齐文字 */
        margin-bottom: 20px; /* 统一间距，与logo底部到此文字顶部的间距相等 */
        width: 100%; /* 确保宽度占满 */
        word-wrap: break-word; /* 允许长单词换行 */
        overflow-wrap: break-word; /* 现代浏览器 */
    }
    
    .welcome-text-normal {
        font-size: 0.9rem;
        text-align: center; /* 居中对齐文字 */
        margin-bottom: 20px;
        width: 100%; /* 确保宽度占满 */
        word-wrap: break-word; /* 允许长单词换行 */
        overflow-wrap: break-word; /* 现代浏览器 */
    }
    
    /* 调整聊天消息区域 */
    .chat-messages {
        margin-bottom: 5px; /* 减小底部边距 */
        max-height: calc(var(--vh, 1vh) * 70); /* 限制高度 */
    }

    /* 统一移动端输入框尺寸 - 调整宽度和高度 */
    .input-wrapper {
        max-width: 100%;
        width: 100%; /* 使用完整宽度 */
        padding: 0; /* 移除内边距 */
        margin: 0 auto; /* 居中显示 */
    }
    
    #user-input, #chat-user-input {
        height: 110px; /* 统一增加移动端输入框高度 */
        font-size: 16px; /* 增大字体 */
        border-radius: 18px; /* 略微减小圆角 */
        padding: 12px 50px 12px 15px; /* 调整内边距 */
        width: 100%; /* 确保宽度占满 */
        box-shadow: 0 1px 8px var(--shadow-color); /* 减小阴影 */
    }
    
    /* 输入框获得焦点时的效果 */
    #user-input:focus, #chat-user-input:focus {
        box-shadow: 0 0 12px var(--primary-color);
        border-color: var(--primary-color);
    }
    
    /* 调整聊天输入容器 */
    .chat-input-container {
        padding: 10px 12px;
        width: 100%; /* 确保宽度占满 */
    }
    
    /* 调整按钮位置 */
    .input-actions {
        right: 12px;
        bottom: 12px;
    }
    
    /* 调整消息气泡最大宽度和字体大小 */
    .message {
        max-width: 85%;
        font-size: 16px; /* 增大气泡中的字体 */
    }
    
    /* 调整AI头像位置 */
    .message.ai::before {
        left: 12px; /* 统一调整左侧边距为12px */
        top: 12px; /* 统一调整顶部边距为12px */
        width: 28px; /* 移动端略小的头像 */
        height: 28px;
    }
    
    .message.ai {
        padding-left: 50px;
    }
    
    /* 调整顶部栏 */
    .top-bar {
        padding: 8px;
        margin-bottom: 5px;
    }
    
    /* 调整底部容器 */
    .chat-bottom-container {
        margin-top: auto; /* 推至底部 */
    }
    
    /* 增大按钮尺寸 */
    .file-upload-button,
    .send-button {
        width: 44px;
        height: 44px;
        font-size: 18px; /* 增大图标 */
    }
    
    /* "开启新对话"按钮 */
    .new-chat-button {
        font-size: 14px; /* 增大字体 */
        padding: 8px 16px; /* 增大内边距 */
    }
    
    .new-chat-button i {
        font-size: 16px; /* 增大图标 */
    }

    .preview-close {
        top: 10px;
        right: 10px;
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
}

/* 特小屏幕设备优化 */
@media (max-width: 480px) {
    /* 进一步优化超小屏幕设备 */
    .chat-container {
        padding: 8px;
    }
    
    .welcome-logo {
        width: 50px;
        height: 50px;
        margin-bottom: 15px; /* 保持统一间距，但略小于大屏幕 */
    }
    
    .welcome-text-bold {
        font-size: 1.2rem;
        margin-bottom: 15px; /* 保持统一间距 */
    }
    
    .welcome-text-normal {
        font-size: 0.85rem;
        margin-bottom: 15px;
    }
    
    /* 特小屏幕的输入框尺寸更加一致化 */
    .input-wrapper {
        width: 100%; /* 使用完整宽度 */
    }
    
    #user-input, #chat-user-input {
        height: 100px; /* 统一高度 */
        padding: 10px 45px 10px 12px;
        font-size: 16px;
        border-radius: 16px; /* 再减小圆角 */
    }
    
    /* 调整输入容器 */
    .chat-input-container {
        padding: 8px 10px;
    }
    
    /* 欢迎页面的内容区域与输入框保持一致 */
    .welcome-content {
        padding: 0;
        width: 100%;
    }
    
    /* 欢迎页面也使用相同的输入框样式 */
    .welcome-container .input-wrapper {
        width: 100%;
        margin: 0 auto;
    }
    
    .welcome-container #user-input {
        height: 100px; /* 与聊天页面一致 */
    }
    
    /* 头像位置精确调整 */
    .message.ai::before {
        width: 26px;
        height: 26px;
        left: 12px; /* 调整左侧边距为12px */
        top: 12px; /* 调整顶部边距为12px */
    }
    
    .message.ai {
        padding-left: 46px;
    }
    
    /* 底部按钮微调 */
    .file-upload-button,
    .send-button {
        width: 40px;
        height: 40px;
    }
    
    /* 新对话按钮微调 */
    .new-chat-button {
        font-size: 13px;
        padding: 6px 14px;
    }
    
    /* 消息气泡微调 */
    .message {
        padding: 12px 16px;
        font-size: 16px;
    }
}

/* 确保气泡内链接不溢出 */
.message a {
    word-break: break-all; /* 所有可能的断点处都断行 */
    word-wrap: break-word; /* 允许长单词换行 */
    overflow-wrap: break-word; /* 现代浏览器 */
    display: inline-block; /* 确保链接可以换行 */
    max-width: 100%; /* 限制最大宽度 */
    white-space: normal; /* 确保正常换行 */
    text-overflow: ellipsis; /* 超出部分显示省略号 */
    color: var(--primary-color); /* 使用主题色 */
    text-decoration: underline; /* 添加下划线 */
    transition: color 0.2s ease; /* 平滑过渡效果 */
}

.message a:hover {
    color: var(--hover-color); /* 悬停时颜色变化 */
}

/* Markdown样式 */
.message.ai .markdown-content {
    width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

/* 代码块样式 */
.message.ai .markdown-content pre {
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 5px;
    padding: 12px;
    margin: 10px 0;
    overflow-x: auto;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 13px;
    line-height: 1.45;
}

/* 适配暗色模式的代码块 */
[data-theme="dark"] .message.ai .markdown-content pre {
    background-color: rgba(255, 255, 255, 0.1);
}

/* 行内代码样式 */
.message.ai .markdown-content code {
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
    padding: 2px 4px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 90%;
}

/* 适配暗色模式的行内代码 */
[data-theme="dark"] .message.ai .markdown-content code {
    background-color: rgba(255, 255, 255, 0.1);
}

/* 表格样式 */
.message.ai .markdown-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 15px 0;
    font-size: 14px;
    overflow-x: auto;
    display: block;
}

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

.message.ai .markdown-content th {
    background-color: rgba(0, 0, 0, 0.03);
    font-weight: 600;
}

[data-theme="dark"] .message.ai .markdown-content th {
    background-color: rgba(255, 255, 255, 0.05);
}

/* 引用块样式 */
.message.ai .markdown-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 15px;
    margin: 10px 0 10px 0;
    color: rgba(0, 0, 0, 0.6);
    font-style: italic;
}

[data-theme="dark"] .message.ai .markdown-content blockquote {
    color: rgba(255, 255, 255, 0.6);
}

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

.message.ai .markdown-content h1 { font-size: 1.6em; }
.message.ai .markdown-content h2 { font-size: 1.4em; }
.message.ai .markdown-content h3 { font-size: 1.2em; }
.message.ai .markdown-content h4 { font-size: 1.1em; }
.message.ai .markdown-content h5 { font-size: 1em; }
.message.ai .markdown-content h6 { font-size: 0.9em; }

/* 列表样式 */
.message.ai .markdown-content ul,
.message.ai .markdown-content ol {
    padding-left: 2em;
    margin: 8px 0;
}

.message.ai .markdown-content li {
    margin-bottom: 4px;
}

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

/* 全局滚动条基本样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-color);
    border-radius: 4px;
    margin: 8px 0; /* 增加上下空白，消除箭头位置 */
    padding: 0;
    border: none;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
    border: 1px solid transparent;
    background-clip: padding-box;
    min-height: 50px; /* 确保滑块有足够高度 */
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
    border: 1px solid transparent;
    background-clip: padding-box;
}

/* 自定义输入框滚动条 */
#user-input::-webkit-scrollbar,
#chat-user-input::-webkit-scrollbar {
    width: 6px;
    margin-right: 4px;
}

#user-input::-webkit-scrollbar-track,
#chat-user-input::-webkit-scrollbar-track {
    background: transparent;
    margin: 10px 0; /* 增大上下边距，移除箭头位置 */
    border-radius: 3px;
    border: none;
}

/* 强制清除所有三角形按钮 - 更强力版本 */
::-webkit-scrollbar-button,
::-webkit-scrollbar-button:vertical:start:decrement,
::-webkit-scrollbar-button:vertical:end:increment,
::-webkit-scrollbar-button:horizontal:start:decrement,
::-webkit-scrollbar-button:horizontal:end:increment,
::-webkit-scrollbar-button:vertical:start,
::-webkit-scrollbar-button:vertical:end,
::-webkit-scrollbar-button:horizontal:start,
::-webkit-scrollbar-button:horizontal:end,
::-webkit-scrollbar-button:single-button,
::-webkit-scrollbar-button:double-button {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    min-width: 0 !important;
    max-height: 0 !important;
    max-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
    background-image: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(0) !important;
}

/* 特别针对输入框的滚动条完全净化 */
#user-input::-webkit-scrollbar-button,
#chat-user-input::-webkit-scrollbar-button,
#user-input::-webkit-scrollbar-button:vertical:start:decrement,
#chat-user-input::-webkit-scrollbar-button:vertical:start:decrement,
#user-input::-webkit-scrollbar-button:vertical:end:increment,
#chat-user-input::-webkit-scrollbar-button:vertical:end:increment,
.chat-messages::-webkit-scrollbar-button {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    min-width: 0 !important;
    max-height: 0 !important;
    max-width: 0 !important;
    opacity: 0 !important;
    border: none !important;
    background: transparent !important;
    background-image: none !important;
    background-color: transparent !important;
}

/* 增加滚动条轨道上下边距，完全消除箭头空间 */
::-webkit-scrollbar-track {
    margin: 12px 0 !important; /* 增加更大边距确保箭头位置被完全清除 */
}

/* 确保输入框滚动条轨道更大间距 */
#user-input::-webkit-scrollbar-track,
#chat-user-input::-webkit-scrollbar-track {
    margin: 16px 0 !important; /* 输入框特别增加边距 */
}

/* 输入框获得焦点时特别样式处理 */
#user-input:focus::-webkit-scrollbar-button,
#chat-user-input:focus::-webkit-scrollbar-button {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
}

#user-input:focus::-webkit-scrollbar-track,
#chat-user-input:focus::-webkit-scrollbar-track {
    margin: 16px 0 !important; /* 确保聚焦时也有足够边距 */
    background: transparent !important;
    border: none !important;
}

/* 通过创建不可滚动内容区间来排除按钮区域 */
::-webkit-scrollbar::before,
::-webkit-scrollbar::after {
    content: "";
    display: block;
    height: 0;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99;
    pointer-events: none;
    visibility: hidden;
}

/* 优化Firefox的滚动条按钮 */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

/* 优化IE/Edge的滚动条 */
* {
    -ms-overflow-style: none;
}

/* 重置输入框的滚动条样式，保证没有按钮 */
#user-input, #chat-user-input {
    scrollbar-width: thin;
    -ms-overflow-style: none;
}

/* 覆盖三角形区域的额外方法 */
::-webkit-scrollbar {
    overflow: hidden !important; /* 尝试隐藏溢出内容 */
}

/* 使用伪类隐藏三角形区域 */
::-webkit-scrollbar-track:before,
::-webkit-scrollbar-track:after {
    content: "";
    display: block;
    height: 12px;
    width: 100%;
    position: absolute;
    background-color: var(--background-color) !important;
    z-index: 999;
    pointer-events: none;
}

::-webkit-scrollbar-track:before {
    top: -12px;
}

::-webkit-scrollbar-track:after {
    bottom: -12px;
}

/* 通过设置轨道内容区更加彻底地处理 */
#user-input::-webkit-scrollbar-track-piece,
#chat-user-input::-webkit-scrollbar-track-piece {
    background: transparent !important;
    border: none !important;
    margin-top: 16px !important;
    margin-bottom: 16px !important;
}

/* 消息内图片样式 */
.message img {
    max-width: 100%;
    max-height: 300px; /* 限制最大高度 */
    height: auto;
    width: auto; /* 保持图片原始宽高比 */
    border-radius: 8px;
    margin: 8px 0; /* 上下边距，左侧无边距实现左对齐 */
    cursor: zoom-in;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    object-fit: contain; /* 确保图片完整显示 */
    display: block; /* 块级显示更好控制尺寸 */
    margin-left: 0; /* 确保左对齐 */
    margin-right: auto; /* 右侧自动，保证左对齐 */
}

.message img:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

/* 图片容器样式，确保图片左对齐显示 */
.message .markdown-content p:has(img) {
    text-align: left; /* 左对齐 */
    overflow: hidden; /* 防止溢出 */
    margin: 10px 0;
    max-width: 100%; /* 确保不超过父容器 */
}

/* 创建图片容器类，用于更好地控制图片 */
.image-container {
    max-width: 100%;
    margin: 10px 0;
    text-align: left; /* 左对齐 */
    overflow: hidden;
    border-radius: 8px;
    display: flex; /* 使用flex布局 */
    justify-content: flex-start; /* 左对齐 */
    align-items: flex-start; /* 顶部对齐 */
}

/* 调整AI消息内的图片容器，考虑左侧头像留出的空间 */
.message.ai .image-container {
    max-width: calc(100% - 10px);
    margin-left: 0;
}

/* 超长图片特殊处理 - 限制最大高度并添加渐变底部 */
.message img.tall-image {
    max-height: 400px; /* 稍微增加高图片的高度上限 */
    position: relative;
}

/* 移动端图片样式适配 */
@media (max-width: 768px) {
    .message img {
        max-height: 250px; /* 移动端略小的高度限制 */
    }
    
    .message img.tall-image {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .message img {
        max-height: 200px; /* 更小屏幕进一步减小高度 */
    }
    
    .message img.tall-image {
        max-height: 240px;
    }
}

/* 图片预览模态框 */
.image-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.image-preview-modal.active {
    opacity: 1;
    visibility: visible;
}

/* 加载状态样式 */
.image-preview-modal.loading {
    cursor: wait;
}

/* 图片加载指示器 */
.preview-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 40px;
    animation: spin 1.5s linear infinite;
}

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

/* 图片加载错误提示 */
.preview-error {
    color: white;
    text-align: center;
    font-size: 16px;
}

.preview-error i {
    font-size: 40px;
    margin-bottom: 10px;
    color: #ff5252;
}

.preview-image-container {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    overflow: visible; /* 改为visible确保缩放时不裁剪 */
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: zoomIn 0.5s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
    display: flex; /* 使用flex布局 */
    justify-content: center; /* 水平居中 */
    align-items: center; /* 垂直居中 */
}

/* 垂直图片特殊处理 */
.preview-image-container.vertical-image {
    max-height: 85vh;
    max-width: 80%;
}

/* 水平图片特殊处理 */
.preview-image-container.horizontal-image {
    max-width: 90%;
    max-height: 80vh;
}

.preview-image {
    display: block;
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain; /* 保持图片比例，确保完整显示 */
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    animation: fadeIn 0.5s 0.2s ease forwards;
    height: auto; /* 自动高度 */
    width: auto; /* 自动宽度 */
}

/* 激活时图片放大到原始大小 */
.image-preview-modal.active .preview-image {
    transform: scale(1);
}

/* 垂直图片样式调整 */
.vertical-image .preview-image {
    max-height: 85vh;
    max-width: 100%;
    width: auto; /* 自动调整宽度 */
    height: auto; /* 自动调整高度 */
}

/* 水平图片样式调整 */
.horizontal-image .preview-image {
    max-width: 90vw;
    max-height: 80vh;
    width: auto; /* 自动调整宽度 */
    height: auto; /* 自动调整高度 */
}

.preview-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: white;
    font-size: 24px;
    transition: all 0.3s ease;
    opacity: 0;
    transform: rotate(-90deg) scale(0.8);
    animation: fadeRotateIn 0.3s 0.4s ease forwards;
}

.preview-close:hover {
    background-color: rgba(255, 255, 255, 0.4);
    transform: rotate(0deg) scale(1.1);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

/* 图片控制器 */
.image-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    display: flex;
    gap: 15px;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 50px;
    opacity: 0;
    animation: slideUp 0.4s 0.5s ease forwards;
}

.image-control-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.image-control-button:hover {
    background-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

/* 增强动画效果 */
@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(50px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

@keyframes fadeRotateIn {
    from {
        opacity: 0;
        transform: rotate(-90deg) scale(0.8);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* 响应式调整 */
@media (max-width: 768px) {
    .preview-close {
        top: 10px;
        right: 10px;
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
}

/* 视频容器样式 */
.video-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 10px 0;
    border-radius: 8px;
    overflow: hidden;
    background-color: #000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* 视频播放器样式 */
.video-container video {
    width: 100%;
    display: block;
}

/* 视频播放按钮覆盖层 */
.video-container .video-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s;
    z-index: 1;
}

.video-container .video-play-overlay:hover {
    background-color: rgba(0, 0, 0, 0.4);
}

.video-container .video-play-overlay i {
    font-size: 48px;
    color: #fff;
    opacity: 0.8;
    transition: transform 0.3s, opacity 0.3s;
}

/* 视频全屏按钮 */
.video-fullscreen-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    opacity: 0.7;
    z-index: 10; /* 确保全屏按钮始终在最上层 */
}

.video-fullscreen-btn:hover {
    background-color: rgba(0, 0, 0, 0.8);
    opacity: 1;
}

.video-container:hover .video-fullscreen-btn {
    opacity: 1;
}

/* 视频错误提示 */
.video-error {
    color: #ff5252;
    font-size: 14px;
    padding: 10px;
    background-color: rgba(255, 82, 82, 0.1);
    border-radius: 5px;
    margin-top: 5px;
}

/* 视频预览模态框 */
.video-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.video-preview-modal.active {
    opacity: 1;
    visibility: visible;
}

.video-preview-modal.loading {
    cursor: wait;
}

/* 视频预览容器 */
.preview-video-container {
    max-width: 90%;
    max-height: 80vh;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 预览视频样式 */
.preview-video {
    max-width: 100%;
    max-height: 80vh;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    background-color: #000;
}

/* 预览加载动画 */
.preview-loading {
    position: absolute;
    width: 80px;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    color: white;
}

.preview-loading i {
    animation: spin 1s linear infinite;
}

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

/* 预览关闭按钮 */
.preview-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.preview-close:hover {
    background-color: rgba(255, 255, 255, 0.4);
    transform: rotate(90deg);
}

.preview-close i {
    color: white;
    font-size: 20px;
}

/* 预览错误信息 */
.preview-error {
    color: white;
    text-align: center;
    font-size: 16px;
    padding: 20px;
}

.preview-error i {
    font-size: 40px;
    margin-bottom: 10px;
    color: #ff5252;
}

/* 视频控制区域 */
.video-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    gap: 15px;
    z-index: 10;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 30px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.video-controls:hover {
    opacity: 1;
}

/* 视频控制按钮 */
.video-control-button {
    background-color: transparent;
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    transition: all 0.3s ease;
}

.video-control-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* 移动端适配 */
@media (max-width: 768px) {
    .video-play-overlay i {
        font-size: 36px;
    }
    
    .video-fullscreen-btn {
        width: 30px;
        height: 30px;
    }
    
    .video-controls {
        padding: 8px 15px;
        gap: 10px;
    }
    
    .video-control-button {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .preview-close {
        top: 15px;
        right: 15px;
        width: 36px;
        height: 36px;
    }
}

/* AI免责声明样式 */
.ai-disclaimer {
    position: fixed;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #999999;
    text-align: center;
    opacity: 0.8;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    cursor: pointer;
    user-select: none;
}

.ai-disclaimer:hover {
    transform: translateX(-50%) scale(1.05);
}

[data-theme="dark"] .ai-disclaimer {
    color: #888888;
}

@media (max-width: 768px) {
    .ai-disclaimer {
        font-size: 11px;
        bottom: 2px;
    }
    
    .ai-disclaimer:hover {
        transform: translateX(-50%) scale(1.03);
    }
}

@media (max-width: 480px) {
    .ai-disclaimer {
        font-size: 10px;
        bottom: 1px;
        max-width: 90%;
    }
    
    .ai-disclaimer:hover {
        transform: translateX(-50%) scale(1.02);
    }
} 