/**
 * ai-creative.css - AI 创意工坊（完整样式，含消息左右布局）
 */
.ai-creative-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 16px 0;
    margin-bottom: 16px;
    border-bottom: 2px solid #f0f2f5;
    flex-wrap: wrap;
    gap: 8px;
}
.ai-creative-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: #1a202c;
    display: flex;
    align-items: center;
    gap: 10px;
}
.ai-creative-header h1 i {
    color: #4a6cf7;
    background: rgba(74, 108, 247, 0.10);
    padding: 6px 10px;
    border-radius: 10px;
}

/* ===== 对话容器 ===== */
.chat-container {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #eef2f6;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
    height: 540px;
    max-height: 70vh;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    background: #fafbfc;
}

/* ===== 消息布局（左右分离） ===== */
.chat-messages .message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    align-items: flex-start;
}
/* 用户消息：靠右，头像在右 */
.chat-messages .message.user {
    flex-direction: row-reverse;
}
/* AI消息：靠左，头像在左 */
.chat-messages .message.assistant {
    flex-direction: row;
}

.chat-messages .message .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
.chat-messages .message.user .avatar {
    background: #4a6cf7;
    color: #fff;
}
.chat-messages .message.assistant .avatar {
    background: #e8edfc;
    color: #4a6cf7;
}

.chat-messages .message .bubble {
    background: #ffffff;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid #eef2f6;
    font-size: 14px;
    line-height: 1.7;
    color: #2d3748;
    max-width: 80%;
    word-wrap: break-word;
    position: relative;
}
/* 用户气泡：背景色不同，靠右 */
.chat-messages .message.user .bubble {
    background: #4a6cf7;
    color: #fff;
    border-color: #4a6cf7;
    margin-left: auto;      /* 确保气泡靠右 */
}
/* AI气泡：靠左 */
.chat-messages .message.assistant .bubble {
    background: #f7fafc;
    margin-right: auto;     /* 确保气泡靠左 */
}

/* ===== Markdown / 代码块样式 ===== */
.chat-messages .message .bubble .markdown-body pre {
    position: relative;
    background: #1e1e2e !important;
    border-radius: 8px;
    padding: 16px 20px;
    margin: 8px 0 12px 0;
    overflow-x: auto;
    border: 1px solid #2a2a4a;
}
.chat-messages .message .bubble .markdown-body pre code {
    background: transparent !important;
    color: #cbd5e0;
    font-size: 13px;
    line-height: 1.7;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}
.chat-messages .message .bubble .markdown-body .code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255,255,255,0.1);
    color: #a0aec0;
    border: none;
    border-radius: 4px;
    padding: 2px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: 0.2s;
}
.chat-messages .message .bubble .markdown-body .code-copy-btn:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}
.chat-messages .message .bubble .markdown-body p {
    margin: 4px 0 8px 0;
}
.chat-messages .message .bubble .markdown-body ul,
.chat-messages .message .bubble .markdown-body ol {
    padding-left: 20px;
}
.chat-messages .message .bubble .markdown-body h1,
.chat-messages .message .bubble .markdown-body h2,
.chat-messages .message .bubble .markdown-body h3,
.chat-messages .message .bubble .markdown-body h4 {
    margin: 12px 0 6px 0;
    font-weight: 600;
}
.chat-messages .message .bubble .markdown-body h1 { font-size: 22px; }
.chat-messages .message .bubble .markdown-body h2 { font-size: 19px; }
.chat-messages .message .bubble .markdown-body h3 { font-size: 16px; }
.chat-messages .message .bubble .markdown-body blockquote {
    border-left: 3px solid #4a6cf7;
    padding-left: 12px;
    margin: 8px 0;
    color: #718096;
}

/* ===== 思考中动画 ===== */
.thinking-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.thinking-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #4a6cf7;
    border-radius: 50%;
    animation: dot-bounce 1.4s ease-in-out infinite both;
}
.thinking-dots span:nth-child(1) { animation-delay: 0s; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}
body.dark-mode .thinking-dots span {
    background: #6a8cff;
}

/* ===== 消息元信息（耗时/状态） ===== */
.message .bubble .message-meta {
    font-size: 12px;
    color: #a0aec0;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f0f2f5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.message .bubble .message-meta .status-text {
    font-weight: 500;
    color: #4a6cf7;
}
.message .bubble .message-meta .duration {
    font-size: 12px;
    color: #a0aec0;
}
.message.user .bubble .message-meta {
    border-top-color: rgba(255,255,255,0.2);
}
.message.user .bubble .message-meta .status-text {
    color: #fff;
}
body.dark-mode .message .bubble .message-meta {
    border-top-color: #2a3a5a;
}
body.dark-mode .message .bubble .message-meta .status-text {
    color: #6a8cff;
}
body.dark-mode .message.user .bubble .message-meta {
    border-top-color: rgba(255,255,255,0.15);
}

/* ===== 图片消息 ===== */
.message .bubble .image-result {
    margin-top: 10px;
    position: relative;
    display: inline-block;
    width: 100%;
}
.message .bubble .image-result img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    border: 1px solid #eef2f6;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: block;
}
.message .bubble .image-result .image-caption {
    font-size: 13px;
    color: #4a5568;
    margin-bottom: 6px;
    font-weight: 500;
}
.message .bubble .image-result .image-actions-overlay {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}
.message .bubble .image-result:hover .image-actions-overlay {
    opacity: 1;
}
.message .bubble .image-result .image-actions-overlay button {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    border: none;
    background: rgba(0,0,0,0.6);
    color: #fff;
    cursor: pointer;
    transition: 0.2s;
}
.message .bubble .image-result .image-actions-overlay button:hover {
    background: rgba(0,0,0,0.8);
}

/* ===== 输入区域 ===== */
.chat-input-area {
    display: flex;
    flex-direction: column;
    border-top: 1px solid #eef2f6;
    background: #fff;
}
.chat-input-area .input-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px solid #f0f2f5;
    flex-wrap: wrap;
}
.chat-input-area .input-toolbar .mode-toggle {
    display: flex;
    background: #f0f2f5;
    border-radius: 30px;
    padding: 3px;
}
.chat-input-area .input-toolbar .mode-toggle button {
    border: none;
    background: transparent;
    padding: 4px 14px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    color: #718096;
    cursor: pointer;
    transition: 0.2s;
}
.chat-input-area .input-toolbar .mode-toggle button.active {
    background: #ffffff;
    color: #4a6cf7;
    box-shadow: 0 2px 8px rgba(74,108,247,0.12);
}
.chat-input-area .input-toolbar .mode-toggle button:hover:not(.active) {
    color: #4a5568;
}
.chat-input-area .input-row {
    display: flex;
    gap: 10px;
    padding: 8px 12px 12px;
    align-items: center;
}
.chat-input-area .input-row textarea {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #f7fafc;
}
.chat-input-area .input-row textarea:focus {
    border-color: #4a6cf7;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(74,108,247,0.08);
}
.chat-input-area .input-row .btn-send {
    padding: 8px 20px;
    background: #4a6cf7;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.25s;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.chat-input-area .input-row .btn-send:hover {
    background: #3a5cd9;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(74,108,247,0.25);
}
.chat-input-area .input-row .btn-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}
.chat-input-area .input-row .btn-send.generating {
    background: #a0aec0;
}

/* ===== 语音按钮 ===== */
.btn-voice {
    padding: 8px 12px;
    background: #f0f2f5;
    color: #4a5568;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
    transition: 0.25s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
}
.btn-voice:hover {
    background: #e2e8f0;
    border-color: #4a6cf7;
    color: #4a6cf7;
}
.btn-voice.listening {
    background: #fc8181;
    border-color: #e53e3e;
    color: #fff;
    animation: pulse-mic 1.2s ease-in-out infinite;
}
@keyframes pulse-mic {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}
.btn-voice:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    animation: none;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .chat-container {
        max-height: 70vh;
    }
    .chat-messages {
        padding: 12px 16px;
    }
    .chat-messages .message .bubble {
        max-width: 90%;
        font-size: 14px;
    }
    .chat-messages .message .bubble .markdown-body pre {
        padding: 12px 14px;
        font-size: 12px;
    }
    .chat-input-area .input-toolbar {
        padding: 4px 10px;
        gap: 4px;
    }
    .chat-input-area .input-toolbar .mode-toggle button {
        font-size: 12px;
        padding: 3px 10px;
    }
    .chat-input-area .input-row {
        padding: 6px 10px 10px;
        gap: 6px;
    }
    .chat-input-area .input-row textarea {
        font-size: 14px;
        padding: 8px 12px;
    }
    .chat-input-area .input-row .btn-send {
        padding: 6px 14px;
        font-size: 14px;
    }
    .btn-voice {
        width: 38px;
        padding: 6px 10px;
        font-size: 16px;
    }
}

/* ===== 深色模式 ===== */
body.dark-mode .ai-creative-header {
    border-bottom-color: #2a2a4a;
}
body.dark-mode .ai-creative-header h1 {
    color: #e2e8f0;
}
body.dark-mode .chat-container {
    background: #16213e;
    border-color: #2a3a5a;
}
body.dark-mode .chat-messages {
    background: #1a2a4a;
}
body.dark-mode .chat-messages .message .bubble {
    background: #16213e;
    border-color: #2a3a5a;
    color: #cbd5e0;
}
body.dark-mode .chat-messages .message.user .bubble {
    background: #4a6cf7;
    color: #fff;
}
body.dark-mode .chat-messages .message.assistant .bubble {
    background: #2a3a5a;
}
body.dark-mode .chat-messages .message .bubble .markdown-body pre {
    background: #0d0d1a !important;
    border-color: #2a2a4a;
}
body.dark-mode .chat-messages .message .bubble .markdown-body pre code {
    color: #cbd5e0;
}
body.dark-mode .chat-messages .message .bubble .markdown-body .code-copy-btn {
    background: rgba(255,255,255,0.08);
    color: #888;
}
body.dark-mode .chat-messages .message .bubble .markdown-body .code-copy-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #cbd5e0;
}
body.dark-mode .chat-messages .message .bubble .markdown-body blockquote {
    color: #a0aec0;
}
body.dark-mode .chat-input-area {
    background: #16213e;
    border-top-color: #2a3a5a;
}
body.dark-mode .chat-input-area .input-toolbar {
    border-bottom-color: #2a3a5a;
}
body.dark-mode .chat-input-area .input-toolbar .mode-toggle {
    background: #2a3a5a;
}
body.dark-mode .chat-input-area .input-toolbar .mode-toggle button {
    color: #a0aec0;
}
body.dark-mode .chat-input-area .input-toolbar .mode-toggle button.active {
    background: #1a2a4a;
    color: #6a8cff;
}
body.dark-mode .chat-input-area .input-toolbar .mode-toggle button:hover:not(.active) {
    color: #cbd5e0;
}
body.dark-mode .chat-input-area .input-row textarea {
    background: #2a3a5a;
    border-color: #3a4a5a;
    color: #cbd5e0;
}
body.dark-mode .chat-input-area .input-row textarea:focus {
    border-color: #4a6cf7;
    background: #1a2a4a;
}
body.dark-mode .chat-messages .message .bubble .image-result img {
    border-color: #2a3a5a;
}
body.dark-mode .chat-messages .message .bubble .image-result .image-actions-overlay button {
    background: rgba(0,0,0,0.7);
}
body.dark-mode .chat-messages .message .bubble .image-result .image-actions-overlay button:hover {
    background: rgba(0,0,0,0.9);
}
body.dark-mode .btn-voice {
    background: #2a3a5a;
    border-color: #3a4a6a;
    color: #a0aec0;
}
body.dark-mode .btn-voice:hover {
    background: #3a4a6a;
    border-color: #4a6cf7;
    color: #6a8cff;
}
body.dark-mode .btn-voice.listening {
    background: #6a1a1a;
    border-color: #e53e3e;
    color: #fc8181;
}
body.dark-mode .thinking-dots span {
    background: #6a8cff;
}
body.dark-mode .chat-messages .message.user .bubble .message-meta {
    border-top-color: rgba(255,255,255,0.15);
}