/* 基础样式 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f0f2f5;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* 聊天框 */
.chat-box {
    height: 78vh;
    padding: 10px 20px;
    overflow-y: auto;
    background: #fafafa;
}

/* 消息 */
.message {
    display: flex;
    gap: 8px;
    margin: 8px 0;
    max-width: 96%;
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

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

/* 用户消息 */
.message.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.message.user .content {
    background: #1890ff;
    color: white;
    border-radius: 18px 4px 18px 18px;
}

/* 助手消息 */
.message.assistant .content {
    background: #ffffff;
    border: 1px solid #eee;
    border-radius: 4px 18px 18px 18px;
}

/* 头像 */
.avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    flex-shrink: 0;
    background: rgba(0,0,0,0.05);
}

/* 内容区域 */
.content {
    padding: 8px 12px;
    line-height: 1.6;
    word-break: break-word;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    max-width: 90%;
}

/* 输入区域 */
.input-area {
    display: flex;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #eee;
    gap: 8px;
}

input[type="text"] {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
}

button {
    padding: 10px 20px;
    background: #1890ff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover {
    background: #1476d4;
}

/* Markdown增强 */
.content pre {
    background: rgba(0,0,0,0.05);
    padding: 8px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 14px;
}

.content code {
    font-family: 'SFMono-Regular', Consolas, monospace;
}

.content blockquote {
    border-left: 3px solid #ddd;
    margin: 4px 0;
    padding-left: 8px;
    color: #666;
}

/* 加载指示器 */
.typing-indicator {
    display: none;
    padding: 10px;
    align-items: center;
    color: #666;
}

.dot-flashing {
    position: relative;
    width: 6px;
    height: 6px;
    border-radius: 3px;
    background-color: #999;
    animation: dotFlashing 1s infinite linear;
    margin-right: 8px;
}

@keyframes dotFlashing {
    0% { background-color: #999; }
    50%, 100% { background-color: rgba(153,153,153,0.2); }
}

/* 添加打字光标效果 */

.streaming {
    position: relative;
    min-height: 1.2em; /* 防止内容为空时消失 */
}

.streaming::after {
    content: "|";
    position: absolute;
    margin-left: 2px;
    animation: blink 0.3s step-end infinite;
    color: #666;
}

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

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

/* 优化代码块悬停效果 */
pre:hover .copy-btn {
    opacity: 1;
}

.copy-btn {
    opacity: 0.3;
    transition: opacity 0.2s;
}
