/* ========== 消息区域 ========== */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 0;
    scroll-behavior: smooth;
}

.message-row {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.message-row.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.message-row.ai {
    align-self: flex-start;
}
.message-body {
    min-width: 0;
}

.message-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    font-weight: 700;
}
.message-row.user .message-avatar {
    background: #c8ddf0;
    color: #3a5f7c;
}
.message-row.ai .message-avatar {
    background: #d5e8d4;
    color: #3d6b3d;
}

.message-bubble {
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    font-size: var(--font-size-md);
    line-height: 1.7;
    word-break: break-word;
    box-shadow: var(--shadow-sm);
    position: relative;
    min-width: 60px;
}
.message-bubble p {
    margin: 0 0 0.85em;
}
.message-bubble p:last-child,
.message-bubble ul:last-child,
.message-bubble ol:last-child,
.message-bubble pre:last-child {
    margin-bottom: 0;
}
.message-bubble ul,
.message-bubble ol {
    margin: 0 0 0.85em 1.5em;
    padding: 0;
}
.message-bubble li {
    margin: 0.25em 0;
}
.message-bubble h1,
.message-bubble h2,
.message-bubble h3 {
    margin: 0.8em 0 0.4em;
    line-height: 1.35;
}
.message-bubble h1:first-child,
.message-bubble h2:first-child,
.message-bubble h3:first-child {
    margin-top: 0;
}
.message-row.user .message-bubble {
    background: var(--color-message-user);
    border-bottom-right-radius: 6px;
}
.message-row.ai .message-bubble {
    background: var(--color-message-ai);
    border-bottom-left-radius: 6px;
    border: 1px solid #e8e5df;
}
.message-bubble .system-prompt-tag {
    display: inline-block;
    background: #f0e6d3;
    color: #8b6914;
    font-size: var(--font-size-xs);
    padding: 3px 10px;
    border-radius: 12px;
    margin-bottom: 8px;
    font-weight: 600;
    letter-spacing: 1px;
}
.message-bubble img {
    max-width: 300px;
    max-height: 300px;
    border-radius: var(--radius-md);
    margin: 8px 0;
    cursor: pointer;
    border: 2px solid var(--color-border);
}
.message-bubble pre {
    background: #f7f6f3;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: var(--font-size-sm);
    margin: 8px 0;
    border: 1px solid #e8e5df;
}
.message-bubble code {
    font-size: var(--font-size-sm);
    background: #f7f6f3;
    padding: 2px 6px;
    border-radius: 4px;
}

.message-time {
    font-size: var(--font-size-xs);
    color: var(--color-text-light);
    margin-top: 4px;
    text-align: right;
}

.message-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
}
.copy-message-btn {
    border: 1px solid #d8d4cc;
    background: #fffaf1;
    color: var(--color-text);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: var(--font-size-xs);
    cursor: pointer;
}
.copy-message-btn:hover {
    background: #f4ead7;
}

/* ========== Loading 动画 ========== */
.loading-bubble {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    min-height: 48px;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 0;
}
.typing-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-primary);
    display: inline-block;
    animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}
.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}
.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.loading-text {
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
    font-weight: 600;
    animation: pulseText 1.5s ease-in-out infinite;
}

@keyframes pulseText {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
}
