* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #ffffff;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.chat-container {
    width: 100%;
    max-width: 800px;
    height: 90vh;
    max-height: 800px;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 聊天头部 */
.chat-header {
    background: #ffffff;
    color: #333333;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid #e5e7eb;
}

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

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    overflow: hidden;
}

.ai-avatar {
    background: transparent;
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
}

.header-text h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 5px;
}

.status {
    font-size: 12px;
    opacity: 0.7;
    display: flex;
    align-items: center;
    gap: 5px;
    color: #666666;
}

.status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

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

.header-actions {
    display: flex;
    gap: 10px;
}

.btn-clear {
    background: #f3f4f6;
    border: none;
    color: #333333;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-clear:hover {
    background: #e5e7eb;
    transform: scale(1.1);
}

.btn-settings {
    background: #f3f4f6;
    border: none;
    color: #333333;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn-settings:hover {
    background: #e5e7eb;
    transform: scale(1.1);
}

/* 消息区域 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f7fa;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.message {
    display: flex;
    gap: 12px;
    animation: messageSlideIn 0.3s ease-out;
}

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

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    flex-shrink: 0;
    overflow: hidden;
}

.message-avatar .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
}

.ai-message .message-avatar {
    background: transparent;
    color: #ffffff;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #ffffff;
}

.message-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 70%;
}

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

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
    position: relative;
}

/* Markdown样式 */
.message-bubble.markdown-content {
    padding: 16px 20px;
}

.message-bubble.markdown-content h1,
.message-bubble.markdown-content h2,
.message-bubble.markdown-content h3,
.message-bubble.markdown-content h4,
.message-bubble.markdown-content h5,
.message-bubble.markdown-content h6 {
    margin: 16px 0 12px 0;
    font-weight: 600;
    line-height: 1.4;
    color: #333;
}

.message-bubble.markdown-content h1 {
    font-size: 24px;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 8px;
}

.message-bubble.markdown-content h2 {
    font-size: 20px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 6px;
}

.message-bubble.markdown-content h3 {
    font-size: 18px;
}

.message-bubble.markdown-content h4 {
    font-size: 16px;
}

.message-bubble.markdown-content h5 {
    font-size: 14px;
}

.message-bubble.markdown-content h6 {
    font-size: 13px;
    color: #666;
}

.message-bubble.markdown-content p {
    margin: 10px 0;
    line-height: 1.6;
}

.message-bubble.markdown-content ul,
.message-bubble.markdown-content ol {
    margin: 10px 0;
    padding-left: 24px;
}

.message-bubble.markdown-content li {
    margin: 6px 0;
    line-height: 1.6;
}

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

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

.message-bubble.markdown-content code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 0.9em;
    color: #e83e8c;
}

.message-bubble.markdown-content pre {
    background: #f3f4f6;
    padding: 12px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    border-left: 4px solid #34495e;
}

.message-bubble.markdown-content pre code {
    background: transparent;
    padding: 0;
    color: #333;
    font-size: 0.9em;
}

.message-bubble.markdown-content blockquote {
    border-left: 4px solid #34495e;
    padding-left: 16px;
    margin: 12px 0;
    color: #666;
    font-style: italic;
}

.message-bubble.markdown-content strong {
    font-weight: 600;
    color: #333;
}

.message-bubble.markdown-content em {
    font-style: italic;
}

.message-bubble.markdown-content a {
    color: #34495e;
    text-decoration: underline;
}

.message-bubble.markdown-content a:hover {
    color: #2c3e50;
}

.message-bubble.markdown-content hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 16px 0;
}

.message-bubble.markdown-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
}

.message-bubble.markdown-content table th,
.message-bubble.markdown-content table td {
    border: 1px solid #e5e7eb;
    padding: 8px 12px;
    text-align: left;
}

.message-bubble.markdown-content table th {
    background: #f3f4f6;
    font-weight: 600;
}

.ai-message .message-bubble {
    background: #ffffff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ai-message .message-bubble::before {
    content: '';
    position: absolute;
    left: -8px;
    bottom: 12px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 8px 8px 0;
    border-color: transparent #ffffff transparent transparent;
}

.user-message .message-bubble {
    background: #34495e;
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(52, 73, 94, 0.3);
}

.user-message .message-bubble::after {
    content: '';
    position: absolute;
    right: -8px;
    bottom: 12px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 0 8px 8px;
    border-color: transparent transparent transparent #34495e;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 5px;
    padding: 0 5px;
}

.user-message .message-time {
    text-align: right;
}

/* 输入区域 */
.chat-input-area {
    background: #ffffff;
    padding: 20px;
    border-top: 1px solid #e5e7eb;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    border: 2px solid #e5e7eb;
    border-radius: 20px;
    padding: 12px 18px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    height: 44px;
    overflow-y: auto;
    transition: border-color 0.3s, box-shadow 0.3s;
    line-height: 1.5;
    box-sizing: border-box;
}

.message-input:focus {
    outline: none;
    border-color: #34495e;
    box-shadow: 0 0 0 3px rgba(52, 73, 94, 0.1);
}

.message-input::-webkit-scrollbar {
    width: 4px;
}

.message-input::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.btn-send {
    background: #34495e;
    border: none;
    color: #ffffff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
    background: #2c3e50;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(52, 73, 94, 0.4);
}

.btn-send:active:not(:disabled) {
    transform: scale(0.95);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-tips {
    font-size: 12px;
    color: #999;
    margin-top: 8px;
    text-align: center;
}

/* 加载动画 */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .chat-container {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .message-content {
        max-width: 85%;
    }

    .chat-header {
        padding: 15px;
    }

    .header-text h2 {
        font-size: 18px;
    }
}
