/* 全局样式 */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --dark-bg: #0f172a;
    --light-bg: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-primary);
    background-color: var(--light-bg);
    line-height: 1.5;
}

/* 启动屏幕 */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color), #1e40af);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.splash-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.splash-content {
    text-align: center;
    color: white;
}

.splash-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

.splash-content h1 {
    font-size: 32px;
    margin-bottom: 10px;
}

.splash-content p {
    font-size: 18px;
    opacity: 0.9;
    margin-bottom: 30px;
}

.splash-loader {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 应用容器 */
.app-container {
    display: flex;
    min-height: 100vh;
}

.app-container.hidden {
    display: none;
}

/* 侧边栏 */
.sidebar {
    width: 260px;
    background-color: var(--dark-bg);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
}

.logo {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo-icon {
    font-size: 32px;
}

.logo-text {
    font-size: 20px;
    font-weight: 600;
}

.nav-menu {
    flex: 1;
    padding: 24px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.3s;
    border-left: 4px solid transparent;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-item.active {
    background-color: rgba(37, 99, 235, 0.2);
    color: white;
    border-left-color: var(--primary-color);
}

.nav-icon {
    font-size: 20px;
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.system-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    color: rgba(255, 255, 255, 0.7);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.success {
    background-color: var(--success-color);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.student-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.student-selector label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.student-selector select {
    padding: 8px 12px;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 14px;
}

.student-selector select option {
    background-color: var(--dark-bg);
    color: white;
}

/* 主内容区 */
.main-content {
    flex: 1;
    margin-left: 260px;
    background-color: var(--light-bg);
}

.content-header {
    padding: 24px 32px;
    background-color: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.content-header h1 {
    font-size: 24px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.date-display {
    color: var(--text-secondary);
    font-size: 14px;
}

.btn-refresh {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    transition: background-color 0.3s;
}

.btn-refresh:hover {
    background-color: var(--light-bg);
}

.content-body {
    padding: 32px;
}

.content-frame {
    width: 100%;
    min-height: calc(100vh - 140px);
    background: none;
}

/* 仪表盘卡片 */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

.stat-card {
    background-color: white;
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color), #60a5fa);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.stat-info h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.dashboard-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.dashboard-card {
    background-color: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.dashboard-card.full-width {
    grid-column: 1 / -1;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.card-more {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 14px;
}

/* 最近对话列表 */
.chat-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.chat-item:last-child {
    border-bottom: none;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background-color: var(--light-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.chat-content {
    flex: 1;
}

.chat-message {
    font-size: 14px;
    margin-bottom: 4px;
}

.chat-time {
    font-size: 12px;
    color: var(--text-secondary);
}

/* 学生列表 */
.student-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.student-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background-color: var(--light-bg);
    border-radius: var(--radius);
}

.student-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), #60a5fa);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.student-details {
    flex: 1;
}

.student-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.student-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

/* 学生档案页面 */
.profile-container {
    padding: 24px;
}

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.profile-header h1 {
    font-size: 24px;
    font-weight: 600;
}

.profile-actions {
    display: flex;
    gap: 12px;
}

.profile-content {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 24px;
}

.profile-card {
    background-color: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.profile-avatar {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.avatar-large {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--primary-color), #60a5fa);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: white;
}

.profile-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.profile-stats {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.stats-card {
    background-color: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.stats-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 14px;
}

.stat-item span:first-child {
    color: var(--text-secondary);
}

.stat-item strong {
    font-weight: 600;
}

/* 按钮样式 */
.btn-primary, .btn-success, .btn-test {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #0b9f6e;
}

.btn-test {
    background-color: var(--light-bg);
    color: var(--text-primary);
}

.btn-test:hover {
    background-color: var(--border-color);
}

/* API测试页面 */
.test-container {
    padding: 24px;
}

.test-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.test-header h1 {
    font-size: 24px;
    font-weight: 600;
}

.api-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background-color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.success {
    background-color: #d1fae5;
    color: #065f46;
}

.status-badge.error {
    background-color: #fee2e2;
    color: #991b1b;
}

.test-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.test-card {
    background-color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.test-card-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.test-card-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.test-card-body {
    padding: 20px;
    flex: 1;
}

.test-card-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background-color: var(--light-bg);
    border-radius: 0 0 var(--radius) var(--radius);
}

.response-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.response-preview {
    background-color: var(--dark-bg);
    color: #e2e8f0;
    padding: 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-family: 'Monaco', 'Menlo', monospace;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 300px;
    overflow-y: auto;
}

.api-test-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.api-test-item:last-child {
    border-bottom: none;
}

.api-method {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin-right: 12px;
}

.api-method.get {
    background-color: #dbeafe;
    color: #1e40af;
}

.api-method.post {
    background-color: #dcfce7;
    color: #166534;
}

.api-method.put {
    background-color: #fef3c7;
    color: #92400e;
}

/* 对话历史页面 */
.chat-history-container {
    padding: 24px;
}

.chat-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.chat-history-header h1 {
    font-size: 24px;
    font-weight: 600;
}

.chat-filters {
    display: flex;
    gap: 12px;
}

.chat-timeline {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-entry {
    display: flex;
    gap: 16px;
    padding: 20px;
    background-color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.chat-entry.user {
    border-left: 4px solid var(--primary-color);
}

.chat-entry.ai {
    border-left: 4px solid var(--success-color);
}

.chat-entry-avatar {
    width: 48px;
    height: 48px;
    background-color: var(--light-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.chat-entry-content {
    flex: 1;
}

.chat-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.chat-entry-sender {
    font-weight: 600;
    font-size: 16px;
}

.chat-entry-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.chat-entry-message {
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 12px;
    white-space: pre-wrap;
}

.chat-entry-context {
    margin-top: 12px;
    padding: 12px;
    background-color: var(--light-bg);
    border-radius: var(--radius);
    font-size: 13px;
}

.chat-entry-context details summary {
    cursor: pointer;
    color: var(--text-secondary);
}

.chat-entry-context pre {
    margin-top: 12px;
    padding: 12px;
    background-color: var(--dark-bg);
    color: #e2e8f0;
    border-radius: var(--radius);
    overflow-x: auto;
}

/* 通知 */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    background-color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.notification.success {
    border-left: 4px solid var(--success-color);
}

.notification.error {
    border-left: 4px solid var(--danger-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 加载和空状态 */
.loading-spinner, .empty-state, .error-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.empty-state {
    font-style: italic;
}

.error-state {
    color: var(--danger-color);
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
    }
    
    .logo-text,
    .nav-item span:last-child,
    .sidebar-footer .system-status span:last-child,
    .student-selector label {
        display: none;
    }
    
    .main-content {
        margin-left: 80px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-row {
        grid-template-columns: 1fr;
    }
    
    .profile-content {
        grid-template-columns: 1fr;
    }
    
    .test-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .profile-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
    
    .profile-actions {
        width: 100%;
    }
    
    .chat-filters {
        flex-direction: column;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .checkbox-group {
        grid-template-columns: 1fr 1fr;
    }
}