/* === 全局与基础设置 === */
html, body {
    margin: 0; padding: 0;
    height: 100%; width: 100%;
    /* 【优化】引入更适合中文阅读的 Noto Sans SC 字体 */
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow: hidden; 
}
body { background-color: #000; }
*, *::before, *::after { box-sizing: border-box; }


/* === 布局核心 === */
.video-background-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; 
}
.video-background-container video {
    width: 100%; height: 100%;
    object-fit: cover; object-position: 75% 50%; 
}

.container {
    position: relative;
    display: flex; flex-direction: column;
    height: 100dvh; /* 使用dvh兼容移动端 */
    width: 100%; max-width: 800px; margin: 0 auto;
    background-color: transparent;
}


/* === 聊天窗口内部样式 === */
.chat-history {
    flex: 1;
    padding: 20px 10px 100px 10px; /* 增大顶部和底部内边距 */
    overflow-y: auto; 
    -webkit-overflow-scrolling: touch;
}

.message-item { 
    display: flex; 
    margin-bottom: 15px; /* 增大消息间距 */
    position: relative;
}
.message-item.user { justify-content: flex-end; }
.message-item.bot { justify-content: flex-start; }
.message-bubble {
    max-width: 80%; /* 适当增大最大宽度 */
    padding: 12px 18px; 
    border-radius: 20px; 
    line-height: 1.7; 
    font-size: 16px; /* 稍稍增大字体 */
    word-break: break-word; /* 优化长单词换行 */
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.15); 
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    color: #111;
    position: relative;
}

/* 【美化】为消息气泡增加小尾巴 - 已修复定位 */
.message-bubble::after {
    content: '';
    position: absolute;
    bottom: 15px; /* 微调垂直位置，使其更居中 */
    width: 0;
    height: 0;
    border: 8px solid transparent; /* 将尾巴调小一点，更精致 */
}
.bot .message-bubble::after {
    left: -16px; /* 修正：向左移动自身宽度(8px*2)，实现无缝贴合 */
    border-right-color: rgba(255, 255, 255, 0.5); /* 与气泡背景色一致 */
}
.user .message-bubble::after {
    right: -16px; /* 修正：向右移动自身宽度(8px*2)，实现无缝贴合 */
    border-left-color: #5496E3; /* 与气泡渐变色起始色一致 */
}

.bot .message-bubble { 
    background-color: rgba(255, 255, 255, 0.5); 
}
/* 【美化】为用户消息气泡应用渐变色 */
.user .message-bubble { 
    background-image: linear-gradient(45deg, #36D1DC, #5B86E5);
    color: #fff;
    border: none;
}

/* === Markdown 内容样式 === */
.message-bubble strong { font-weight: 500; }
.message-bubble a { color: #8A2BE2; text-decoration: none; }
.message-bubble a:hover { text-decoration: underline; }
.message-bubble pre { 
    position: relative; /* 为复制按钮定位 */
    white-space: pre-wrap; 
    overflow-x: auto; 
    background-color: rgba(0, 0, 0, 0.6); 
    color: #f0f0f0;
    padding: 15px; 
    margin: 10px -5px;
    border-radius: 12px; 
    font-size: 14px; 
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
}
.message-bubble code:not(pre > code) {
    background-color: rgba(0,0,0,0.1);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.9em;
}

/* 【新增】代码块复制按钮 */
.copy-code-button {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    opacity: 0.5;
    transition: opacity 0.2s, background-color 0.2s;
}
.message-bubble pre:hover .copy-code-button {
    opacity: 1;
}
.copy-code-button:hover {
    background-color: rgba(255, 255, 255, 0.4);
}
.copy-code-button:active {
    background-color: rgba(255, 255, 255, 0.6);
}


/* === 输入区域 === */
.input-area {
    position: absolute; bottom: 0; left: 0; right: 0;
    display: flex; align-items: flex-end; /* 改为 flex-end 对齐底部 */
    padding: 10px;
    max-width: 800px; margin: 0 auto;
}

.input-field {
    flex: 1;
    min-height: 48px; max-height: 150px;
    padding: 12px 20px;
    margin-right: 10px;
    border-radius: 24px;
    background-color: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    font-size: 16px; line-height: 1.6; outline: none;
    resize: none; overflow-y: auto; color: #000;
    transition: box-shadow 0.3s ease;
}
/* 【优化】增加更美观的焦点状态 */
.input-field:focus {
    box-shadow: 0 0 0 3px rgba(91, 134, 229, 0.5), 0 4px 15px rgba(0, 0, 0, 0.2);
}
.input-field::placeholder { 
    color: #333; opacity: 0.8;
}

/* === 发送按钮 === */
.send-button {
    width: 48px; height: 48px;
    border-radius: 50%;
    flex-shrink: 0;
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    display: flex; justify-content: center; align-items: center;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s ease, background-image 0.3s ease;
}
.send-button:active {
    transform: scale(0.9);
}
.send-button:focus { outline: none; }

/* 【美化】激活状态使用渐变色 */
.send-button:not(:disabled) {
    background-image: linear-gradient(45deg, #36D1DC, #5B86E5);
}
/* 【美化】禁用状态 */
.send-button:disabled {
    background-color: rgba(255, 255, 255, 0.4);
    cursor: not-allowed;
}

.send-button .send-icon-image {
    width: 24px; height: 24px;
    transition: filter 0.3s ease-in-out;
}
.send-button:disabled .send-icon-image {
    filter: brightness(0) saturate(100%) invert(50%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(95%) contrast(90%);
}

.video-tutorial-link, .fee-calculation-link {
    display: inline-flex;         /* 使用flex布局，完美对齐图标和文字 */
    align-items: center;          /* 垂直居中 */
    gap: 6px;                     /* 图标与文字的间距 */
    
    /* --- 核心颜色修复 (普通状态) --- */
    background-color: #7C3AED;    /* 一个清晰、现代的紫色背景 */
    color: #FFFFFF !important;    /* 强制使用白色文字，确保高对比度，覆盖其他样式 */
    
    font-weight: 500;             /* 字体稍粗，更易读 */
    text-decoration: none;
    padding: 6px 14px;            /* 调整内边距，让按钮更饱满 */
    border-radius: 16px;          /* 圆角 */
    border: none;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
    transition: all 0.2s ease-in-out; /* 让所有动效都变得平滑 */
}

/* --- 鼠标悬停状态 --- */
.video-tutorial-link:hover, .fee-calculation-link:hover {
    background-color: #6D28D9;    /* 悬停时背景色加深，提供清晰反馈 */
    color: #FFFFFF !important;    /* 悬停时文字依旧保持白色 */
    transform: translateY(-2px);  /* 保留并优化上浮动效 */
    box-shadow: 0 4px 12px rgba(109, 40, 217, 0.5); /* 阴影加深，更有立体感 */
}


/* === 动画模块 === */
@keyframes slide-in-bottom {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.new-message-animation {
    animation: slide-in-bottom 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

/* 【美化】升级“思考中”的动画 */
.typing-indicator { display: flex; align-items: center; padding: 10px 0; }
.typing-indicator span {
    height: 10px; width: 10px;
    margin: 0 3px;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    display: inline-block;
    animation: typing-bounce 1.4s infinite;
}
.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}


@media (max-width: 768px) {
    .video-background-container video { object-position: 50% 50%; }
    .message-bubble { max-width: 85%; }
}

/* === 滚动条美化 === */
.chat-history::-webkit-scrollbar, .input-field::-webkit-scrollbar { width: 6px; }
.chat-history::-webkit-scrollbar-track, .input-field::-webkit-scrollbar-track { background: transparent; }
.chat-history::-webkit-scrollbar-thumb, .input-field::-webkit-scrollbar-thumb { background-color: rgba(255, 255, 255, 0.3); border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.1); }
.chat-history::-webkit-scrollbar-thumb:hover, .input-field::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.5); }
.chat-history, .input-field { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.3) transparent; }

/* === 页面加载器 === */
#page-loader {
    position: fixed; top: 0; left: 0;
    width: 100vw; height: 100vh;
    background-color: #111; z-index: 9999;
    display: flex; justify-content: center; align-items: center;
    opacity: 1; transition: opacity 0.5s ease;
}
body.loaded #page-loader { opacity: 0; pointer-events: none; }
.spinner {
    width: 50px; height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #5B86E5; /* 使用品牌色 */
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }