/* ========== 全局变量与主题 ========== */
:root {
    --bg-primary: #f7f5f0;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0ede8;
    --text-primary: #2c3e50;
    --text-secondary: #5d6d7e;
    --text-muted: #95a5a6;
    --border-color: #e0ddd5;
    --accent-color: #3498db;
    --accent-hover: #2980b9;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --sidebar-width: 220px;
    --sidebar-collapsed: 60px;
    --header-height: 56px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --transition: all 0.25s ease;
}
[data-theme="dark"] {
    --bg-primary: #1a1d23;
    --bg-secondary: #242830;
    --bg-tertiary: #2c313a;
    --text-primary: #e8eaed;
    --text-secondary: #b0b5bd;
    --text-muted: #707782;
    --border-color: #3a3f4a;
    --accent-color: #4dabf7;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    overflow: hidden;
}
/* ========== 登录页 ========== */
.login-page {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    width: 360px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-title {
    text-align: center;
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 24px;
    color: #2c3e50;
}
.login-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 16px;
    box-sizing: border-box;
}
.login-input:focus { outline: none; border-color: #3498db; }
.login-btn {
    width: 100%;
    padding: 12px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
    margin-top: 4px;
}
.login-btn:hover { background: #2980b9; }
.login-tip {
    text-align: center;
    font-size: 12px;
    color: #999;
    margin-top: 16px;
}
.login-error {
    color: #e74c3c;
    font-size: 12px;
    margin-bottom: 10px;
    text-align: center;
    min-height: 16px;
}
.login-back {
    text-align: center;
    margin-top: 12px;
}
.login-back a {
    color: #3498db;
    text-decoration: none;
    font-size: 12px;
}
/* ========== 顶部全局栏 ========== */
.header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}
.header-left { display: flex; align-items: center; gap: 16px; flex: 1; }
.header-center { flex: 2; text-align: center; }
.header-right { flex: 1; display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.header-date { font-size: 15px; font-weight: 500; color: var(--text-primary); }
.header-countdown {
    color: var(--accent-color);
    font-weight: 600;
    padding: 4px 12px;
    background: rgba(52, 152, 219, 0.1);
    border-radius: 20px;
    font-size: 14px;
}
.admin-badge {
    background: var(--danger-color);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    margin-left: 8px;
}
.icon-btn {
    width: 36px; height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.icon-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.btn {
    padding: 7px 16px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.btn:hover { border-color: var(--accent-color); color: var(--accent-color); }
.btn-primary { background: var(--accent-color); color: white; border-color: var(--accent-color); }
.btn-primary:hover { background: var(--accent-hover); color: white; }
.btn-danger { background: var(--danger-color); color: white; border-color: var(--danger-color); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
/* ========== 侧边栏 ========== */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    z-index: 90;
    overflow-y: auto;
    transition: var(--transition);
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar-toggle {
    position: absolute;
    top: 10px; right: -12px;
    width: 24px; height: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    z-index: 91;
    color: var(--text-secondary);
    font-size: 12px;
}
.nav-group { padding: 12px 0; border-bottom: 1px solid var(--border-color); }
.nav-group-title {
    padding: 6px 16px;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    white-space: nowrap;
    border-left: 3px solid transparent;
    text-decoration: none;
}
.nav-item:hover { background: var(--bg-tertiary); }
.nav-item.active { 
    background: rgba(52, 152, 219, 0.1); 
    color: var(--accent-color);
    border-left-color: var(--accent-color);
}
.nav-item svg { flex-shrink: 0; width: 18px; height: 18px; }
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-group-title { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px; }
/* ========== 主内容区 ========== */
.main {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    padding: 20px;
    transition: var(--transition);
}
.main.expanded { margin-left: var(--sidebar-collapsed); }
.page { display: none; }
.page.active { display: block; }
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.page-title { font-size: 20px; font-weight: 600; }
.page-actions { display: flex; gap: 8px; }
.card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 16px;
}
.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}
/* ========== 前台只读模式 ========== */
body.frontend .page-actions,
body.frontend .quick-actions,
body.frontend .score-panel,
body.frontend .seat-config { display: none !important; }
body.frontend .table-actions { display: none !important; }
body.frontend .schedule-cell { cursor: default; }
body.frontend .seat-cell { cursor: default; }
body.frontend .tree-item { cursor: default; }
body.frontend .todo-item input[type="checkbox"] { pointer-events: none; }
/* ========== 仪表盘 ========== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px solid var(--border-color);
}
.stat-value { font-size: 32px; font-weight: 700; color: var(--accent-color); }
.stat-label { color: var(--text-secondary); margin-top: 4px; font-size: 13px; }
.dashboard-main {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
}
.big-date {
    text-align: center;
    padding: 30px;
    background: linear-gradient(135deg, var(--accent-color), #6c5ce7);
    color: white;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}
.big-date .date { font-size: 48px; font-weight: 700; }
.big-date .weekday { font-size: 18px; opacity: 0.9; margin-top: 4px; }
.big-date .countdown { 
    margin-top: 12px; 
    font-size: 16px; 
    padding: 8px 20px;
    background: rgba(255,255,255,0.2);
    border-radius: 20px;
    display: inline-block;
}
.today-classes { margin-bottom: 16px; }
.class-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}
.class-time { width: 50px; font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.class-name { font-weight: 500; flex: 1; }
.class-teacher { font-size: 12px; color: var(--text-secondary); }
.class-tag {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    color: white;
}
.todo-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}
.todo-item:last-child { border-bottom: none; }
.todo-priority {
    width: 4px;
    height: 20px;
    border-radius: 2px;
    flex-shrink: 0;
}
.todo-priority { width: 4px; height: 20px; border-radius: 2px; }
.priority-high { background: var(--danger-color); }
.priority-medium { background: var(--warning-color); }
.priority-low { background: var(--success-color); }
.todo-text {
    flex: 1;
    font-size: 13px;
    line-height: 1.5;
}
.todo-time {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.record-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}
.record-item:last-child { border-bottom: none; }
.record-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.record-student { font-weight: 500; }
.record-date { color: var(--text-muted); font-size: 11px; }
.record-content { color: var(--text-secondary); }
.quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.quick-btn {
    padding: 14px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-primary);
    font-size: 13px;
    transition: var(--transition);
    display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.quick-btn:hover { background: var(--accent-color); color: white; }
.quick-btn svg { width: 24px; height: 24px; }
/* ========== 表格通用 ========== */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}
th { 
    background: var(--bg-tertiary); 
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
}
tr:hover td { background: var(--bg-tertiary); }
/* ========== 表单通用 ========== */
.form-row { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.form-group { flex: 1; min-width: 150px; }
.form-label { display: block; margin-bottom: 4px; font-size: 12px; color: var(--text-secondary); }
input, select, textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    transition: var(--transition);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-color); }
textarea { resize: vertical; min-height: 60px; }
/* ========== 随机点名器 ========== */
.rollcall-container { text-align: center; padding: 40px 20px; }
.rollcall-display {
    font-size: 72px;
    font-weight: 700;
    color: var(--accent-color);
    height: 120px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 30px;
    transition: all 0.1s;
}
.rollcall-display.rolling { animation: shake 0.1s infinite; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}
.rollcall-btn {
    width: 160px; height: 50px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 25px;
    margin: 0 auto;
    display: block;
}
.rollcall-progress { max-width: 400px; margin: 20px auto 0; }
.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}
.progress-fill {
    height: 100%;
    background: var(--accent-color);
    transition: width 0.3s;
}
/* ========== 座位表 ========== */
.seat-config { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
.seat-config .form-group { flex: 0 0 120px; }
.classroom { max-width: 900px; margin: 0 auto; }
.podium {
    text-align: center;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-weight: 600;
    color: var(--text-secondary);
}
.seat-grid {
    display: grid;
    gap: 8px;
    margin-bottom: 20px;
}
.seat-cell {
    padding: 10px 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 12px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    user-select: none;
}
.seat-cell.empty { 
    color: var(--text-muted); 
    border-style: dashed; 
}
/* 管理员可拖拽样式 */
body:not(.frontend) .seat-cell:not(.empty) {
    cursor: grab;
}
body:not(.frontend) .seat-cell:not(.empty):active {
    cursor: grabbing;
}
.seat-cell.drag-over {
    border-color: var(--accent-color);
    background: rgba(52, 152, 219, 0.1);
}
.seat-cell.dragging {
    opacity: 0.4;
}
/* ========== 成长树 ========== */
.tree-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 16px;
    padding: 20px 0;
}
.tree-item {
    text-align: center;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.tree-svg { width: 70px; height: 90px; margin: 0 auto 6px; }
.tree-name { font-size: 12px; margin-bottom: 4px; }
.tree-score { font-size: 14px; font-weight: 700; color: var(--accent-color); }
.score-panel {
    display: flex; gap: 12px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}
/* ========== 课表 ========== */
.schedule-table th { text-align: center; }
.schedule-table td {
    text-align: center;
    height: 50px;
    vertical-align: middle;
}
.schedule-cell {
    padding: 6px;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    cursor: pointer;
}
.schedule-cell .subject { font-weight: 600; }
.schedule-cell .teacher { font-size: 10px; opacity: 0.9; margin-top: 2px; }
.time-col { width: 70px; font-size: 11px; color: var(--text-muted); }
/* ========== 值日表 ========== */
.duty-week {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.duty-day {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 12px;
}
.duty-day-title {
    font-weight: 600;
    text-align: center;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}
.duty-student { font-size: 12px; padding: 3px 0; }
/* ========== 弹窗 ========== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center; justify-content: center;
    z-index: 1000;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    min-width: 400px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
    background: none; border: none;
    font-size: 20px; cursor: pointer;
    color: var(--text-muted);
}
.modal-footer {
    display: flex; justify-content: flex-end; gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}
/* ========== 标签 ========== */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    vertical-align: middle;
}
.tag-success { background: rgba(39, 174, 96, 0.15); color: var(--success-color); }
.tag-warning { background: rgba(243, 156, 18, 0.15); color: var(--warning-color); }
.tag-danger { background: rgba(231, 76, 60, 0.15); color: var(--danger-color); }
.tag-info { background: rgba(52, 152, 219, 0.15); color: var(--accent-color); }
/* ========== 导入区域 ========== */
.import-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
    margin-bottom: 12px;
    transition: var(--transition);
}
.import-area:hover { border-color: var(--accent-color); }
.import-area input[type="file"] { display: none; }
.import-label { cursor: pointer; color: var(--accent-color); }
.textarea-import { width: 100%; min-height: 80px; margin-bottom: 8px; }
/* ========== 响应式 ========== */
@media (max-width: 1280px) {
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-main { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .sidebar { width: var(--sidebar-collapsed); }
    .sidebar .nav-item span, .sidebar .nav-group-title { display: none; }
    .sidebar .nav-item { justify-content: center; padding: 12px; }
    .main { margin-left: var(--sidebar-collapsed); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .header-date { display: none; }
    .modal { min-width: 90vw; }
    .duty-week { grid-template-columns: repeat(2, 1fr); }
}
/* ========== 打印样式 ========== */
@media print {
    .header, .sidebar, .page-actions, .no-print { display: none !important; }
    .main { margin-left: 0; margin-top: 0; padding: 0; }
    body { background: white; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}
