/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* 登录界面 */
.login-container {
    max-width: 500px;
    margin: 50px auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
}

.login-box h1 {
    color: #667eea;
    margin-bottom: 10px;
    text-align: center;
    font-size: 2em;
}

/* 教师入口提示 */
.teacher-entry-hint {
    background: linear-gradient(135deg, #fff3cd 0%, #fffde7 100%);
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #ffc107;
    margin-bottom: 20px;
}

.teacher-entry-hint p {
    text-align: center;
    color: #856404;
    font-weight: 600;
    margin-bottom: 10px;
}

.password-hint {
    background: #e3f2fd;
    padding: 10px;
    border-radius: 8px;
    margin-top: 15px;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1em;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1em;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 按钮样式 */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: #667eea;
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-warning {
    background: #ffc107;
    color: #333;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

/* 答题界面 */
.quiz-container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.quiz-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.quiz-header h2 {
    margin-bottom: 15px;
    font-size: 1.8em;
}

.student-info {
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.2);
    padding: 15px;
    border-radius: 10px;
    font-size: 1.1em;
}

.student-info span {
    font-weight: 600;
}

.quiz-content {
    padding: 30px;
}

.question-card {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 25px;
    border-left: 4px solid #667eea;
}

.question-card h3 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.3em;
}

.options-grid {
    display: grid;
    gap: 12px;
    margin-top: 15px;
}

.option-item {
    background: white;
    padding: 15px 20px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
}

.option-item:hover {
    border-color: #667eea;
    background: #f0f0f0;
}

.option-item.selected {
    border-color: #667eea;
    background: #e7edf4;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.option-item input[type="radio"] {
    margin-right: 12px;
    width: 18px;
    height: 18px;
}

.quiz-result {
    padding: 30px;
    text-align: center;
}

.result-header {
    font-size: 2em;
    margin-bottom: 20px;
    font-weight: bold;
}

.result-score {
    font-size: 3em;
    color: #667eea;
    margin: 20px 0;
    font-weight: bold;
}

.result-details {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
}

.correct-answers {
    color: #28a745;
    margin: 10px 0;
}

.wrong-answers {
    color: #dc3545;
    margin: 10px 0;
}

.score-change {
    font-size: 1.5em;
    margin: 15px 0;
    font-weight: bold;
}

.score-change.positive {
    color: #28a745;
}

.score-change.negative {
    color: #dc3545;
}

.score-change.neutral {
    color: #6c757d;
}

.retry-hint {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

.completed-hint {
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.quiz-actions {
    padding: 20px 30px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* 教师管理界面 */
.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.dashboard-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-header h2 {
    margin: 0;
    font-size: 1.8em;
}

.teacher-actions {
    display: flex;
    gap: 10px;
}

/* 选项卡 */
.tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}

.tab-button {
    flex: 1;
    padding: 20px;
    border: none;
    background: none;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #666;
    font-weight: 500;
}

.tab-button:hover {
    background: #e9ecef;
    color: #667eea;
}

.tab-button.active {
    background: white;
    color: #667eea;
    border-bottom: 3px solid #667eea;
    font-weight: bold;
}

.tab-content {
    display: none;
    padding: 30px;
}

.tab-content.active {
    display: block;
}

/* 内容区域 */
.content-section {
    margin-bottom: 30px;
}

.content-section h3 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.5em;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
}

/* 批量导入 */
.batch-import {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.import-methods {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.import-btn {
    flex: 1;
}

.import-area {
    margin-top: 15px;
}

.format-help {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #17a2b8;
    margin-bottom: 15px;
}

.format-help pre {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 10px 0;
    font-size: 0.9em;
}

.format-help p {
    margin: 10px 0;
}

.format-help ul {
    margin: 10px 0;
    padding-left: 20px;
}

.format-help li {
    margin: 5px 0;
}

#batchQuestions {
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
}

/* 题目管理 */
.question-item {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 15px;
    border: 2px solid #e9ecef;
}

.question-item h4 {
    color: #667eea;
    margin-bottom: 15px;
}

.options-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.option-input {
    padding: 10px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.95em;
}

.history-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid #e9ecef;
}

.history-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid #667eea;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.history-date {
    font-weight: bold;
    color: #667eea;
}

.history-actions {
    display: flex;
    gap: 10px;
}

.history-content {
    color: #666;
    margin-bottom: 10px;
}

/* 学生管理 */
.filter-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-bar input,
.filter-bar select {
    flex: 1;
    min-width: 200px;
}

/* 班级管理 */
.class-management {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.class-add {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
}

.class-add h4 {
    color: #667eea;
    margin-bottom: 15px;
}

.class-list h4 {
    color: #667eea;
    margin-bottom: 15px;
}

.class-list-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.class-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.class-item:hover {
    border-color: #667eea;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.class-name {
    font-weight: 600;
    color: #333;
}

.class-delete {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

.class-delete:hover {
    background: #c82333;
}

/* 学生添加 */
.student-add {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
}

.student-add h4 {
    color: #667eea;
    margin-bottom: 15px;
}

.student-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.student-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
}

.student-card:hover {
    border-color: #667eea;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.student-name {
    font-size: 1.3em;
    color: #667eea;
    margin-bottom: 10px;
    font-weight: bold;
}

.student-class {
    color: #666;
    margin-bottom: 8px;
}

.student-score {
    font-size: 1.8em;
    color: #28a745;
    font-weight: bold;
    margin-bottom: 8px;
}

.student-stats {
    display: flex;
    gap: 15px;
    color: #666;
    font-size: 0.9em;
}

/* 排行榜 */
.leaderboard {
    overflow-x: auto;
    margin-bottom: 30px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

table thead {
    background: #667eea;
    color: white;
}

table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

table tbody tr {
    border-bottom: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

table tbody tr:hover {
    background: #f8f9fa;
}

table td {
    padding: 15px;
}

.rank-1 {
    color: #ffd700;
    font-size: 1.5em;
    font-weight: bold;
}

.rank-2 {
    color: #c0c0c0;
    font-size: 1.4em;
    font-weight: bold;
}

.rank-3 {
    color: #cd7f32;
    font-size: 1.3em;
    font-weight: bold;
}

/* 奖励预览 */
.reward-preview {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid #e9ecef;
}

.reward-levels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.reward-card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    border: 2px solid #e9ecef;
    text-align: center;
    transition: all 0.3s ease;
}

.reward-card:hover {
    border-color: #667eea;
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.reward-highlight {
    border-color: #ffc107;
    background: linear-gradient(135deg, #fff3cd 0%, #fffde7 100%);
}

.reward-icon {
    font-size: 4em;
    margin-bottom: 15px;
}

.reward-title {
    font-size: 1.8em;
    color: #667eea;
    margin-bottom: 10px;
    font-weight: bold;
}

.reward-desc {
    color: #666;
    font-size: 1.1em;
}

/* 奖励记录 */
.reward-form {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    margin-top: 20px;
}

/* 提示框 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    background: #333;
    color: white;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: none;
    animation: slideIn 0.3s ease;
}

.toast.show {
    display: block;
}

.toast.success {
    background: #28a745;
}

.toast.error {
    background: #dc3545;
}

.toast.warning {
    background: #ffc107;
    color: #333;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .login-container {
        margin: 20px;
        padding: 20px;
    }

    .tabs {
        flex-direction: column;
    }

    .tab-button {
        padding: 15px;
    }

    .student-info {
        flex-direction: column;
        gap: 10px;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }

    .options-group {
        grid-template-columns: 1fr;
    }

    .quiz-actions {
        flex-direction: column;
    }

    .teacher-actions {
        flex-direction: column;
    }
}

/* ====== 手机端优化 (<480px) ====== */
@media (max-width: 480px) {
    .login-box {
        padding: 20px 16px;
        margin: 10px;
    }
    .login-box h1 { font-size: 1.3em; }
    .quiz-header h2 { font-size: 1.1em; }
    .student-info { flex-wrap: wrap; gap: 6px; font-size: 0.85em; }
    .question-card { padding: 12px; }
    .option-item { padding: 10px; font-size: 0.9em; }
    .quiz-actions { flex-wrap: wrap; }
    .quiz-actions .btn { flex: 1 1 auto; font-size: 0.85em; padding: 8px 10px; }
    .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tab-button { padding: 8px 10px; font-size: 0.8em; white-space: nowrap; }
    table { font-size: 0.8em; }
    th, td { padding: 6px 4px; }
    /* 表格横向滚动 */
    .leaderboard, #studentLeaderboardBody { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .leaderboard table, #studentLeaderboardBody table { min-width: 500px; }
    /* 按钮增大触控面积 */
    .btn { min-height: 36px; min-width: 44px; }
    .student-tab-btn { padding: 10px 6px; font-size: 0.82em; }
    .content-section { padding: 12px 10px; }
    .form-group input, .form-group select, .form-group textarea { font-size: 16px; }
}
