/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

:root {
    /* 浅色主题变量 */
    --bg-color: #f5f7fa;
    --sidebar-bg: #fff;
    --sidebar-border: #e8e8e8;
    --primary-color: #1890ff;
    --primary-hover: #40a9ff;
    --text-color: #333;
    --text-secondary: #8c8c8c;
    --message-bg: #fff;
    --message-user-bg: #f5f7fa;
    --message-border: #e8e8e8;
    --input-area-bg: #fff;
    --hover-bg: #f0f2f5;
    --active-bg: #e6f7ff;
    --avatar-bg: #1890ff;
    --avatar-user-bg: #722ed1;
    --scrollbar-track: #f1f1f1;
    --scrollbar-thumb: #c1c1c1;
    --scrollbar-hover: #a8a8a8;
    --box-shadow: rgba(0, 0, 0, 0.08);
    --question-text: #676c90;
}

.dark-theme {
    /* 深色主题变量 */
    --bg-color: #1f1f1f;
    --sidebar-bg: #2d2d2d;
    --sidebar-border: #3a3a3a;
    --primary-color: #177ddc;
    --primary-hover: #3c9ae8;
    --text-color: #e0e0e0;
    --text-secondary: #aaaaaa;
    --message-bg: #2d2d2d;
    --message-user-bg: #363636;
    --message-border: #404040;
    --input-area-bg: #363636;
    --hover-bg: #404040;
    --active-bg: #1a365d;
    --avatar-bg: #177ddc;
    --avatar-user-bg: #722ed1;
    --scrollbar-track: #2d2d2d;
    --scrollbar-thumb: #555555;
    --scrollbar-hover: #777777;
    --box-shadow: rgba(0, 0, 0, 0.2);
    --question-text: #dbdef8;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

/* 主容器样式 */
.main-container {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* 左侧边栏样式 */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--sidebar-border);
    position: relative;
}

.sidebar-header h1 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 16px;
}

.new-chat-btn {
    width: 100%;
    padding: 10px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    transition: background-color 0.3s;
}

.new-chat-btn:hover {
    background-color: var(--primary-hover);
}

.plus-icon {
    margin-right: 8px;
    font-size: 16px;
    font-weight: bold;
}

/* 主题切换按钮 */
.theme-toggle {
    position: absolute;
    right: 16px;
    top: 16px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.theme-toggle:hover {
    background-color: var(--hover-bg);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    fill: var(--text-secondary);
}

/* 历史对话列表样式 */
.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
    max-height: calc(100vh - 90px);
}

.history-section {
    margin-bottom: 16px;
}

.time-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 5px 10px;
    margin-bottom: 5px;
}

.history-item {
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item:hover {
    background-color: var(--hover-bg);
}

.history-item.active {
    background-color: var(--active-bg);
    border-left: 3px solid var(--primary-color);
}

.history-title {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
    color: var(--text-color);
}

.delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    opacity: 0.5;
    transition: opacity 0.2s;
    color: red;
}

.delete-btn:hover {
    opacity: 1;
}

.delete-btn svg {
    display: block;
}

.history-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* 右侧聊天区域 */
.fist-loading{
    width: 900px;
    margin: 8% auto 10px;
}
.fist-loading>p{
    color: var(--primary-color);
    font-weight: bold;
    font-size: 20px;
    width: 500px;
    margin:0 auto;
}

.expert-guides-container {
    width: 500px;
    height: 240px; /* 高度为每条推荐项高度的3倍 */
    margin: 0 auto;
    overflow: hidden;
    position: relative;
}

.expert-guides-scroll {
    width: 100%;
    position: absolute;
    transition: transform 0.5s ease;
}

.expert-guide-item {
    width: 500px;
    height: 70px;
    line-height: 70px;
    border-radius: 16px;
    padding: 0 16px;
    background-color: var(--sidebar-bg);
    border: 1px solid var(--box-shadow);
    /*box-shadow: 0 1px 8px var(--box-shadow);*/
    /*box-sizing: border-box;*/
    align-items: center;
    margin: 10px auto 0;
    font-size: 16px;
    cursor: pointer;
    color: var(--question-text);
}

.expert-guide-item:hover{
    background-color: #e5eaf6;
    color: #475ada;
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100vh;
    overflow-y: auto; /* 使整个聊天区域可滚动，滚动条显示在最右边 */
    overflow-x: hidden;
    background-color: var(--bg-color);
}

.scrollContainer{
    width: 100%;
    overflow-y: auto; /* 让内容继续流动 */
    height: calc(100vh - 150px); /* 确保占据足够高度 */
    overflow-x: hidden;
    padding-top: 20px;
}

/* 聊天消息区域 */
.chat-messages {
    width: 900px;
    margin: 0 auto 10px;
}

/* 输入区域 */
.input-area {
    width: 900px;
    max-width: 95%;
    margin: 0 auto 30px auto;
    padding: 8px 10px;
    display: flex;
    background-color: var(--input-area-bg);
    border-radius: 15px;
    box-shadow: 0 1px 8px var(--box-shadow);
    position: sticky;
    bottom: 30px;
    flex-shrink: 0; /* 防止被压缩 */
    flex-direction: column;
    justify-content: flex-start;
}

.input-area-content{
    display: flex;
    justify-content: space-between;
    padding-left: 10px;
}

/* 单条消息样式 */
.message {
    display: flex;
    margin-bottom: 20px;
    align-items: flex-start;
}

/* 用户消息 */
.question{
    display: flex;
    justify-content: flex-start;
}
.question_left{
    width: 40px;
    margin: 0 10px;
}
.question_right{
    padding:0 6px;
}
.question_right>p{
    font-size: 14px;
    color: var(--question-text);
}
.questionContent{
    font-size: 13px;
    color: var(--question-text);
    background-color: var(--input-area-bg);
    border-radius: 6px;
    box-shadow: 0 16px 20px 0 rgba(174, 167, 223, .06);
    line-height: 20px;
    max-width: 800px;
    overflow: hidden;
    padding: 8px 16px;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: -moz-fit-content;
    width: fit-content;
    margin: 10px 0;
    cursor: pointer;
}

.questionContent:hover{
    background-color: #e5eaf6;
    color: #475ada;
}

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

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--avatar-bg);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
    margin: 0 10px;
}

.user-message .avatar {
    background-color: var(--avatar-user-bg);
}

.message .content {
    max-width: 87%;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 1px 2px var(--box-shadow);
}

.ai-message .content {
    background-color: var(--message-bg);
    border-top-left-radius: 0;
}

.user-message .content {
    background-color: var(--message-user-bg);
    border: 1px solid var(--message-border);
    color: var(--text-color);
    border-top-right-radius: 0;
}

.content p {
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-color);
}

#user-input {
    flex: 1;
    padding: 8px 10px;
    border: none;
    border-radius: 0;
    resize: none;
    outline: none;
    height: 100px;
    max-height: 150px;
    background-color: transparent;
    transition: all 0.3s;
    margin-right: 8px;
    line-height: 20px;
    box-shadow: none;
    overflow-y: auto;
    color: var(--text-color);
}

#user-input:focus {
    box-shadow: none;
}

#user-input::placeholder {
    color: var(--text-secondary);
}

.send-btn, .stop-btn {
    width: 36px;
    height: 36px;
    min-height: 36px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    padding: 0;
}

.send-btn:hover, .stop-btn:hover {
    background-color: var(--primary-hover);
}

.stop-btn {
    background-color: #ff4d4f;
}

.stop-btn:hover {
    background-color: #ff7875;
}

.stop-icon, .send-icon {
    width: 18px;
    height: 18px;
    stroke: white;
}

/* 打字指示器样式 */
.typing-indicator {
    display: inline-block;
    position: relative;
    min-height: 20px;
    font-size: 25px;
    font-weight: bold;
}

.typing-indicator::after {
    content: "···";
    animation: typing 1.5s infinite;
}

@keyframes typing {
    0%, 100% { content: "."; }
    33% { content: ".."; }
    66% { content: "..."; }
}

@media(max-width: 1190px){
    .chat-messages{
        width: 800px;
    }
}
@media(max-width: 1090px){
    .chat-messages{
        width: 700px;
    }
}
@media(max-width: 990px){
    .chat-messages{
        width: 600px;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: -280px;
        height: 100vh;
        z-index: 10;
        transition: left 0.3s;
    }
    
    .sidebar.visible {
        left: 0;
    }
    
    .chat-messages,
    .input-area {
        width: 100%;
        max-width: 100%;
    }
    
    .message .content {
        max-width: 85%;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-hover);
}

/* 动画效果 */
.message {
    animation: fadeIn 0.3s ease-out;
}

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

/* 自定义选择器样式 */
.custom-select {
    position: relative;
    width: auto;
    min-width: 70px;
    cursor: pointer;
    user-select: none;
    margin-right: 10px;
    margin-left: 0;
}

.selected-option {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px 5px;
    border-radius: 8px;
    /*background-color: rgba(230, 220, 250, 0.5);*/
    background-color: #f5f6fa;
    /*color: #6633ff;*/
    color: #4c4c4c;
    font-size: 14px;
    transition: all 0.2s;
}

.selected-option span {
    margin-right: 2px;
    text-align: center;
    display: inline-block;
    width: 100%;
}

.dark-theme .selected-option {
    background-color: rgba(130, 100, 200, 0.2);
    color: #9980ff;
}

.selected-option:hover {
    background-color: rgba(210, 200, 250, 0.7);
}

.dark-theme .selected-option:hover {
    background-color: rgba(150, 120, 220, 0.3);
}

.dropdown-icon {
    transition: transform 0.2s;
    margin-left: 2px;
    flex-shrink: 0;
    stroke: #6633ff;
}

.dark-theme .dropdown-icon {
    stroke: #9980ff;
}

.dropdown-icon.rotated {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 100%;
    margin-bottom: 5px;
    background-color: var(--message-bg);
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--box-shadow);
    z-index: 100;
    overflow: hidden;
}

.dropdown-item {
    padding: 6px 8px;
    transition: background-color 0.2s;
    font-size: 13px;
    color: var(--text-color);
    text-align: center;
}

.dropdown-item:hover {
    background-color: var(--hover-bg);
}

.dropdown-item.active {
    background-color: var(--active-bg);
    font-weight: 500;
}

/* 输入区域内容样式 */
.input-area-content {
    display: flex;
    align-items: center;
}

.selected-option.active {
    /* 选中样式 */
    /*background-color: #f5f6fa;*/
    background-color: rgba(230, 220, 250, 0.5);
    /*color: #272933;*/
    color: #6633ff;
}
.expert-toast {
    position: fixed;
    left: 50%;
    top: 65%;        /* 垂直居中 */
    background-color: rgba(230, 220, 250, 0.5);
    color: #6633ff;
    padding: 10px 20px;
    border-radius: 4px;
    z-index: 1000;
}