/* 使用字节跳动CDN加速的字体资源 */
@import url('https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/font-awesome/6.0.0/css/all.min.css');

/* 全局样式 */
:root {
    --primary-color: #0078d7;
    --secondary-color: #f3f3f3;
    --border-color: #ddd;
    --text-color: #333;
    --background-color: #fff;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --bg-color: #f5f7fa;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-color);
    background-color: #f5f5f5;
    min-height: 100vh;
    overflow-y: auto;
}

/* 容器样式 */
.container-fluid {
    height: 100vh;
    overflow: hidden;
}

.row {
    height: 100%;
}

/* 侧边栏样式 */
.sidebar {
    background-color: var(--background-color);
    border-right: 1px solid var(--border-color);
    height: 100%;
    overflow-y: auto;
    padding: 15px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 10px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h3 {
    display: flex;
    align-items: center;
    font-size: 1.2rem;
    color: var(--primary-color);
}

.sidebar-header h3 i {
    margin-right: 10px;
}

.new-chat-btn {
    margin-bottom: 20px;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 20px;
}

.chat-history h5 {
    margin-bottom: 10px;
    color: var(--text-color);
    font-weight: 600;
}

.history-item {
    display: flex;
    flex-direction: column;
    padding: 12px 15px;
    margin-bottom: 8px;
    background-color: var(--secondary-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    font-size: 14px;
}

.history-item:hover {
    background-color: #e9e9e9;
}

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

.history-title {
    font-weight: 500;
    word-break: break-all;
    margin-right: 20px;
    color: #333;
    font-size: 14px;
}

.history-date {
    font-size: 0.8rem;
    color: #666;
    margin-top: 5px;
}

.history-delete {
    position: absolute;
    top: 10px;
    right: 10px;
    color: var(--danger-color);
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s ease;
    font-size: 14px;
}

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

.no-history {
    color: #666;
    font-style: italic;
    text-align: center;
    padding: 20px;
    font-size: 14px;
}

/* 主内容区样式 */
.main-content {
    height: 100%;
    overflow: hidden;
    padding: 0;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: #fff;
}

.chat-header {
    padding: 15px;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow);
}

.chat-header h2 {
    font-size: 1.5rem;
    margin: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #f5f5f5;
}

.message {
    display: flex;
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    font-size: 20px;
}

.message .icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    flex-shrink: 0;
    font-size: 20px;
}

.message .content-wrapper {
    flex: 1;
}

.message .content {
    margin-bottom: 10px;
    line-height: 1.4;
    font-size: 20px;
}

.message .content p {
    margin: 0.2em 0;
}

.message .content br {
    display: block;
    margin: 0.1em 0;
    content: "";
}

.message .content > *:first-child {
    margin-top: 0;
}

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

.message .content h1,
.message .content h2,
.message .content h3 {
    margin: 0.3em 0 0.2em;
    color: var(--primary-color);
    font-weight: 600;
    line-height: 1.3;
}

.message .content h1 { font-size: 1.8em; }
.message .content h2 { font-size: 1.5em; }
.message .content h3 { font-size: 1.3em; }

.message .content ul {
    margin: 0.2em 0;
    padding-left: 1.5em;
}

.message .content li {
    margin: 0.1em 0;
}

.message .content code {
    background-color: #f5f5f5;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95em;
}

.message .content pre.code-block {
    background-color: #f8f9fa;
    padding: 1em;
    border-radius: 5px;
    overflow-x: auto;
    margin: 0.5em 0;
}

.message .content pre.code-block code {
    background-color: transparent;
    padding: 0;
    display: block;
    color: #333;
    font-size: 0.95em;
    line-height: 1.5;
}

.message .content a {
    color: #0366d6;
    text-decoration: none;
}

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

.message .content strong {
    font-weight: 600;
}

.message .content em {
    font-style: italic;
}

/* 表格样式 */
.message .content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message .content table th,
.message .content table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
    line-height: 1.5;
}

.message .content table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 1;
}

.message .content table tr:hover {
    background-color: #f5f5f5;
}

.message .content table tr:last-child td {
    border-bottom: none;
}

.message .content table td:first-child,
.message .content table th:first-child {
    padding-left: 20px;
}

.message .content table td:last-child,
.message .content table th:last-child {
    padding-right: 20px;
}

/* 表格响应式设计 */
@media (max-width: 768px) {
    .message .content table {
        font-size: 12px;
        margin: 0.8em 0;
    }
    
    .message .content table th,
    .message .content table td {
        padding: 8px 10px;
    }
    
    .message .content table td:first-child,
    .message .content table th:first-child {
        padding-left: 12px;
    }
    
    .message .content table td:last-child,
    .message .content table th:last-child {
        padding-right: 12px;
    }
}

/* 表格容器，用于水平滚动 */
.message .content .table-container {
    overflow-x: auto;
    margin: 1em 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message .content .table-container table {
    margin: 0;
    box-shadow: none;
    border-radius: 0;
}

.message .content .math {
    font-family: 'KaTeX_Math', 'Times New Roman', serif;
}

.message .content .math.inline {
    display: inline-block;
    margin: 0 0.2em;
}

.message .content .math.display {
    display: block;
    margin: 1em 0;
    text-align: center;
}

.message.user .content {
    background-color: #e0f7fa;
}

.message.assistant .content {
    background-color: #fff;
}

.message .message-stats {
    font-size: 0.8rem;
    color: #666;
}

.message-stats .stat-row {
    display: flex;
    gap: 15px;
    font-size: 0.8rem;
}

.message-stats .stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.message-stats .stat-item i {
    font-size: 14px;
}

/* 用户消息和AI消息的统计信息样式区分 */
.message.user .message-stats {
    background-color: #d4eeff;
}

.message.assistant .message-stats {
    background-color: #f0f0f0;
}

.typing-indicator {
    display: flex;
    margin: 10px 0;
}

.typing-indicator span {
    height: 10px;
    width: 10px;
    margin: 0 2px;
    background-color: #9E9E9E;
    border-radius: 50%;
    display: inline-block;
    animation: typing 1.4s infinite both;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
    100% { transform: translateY(0); }
}

.chat-input-container {
    padding: 15px;
    background-color: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}

.chat-input-container textarea {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 10px;
    resize: none;
    min-height: 60px;
    margin-right: 10px;
    font-size: 14px;
    font-family: inherit;
}

.chat-input-container button {
    height: 60px;
    padding: 0 20px;
}

.error-message {
    color: var(--danger-color);
    padding: 5px 10px;
    border-left: 3px solid var(--danger-color);
    background-color: rgba(220, 53, 69, 0.1);
    margin: 10px 0;
}

/* 媒体查询 - 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    
    .row {
        flex-direction: column;
    }
    
    .main-content {
        width: 100%;
    }
    
    .message .message-stats .stat-row {
        gap: 8px;
    }
    
    .message .stat-item {
        font-size: 0.75rem;
    }
    
    .message .content {
        padding: 10px;
    }
    
    .message .content pre.code-block {
        padding: 0.8em;
        font-size: 0.85em;
    }
    
    .message .content h1 { font-size: 1.3em; }
    .message .content h2 { font-size: 1.2em; }
    .message .content h3 { font-size: 1.1em; }
}

/* 管理员登录样式 */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.login-container h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #666;
}

.form-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.error-message {
    background: #ffe6e6;
    color: #c00;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
    text-align: center;
}

/* 管理员面板样式 */
.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.admin-container header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.admin-container h1 {
    margin: 0;
    color: #333;
}

.logout-btn {
    padding: 8px 15px;
    background: #f44336;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
}

.logout-btn:hover {
    background: #d32f2f;
}

.admin-section {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.admin-section h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
    font-size: 18px;
}

/* 管理员统计部分样式 */
.stats-section {
    margin-bottom: 30px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.stats-grid .stat-item {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 15px;
}

.stats-grid .stat-item i {
    font-size: 24px;
    color: var(--primary-color);
    background: rgba(0, 120, 215, 0.1);
    padding: 15px;
    border-radius: 10px;
}

.stats-grid .stat-details {
    display: flex;
    flex-direction: column;
}

.stats-grid .stat-label {
    color: #666;
    font-size: 14px;
    margin-bottom: 5px;
}

.stats-grid .stat-value {
    font-size: 20px;
    font-weight: bold;
    color: #333;
}

/* 对话记录样式 */
.chat-records {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-record {
    background: #fff;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.record-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.record-title {
    font-weight: 500;
    color: #333;
    font-size: 16px;
}

.record-date {
    color: #666;
    font-size: 14px;
}

.record-stats {
    display: flex;
    gap: 20px;
    color: #666;
    font-size: 14px;
}

.record-stats span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.record-stats i {
    color: var(--primary-color);
}

.no-records {
    text-align: center;
    padding: 30px;
    color: #666;
    font-style: italic;
    background: #f9f9f9;
    border-radius: 10px;
}

.admin-section h2 i {
    margin-right: 10px;
    color: var(--primary-color);
}

/* 响应式设计补充 */
@media (max-width: 768px) {
    .login-container {
        margin: 50px 20px;
    }
    
    .admin-container {
        padding: 10px;
    }
    
    .admin-section {
        padding: 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .record-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .record-stats {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .record-stats span {
        font-size: 13px;
    }
}

/* 系统错误消息样式 */
.system-error {
    background-color: #fff3f3;
    color: #d32f2f;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 14px;
    border: 1px solid #ffcdd2;
}

.system-error i {
    font-size: 18px;
    color: #d32f2f;
}

.system-error code {
    display: block;
    background: #fff;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #ffcdd2;
    color: #d32f2f;
    font-family: monospace;
    margin-top: 5px;
    user-select: all;
    cursor: pointer;
}

/* 响应式设计补充 */
@media (max-width: 768px) {
    .system-error {
        padding: 12px;
        font-size: 13px;
    }
    
    .system-error code {
        padding: 8px;
        font-size: 12px;
        overflow-x: auto;
    }
}

.thinking-status {
    font-size: 20px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 10px;
}

.thinking-time {
    font-weight: bold;
    color: #007bff;
}