/* ===== 全局样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f7f7f8;
    --bg-tertiary: #ececf1;
    --text-primary: #1a1a2e;
    --text-secondary: #6e6e80;
    --text-muted: #9a9aab;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-light: #eef2ff;
    --user-bubble: #4f46e5;
    --user-bubble-text: #ffffff;
    --assistant-bubble: #f3f4f6;
    --assistant-bubble-text: #1a1a2e;
    --border: #e5e7eb;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-lg: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
    overflow: hidden;
}

/* ===== 布局 ===== */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ===== 侧边栏 ===== */
.sidebar {
    width: 260px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.logo-icon {
    font-size: 24px;
}

.logo-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.new-chat-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s;
}

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

.new-chat-btn span {
    font-size: 18px;
    line-height: 1;
}

/* 侧边栏分区 */
.sidebar-section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.section-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.model-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.model-select:focus {
    border-color: var(--accent);
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.empty-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 40px 16px;
    line-height: 1.8;
}

.conversation-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 2px;
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s;
    position: relative;
}

.conversation-item:hover {
    background: var(--bg-secondary);
}

.conversation-item.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 500;
}

.conversation-item .conv-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conv-model {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-item.active .conv-model {
    color: var(--accent);
    opacity: 0.7;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.sidebar-nav {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    padding: 4px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.nav-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-primary);
    color: var(--accent);
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.model-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.model-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
}

/* ===== 聊天主区域 ===== */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    min-width: 0;
}

/* 顶部工具栏 */
.top-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.toolbar-left h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

/* 文件上传下拉 */
.file-upload-wrapper {
    position: relative;
}

.file-list-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 280px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    overflow: hidden;
}

.file-list-header {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.file-list-content {
    max-height: 300px;
    overflow-y: auto;
    padding: 8px;
}

.file-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 24px 16px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    transition: background 0.15s;
}

.file-item:hover {
    background: var(--bg-secondary);
}

.file-icon {
    font-size: 16px;
}

.file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.file-size {
    color: var(--text-muted);
    font-size: 12px;
    flex-shrink: 0;
}

/* ===== 欢迎页 ===== */
.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.welcome-content {
    text-align: center;
    max-width: 720px;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.welcome-content h1 {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.welcome-desc {
    color: var(--text-secondary);
    margin-bottom: 40px;
    font-size: 16px;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 600px;
    margin: 0 auto;
}

.quick-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.quick-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.quick-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.quick-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===== 消息列表 ===== */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
}

.messages {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* 系统消息 */
.system-message {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    align-self: center;
    max-width: 80%;
}

/* 消息气泡 */
.message {
    display: flex;
    gap: 12px;
    max-width: 100%;
}

.message.user {
    justify-content: flex-end;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.message.user .message-avatar {
    order: 2;
    background: var(--accent);
    color: white;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    max-width: 70%;
    word-wrap: break-word;
    line-height: 1.7;
}

.message.user .message-bubble {
    background: var(--user-bubble);
    color: var(--user-bubble-text);
    border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
    background: var(--bg-primary);
    color: var(--assistant-bubble-text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.message-content {
    white-space: pre-wrap;
}

.message-content p {
    margin-bottom: 8px;
}

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

/* 光标闪烁效果 */
.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: var(--text-primary);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* 工具调用卡片 */
.tool-call {
    margin: 12px 0;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-size: 13px;
}

.tool-call-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.tool-call-icon {
    font-size: 16px;
}

.tool-call-name {
    color: var(--accent);
    font-family: monospace;
}

.tool-call-status {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
}

.tool-call.status-running .tool-call-status {
    color: #f59e0b;
}

.tool-call.status-done .tool-call-status {
    color: #10b981;
}

.tool-call-args {
    background: var(--bg-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.tool-call-result {
    background: var(--bg-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 12px;
    color: var(--text-secondary);
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* 加载动画 */
.thinking-dots {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}

.thinking-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===== 输入区 ===== */
.input-area {
    padding: 16px 24px 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: flex-end;
    padding: 8px 8px 8px 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

#messageInput {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.5;
    padding: 8px 0;
    max-height: 200px;
    background: transparent;
    color: var(--text-primary);
}

#messageInput::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 8px;
    transition: background 0.2s, opacity 0.2s;
}

.send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.input-hint {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ===== 评测页面 ===== */
.eval-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    min-width: 0;
    overflow: hidden;
}

.eval-header {
    padding: 20px 24px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
}

.eval-header h1 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.eval-header p {
    font-size: 14px;
    color: var(--text-secondary);
}

.eval-main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.eval-sidebar {
    width: 300px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.eval-sidebar-section {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.eval-sidebar-section h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.preset-item {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-item:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.preset-item.active {
    border-color: var(--accent);
    background: var(--accent-light);
}

.preset-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.preset-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.preset-count {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

.eval-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.eval-form {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border);
}

.eval-form-group {
    margin-bottom: 20px;
}

.eval-form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.eval-form-group input[type="text"],
.eval-form-group select,
.eval-form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.eval-form-group input:focus,
.eval-form-group select:focus,
.eval-form-group textarea:focus {
    border-color: var(--accent);
}

.eval-form-group textarea {
    resize: vertical;
    min-height: 200px;
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 13px;
}

.eval-form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.eval-btn {
    padding: 12px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.eval-btn:hover {
    background: var(--accent-hover);
}

.eval-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.eval-btn.secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.eval-btn.secondary:hover {
    background: var(--bg-tertiary);
}

.eval-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* 评测结果 */
.eval-result-card {
    max-width: 800px;
    margin: 0 auto 20px;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    border: 1px solid var(--border);
}

.eval-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.eval-result-title {
    font-size: 16px;
    font-weight: 600;
}

.eval-result-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-running {
    background: #dbeafe;
    color: #1e40af;
}

.status-done {
    background: #d1fae5;
    color: #065f46;
}

.eval-result-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.eval-stat {
    text-align: center;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.eval-stat-value {
    font-size: 24px;
    font-weight: 600;
    color: var(--accent);
}

.eval-stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.eval-progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.eval-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s;
}

.eval-case-list {
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.eval-case-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.eval-case-item:last-child {
    border-bottom: none;
}

.eval-case-question {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.eval-case-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.eval-case-answer {
    background: var(--bg-secondary);
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }

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

    .messages {
        padding: 0 16px;
    }

    .input-area {
        padding: 12px 16px 16px;
    }

    .eval-main {
        flex-direction: column;
    }

    .eval-sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .eval-result-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}
