.ai-chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    height: calc(100vh - 40px);
    border-radius: 16px;
    background: white;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    font-family: 'Segoe UI', Roboto, sans-serif;
}

.ai-chat-container.minimized {
    height: 50px;
    overflow: hidden;
}

.ai-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: linear-gradient(135deg, #0b3f64 0%, #1a5a8c 100%);
    color: white;
    border-radius: 16px 16px 0 0;
    cursor: pointer;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.ai-chat-title {
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-chat-title::before {
    content: "🤖";
    font-size: 1.2rem;
}

.ai-chat-controls {
    display: flex;
    gap: 10px;
}

.ai-chat-controls button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-chat-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ai-chat-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background: #f8fafd;
}

.ai-chat-settings {
    border-bottom: 1px solid #e1eaf2;
    background: #ffffff;
}

.ai-settings-header {
    padding: 10px 18px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e4a76;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f0f7ff;
}

.ai-settings-header:hover {
    background: #e3f0fc;
}

.ai-settings-panel {
    padding: 16px 18px;
    background: #ffffff;
    border-top: 1px solid #e1eaf2;
}

.setting-item {
    margin-bottom: 14px;
}

.setting-item label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #2a5f8a;
    margin-bottom: 4px;
}

.setting-item select,
.setting-item input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd6e4;
    border-radius: 24px;
    font-size: 0.85rem;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}

.setting-item select:focus,
.setting-item input:focus {
    border-color: #1f6aa5;
    box-shadow: 0 0 0 2px rgba(31, 106, 165, 0.1);
}

#ai-save-settings {
    background: #1f6aa5;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s;
    width: 100%;
}

#ai-save-settings:hover {
    background: #0b3f64;
}

#settings-status {
    display: block;
    margin-top: 8px;
    font-size: 0.8rem;
    text-align: center;
    min-height: 20px;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    background: #f8fafd;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-message {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-message.user {
    justify-content: flex-end;
}

.ai-message.assistant {
    justify-content: flex-start;
}

.ai-message-content {
/*    max-width: 95%;*/
/*    padding: 6px 14px;*/
/*    border-radius: 18px;*/
/*    font-size: 0.9rem;*/
/*    line-height: 1.4;*/
/*    word-wrap: break-word;*/
/*    box-shadow: 0 1px 2px rgba(0,0,0,0.05);*/
/*    white-space: normal;*/
/*    overflow-wrap: break-word;*/
/*}*/
    max-width: 95%;
    padding: 6px 14px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    background-color: white;  /* 确保助手消息有白色背景 */
}

.user .ai-message-content {
    background: #1f6aa5;
    color: white;
    border-bottom-right-radius: 4px;
}

.assistant .ai-message-content {
    background: white;
    color: #1e2f3e;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

/* 光标样式 */
.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background-color: #1f6aa5;
    margin-left: 2px;
    animation: blink 1s infinite;
    vertical-align: middle;
    white-space: nowrap;
}

/* 正在生成回答提示 - 内联显示 */
.generating-indicator {
    display: inline-block;
    color: #1f6aa5;
    font-style: italic;
    margin-right: 4px;
    font-size: 0.9rem;
    vertical-align: middle;
    white-space: nowrap;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.ai-chat-input-area {
    display: flex;
    padding: 12px 18px;
    border-top: 1px solid #e1eaf2;
    background: white;
    gap: 8px;
}

#ai-chat-input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #cbd6e4;
    border-radius: 30px;
    outline: none;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

#ai-chat-input:focus {
    border-color: #1f6aa5;
    box-shadow: 0 0 0 2px rgba(31, 106, 165, 0.1);
}

#ai-chat-send {
    background: #1f6aa5;
    color: white;
    border: none;
    padding: 0 20px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.2s;
}

#ai-chat-send:hover {
    background: #0b3f64;
}

#ai-chat-stop {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0 20px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.2s;
    margin-left: 5px;
}

#ai-chat-stop:hover {
    background: #b02a37;
}

#ai-chat-stop:disabled {
    background: #aaa;
    cursor: not-allowed;
}

/* 搜索结果摘要样式 */
.search-summary {
    background-color: #f0f8ff;
    border-left: 4px solid #1f6aa5;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #333;
    line-height: 1.5;
    width: 100%;
    box-sizing: border-box;
}

/* 滚动条美化 */
.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: #eef2f6;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #b0c8dd;
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #8fb0cc;
}