/**
 * ChatWidget 样式（js/chat-widget.js 配套）
 *
 * 视觉语言对齐 chat.css 的消息气泡（.message-* / .typing-* / .thinking-* 同名类），
 * 但全部 scope 在 .chat-widget 下，宿主页样式零污染。
 * 颜色沿用 base.css 变量。
 */

.chat-widget {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-primary);
}

.chat-widget .cw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 20px 8px;
}

/* ===== 气泡（对齐 chat.css .message-*） ===== */
.chat-widget .message {
    margin-bottom: 20px;
}

.chat-widget .message-user {
    display: flex;
    justify-content: flex-end;
}

.chat-widget .message-user .message-content {
    background: var(--accent-blue);
    color: white;
    border-radius: 16px 16px 4px 16px;
    padding: 12px 16px;
    max-width: 80%;
    line-height: 1.6;
    font-size: 14px;
    word-break: break-word;
}

.chat-widget .message-assistant {
    display: flex;
    gap: 12px;
}

.chat-widget .message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.chat-widget .message-assistant .message-content {
    flex: 1;
    min-width: 0;
    line-height: 1.7;
    font-size: 14px;
    word-break: break-word;
}

.chat-widget .message-assistant .message-content p { margin-bottom: 12px; }
.chat-widget .message-assistant .message-content p:last-child { margin-bottom: 0; }

.chat-widget .message-assistant .message-content pre {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 12px;
    overflow-x: auto;
    margin: 12px 0;
}

.chat-widget .message-assistant .message-content code {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
}

.chat-widget .message-assistant .message-content ul,
.chat-widget .message-assistant .message-content ol {
    padding-left: 24px;
    margin: 12px 0;
}

.chat-widget .message-assistant .message-content li { margin-bottom: 8px; }

.chat-widget .message-assistant .message-content h1,
.chat-widget .message-assistant .message-content h2,
.chat-widget .message-assistant .message-content h3 {
    margin: 16px 0 12px;
}

.chat-widget .message-assistant .message-content blockquote {
    border-left: 3px solid var(--accent-green);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--text-secondary);
}

.chat-widget .message-assistant .message-content a {
    color: var(--accent-blue);
    text-decoration: none;
}

.chat-widget .message-assistant .message-content a:hover { text-decoration: underline; }

.chat-widget .cw-error { color: #f44336; }

/* ===== 打字指示（对齐 chat.css .typing-*） ===== */
.chat-widget .typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.chat-widget .typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: cw-typing 1.4s infinite ease-in-out;
}

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

@keyframes cw-typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ===== 思考折叠块（对齐 chat.css .thinking-*） ===== */
.chat-widget .thinking-container {
    background: linear-gradient(135deg, rgba(156, 39, 176, 0.1), rgba(103, 58, 183, 0.1));
    border: 1px solid rgba(156, 39, 176, 0.3);
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
}

.chat-widget .thinking-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    background: rgba(156, 39, 176, 0.15);
    font-size: 13px;
}

.chat-widget .thinking-header:hover { background: rgba(156, 39, 176, 0.25); }

.chat-widget .thinking-icon { font-size: 16px; }

.chat-widget .thinking-toggle {
    margin-left: auto;
    font-size: 10px;
    color: var(--text-secondary);
    transition: transform 0.3s;
}

.chat-widget .thinking-content {
    padding: 12px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
    transition: max-height 0.3s, padding 0.3s, opacity 0.3s;
}

.chat-widget .thinking-container.collapsed .thinking-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

.chat-widget .thinking-container.collapsed .thinking-toggle { transform: rotate(-90deg); }

/* ===== 输入条 ===== */
.chat-widget .cw-inputbar {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.chat-widget .cw-input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    outline: none;
    resize: none;
    max-height: 120px;
}

.chat-widget .cw-input:focus { border-color: var(--accent-blue); }

.chat-widget .cw-send-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: var(--accent-blue);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
}

.chat-widget .cw-send-btn:hover { opacity: 0.85; }
.chat-widget .cw-send-btn.cw-stop { background: #f44336; }
