/* ==================== 全局重置与变量 ==================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #4A90D9;
  --primary-dark: #357ABD;
  --primary-light: #E8F0FE;
  --danger: #E74C3C;
  --danger-light: #FDEDEC;
  --success: #27AE60;
  --success-light: #E8F8F0;
  --warning: #F39C12;
  --warning-light: #FEF3E2;
  --bg: #F5F7FA;
  --card-bg: #FFFFFF;
  --text: #2C3E50;
  --text-secondary: #7F8C8D;
  --border: #E1E8ED;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 52px;
  --nav-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  user-select: none;
  -webkit-user-select: none;
}

/* ==================== 顶部标题栏 ==================== */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  padding: 0 16px;
}
.app-title {
  color: #fff; font-size: 18px; font-weight: 600; letter-spacing: 0.5px;
}

/* ==================== 主体区域 ==================== */
.app-main {
  position: fixed;
  top: var(--header-h); left: 0; right: 0;
  bottom: calc(var(--nav-h) + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
}
.page { display: none; }
.page.active { display: block; }

/* ==================== 底部导航栏 ==================== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--card-bg);
  display: flex;
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer; color: var(--text-secondary);
  transition: color 0.2s; gap: 2px; padding: 6px 0;
}
.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 22px; line-height: 1; }
.nav-label { font-size: 11px; font-weight: 500; }

/* ==================== 工具栏 & 筛选行 ==================== */
.toolbar {
  display: flex; gap: 8px; margin-bottom: 12px; align-items: center;
}
.search-box { flex: 1; }
.search-box input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; background: var(--card-bg); outline: none; transition: border-color 0.2s;
}
.search-box input:focus { border-color: var(--primary); }

.filter-row {
  display: flex; gap: 8px; margin-bottom: 12px;
}
.filter-row select, .filter-row input {
  flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; background: var(--card-bg); outline: none; color: var(--text);
}
.filter-row select:focus, .filter-row input:focus { border-color: var(--primary); }

.view-toggle {
  display: flex; background: var(--card-bg); border-radius: var(--radius-sm);
  border: 1px solid var(--border); margin-bottom: 12px; overflow: hidden;
}
.toggle-btn {
  flex: 1; padding: 10px; border: none; background: none; font-size: 14px;
  cursor: pointer; color: var(--text-secondary); transition: all 0.2s;
}
.toggle-btn.active { background: var(--primary); color: #fff; }

/* ==================== 按钮 ==================== */
.btn {
  padding: 10px 18px; border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: opacity 0.2s, background 0.2s;
}
.btn:active { opacity: 0.8; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-cancel { background: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: var(--card-bg); color: var(--primary); border: 1px solid var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ==================== 列表容器 ==================== */
.list-container { display: flex; flex-direction: column; gap: 10px; }
.hidden { display: none !important; }

/* 卡片 */
.card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); position: relative;
}
.card-header {
  display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px;
}
.card-title { font-size: 16px; font-weight: 600; }
.card-subtitle { font-size: 13px; color: var(--text-secondary); }
.card-body { font-size: 14px; }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tag {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
}
.tag-primary { background: var(--primary-light); color: var(--primary); }
.tag-success { background: #E8F8F0; color: var(--success); }
.tag-warning { background: #FEF3E2; color: var(--warning); }
.tag-danger { background: var(--danger-light); color: var(--danger); }
.tag-gray { background: #F0F0F0; color: #666; }

.card-actions {
  display: flex; gap: 6px; margin-top: 8px; justify-content: flex-end;
}
.card-actions .btn { padding: 6px 14px; font-size: 13px; }

.pin-badge {
  position: absolute; top: 8px; right: 8px;
  font-size: 16px; color: var(--warning);
}

/* 空状态 */
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--text-secondary);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ==================== 日历视图 ==================== */
.calendar-container { background: var(--card-bg); border-radius: var(--radius); overflow: hidden; }
.calendar-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.calendar-nav button {
  background: none; border: none; font-size: 18px; cursor: pointer;
  color: var(--primary); padding: 4px 8px;
}
.calendar-month { font-size: 16px; font-weight: 600; }

.calendar-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; padding: 8px 0;
  font-size: 13px; color: var(--text-secondary); font-weight: 500;
}
.calendar-days {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px; padding: 4px 8px 12px;
}
.calendar-day {
  aspect-ratio: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; border-radius: 50%;
  font-size: 14px; cursor: pointer; position: relative; transition: background 0.15s;
}
.calendar-day:hover { background: var(--primary-light); }
.calendar-day.today { background: var(--primary); color: #fff; font-weight: 600; }
.calendar-day.other-month { color: #ccc; }
.calendar-day.has-schedule::after {
  content: ''; position: absolute; bottom: 4px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--primary);
}
.calendar-day.today.has-schedule::after { background: #fff; }

.day-schedules {
  padding: 12px 16px; border-top: 1px solid var(--border);
  min-height: 60px;
}
.day-schedules h4 { font-size: 14px; margin-bottom: 8px; color: var(--text-secondary); }

.schedule-item {
  display: flex; align-items: center; gap: 10px; padding: 10px;
  background: var(--bg); border-radius: var(--radius-sm); margin-bottom: 6px;
}
.schedule-time {
  font-weight: 600; font-size: 14px; color: var(--primary); white-space: nowrap;
}
.schedule-info { flex: 1; font-size: 13px; }
.schedule-info .name { font-weight: 500; }
.schedule-info .detail { color: var(--text-secondary); font-size: 12px; }

/* ==================== 统计卡片 ==================== */
.stats-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 16px; text-align: center; box-shadow: var(--shadow);
}
.stat-card .stat-value {
  font-size: 28px; font-weight: 700; color: var(--primary);
}
.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ==================== 设置页面 ==================== */
.settings-group {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.section-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; color: var(--text); }
.setting-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border); gap: 12px;
}
.setting-item:last-child { border-bottom: none; }
.setting-item label { font-size: 14px; flex-shrink: 0; }
.setting-item input, .setting-item select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; background: var(--bg); outline: none; width: 100px; text-align: center;
}
.danger-zone { border: 1px solid var(--danger); }
.danger-zone .section-title { color: var(--danger); }
.danger-zone .btn-danger { width: 100%; }

/* ==================== 模态框 ==================== */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.4);
}
.modal-overlay.show { display: block; }
.modal {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 201;
  background: var(--card-bg); border-radius: 16px 16px 0 0;
  max-height: 85vh; overflow-y: auto; padding-bottom: var(--safe-bottom);
  transform: translateY(100%); transition: transform 0.3s ease;
}
.modal.show { display: block; transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--card-bg); z-index: 1;
}
.modal-header h2 { font-size: 17px; font-weight: 600; }
.modal-close {
  background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--text-secondary); padding: 4px;
}
.modal-body { padding: 16px; }
.modal-footer {
  display: flex; gap: 10px; padding: 12px 16px;
  border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--card-bg);
}
.modal-footer .btn { flex: 1; text-align: center; padding: 12px; }

/* ==================== 表单 ==================== */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 15px; background: var(--bg); outline: none; color: var(--text);
  transition: border-color 0.2s; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
}
.form-group textarea { resize: vertical; min-height: 60px; }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }
.required { color: var(--danger); }

/* ==================== Toast提示 ==================== */
.toast {
  position: fixed; top: calc(var(--header-h) + 12px); left: 50%; transform: translateX(-50%);
  z-index: 300; padding: 10px 24px; border-radius: 24px;
  font-size: 14px; color: #fff; font-weight: 500;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2s forwards;
  white-space: nowrap; box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(-10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ==================== 响应式细节 ==================== */
@media (min-width: 500px) {
  .app-main { max-width: 480px; left: 50%; transform: translateX(-50%); width: 100%; }
  .bottom-nav { max-width: 480px; left: 50%; transform: translateX(-50%); }
}

/* ==================== 当前课程卡片（主页顶部） ==================== */
.current-class-card {
  background: linear-gradient(135deg, var(--primary), #6BB3F0);
  border-radius: var(--radius);
  padding: 20px 16px 24px;
  margin-bottom: 12px;
  text-align: center;
  color: #fff;
  box-shadow: 0 4px 20px rgba(74, 144, 217, 0.3);
}
.current-class-card.hidden { display: none; }
.current-class-card .cc-title {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 4px;
}
.current-class-card .cc-student {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 2px;
}
.current-class-card .cc-subject {
  font-size: 15px;
  opacity: 0.9;
  margin-bottom: 8px;
}
.current-class-card .cc-time {
  font-size: 13px;
  opacity: 0.8;
  margin-bottom: 16px;
}
.current-class-card .cc-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255,255,255,0.25);
  margin-bottom: 16px;
  animation: pulse 1.5s ease-in-out infinite;
}
.current-class-card .cc-location {
  font-size: 12px;
  opacity: 0.7;
  margin-bottom: 16px;
}

.btn-circle-confirm {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: rgba(255,255,255,0.2);
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.15);
  transition: transform 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  margin: 0 auto;
}
.btn-circle-confirm:active {
  transform: scale(0.92);
  background: rgba(255,255,255,0.35);
}
.btn-circle-icon {
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
}
.btn-circle-label {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1px;
}

.cc-empty {
  text-align: center;
  padding: 16px;
  background: var(--card-bg);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* 滚动条美化 */
.app-main::-webkit-scrollbar { width: 0; }

/* ==================== 周视图样式 ==================== */
.week-container {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}

.week-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.week-nav {
  display: flex;
  gap: 8px;
}

.week-nav button {
  background: var(--primary-light);
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  color: var(--primary);
  cursor: pointer;
  font-size: 14px;
}

.week-nav button:active {
  background: var(--primary);
  color: #fff;
}

.week-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.week-day {
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: var(--bg);
}

.week-day.today {
  border-color: var(--primary);
  background: var(--primary-light);
}

.week-day-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-align: center;
}

.week-day.today .week-day-header {
  color: var(--primary);
}

.week-day-date {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
}

.week-schedule-item {
  background: var(--card-bg);
  border-radius: 6px;
  padding: 6px;
  margin-bottom: 4px;
  font-size: 11px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.week-schedule-time {
  font-weight: 600;
  color: var(--primary);
  font-size: 10px;
}

.week-schedule-student {
  color: var(--text);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==================== 批量操作样式 ==================== */
.batch-action-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--primary-light);
  border-radius: 8px;
  margin-bottom: 12px;
}

.batch-action-bar span {
  flex: 1;
  font-size: 14px;
  color: var(--primary);
  font-weight: 500;
}

.card.batch-selectable {
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
}

.card.batch-selectable:hover {
  box-shadow: 0 4px 16px rgba(74, 144, 217, 0.15);
}

.card.batch-selected {
  background: var(--primary-light);
  border: 2px solid var(--primary);
}

.batch-checkbox {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
  transition: all 0.2s;
}

.card.batch-selected .batch-checkbox {
  background: var(--primary);
  border-color: var(--primary);
}

/* ==================== 多选日期样式 ==================== */
.multi-date-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.multi-date-nav button {
  background: var(--primary-light);
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  color: var(--primary);
  cursor: pointer;
}

.multi-date-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.multi-date-weekdays span {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 6px 0;
}

.multi-date-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.multi-date-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  background: var(--bg);
  transition: all 0.2s;
}

.multi-date-day:hover {
  background: var(--primary-light);
}

.multi-date-day.selected {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.multi-date-day.other-month {
  color: var(--text-secondary);
  opacity: 0.4;
}

/* ==================== 收费管理样式 ==================== */
.charge-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
}

.charge-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.charge-student {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.charge-month {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.charge-amount {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.charge-details {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.charge-detail-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.charge-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.paid-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.paid-badge.paid {
  background: var(--success-light);
  color: var(--success);
}

.paid-badge.unpaid {
  background: var(--warning-light);
  color: var(--warning);
}

/* ==================== 版本管理样式 ==================== */
.version-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}

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

.version-number {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
}

.version-date {
  font-size: 12px;
  color: var(--text-secondary);
}

.version-changelog {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

/* ==================== 响应式调整 ==================== */
@media (max-width: 480px) {
  .week-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .week-day {
    min-height: 100px;
  }
  
  .week-day-date {
    font-size: 16px;
  }
  
  .week-schedule-item {
    font-size: 10px;
    padding: 4px;
  }
}
