/**
 * 百度智能体聊天页面样式
 * 适配 AeroCore 主题变量，同时提供默认变量回退
 * 支持页面独立颜色配置
 * 移动端宽度完美适配 child-page__body
 */

:root {
    --theme-color: #FF597D;
    --bg-card: #ffffff;
    --border-primary: #e5e7eb;
    --border-input: #d1d5db;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --bg-input: #ffffff;
    
    /* 页面独立颜色变量（会通过内联样式覆盖） */
    --chat-title-gradient: linear-gradient(135deg, #FF597D, #FF8E93);
    --user-bubble-gradient: linear-gradient(135deg, #FF597D, #FF8E93);
    --accent-color: #FF597D;
}

html[data-theme="dark"] {
    --bg-card: #1f2937;
    --border-primary: #374151;
    --border-input: #4b5563;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --bg-input: #374151;
}

.bot-chat-page {
    padding: 40px 0 80px;
    background: transparent;
}

.bot-chat-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 头部 */
.bot-chat-header {
    text-align: center;
    margin-bottom: 40px;
}

.bot-chat-title {
    font-size: 36px;
    font-weight: 700;
    background: var(--chat-title-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    margin: 0 0 10px;
}

.bot-chat-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 0;
}

/* 布局 */
.bot-chat-main {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.bot-chat-sidebar {
    flex: 0 0 280px;
}

.bot-info-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 30px 20px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-primary);
    transition: transform 0.3s ease;
    position: sticky;
    top: 100px;
}

.bot-info-card:hover {
    transform: translateY(-5px);
}

.bot-avatar-large {
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--user-bubble-gradient);
    padding: 3px;
}

.bot-avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    background: var(--bg-card);
}

.bot-info-card h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 10px;
}

.bot-info-card p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0 0 20px;
}

.bot-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    border-top: 1px solid var(--border-primary);
    padding-top: 20px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: var(--accent-color);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

.bot-chat-area {
    flex: 1;
    min-width: 0;
}

/* 消息容器 */
.chat-messages-container {
    background: var(--bg-card);
    border-radius: 24px;
    border: 1px solid var(--border-primary);
    overflow: hidden;
    margin-bottom: 20px;
}

.chat-messages {
    height: 500px;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: var(--border-primary);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 3px;
}

/* 消息气泡 */
.message-wrapper {
    display: flex;
    gap: 12px;
    animation: fadeInUp 0.3s ease-out;
}

.message-wrapper.bot {
    flex-direction: row;
}

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

.message-avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.message-bubble {
    max-width: 70%;
    padding: 12px 18px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
}

.message-wrapper.bot .message-bubble {
    background: #f5f5f5;
    border-bottom-left-radius: 4px;
    color: #333;
}

html[data-theme="dark"] .message-wrapper.bot .message-bubble {
    background: #2a2a2a;
    color: #e0e0e0;
}

.message-wrapper.user .message-bubble {
    background: var(--user-bubble-gradient);
    border-bottom-right-radius: 4px;
    color: white;
}

.message-content {
    line-height: 1.5;
    font-size: 14px;
}

.message-content p {
    margin: 0 0 8px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
}

.message-content pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-content pre code {
    background: transparent;
    padding: 0;
}

.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

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

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

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

/* 加载动画 */
.loading-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--accent-color);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

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

/* 快捷提问 */
.faq-questions {
    margin-bottom: 20px;
}

.faq-title {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.faq-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.faq-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 30px;
    padding: 8px 18px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.faq-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
    transform: translateY(-2px);
}

/* 输入区域 */
.chat-input-area {
    background: var(--bg-card);
    border-radius: 24px;
    border: 1px solid var(--border-primary);
    padding: 16px 20px;
}

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

.chat-input {
    flex: 1;
    min-height: 100px;
    max-height: 200px;
    padding: 12px 16px;
    border: 1px solid var(--border-input);
    border-radius: 22px;
    background: var(--bg-input, var(--bg-card));
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.chat-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(255, 89, 125, 0.1);
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--user-bubble-gradient);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.input-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 10px;
    text-align: center;
}

/* 清空按钮 */
.clear-chat-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--border-primary);
    border-radius: 30px;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 16px;
}

.clear-chat-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* 滚动动画 */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
}

.delay-1 { transition-delay: 0.1s; }
.delay-2 { transition-delay: 0.2s; }

/* ========== 移动端完美适配（宽度填满 child-page__body） ========== */
@media (max-width: 768px) {
    /* 让聊天组件突破父级 .child-page__body 的左右内边距（默认按 15px 处理） 
       如果您的主题内边距不同，请修改下面的 -15px 数值 */
    .bot-chat-page {
        margin-left: -15px;
        margin-right: -15px;
        width: calc(100% + 30px);
        max-width: none;
    }

    /* 恢复容器内部宽度，去除原有内边距避免二次偏移 */
    .bot-chat-container {
        padding-left: 0;
        padding-right: 0;
        width: 100%;
    }

    /* 聊天主区域宽度完全等于 .child-page__body 的宽度 */
    .bot-chat-area {
        width: 100%;
    }

    /* 消息列表：增加左右内边距，防止文字贴边 */
    .chat-messages {
        height: 400px;
        padding: 16px 15px;
    }

    /* 常见问题区域：左右内边距保持一致 */
    .faq-questions {
        padding: 0 15px;
        margin-bottom: 20px;
    }

    /* 输入区域：背景铺满，内容左右留白 */
    .chat-input-area {
        padding: 12px 15px;
        margin: 0;
        border-radius: 20px;
    }

    /* 输入框触控优化 */
    .chat-input {
        padding: 10px 14px;
        min-height: 80px;
        font-size: 15px;
    }

    /* 发送按钮大小 */
    .send-btn {
        width: 48px;
        height: 48px;
    }

    /* 消息气泡宽度增加，阅读更舒适 */
    .message-bubble {
        max-width: 85%;
        padding: 10px 14px;
    }

    /* 头像大小微调 */
    .message-avatar {
        width: 36px;
        height: 36px;
    }

    /* 快捷提问按钮更易点击 */
    .faq-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    /* 侧边栏占满宽度，卡片左右留白 */
    .bot-chat-sidebar {
        flex: auto;
        padding: 0 15px;
    }

    .bot-info-card {
        position: static;
        padding: 20px 16px;
    }

    /* 清空按钮居中 */
    .clear-chat-btn {
        margin: 16px auto 0;
        display: flex;
        width: fit-content;
    }

    /* 头部文字大小适配 */
    .bot-chat-title {
        font-size: 28px;
    }

    .bot-chat-subtitle {
        font-size: 14px;
    }

    /* 整体页面上下边距减少 */
    .bot-chat-page {
        padding: 20px 0 40px;
    }
}

/* 小尺寸手机（宽度 ≤ 480px）进一步优化 */
@media (max-width: 480px) {
    .chat-messages {
        height: 350px;
        padding: 12px 12px;
    }

    .faq-questions {
        padding: 0 12px;
    }

    .chat-input-area {
        padding: 10px 12px;
    }

    .message-bubble {
        max-width: 90%;
        padding: 8px 12px;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
    }

    .send-btn {
        width: 44px;
        height: 44px;
    }

    .bot-chat-title {
        font-size: 24px;
    }

    .bot-chat-subtitle {
        font-size: 13px;
    }

    .bot-chat-sidebar {
        padding: 0 12px;
    }
}