/* ==========================================================================
   v4 平时分（学科）页面样式 —— 统一前缀 sd-
   --------------------------------------------------------------------------
   已在 public/index.html 中通过 <link> 全局引入。只使用 tokens.css 的语义变量，
   因此浅色 / 深色主题都自动适配；不引入任何外部资源。

   分区：
     1. 日分数变动查询（.sd-daily__* / .sd-tl*）—— 竖向时间线
     2. 同批 v4 页面共享构件（.sd-switch / .sd-student-picker / .sd-result-* / .sd-fail-*）
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 日分数变动查询
   -------------------------------------------------------------------------- */
/* 查询进行中：保留上一次结果（弱化显示），首次查询则由骨架屏占位 */
.sd-daily__result.is-busy {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out);
}

/* 日期 + 快捷按钮（今天 / 昨天） */
.sd-daily__date-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.sd-daily__date-row .input {
  flex: 1 1 150px;
  min-width: 140px;
}

.sd-daily__quick {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 0 0 auto;
}

/* 统计条：加分合计数字用绿色、扣分合计数字用红色
   （statCard 默认只给图标上色，这里把数值本身也上色） */
.sd-stat--add .stat-card__value { color: var(--success); }
.sd-stat--deduct .stat-card__value { color: var(--danger); }

/* 图例 */
.sd-tl-legend {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.sd-tl-legend__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.sd-tl-legend__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.sd-tl-legend__dot--add { background: var(--success); }
.sd-tl-legend__dot--deduct { background: var(--danger); }

.sd-tl-legend__hint {
  margin-left: auto;
  color: var(--text-tertiary);
}

/* 学生卡片列表 */
.sd-tl-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.sd-tl {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  overflow: hidden;
}

/* 卡片头（可点击折叠 / 展开，默认展开） */
.sd-tl__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-4);
  border: 0;
  background: var(--bg-muted);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}

.sd-tl__head:hover { background: var(--bg-hover); }

.sd-tl__head:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--brand-400);
}

.sd-tl__avatar {
  display: inline-flex;
  flex: 0 0 auto;
}

.sd-tl__who {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sd-tl__name {
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--text-primary);
}

.sd-tl__username {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.sd-tl__sum {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
  flex-wrap: wrap;
}

.sd-tl__sum-item {
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--bg-surface-sunken);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.sd-tl__sum-item--add {
  background: var(--success-soft);
  color: var(--success);
}

.sd-tl__sum-item--deduct {
  background: var(--danger-soft);
  color: var(--danger);
}

/* 当日净变动：+3 绿色 / -1 红色 / 0 中性 */
.sd-tl__delta {
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sd-tl__delta--add { color: var(--success); }
.sd-tl__delta--deduct { color: var(--danger); }
.sd-tl__delta--zero { color: var(--text-tertiary); }

.sd-tl__chevron {
  display: inline-flex;
  color: var(--text-tertiary);
  transition: transform var(--dur-fast) var(--ease-out);
}

.sd-tl.is-collapsed .sd-tl__chevron { transform: rotate(180deg); }

.sd-tl__body {
  padding: var(--space-3) var(--space-4) var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.sd-tl.is-collapsed .sd-tl__body { display: none; }
.sd-tl__body[hidden] { display: none; }

/* ---------------- 竖向时间线本体 ---------------- */
.sd-tl__nodes {
  position: relative;
  margin: 0;
  padding: 0 0 0 var(--space-6);
  list-style: none;
}

/* 左侧竖线 */
.sd-tl__nodes::before {
  content: '';
  position: absolute;
  left: 5px;
  top: var(--space-4);
  bottom: var(--space-4);
  width: 2px;
  border-radius: var(--radius-full);
  background: var(--border-default);
}

.sd-tl__node {
  position: relative;
  padding: var(--space-3) 0;
}

.sd-tl__node + .sd-tl__node {
  border-top: 1px dashed var(--border-subtle);
}

/* 节点圆点：加分绿色 / 扣分红色 */
.sd-tl__dot {
  position: absolute;
  left: calc(var(--space-6) * -1);
  top: 16px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.sd-tl__node--add .sd-tl__dot {
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
}

.sd-tl__node--deduct .sd-tl__dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px var(--danger-soft);
}

.sd-tl__row {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.sd-tl__time {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.sd-tl__sep { color: var(--text-tertiary); }

.sd-tl__reason {
  color: var(--text-primary);
  font-size: var(--text-sm);
  word-break: break-word;
}

.sd-tl__score {
  font-weight: 700;
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
}

.sd-tl__score--add { color: var(--success); }
.sd-tl__score--deduct { color: var(--danger); }

.sd-tl__operator {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
}

.sd-tl__empty {
  padding: var(--space-3) 0;
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  list-style: none;
}

@media (max-width: 640px) {
  .sd-tl__head { flex-wrap: wrap; }

  .sd-tl__sum {
    margin-left: 0;
    width: 100%;
  }

  .sd-tl__delta { margin-left: auto; }
  .sd-tl-legend__hint { display: none; }
}

/* --------------------------------------------------------------------------
   2. 同批 v4 平时分页面共享构件
   （单次扣分 / 批量扣分等页面已使用这些类名）
   -------------------------------------------------------------------------- */
.sd-switch {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sd-switch__hint {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.sd-switch__hint b { color: var(--text-primary); }

/* 学生单选器（搜索 + 候选列表 + 已选提示） */
.sd-student-picker {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sd-student-picker__list {
  display: flex;
  flex-direction: column;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface-sunken);
}

.sd-student-picker__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}

.sd-student-picker__option:last-child { border-bottom: 0; }
.sd-student-picker__option:hover { background: var(--bg-hover); }

.sd-student-picker__option.is-active {
  background: var(--bg-active);
  color: var(--brand-500);
}

.sd-student-picker__option-name { font-weight: 600; }
.sd-student-picker__option-id { color: var(--text-tertiary); }

.sd-student-picker__option.is-active .sd-student-picker__option-id {
  color: inherit;
  opacity: 0.85;
}

.sd-student-picker__selected {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.sd-student-picker__selected b { color: var(--brand-500); }

.sd-student-picker__empty {
  padding: var(--space-4);
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  text-align: center;
}

/* 结果概览栅格 */
.sd-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
}

.sd-result-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface-sunken);
}

.sd-result-item__label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.sd-result-item__value {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-word;
}

.sd-result-item__value--strong {
  font-size: var(--text-md);
  color: var(--brand-500);
}

.sd-result-item__value--deduct { color: var(--danger); }

/* 逐人结果行（可展开） */
.sd-result-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sd-result-row {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  overflow: hidden;
}

.sd-result-row.is-open { border-color: var(--border-default); }

.sd-result-row__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}

.sd-result-row__head:hover { background: var(--bg-hover); }

.sd-result-row__name { font-weight: 600; }

.sd-result-row__meta {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.sd-result-row__state { display: inline-flex; }

.sd-result-row__score {
  margin-left: auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.sd-result-row__chevron {
  display: inline-flex;
  color: var(--text-tertiary);
  transition: transform var(--dur-fast) var(--ease-out);
}

.sd-result-row.is-open .sd-result-row__chevron { transform: rotate(180deg); }

.sd-result-row__body { padding: 0 var(--space-4) var(--space-4); }
.sd-result-row__body[hidden] { display: none; }

.sd-result-detail {
  display: flex;
  flex-direction: column;
}

/* 失败名单 */
.sd-fail-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sd-fail-item {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-md);
  background: var(--danger-soft);
}

.sd-fail-item__who {
  font-weight: 600;
  white-space: nowrap;
}

.sd-fail-item__why {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}
