/* 全局样式 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Microsoft YaHei', Arial, sans-serif;
}

body {
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

#app {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background-color: #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    min-height: 100vh;
}

h1, h2, h3, h4 {
    margin-bottom: 20px;
    color: #333;
}

h1 {
    text-align: center;
    margin-top: 20px;
    color: #007bff;
}

/* 视图管理 */
.view {
    display: none;
    padding: 20px 0;
}

.view.active {
    display: block;
}

/* 按钮样式 */
button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 15px;
    margin: 5px 0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #0056b3;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.back-btn {
    background-color: #6c757d;
    margin-top: 20px;
}

.back-btn:hover {
    background-color: #5a6268;
}

/* 表单元素 */
input, select, textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

/* 角色选择页面 */
.role-buttons {
    display: flex;
    justify-content: space-around;
    margin-top: 40px;
}

.role-buttons button {
    width: 40%;
    padding: 15px;
    font-size: 18px;
}

/* 题目回答页面 */
.actions {
    margin: 20px 0;
}

.result {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
}

/* 学生表现记录 */
.performance-record {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-left: 5px solid #007bff;
    border-radius: 3px;
}

.performance-record h4 {
    margin-bottom: 10px;
    color: #007bff;
}

.performance-record small {
    display: block;
    margin-top: 10px;
    color: #6c757d;
}

/* 教师仪表盘 */
.dashboard-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dashboard-nav button, .dashboard-nav .dashboard-btn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    text-decoration: none;
    display: block;
    text-align: center;
}

.dashboard-nav .dashboard-btn {
    background-color: #17a2b8;
}

.dashboard-nav .dashboard-btn:hover {
    background-color: #138496;
}

/* 响应式设计 */
@media (max-width: 600px) {
    #app {
        padding: 10px;
    }
    
    .role-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .role-buttons button {
        width: 80%;
        margin-bottom: 15px;
    }
}

/* 题库管理页面 */
#question-list-container .question-item {
    border: 1px solid #ddd;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 5px;
    background-color: #fafafa;
}

#question-list-container .question-item h4 {
    margin-bottom: 5px;
    color: #0056b3;
}

#question-list-container .question-item p {
    margin-bottom: 10px;
    white-space: pre-wrap;
}

#question-list-container .question-actions button {
    margin-right: 10px;
    padding: 5px 10px;
    font-size: 14px;
}

.delete-btn {
    background-color: #dc3545;
}

.delete-btn:hover {
    background-color: #c82333;
}

/* 模态框 (Modal) 样式 */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #fefefe;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    border-radius: 8px;
    position: relative;
}

.close-btn {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-btn:hover,
.close-btn:focus {
    color: black;
    text-decoration: none;
}

/* 报告表格样式 */
.report-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 14px;
}

.report-table th, .report-table td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

.report-table thead th {
    background-color: #007bff;
    color: white;
    font-weight: bold;
}

.report-table tbody tr:nth-child(even) {
    background-color: #f2f2f2;
}

.report-table tbody tr:hover {
    background-color: #e9ecef;
}

#raw-data-container .report-table tbody tr {
    cursor: pointer;
}

/* 学生报告中掌握/未掌握的样式 */
.report-table tr.mastered td {
    background-color: #d4edda; /* 绿色表示掌握 */
    color: #155724;
}

.report-table tr.not-mastered td {
    background-color: #f8d7da; /* 红色表示未掌握 */
    color: #721c24;
}

/* 学生选择页面样式 */
#student-choice-view {
    max-width: 400px;
    margin: 0 auto;
    padding: 30px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
}

#student-choice-view h2 {
    color: #007bff;
    margin-bottom: 30px;
}

#student-choice-view .choice-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

#student-choice-view .choice-buttons button {
    padding: 15px;
    font-size: 16px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

#student-register-choice-btn {
    background-color: #28a745;
}

#student-register-choice-btn:hover {
    background-color: #218838;
}

#student-login-choice-btn {
    background-color: #007bff;
}

#student-login-choice-btn:hover {
    background-color: #0056b3;
}

/* 学生注册和登录页面样式 */
#student-register-view, #student-login-view {
    max-width: 400px;
    margin: 0 auto;
    padding: 30px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#student-register-view h2, #student-login-view h2 {
    text-align: center;
    color: #007bff;
    margin-bottom: 30px;
}

#student-register-view input, #student-login-view input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
}

#student-register-view input:focus, #student-login-view input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
}

#student-register-view button, #student-login-view button {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    font-size: 16px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

#student-register-view .back-btn, #student-login-view .back-btn {
    background-color: #6c757d;
    margin-top: 10px;
}

#student-register-view .back-btn:hover, #student-login-view .back-btn:hover {
    background-color: #5a6268;
}

#student-register-view p, #student-login-view p {
    text-align: center;
    color: #666;
    font-size: 14px;
}

#student-register-view a, #student-login-view a {
    color: #007bff;
    text-decoration: none;
}

#student-register-view a:hover, #student-login-view a:hover {
    text-decoration: underline;
}

/* 数据库管理页面样式 */
.db-section {
    margin-bottom: 30px;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #f9f9f9;
}

.db-section h3 {
    margin-bottom: 15px;
    color: #007bff;
    border-bottom: 2px solid #007bff;
    padding-bottom: 5px;
}

.db-actions {
    margin-bottom: 15px;
}

.db-actions button {
    margin-right: 10px;
    margin-bottom: 10px;
}

.table-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
}

.data-table th,
.data-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.data-table th {
    background-color: #f8f9fa;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table tr:hover {
    background-color: #f5f5f5;
}

.data-table td button {
    padding: 4px 8px;
    font-size: 12px;
    margin-right: 5px;
}

/* 危险操作按钮样式 */
button[style*="background-color: #dc3545"] {
    background-color: #dc3545 !important;
}

button[style*="background-color: #dc3545"]:hover {
    background-color: #c82333 !important;
}

/* 答题历史记录样式 */
#answer-history-container {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #f8f9fa;
    padding: 16px;
    margin-top: 20px;
}

#answer-history-container h4 {
    color: #495057;
    font-size: 16px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

#toggle-history-btn {
    font-size: 12px;
    padding: 4px 8px;
    background: #e9ecef;
    border: 1px solid #ced4da;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#toggle-history-btn:hover {
    background: #dee2e6;
    border-color: #adb5bd;
}

#answer-history-content {
    border: 1px solid #e9ecef;
    border-radius: 6px;
    background: white;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 10px;
}

#answer-history-content::-webkit-scrollbar {
    width: 6px;
}

#answer-history-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#answer-history-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

#answer-history-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

#answer-history-list {
    padding: 0;
    margin: 0;
    list-style: none;
}

#no-history-message {
    padding: 20px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

/* 历史记录项样式 */
.history-item {
    padding: 12px;
    margin-bottom: 8px;
    background: white;
    border-radius: 6px;
    border-left: 4px solid #6c757d;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}

.history-item:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

.history-item.score-excellent {
    border-left-color: #28a745;
}

.history-item.score-good {
    border-left-color: #ffc107;
}

.history-item.score-poor {
    border-left-color: #dc3545;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    color: #6c757d;
}

.history-content {
    margin-bottom: 6px;
}

.history-content strong {
    color: #495057;
    font-weight: 600;
}

.history-answer {
    color: #212529;
    margin-left: 4px;
}

.history-score {
    font-weight: 600;
    margin-left: 4px;
}

.history-score.excellent {
    color: #28a745;
}

.history-score.good {
    color: #ffc107;
}

.history-score.poor {
    color: #dc3545;
}

.history-feedback {
    margin-top: 8px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #007bff;
}

.history-feedback strong {
    color: #495057;
    font-size: 12px;
}

.history-feedback-content {
    margin-top: 4px;
    color: #495057;
    font-size: 13px;
    white-space: pre-wrap;
    line-height: 1.4;
}

/* 排行榜样式 */
.leaderboard-section {
    margin-top: 40px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    color: white;
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.leaderboard-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.leaderboard-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-select {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    font-size: 14px;
    min-width: 120px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-select:hover {
    background: white;
    transform: translateY(-1px);
}

.refresh-btn {
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.refresh-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.leaderboard-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    padding: 20px;
    color: #333;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.loading-message, .error-message {
    text-align: center;
    padding: 40px 20px;
    font-size: 16px;
    color: #666;
}

.error-message {
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
}

.leaderboard-stats {
    margin-bottom: 15px;
    padding: 10px 15px;
    background: #e3f2fd;
    border-radius: 6px;
    border-left: 4px solid #2196f3;
    font-size: 14px;
    color: #1565c0;
}

.leaderboard-table-container {
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 14px;
}

.leaderboard-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    border: none;
    white-space: nowrap;
}

.leaderboard-table th:first-child {
    border-top-left-radius: 8px;
}

.leaderboard-table th:last-child {
    border-top-right-radius: 8px;
}

.leaderboard-table td {
    padding: 12px 8px;
    text-align: center;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
}

.leaderboard-table tbody tr:hover {
    background: #f8f9fa;
    transform: scale(1.01);
    transition: all 0.2s ease;
}

.leaderboard-table tbody tr:last-child td {
    border-bottom: none;
}

/* 排名样式 */
.rank-1 {
    background: linear-gradient(135deg, #ffd700, #ffed4e) !important;
    color: #b8860b !important;
    font-weight: bold;
    position: relative;
}

.rank-1::before {
    content: "🥇";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
}

.rank-2 {
    background: linear-gradient(135deg, #c0c0c0, #e8e8e8) !important;
    color: #666 !important;
    font-weight: bold;
    position: relative;
}

.rank-2::before {
    content: "🥈";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
}

.rank-3 {
    background: linear-gradient(135deg, #cd7f32, #daa520) !important;
    color: #8b4513 !important;
    font-weight: bold;
    position: relative;
}

.rank-3::before {
    content: "🥉";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
}

.rank-number {
    font-weight: bold;
    font-size: 16px;
}

.student-name {
    font-weight: 600;
    color: #2c3e50;
}

.total-score {
    font-weight: bold;
    color: #e74c3c;
    font-size: 15px;
}

.avg-score {
    color: #27ae60;
    font-weight: 500;
}

.question-count {
    color: #3498db;
    font-weight: 500;
}

.scored-questions {
    color: #17a2b8;
    font-weight: 500;
}

.max-score {
    color: #28a745;
    font-weight: 600;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .leaderboard-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .leaderboard-controls {
        justify-content: center;
    }
    
    .leaderboard-table {
        font-size: 12px;
    }
    
    .leaderboard-table th,
    .leaderboard-table td {
        padding: 8px 4px;
    }
    
    .leaderboard-header h2 {
        font-size: 20px;
        text-align: center;
    }
}