/* 明德通鉴 - 前端样式文件 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: #FFFEF7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* 顶部LOGO区域 */
.header {
    background: linear-gradient(135deg, #AE0B2A 0%, #C93D57 100%);
    padding: 18px 40px;
    box-shadow: 0 4px 20px rgba(174, 11, 42, 0.3);
    text-align: center;
    position: relative;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.logo {
    font-size: 38px;
    font-weight: bold;
    color: #FFFFFF;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 3px;
}

.subtitle {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 300;
}

.user-info {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
}

/* 主内容区域 */
.main-container {
    flex: 1;
    display: flex;
    gap: 20px;
    padding: 25px;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    background: #FFFEF7;
    min-height: 0; /* 重要：确保flex子元素可以正确收缩 */
    overflow: hidden;
}

/* 聊天框区域 */
.chat-container {
    flex: 2;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(174, 11, 42, 0.15);
    overflow: hidden;
    min-height: 0; /* 重要：确保flex子元素可以正确收缩 */
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0; /* 重要：确保可以滚动 */
}

/* 自定义滚动条样式 */
.chat-messages::-webkit-scrollbar,
.status-panel::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track,
.status-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb,
.status-panel::-webkit-scrollbar-thumb {
    background: #AE0B2A;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.status-panel::-webkit-scrollbar-thumb:hover {
    background: #8E0A22;
}

.message {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-in;
}

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

.message.assistant {
    text-align: left;
}

.message.user {
    text-align: right;
}

.message-bubble {
    display: inline-block;
    max-width: 80%;
    padding: 12px 18px;
    border-radius: 18px;
    line-height: 1.6;
    word-wrap: break-word;
}

.assistant .message-bubble {
    background: #f0f0f0;
    color: #333;
    border-bottom-left-radius: 6px;
}

.user .message-bubble {
    background: #AE0B2A;
    color: white;
    border-bottom-right-radius: 6px;
}

/* 问题卡片 */
.question-card {
    background: linear-gradient(135deg, #AE0B2A 0%, #C93D57 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
    box-shadow: 0 4px 15px rgba(174, 11, 42, 0.3);
}

.question-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
}

.question-type {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    margin-bottom: 10px;
}

.options {
    margin-top: 15px;
}

.option {
    background: white;
    color: #333;
    padding: 12px 18px;
    margin: 8px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.option:hover {
    background: #f0f0f0;
    border-color: #AE0B2A;
    transform: translateX(5px);
}

.option.selected {
    background: #AE0B2A;
    color: white;
    border-color: #AE0B2A;
}

/* 问题卡片中的输入区域 */
.question-card .input-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.question-card .input-group input {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
}

.question-card .input-group input:focus {
    border-color: white;
}

.question-card .input-group button {
    padding: 12px 30px;
    background: white;
    color: #AE0B2A;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
}

.question-card .input-group button:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.question-card .input-group button:disabled {
    background: rgba(255, 255, 255, 0.5);
    color: #AE0B2A;
    cursor: not-allowed;
    transform: none;
}

/* 聊天输入区域容器 */
.chat-input-container {
    border-top: 1px solid #e0e0e0;
    background: #f9f9f9;
    flex-shrink: 0; /* 防止输入区域被压缩 */
    display: block !important; /* 强制显示 */
    visibility: visible !important; /* 强制可见 */
}

/* 输入区域 */
.input-container {
    padding: 20px;
    background: #f9f9f9;
    border-top: 1px solid #e0e0e0;
}

.input-group {
    display: flex !important; /* 强制显示 */
    gap: 10px;
    padding: 15px 20px;
}

.input-group input {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
    background: white;
    display: block !important; /* 强制显示 */
    visibility: visible !important; /* 强制可见 */
}

.input-group input:focus {
    border-color: #AE0B2A;
}

.input-group button {
    padding: 12px 30px;
    background: #AE0B2A;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    display: block !important; /* 强制显示 */
    visibility: visible !important; /* 强制可见 */
}

.input-group button:hover {
    background: #8E0A22;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(174, 11, 42, 0.4);
}

.input-group button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* 状态面板 */
.status-panel {
    flex: 1;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(174, 11, 42, 0.15);
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* 添加垂直滚动功能 */
    max-height: calc(100vh - 180px); /* 设置最大高度，确保不会超出视窗 */
}

.level-display {
    background: linear-gradient(135deg, #AE0B2A 0%, #C93D57 100%);
    color: white;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 20px;
}

.level-title {
    font-size: 14px;
    opacity: 0.9;
}

.level-value {
    font-size: 32px;
    font-weight: bold;
    margin-top: 5px;
}

.basic-info {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.basic-info h3 {
    font-size: 16px;
    color: #AE0B2A;
    margin-bottom: 10px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.info-label {
    color: #666;
}

.info-value {
    font-weight: bold;
    color: #333;
}

.radar-container {
    /* margin: 20px 0; */
    height: 240px;  /* 缩小雷达图 */
}

.suggestions {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    flex: 1;  /* 增大学习建议区域 */
    overflow-y: auto;
    min-height: 200px;
}

.suggestions h3 {
    font-size: 16px;
    color: #AE0B2A;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.suggestions p {
    font-size: 14px;
    line-height: 1.8;
    color: #666;
}

/* Markdown 样式支持 */
#suggestionText strong,
.message-bubble strong {
    color: #AE0B2A;
    font-weight: bold;
}

#suggestionText em,
.message-bubble em {
    font-style: italic;
    color: #555;
}

#suggestionText h1,
#suggestionText h2,
#suggestionText h3,
.message-bubble h1,
.message-bubble h2,
.message-bubble h3 {
    color: #AE0B2A;
    margin: 15px 0 10px 0;
    font-weight: bold;
}

#suggestionText h1,
.message-bubble h1 { font-size: 18px; }
#suggestionText h2,
.message-bubble h2 { font-size: 16px; }
#suggestionText h3,
.message-bubble h3 { font-size: 14px; }

#suggestionText ul,
#suggestionText ol,
.message-bubble ul,
.message-bubble ol {
    margin: 10px 0;
    padding-left: 25px;
}

#suggestionText li,
.message-bubble li {
    margin: 5px 0;
    line-height: 1.6;
}

#suggestionText code,
.message-bubble code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

#suggestionText pre,
.message-bubble pre {
    background: #f0f0f0;
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 10px 0;
}

#suggestionText blockquote,
.message-bubble blockquote {
    border-left: 3px solid #AE0B2A;
    padding-left: 15px;
    margin: 10px 0;
    color: #555;
    font-style: italic;
}

.refresh-btn {
    background: #AE0B2A;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

.refresh-btn:hover {
    background: #8E0A22;
}

/* 底部版权 */
.footer {
    background: linear-gradient(135deg, #AE0B2A 0%, #C93D57 100%);
    padding: 15px;
    text-align: center;
    color: #FFFFFF;
    font-size: 14px;
    box-shadow: 0 -4px 20px rgba(174, 11, 42, 0.3);
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-title {
    font-size: 20px;
    color: #AE0B2A;
    margin-bottom: 20px;
    font-weight: bold;
}

.modal-input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.modal-input:focus {
    border-color: #AE0B2A;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.modal-btn-primary {
    background: #AE0B2A;
    color: white;
}

.modal-btn-primary:hover {
    background: #8E0A22;
}

.modal-btn-secondary {
    background: #ccc;
    color: #333;
}

.modal-btn-secondary:hover {
    background: #999;
}

/* 排行榜样式 */
.leaderboard-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.leaderboard-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.leaderboard-title {
    font-size: 20px;
    color: #AE0B2A;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
}

.leaderboard-list {
    list-style: none;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    background: #f9f9f9;
    border-radius: 6px;
}

.leaderboard-item.current-user {
    background: #e8f4f8;
    border: 1px solid #AE0B2A;
}

.rank-number {
    font-weight: bold;
    color: #AE0B2A;
    margin-right: 10px;
}

.rank-1 { color: #FFD700; }
.rank-2 { color: #C0C0C0; }
.rank-3 { color: #CD7F32; }

.close-btn {
    background: #AE0B2A;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    float: right;
    margin-bottom: 10px;
}

.close-btn:hover {
    background: #8E0A22;
}

/* 思考模式选择器 */
.reasoning-mode-selector {
    padding: 8px 20px;
    background-color: #f9f9f9;
    display: none;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #666;
}

.reasoning-mode-select {
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    font-size: 14px;
    color: #333;
}

.reasoning-mode-select:focus {
    outline: none;
    border-color: #AE0B2A;
    box-shadow: 0 0 0 2px rgba(174, 11, 42, 0.2);
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .main-container {
        flex-direction: column;
    }

    /* .status-panel {
        max-height: 400px;
    } */

    .user-info {
        position: static;
        transform: none;
        margin-top: 10px;
        text-align: center;
    }

    .header {
        padding: 15px 20px;
    }

    .logo {
        font-size: 28px;
    }

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

/* 移动端等级摘要 */
.mobile-level-summary {
    display: none;
    background: #f9f9f9; /* 改为浅灰色背景，不使用主色 */
    padding: 8px 15px; /* 减小内边距 */
    color: #333; /* 改为深色文字 */
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); /* 减小阴影 */
    border-bottom: 1px solid #e0e0e0; /* 添加底部边框 */
}

.mobile-level-info {
    display: flex;
    flex-direction: column;
}

.mobile-level-label {
    font-size: 10px; /* 减小字体 */
    opacity: 0.8;
}

.mobile-level-value {
    font-size: 18px; /* 减小字体 */
    font-weight: bold;
    color: #AE0B2A; /* 保留主色用于等级值 */
}

/* 新增移动端统计信息样式 */
.mobile-stats {
    display: flex;
    gap: 15px;
}

.mobile-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mobile-stat-label {
    font-size: 10px;
    color: #666;
}

.mobile-stat-value {
    font-size: 14px;
    font-weight: bold;
    color: #333;
}

.mobile-sidebar-toggle {
    background: rgba(174, 11, 42, 0.1); /* 减小背景色透明度 */
    border: 1px solid rgba(174, 11, 42, 0.2); /* 减小边框透明度 */
    color: #AE0B2A; /* 使用主色文字 */
    padding: 6px 12px; /* 减小内边距 */
    border-radius: 16px; /* 减小圆角 */
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px; /* 减小间距 */
    font-size: 12px; /* 减小字体 */
    transition: all 0.3s;
}

.mobile-sidebar-toggle:hover {
    background: rgba(174, 11, 42, 0.2); /* 减小悬停背景色透明度 */
}

.toggle-icon {
    font-size: 14px; /* 减小图标大小 */
}

/* 移动端侧边栏覆盖层 */
.mobile-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
}

/* 移动端侧边栏关闭按钮 */
.mobile-sidebar-close {
    display: none;
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    color: #666;
    font-size: 24px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 101;
    transition: all 0.3s;
}

.mobile-sidebar-close:hover {
    background: rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    /* 隐藏副标题 */
    .subtitle {
        display: none;
    }
    
    /* 显示移动端等级摘要 */
    .mobile-level-summary {
        display: flex;
    }
    
    /* 显示移动端统计信息 */
    .mobile-stats {
        display: flex;
        gap: 10px;
    }
    
    /* 调整主容器布局 */
    .main-container {
        padding: 15px;
        gap: 0;
        position: relative;
        height: calc(100vh - 120px); /* 减去header和等级摘要的高度 */
        overflow-y: auto; /* 允许上下滚动 */
        padding-bottom: 80px; /* 为固定在底部的输入框留出空间 */
    }
    
    /* 聊天容器占满宽度 */
    .chat-container {
        width: 100%;
        flex: none;
        min-height: auto; /* 移除最小高度限制 */
        display: flex;
        flex-direction: column;
    }
    
    /* 侧边栏默认隐藏，以覆盖形式显示 */
    .status-panel {
        display: none;
        position: fixed;
        top: 0;
        right: -100%;
        width: 100%; /* 修改为100%宽度，充满屏幕 */
        max-width: none; /* 移除最大宽度限制 */
        height: 100vh; /* 使用100vh确保充满整个视窗高度 */
        background: white;
        border-radius: 0;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.2);
        z-index: 101;
        overflow-y: auto; /* 确保移动端也能滚动 */
        transition: right 0.3s ease;
        padding: 50px 20px 20px;
        max-height: 100vh; /* 覆盖桌面端的max-height限制 */
    }
    
    /* 侧边栏激活状态 */
    .status-panel.mobile-active {
        display: flex;
        right: 0;
    }
    
    /* 显示移动端侧边栏覆盖层和关闭按钮 */
    .mobile-sidebar-overlay.mobile-active {
        display: block;
    }
    
    .mobile-sidebar-close {
        display: block;
    }
    
    /* 调整聊天区域样式 */
    .chat-messages {
        padding: 15px;
        height: auto; /* 移除固定高度，允许内容自然流动 */
        min-height: 300px; /* 设置最小高度 */
        overflow-y: visible; /* 移除内部滚动，使用外层滚动 */
        flex: 1;
    }

    .message-bubble {
        max-width: 90%;
    }

    /* 移动端输入框固定在底部 */
    .chat-input-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e0e0e0;
        padding: 10px 15px;
        z-index: 100;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }

    .input-group {
        flex-direction: row; /* 保持水平排列 */
        gap: 10px;
        padding: 0;
    }

    .input-group input {
        flex: 1;
        padding: 10px 15px;
        border: 2px solid #e0e0e0;
        border-radius: 20px;
        font-size: 14px;
        outline: none;
        transition: border-color 0.3s;
        background: white;
    }

    .input-group input:focus {
        border-color: #AE0B2A;
    }

    .input-group button {
        padding: 10px 20px;
        background: #AE0B2A;
        color: white;
        border: none;
        border-radius: 20px;
        font-size: 14px;
        cursor: pointer;
        transition: all 0.3s;
        white-space: nowrap;
    }

    .input-group button:hover {
        background: #8E0A22;
    }

    .input-group button:disabled {
        background: #ccc;
        cursor: not-allowed;
    }
    
    /* 调整header样式 */
    .header {
        padding: 12px 15px;
    }
    
    /* 修改logo-container为从左到右平铺 */
    .logo-container {
        display: flex;
        justify-content: space-between; /* 内容从左到右平铺 */
        align-items: center;
        width: 100%;
        gap: 10px;
    }
    
    .logo {
        font-size: 24px;
        order: 1; /* 第一个元素 */
    }
    
    .user-info {
        font-size: 12px;
        order: 2; /* 第二个元素 */
        flex-direction: row; /* 改回水平排列 */
        gap: 5px;
        align-items: center;
        position: static; /* 取消绝对定位 */
        transform: none; /* 取消变换 */
    }
    
    .logout-btn {
        font-size: 10px;
        padding: 3px 8px;
    }
}