/* --- 全局和基础样式 --- */
:root {
    --brand-primary: #0078D4; /* Example: Microsoft Blue */
    --brand-secondary: #e6f2fa;
    --text-dark: #222;
    --text-light: #fff;
    --text-muted: #555;
    --border-color: #ccc;
    --user-msg-bg: #dff1ff; /* Lighter blue for user */
    --ai-msg-bg: #f3f3f3;   /* Off-white for AI */
    --button-bg: #f0f0f0;
    --button-hover-bg: #e0e0e0;
    --source-bg: #eee;
    --link-color: #005da6;
    --report-bg: #e8f4fd; /* Background for report summary */
    --font-family-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

html, body {
    height: 100%;
    margin: 0;
    font-family: var(--font-family-main);
    background-color: #f0f2f5; /* Lighter background for contrast */
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    box-sizing: border-box;
}

/* --- 主容器 --- */
.agent-container {
    width: 95%;
    max-width: 900px; /* Suitable width for chat */
    height: 90vh;
    min-height: 600px;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- 头部 --- */
.agent-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: #f8f9fa; /* Light header background */
    flex-shrink: 0; /* Prevent shrinking */
}

.agent-header h1 {
    font-size: 1.2em;
    margin: 0 0 3px 0;
    color: #111; /* Darker title */
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}
.agent-header .icon {
    margin-right: 8px;
    color: var(--brand-primary);
    font-size: 1.1em;
}

.agent-header p {
    margin: 0;
    font-size: 0.9em;
    color: var(--text-muted);
}

/* --- 聊天显示区 --- */
.chat-display-wrapper {
    flex-grow: 1; /* Takes up available space */
    overflow: hidden;
    position: relative; /* For potential absolute positioned elements */
}

.chat-display {
    padding: 20px 15px;
    overflow-y: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* --- 消息气泡 --- */
.message {
    margin-bottom: 12px;
    display: flex;
    max-width: 85%; /* Limit bubble width, adjust for report */
}

.message .bubble {
    padding: 10px 14px;
    border-radius: 18px;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 1px 1px rgba(0,0,0,0.08);
    word-wrap: break-word;
    font-size: 0.95em; /* Slightly smaller font */
}

.message.user { align-self: flex-end; }
.message.user .bubble {
    background-color: var(--user-msg-bg);
    color: #003366; /* Darker text */
    border-bottom-right-radius: 6px;
}

.message.ai { align-self: flex-start; }
.message.ai .bubble {
    background-color: var(--ai-msg-bg);
    color: var(--text-dark);
    border: 1px solid #e7e7e7;
    border-bottom-left-radius: 6px;
}
/* Make lists inside bubbles look better */
.message.ai .bubble ul, .message.ai .bubble ol {
    padding-left: 20px;
    margin-top: 8px;
    margin-bottom: 5px;
}
.message.ai .bubble li {
    margin-bottom: 4px;
}
.message.ai .bubble p {
    margin-top: 5px;
    margin-bottom: 10px;
}
.message.ai .bubble p:first-child { margin-top: 0; }
.message.ai .bubble p:last-child { margin-bottom: 0; }


/* --- 交互式按钮/选项 within AI bubble --- */
.interactive-options {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.option-button {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background-color: var(--button-bg);
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
.option-button:hover {
    background-color: var(--button-hover-bg);
    border-color: #aaa;
}
.option-button:active {
    background-color: #d0d0d0;
}
/* Disabled state for clicked buttons */
.option-button:disabled {
     cursor: not-allowed;
     opacity: 0.6;
     background-color: var(--button-bg); /* Keep background but faded */
}

/* --- 知识来源 --- */
.knowledge-source {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dotted #d0d0d0;
    font-size: 0.8em;
    color: var(--text-muted);
}
.knowledge-source strong {
    color: var(--text-dark);
    font-weight: 600;
}
.knowledge-source a {
    color: var(--link-color);
    text-decoration: none;
    margin-left: 5px;
    font-weight: 500;
}
.knowledge-source a:hover {
    text-decoration: underline;
}

/* --- 加载指示器 --- */
.message.loading .bubble {
    font-style: italic;
    color: var(--text-muted);
    background-color: transparent;
    box-shadow: none;
    border: none;
    display: flex;
    align-items: center;
}
.spinner-dots { display: inline-block; margin-left: 8px; }
.spinner-dots span { display: inline-block; width: 5px; height: 5px; background-color: var(--text-muted); border-radius: 50%; margin: 0 2px; animation: bounce 1.4s infinite ease-in-out both; }
.spinner-dots span:nth-child(1) { animation-delay: -0.32s; }
.spinner-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1.0); } }

/* --- 报告预览样式 (新增) --- */
.message.ai .bubble.report-summary {
    background-color: var(--report-bg); /* Different background for report */
    border-left: 4px solid var(--brand-primary);
    border-radius: 6px; /* Less rounded for a report feel */
    border-color: #bee5eb; /* Softer border */
    max-width: 95%; /* Allow report to be wider */
    font-size: 0.9em;
}
.report-summary h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1em;
    color: var(--brand-primary);
    border-bottom: 1px solid #ccc;
    padding-bottom: 5px;
    font-weight: 600;
}
.report-summary p { margin-bottom: 8px; }
.report-summary strong { color: #333; font-weight: 600;}
.report-summary small { color: var(--text-muted); }


/* --- 输入区域 --- */
.input-area {
    display: flex;
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
    background-color: #f8f9fa; /* Match header background */
    flex-shrink: 0; /* Prevent shrinking */
    align-items: flex-end; /* Align items to bottom */
}

#user-input {
    flex-grow: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 18px; /* Match bubble radius */
    resize: none;
    overflow-y: auto;
    max-height: 100px; /* Limit expansion */
    line-height: 1.4;
    font-size: 0.95em;
    margin-right: 8px;
    font-family: var(--font-family-main);
    box-sizing: border-box;
}
#user-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.2);
}

#send-button {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border: none;
    background-color: var(--brand-primary);
    color: var(--text-light);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.3em;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s ease;
    margin-bottom: 1px; /* Fine-tune vertical alignment */
}
#send-button:hover {
    background-color: #005a9e; /* Darker blue */
}
#send-button .icon {
    line-height: 1;
    margin-left: 1px;
}


/* --- 响应式调整 (简单示例) --- */
@media (max-width: 600px) {
    .agent-container {
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }
    body {
        padding: 0;
    }
    .message {
        max-width: 90%; /* Slightly wider bubbles on mobile */
    }
    #user-input {
        font-size: 1em; /* Make input slightly larger */
    }
    .input-area {
        padding: 8px 10px;
    }
     #send-button {
        width: 36px;
        height: 36px;
        font-size: 1.2em;
     }
}