/* 全局重置和基础样式 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #3498db;
    --primary-dark: #2980b9;
    --secondary-color: #2ecc71;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --error-color: #e74c3c;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #ecf0f1;
    --border-color: #bdc3c7;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    --super-admin: #8e44ad;
    --major-admin: #2980b9;
    --course-admin: #16a085;
    --user: #95a5a6;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
    min-height: 100vh;
}

/* 容器布局 */
.container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 16px;
}

@media (min-width: 640px) {
    .container { max-width: 640px; padding: 0 20px; }
}
@media (min-width: 768px) {
    .container { max-width: 768px; padding: 0 24px; }
}
@media (min-width: 1024px) {
    .container { max-width: 1024px; padding: 0 32px; }
}
@media (min-width: 1280px) {
    .container { max-width: 1280px; }
}

/* 卡片组件 */
.card {
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
}

.card-lg { padding: 24px; }

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.btn-success {
    background: var(--success-color);
    color: white;
}
.btn-success:hover { background: #219a52; }

.btn-warning {
    background: var(--warning-color);
    color: white;
}
.btn-warning:hover { background: #e67e22; }

.btn-error {
    background: var(--error-color);
    color: white;
}
.btn-error:hover { background: #c0392b; }

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}
.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
    min-height: 40px;
}

.btn-full { width: 100%; }

/* 表单元素 */
.form-group { margin-bottom: 20px; }

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    background: var(--bg-primary);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-textarea { min-height: 120px; resize: vertical; }

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 16px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 48px;
}

/* 网格布局 */
.grid { display: grid; gap: 16px; }
.grid-1 { grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* 导航栏 */
.navbar {
    background: var(--bg-primary);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 16px 0;
}

.nav-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}

.nav-menu {
    display: flex;
    gap: 16px;
    align-items: center;
}

.nav-link {
    color: var(--text-primary);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color 0.3s ease;
}
.nav-link:hover { background: var(--bg-tertiary); }

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
}

@media (max-width: 768px) {
    .mobile-menu-btn { display: block; }
    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-primary);
        flex-direction: column;
        padding: 16px;
        box-shadow: var(--shadow-lg);
    }
    .nav-menu.active { display: flex; }
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.stat-card {
    background: var(--bg-primary);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-color);
}

.stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

/* 消息提示 */
.alert {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-success {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.alert-error {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.alert-warning {
    background: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

/* 角色徽章 */
.role-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.role-super_admin { background: var(--super-admin); }
.role-major_admin { background: var(--major-admin); }
.role-course_admin { background: var(--course-admin); }
.role-user { background: var(--user); }

/* 层级路径显示 */
.hierarchy-path {
    background: var(--bg-tertiary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 8px;
    display: inline-block;
}

.hierarchy-path-sm {
    font-size: 11px;
    padding: 6px 10px;
    line-height: 1.8;
}

/* 工具类 */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }
.p-4 { padding: 32px; }

.hidden { display: none; }

/* 触摸优化 */
@media (hover: none) and (pointer: coarse) {
    .btn, .nav-link, .option-item { min-height: 44px; }
}

/* =====================================================
   错题排行页面专用样式
   ===================================================== */

/* 筛选卡片 - 使用多列网格布局 */
.filter-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.filter-card h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
}

.filter-form {
    display: grid;
    grid-template-columns: repeat(5, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.filter-form .form-group {
    margin-bottom: 0;
}

.filter-form .form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.filter-form .form-input {
    padding: 10px 12px;
    font-size: 14px;
    min-height: 40px;
}

.filter-form .form-group:last-child {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

/* 统计网格 - 4列 */
.stats-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card-lg {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    border-left: 4px solid var(--primary-color);
}

.stat-number-lg {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 6px;
    line-height: 1.2;
}

.stat-label-lg {
    color: var(--text-secondary);
    font-size: 13px;
}

/* 排行区块 */
.rank-section {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.rank-section h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.section-header h3 {
    margin-bottom: 0;
}

/* 排行表格 */
.rank-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

.rank-table th {
    background: var(--bg-tertiary);
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.rank-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
    font-size: 13px;
    word-break: break-word;
}

.rank-table tr:hover { background: var(--bg-secondary); }

/* 排名列 - 居中对齐 */
.rank-table th:first-child,
.rank-table td:first-child {
    text-align: center;
    width: 70px;
    min-width: 70px;
    max-width: 70px;
    padding-left: 8px;
    padding-right: 8px;
}

.rank-number {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 15px;
}

.rank-1 { color: #ffd700; }
.rank-2 { color: #c0c0c0; }
.rank-3 { color: #cd7f32; }

/* 徽章 */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 4px;
}

.badge-high { background: #fee2e2; color: #dc2626; }
.badge-medium { background: #fef3c7; color: #d97706; }
.badge-low { background: #d1fae5; color: #059669; }

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

/* 时间徽章 */
.time-badge {
    display: inline-block;
    padding: 3px 10px;
    background: var(--primary-color);
    color: white;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    margin-left: 4px;
}

/* 排行切换按钮 */
.rank-toggle {
    display: inline-flex;
    gap: 6px;
    margin-right: 12px;
    vertical-align: middle;
}

.rank-toggle-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s;
    white-space: nowrap;
}

.rank-toggle-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.rank-toggle-btn:hover:not(.active) {
    background: var(--bg-tertiary);
}

/* 时间警告 */
.time-warning {
    background: #fef3c7;
    border: 1px solid #fde68a;
    padding: 10px 15px;
    border-radius: 8px;
    margin-top: 15px;
    font-size: 14px;
    color: #92400e;
}

/* =====================================================
   题目选项显示样式
   ===================================================== */
.question-content {
    max-width: 100%;
}

.question-text {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 14px;
}

.question-options {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    background: #f8f9fa;
    padding: 10px 14px;
    border-radius: 6px;
    margin: 8px 0;
    border-left: 3px solid var(--primary-color);
}

.option-item {
    padding: 3px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.option-item strong {
    color: var(--primary-color);
    min-width: 24px;
    font-weight: 700;
}

.correct-option {
    color: #059669;
    font-weight: 600;
    background: #d1fae5;
    padding: 4px 10px;
    border-radius: 4px;
    margin: 2px 0;
}

.correct-badge {
    display: inline-block;
    background: #059669;
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 10px;
    margin-left: 4px;
    font-weight: 500;
}

.question-explanation {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
    padding: 6px 10px;
    background: #fef3c7;
    border-radius: 4px;
    border-left: 3px solid #f59e0b;
}

.rate-info {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* =====================================================
   响应式适配
   ===================================================== */
@media (max-width: 1024px) {
    .filter-form {
        grid-template-columns: repeat(3, 1fr);
    }
    .filter-form .form-group:last-child {
        grid-column: span 3;
    }
}

@media (max-width: 768px) {
    .filter-form {
        grid-template-columns: 1fr;
    }
    .filter-form .form-group:last-child {
        grid-column: span 1;
    }
    
    .stats-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .rank-table {
        font-size: 12px;
    }
    
    .rank-table th,
    .rank-table td {
        padding: 8px 6px;
    }
    
    .rank-table th:first-child,
    .rank-table td:first-child {
        width: 50px;
        min-width: 50px;
        max-width: 50px;
    }
    
    .question-options {
        font-size: 12px;
        padding: 8px 10px;
    }
    
    .rank-section {
        padding: 16px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .stats-grid-4 {
        grid-template-columns: 1fr;
    }
    
    .stat-number-lg {
        font-size: 24px;
    }
}