/* =========================================
   课堂点名系统 - 样式表
   ========================================= */

/* Reset */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* 主色调 - 温暖蓝紫 */
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --primary-bg: #eef2ff;

  /* 语义色 */
  --success: #22c55e;
  --success-bg: #f0fdf4;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;

  /* 中性色 */
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  /* 圆角 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 24px rgba(99, 102, 241, 0.25);

  /* 动效 */
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 暗色模式 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --border: #334155;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --primary-bg: #1e1b4b;
    --success-bg: #052e16;
    --warning-bg: #451a03;
    --danger-bg: #450a0a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* ===== 头部 ===== */
.header {
  text-align: center;
  padding: 32px 0 24px;
}

.title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--primary), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

/* ===== 点名核心区域 ===== */
.roll-call-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
}

.display-card {
  text-align: center;
  padding: 28px 16px 20px;
  border-radius: var(--radius-md);
  background: var(--primary-bg);
  position: relative;
  overflow: hidden;
  transition: background var(--transition);
}

.display-card.rolling {
  background: linear-gradient(135deg, var(--primary-bg), #f0abfc20);
}

.display-card.called {
  background: var(--success-bg);
}

.display-card.duplicate {
  animation: shake 0.5s ease;
}

.display-label {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.display-name-wrapper {
  margin: 16px 0 12px;
}

.display-name {
  font-size: 56px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  letter-spacing: 4px;
}

.display-card.rolling .display-name {
  animation: textRoll 0.08s steps(1) infinite;
  color: var(--primary-light);
}

.display-card.called .display-name {
  color: var(--success);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  background: var(--card-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition);
}

.display-card.called .badge-dot {
  background: var(--success);
}

/* ===== 按钮 ===== */
.action-row {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  outline: none;
  line-height: 1.4;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0) scale(0.97);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn-icon {
  font-size: 18px;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  gap: 4px;
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 6px 10px;
}

.btn-ghost:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

/* ===== 统计信息 ===== */
.stats-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.stat-value.called {
  color: var(--success);
}

.stat-value.uncalled {
  color: var(--primary);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ===== 点名记录 ===== */
.history-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

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

.section-title {
  font-size: 16px;
  font-weight: 600;
}

.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  animation: fadeIn 0.3s ease;
}

.history-item .index {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
}

/* ===== 学生名单 ===== */
.list-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}

.list-actions {
  display: flex;
  gap: 8px;
}

.search-box {
  margin-bottom: 12px;
}

.search-box input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border var(--transition);
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.student-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px 0;
}

.student-list::-webkit-scrollbar {
  width: 4px;
}

.student-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.student-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  gap: 4px;
}

.student-item:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.student-item .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.student-item .del-btn {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}

.student-item .del-btn:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.student-item.called {
  background: var(--success-bg);
  border-color: var(--success);
  opacity: 0.7;
}

.student-item.called .name::after {
  content: ' ✓';
  color: var(--success);
  font-size: 12px;
}

/* ===== 弹窗 ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}

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

.modal-content {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.modal-body {
  padding: 16px 24px;
}

.modal-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.modal-body textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border var(--transition);
}

.modal-body textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 24px 20px;
}

/* ===== 动画 ===== */
@keyframes textRoll {
  0% { transform: translateY(0); }
  25% { transform: translateY(-2px); }
  75% { transform: translateY(2px); }
  100% { transform: translateY(0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes confetti {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-120px) rotate(720deg); opacity: 0; }
}

.confetti-container {
  position: fixed;
  top: 50%;
  left: 50%;
  pointer-events: none;
  z-index: 999;
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: confetti 0.8s ease-out forwards;
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 14px;
  grid-column: 1 / -1;
}

/* ===== Toast 提示 ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  background: var(--success);
  color: #fff;
}

.toast.warning {
  background: var(--warning);
  color: #fff;
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

.toast.info {
  background: var(--primary);
  color: #fff;
}

/* ===== 响应式 ===== */
@media (max-width: 480px) {
  #app {
    padding: 12px 12px 32px;
  }

  .header {
    padding: 20px 0 16px;
  }

  .title {
    font-size: 22px;
  }

  .display-name {
    font-size: 40px;
    min-height: 48px;
  }

  .roll-call-section {
    padding: 20px 16px;
  }

  .display-card {
    padding: 20px 12px 16px;
  }

  .action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    justify-content: center;
    padding: 12px 20px;
  }

  .stats-row {
    gap: 16px;
  }

  .stat-value {
    font-size: 20px;
  }

  .student-list {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  }

  .history-section,
  .list-section {
    padding: 16px;
  }
}