/* ===== CampusHub 校园学习工作台 ===== */
:root {
  --bg: #f4f5f9;
  --card: #ffffff;
  --border: #e5e6eb;
  --text: #1d2129;
  --text-2: #4e5969;
  --text-3: #86909c;
  --primary: #4f6ef7;
  --primary-weak: #eef1fe;
  --success: #00b42a;
  --success-weak: #e8ffea;
  --warning: #ff7d00;
  --warning-weak: #fff3e8;
  --danger: #f53f3f;
  --danger-weak: #ffece8;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(29, 33, 41, .07);
  --sidebar-w: 220px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

.app { display: flex; min-height: 100vh; }

/* ===== 侧边栏 ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.logo { display: flex; align-items: center; gap: 8px; padding: 0 8px; }
.logo-ico { font-size: 26px; }
.logo-txt { font-size: 20px; font-weight: 700; letter-spacing: .5px; }
.logo-sub { font-size: 12px; color: var(--text-3); padding: 2px 8px 18px; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: none; background: none; cursor: pointer;
  border-radius: 10px; color: var(--text-2); font-size: 14px;
  transition: all .15s; text-align: left; font-family: inherit;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-weak); color: var(--primary); font-weight: 600; }
.nav-ico { width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto; font-size: 11px; min-width: 20px; height: 20px;
  border-radius: 10px; background: var(--danger); color: #fff;
  display: none; align-items: center; justify-content: center; padding: 0 6px; font-weight: 600;
}
.nav-badge.show { display: flex; }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 16px; border-top: 1px solid var(--border); }
.foot-btn {
  padding: 8px 12px; border: none; background: none; cursor: pointer;
  border-radius: 8px; color: var(--text-2); font-size: 13px; text-align: left;
  font-family: inherit; transition: background .15s;
}
.foot-btn:hover { background: var(--bg); color: var(--text); }
.ver { font-size: 11px; color: var(--text-3); padding: 4px 12px 0; }

/* ===== 主区域 ===== */
.main { flex: 1; padding: 24px 32px 40px; max-width: 1280px; margin: 0 auto; width: 100%; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.topbar h1 { font-size: 24px; font-weight: 700; }
.topbar p { color: var(--text-3); font-size: 13px; margin-top: 2px; }

.btn {
  border: none; cursor: pointer; border-radius: 8px;
  padding: 8px 16px; font-size: 14px; font-family: inherit;
  transition: all .15s; font-weight: 500;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #3d5cf0; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-ghost { background: var(--bg); color: var(--text-2); }
.btn-ghost:hover { background: #e8eaef; }
.btn-danger { background: var(--danger-weak); color: var(--danger); }

.view { display: none; animation: fadeIn .25s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===== 卡片 ===== */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.card-head h3 { font-size: 15px; font-weight: 600; }
.card-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ===== 统计卡 ===== */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .num { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat .lbl { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.stat.red .num { color: var(--danger); }
.stat.orange .num { color: var(--warning); }
.stat.blue .num { color: var(--primary); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* ===== 今日 ===== */
.today-courses, .today-tasks { display: flex; flex-direction: column; gap: 10px; }
.tc-item {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px;
}
.tc-time { font-size: 12px; color: var(--text-2); font-weight: 600; min-width: 84px; display: flex; flex-direction: column; line-height: 1.3; }
.tc-time em { font-style: normal; font-weight: 400; color: var(--text-3); font-size: 11px; }
.tc-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tc-name { font-weight: 600; }
.tc-meta { color: var(--text-3); font-size: 12px; }
.empty-tip { color: var(--text-3); text-align: center; padding: 26px 0; font-size: 13px; }

.tt-item { display: flex; align-items: center; gap: 10px; border-radius: 10px; padding: 9px 12px; font-size: 13px; }
.tt-item.urgent { background: var(--warning-weak); }
.tt-item.overdue { background: var(--danger-weak); }
.tt-title { flex: 1; font-weight: 500; }
.tt-due { font-size: 12px; white-space: nowrap; }
.tt-due.urgent { color: var(--warning); font-weight: 600; }
.tt-due.overdue { color: var(--danger); font-weight: 600; }

/* ===== 周课表总览 ===== */
.week-overview { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wo-day { border: 1px solid var(--border); border-radius: 8px; padding: 8px; min-height: 74px; }
.wo-day .wo-name { font-size: 12px; color: var(--text-3); margin-bottom: 6px; font-weight: 600; }
.wo-day.today .wo-name { color: var(--primary); }
.wo-course { font-size: 11px; border-radius: 5px; padding: 3px 6px; margin-bottom: 4px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== 课表网格 ===== */
.schedule-wrap { overflow-x: auto; }
.schedule-grid {
  position: relative;
  display: grid;
  grid-template-columns: 64px repeat(7, minmax(96px, 1fr));
  grid-auto-rows: 52px;
  min-width: 800px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fafbfc;
}
.sg-head { background: var(--bg); font-weight: 600; font-size: 12px; display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); color: var(--text-2); }
.sg-head.today { background: var(--primary-weak); color: var(--primary); }
.sg-time { font-size: 11px; color: var(--text-3); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; border-bottom: 1px dashed var(--border); border-right: 1px solid var(--border); line-height: 1.2; }
.sg-time b { color: var(--text-2); font-size: 12px; font-weight: 600; }
.sg-time span { font-size: 10px; }
.sg-cell { border-bottom: 1px dashed var(--border); border-right: 1px solid var(--border); }
.sg-course {
  position: absolute; border-radius: 8px; color: #fff;
  padding: 6px 8px; font-size: 12px; line-height: 1.4;
  overflow: hidden; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.12);
  transition: transform .15s, box-shadow .15s;
  z-index: 2;
}
.sg-course:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,.18); }
.sg-course .c-name { font-weight: 600; }
.sg-course .c-meta { font-size: 11px; opacity: .92; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ===== 任务列表 ===== */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
  transition: box-shadow .15s;
}
.task:hover { box-shadow: var(--shadow); }
.task.done { opacity: .6; }
.task.done .t-title { text-decoration: line-through; color: var(--text-3); }
.t-check {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border);
  cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: transparent; transition: all .15s; background: #fff;
}
.t-check:hover { border-color: var(--success); }
.task.done .t-check { background: var(--success); border-color: var(--success); color: #fff; }
.t-main { flex: 1; min-width: 0; }
.t-title { font-weight: 600; }
.t-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.t-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.t-type { font-size: 11px; border-radius: 5px; padding: 2px 8px; font-weight: 600; }
.t-type.homework { background: var(--primary-weak); color: var(--primary); }
.t-type.exam { background: var(--warning-weak); color: var(--warning); }
.t-type.other { background: var(--bg); color: var(--text-2); }
.t-countdown { font-size: 12px; white-space: nowrap; font-weight: 600; color: var(--text-2); }
.t-countdown.urgent { color: var(--warning); }
.t-countdown.overdue { color: var(--danger); }
.t-del { border: none; background: none; cursor: pointer; color: var(--text-3); font-size: 15px; padding: 4px; border-radius: 6px; }
.t-del:hover { background: var(--danger-weak); color: var(--danger); }
.pri-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ===== 笔记 ===== */
.note-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.note {
  border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
  cursor: pointer; transition: box-shadow .15s, transform .15s; background: #fff;
}
.note:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.note .n-course { font-size: 11px; color: var(--primary); font-weight: 600; margin-bottom: 6px; }
.note .n-title { font-weight: 600; margin-bottom: 6px; }
.note .n-preview { color: var(--text-2); font-size: 12px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.note .n-time { color: var(--text-3); font-size: 11px; margin-top: 10px; }
.note .n-del { float: right; border: none; background: none; color: var(--text-3); cursor: pointer; font-size: 14px; }
.note .n-del:hover { color: var(--danger); }
.select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: #fff; color: var(--text); font-family: inherit; }

/* ===== 筛选 chips ===== */
.filter { display: flex; gap: 6px; }
.chip { border: 1px solid var(--border); background: #fff; color: var(--text-2); padding: 5px 12px; border-radius: 20px; font-size: 12px; cursor: pointer; font-family: inherit; transition: all .15s; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(29, 33, 41, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 460px; box-shadow: 0 12px 40px rgba(0,0,0,.18); animation: popIn .2s ease; }
@keyframes popIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.modal-head h3 { font-size: 16px; }
.modal-close { border: none; background: none; font-size: 16px; cursor: pointer; color: var(--text-3); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 0 20px 18px; display: flex; justify-content: flex-end; gap: 10px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.field input, .field select, .field textarea {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; color: var(--text); background: #fff;
  outline: none; transition: border .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field textarea { resize: vertical; min-height: 90px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* 颜色选择器 */
#fColorPick { display: flex; gap: 8px; flex-wrap: wrap; }
.color-dot {
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
  border: 3px solid transparent; transition: transform .12s, border-color .12s;
}
.color-dot:hover { transform: scale(1.12); }
.color-dot.sel { border-color: #1d2129; }

/* 更新日志 */
.changelog { display: flex; flex-direction: column; gap: 12px; }
.cl-item { background: var(--bg); border-radius: 10px; padding: 12px 14px; font-size: 13px; }
.cl-item b { display: block; margin-bottom: 6px; color: var(--text); }
.cl-item ul { padding-left: 18px; color: var(--text-2); display: flex; flex-direction: column; gap: 3px; }

/* 批量导入 */
#importText { min-height: 120px; font-family: "Consolas", "Menlo", monospace; font-size: 12px; }
.import-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.import-preview { border-top: 1px dashed var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.ip-hint { font-size: 12px; color: var(--text-3); background: var(--bg); border-radius: 8px; padding: 10px 12px; line-height: 1.7; }
.ip-empty { font-size: 13px; color: var(--text-3); text-align: center; padding: 14px 0; }
.ip-errors { font-size: 12px; color: var(--danger); background: var(--danger-weak); border-radius: 8px; padding: 10px 12px; line-height: 1.8; }
.ip-errors b { color: var(--danger); }
.ip-ok { font-size: 13px; color: var(--success); font-weight: 600; }
.import-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.import-table th, .import-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; }
.import-table th { background: var(--bg); color: var(--text-2); font-weight: 600; }
.import-table td { color: var(--text); }
.import-table tbody tr:nth-child(even) { background: #fafbfc; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1d2129; color: #fff; padding: 10px 20px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  .two-col, .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .note-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 68px; padding: 18px 8px; }
  .logo-txt, .logo-sub, .nav-item .nav-ico + span, .nav-item .nav-badge, .foot-btn, .ver { display: none; }
  .nav-item { justify-content: center; }
  .foot-btn { text-align: center; }
  .main { padding: 16px; }
}
@media (max-width: 560px) {
  .stat-grid, .two-col, .note-grid { grid-template-columns: 1fr; }
  .schedule-grid { min-width: 680px; }
}
