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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --radius: 8px;
    --radius-sm: 6px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== 顶部栏 ===== */
.app-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: white;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.subtitle {
    font-size: 12px;
    opacity: 0.85;
    margin-left: 8px;
}

.stats-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    opacity: 0.95;
}

.stat-item b {
    font-size: 16px;
    font-weight: 700;
}

.stat-divider {
    opacity: 0.5;
}

/* ===== 筛选栏 ===== */
.filter-bar {
    background: var(--surface);
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 8px;
}

.filter-row:last-child {
    margin-bottom: 0;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.filter-group label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
}

.filter-select, .filter-input {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    height: 34px;
}

.filter-select {
    min-width: 100px;
    cursor: pointer;
}

.filter-input {
    min-width: 120px;
}

.filter-num {
    width: 80px;
    min-width: 80px;
}

.filter-search {
    flex: 1;
    min-width: 200px;
}

.filter-search .filter-input {
    min-width: 200px;
}

.filter-checkbox label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    height: 34px;
}

.filter-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

.filter-select:focus, .filter-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.filter-actions {
    align-items: center;
    margin-top: 4px;
}

.filter-result {
    margin-left: auto;
    font-size: 13px;
    color: var(--text-secondary);
}

.filter-result b {
    color: var(--primary);
    font-size: 16px;
}

/* ===== 按钮 ===== */
.btn {
    padding: 7px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 34px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-export {
    background: var(--success);
    color: white;
}

.btn-export:hover {
    background: #15803d;
}

.btn:active {
    transform: translateY(1px);
}

/* ===== 表格 ===== */
.table-container {
    flex: 1;
    overflow: hidden;
    padding: 0 24px;
}

.table-wrapper {
    overflow: auto;
    max-height: calc(100vh - 320px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
}

.data-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.data-table th:hover {
    background: var(--bg);
}

.data-table th:not(.sorted-asc):not(.sorted-desc)::after {
    content: ' ⇅';
    color: var(--text-light);
    font-size: 10px;
    opacity: 0.5;
}

.data-table th.sorted-asc::after {
    content: ' ▲';
    color: var(--primary);
    font-size: 10px;
}

.data-table th.sorted-desc::after {
    content: ' ▼';
    color: var(--primary);
    font-size: 10px;
}

.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table tbody tr {
    cursor: pointer;
    transition: background 0.1s;
}

.data-table tbody tr:hover {
    background: var(--primary-light);
}

.data-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.data-table tbody tr:nth-child(even):hover {
    background: var(--primary-light);
}

/* 分数高亮 */
.score-cell {
    font-weight: 600;
}

.score-high {
    color: var(--danger);
}

.score-low {
    color: var(--success);
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin: 1px 2px;
}

.tag-985 { background: #fef3c7; color: #92400e; }
.tag-211 { background: #dbeafe; color: #1e40af; }
.tag-double { background: #fce7f3; color: #9d174d; }
.tag-public { background: #d1fae5; color: #065f46; }
.tag-private { background: #fee2e2; color: #991b1b; }

/* 加载状态 */
.loading-row td {
    text-align: center;
    padding: 40px;
}

.loading-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 空状态 */
.empty-row td {
    text-align: center;
    padding: 60px;
    color: var(--text-light);
    font-size: 15px;
}

/* ===== 底部状态栏 ===== */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 24px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
}

.status-info b {
    color: var(--primary);
    font-weight: 600;
}

/* ===== 懒加载指示器 ===== */
.lazy-load-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    color: var(--text-secondary);
    font-size: 13px;
}

.lazy-load-end {
    text-align: center;
    padding: 12px 16px;
    color: var(--text-secondary);
    font-size: 12px;
    border-top: 1px solid var(--border);
}

.lazy-load-end b {
    color: var(--primary);
}

.loading-spinner.small {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

/* ===== 详情弹窗 ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    width: 100%;
    max-width: 900px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: white;
    border-radius: var(--radius) var(--radius) 0 0;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.modal-close:hover {
    background: rgba(255,255,255,0.2);
}

.modal-body {
    overflow-y: auto;
    padding: 20px 24px;
}

.detail-section {
    margin-bottom: 24px;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--primary-light);
    display: flex;
    align-items: center;
    gap: 6px;
}

.detail-section-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 16px;
    background: var(--primary);
    border-radius: 2px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px 16px;
}

.detail-item {
    display: flex;
    gap: 8px;
    padding: 4px 0;
    border-bottom: 1px solid #f1f5f9;
}

.detail-label {
    color: var(--text-secondary);
    font-size: 12px;
    min-width: 90px;
    flex-shrink: 0;
    font-weight: 500;
}

.detail-value {
    color: var(--text);
    font-size: 13px;
    word-break: break-all;
    flex: 1;
}

.detail-value.empty {
    color: var(--text-light);
    font-style: italic;
}

.detail-value a {
    color: var(--primary);
    text-decoration: none;
}

.detail-value a:hover {
    text-decoration: underline;
}

/* 专业组内专业列表 */
.group-major-list {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-top: 8px;
}

.group-major-list th {
    background: var(--bg);
    padding: 6px 8px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.group-major-list td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.group-major-list tr:hover {
    background: var(--primary-light);
}

/* 长文本 */
.long-text {
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg);
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.6;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 8px;
        padding: 12px 16px;
    }

    .header-left h1 {
        font-size: 16px;
    }

    .stats-bar {
        font-size: 12px;
    }

    .filter-bar {
        padding: 8px 16px;
    }

    .filter-row {
        gap: 6px;
    }

    .filter-select, .filter-input {
        min-width: 90px;
        font-size: 12px;
    }

    .table-container {
        padding: 0 8px;
    }

    .data-table {
        font-size: 12px;
    }

    .data-table th, .data-table td {
        padding: 6px 8px;
    }

    .status-bar {
        padding: 6px 16px;
    }

    .modal-content {
        max-width: 100%;
        max-height: 90vh;
    }
}

/* 滚动条美化 */
.table-wrapper::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-wrapper::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
    background: var(--bg);
}

.table-wrapper::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
