/* ===== 家长端样式 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #4A90D9;
  --primary-dark: #3A7BC8;
  --danger: #E74C3C;
  --success: #27AE60;
  --warning: #F39C12;
  --bg: #F5F7FA;
  --card-bg: #FFFFFF;
  --text: #2C3E50;
  --text-secondary: #7F8C8D;
  --border: #E0E6ED;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.page { display: none; }
.page.active { display: block; }

/* ===== 登录页 ===== */
.login-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: #F5F7FA;
}

.login-header {
  text-align: center;
  margin-bottom: 40px;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.login-logo img {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  color: #2C3E50;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 14px;
  color: #7F8C8D;
  margin-bottom: 8px;
}

.login-brand {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  color: var(--primary);
  background: #EBF3FC;
  padding: 4px 14px;
  border-radius: 20px;
  letter-spacing: 1px;
}

.login-form {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: var(--radius);
  padding: 32px 24px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.06);
  border-top: 3px solid var(--primary);
}

.input-group {
  margin-bottom: 20px;
}

.input-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.input-code {
  width: 100%;
  padding: 14px 16px;
  font-size: 24px;
  letter-spacing: 8px;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s;
  font-family: "Courier New", monospace;
}

.input-code:focus {
  border-color: var(--primary);
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: #FDF2F2;
  border-radius: var(--radius-sm);
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  outline: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
  padding: 14px;
  font-size: 16px;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-text {
  background: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
}

.btn-text:hover { color: var(--danger); }

.btn-icon {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  padding: 8px;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.btn-icon:hover { background: rgba(0,0,0,0.05); }

.icon-back { font-size: 22px; line-height: 1; }

/* ===== 主页面 ===== */
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

#headerTitle {
  font-size: 18px;
  font-weight: 600;
}

.view { display: none; }
.view.active { display: block; }

/* ===== 学生卡片 ===== */
.student-card {
  background: linear-gradient(135deg, #4A90D9 0%, #3A7BC8 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 24px;
  margin: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.student-name {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.student-class {
  font-size: 14px;
  opacity: 0.85;
  margin-bottom: 16px;
}

.student-points {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}

.points-value {
  font-size: 36px;
  font-weight: 700;
}

.points-label {
  font-size: 14px;
  opacity: 0.85;
}

/* ===== 菜单网格 ===== */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 0 16px 24px;
}

.menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.menu-item:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(74,144,217,0.15);
}

.menu-item:active { transform: scale(0.96); }
.menu-item.hidden { display: none; }

.menu-icon { font-size: 28px; }
.menu-text { font-size: 13px; font-weight: 500; color: var(--text); }

/* ===== 积分摘要 ===== */
.points-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  margin: 16px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.summary-label { font-size: 14px; color: var(--text-secondary); }
.summary-value { font-size: 28px; font-weight: 700; color: var(--primary); }

/* ===== 列表容器 ===== */
.list-container {
  padding: 0 16px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ===== 积分记录项 ===== */
.points-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.points-item-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.points-item-reason {
  font-size: 14px;
  font-weight: 500;
}

.points-item-time {
  font-size: 12px;
  color: var(--text-secondary);
}

.points-item-value {
  font-size: 18px;
  font-weight: 700;
}

.points-item-value.positive { color: var(--success); }
.points-item-value.negative { color: var(--danger); }

/* ===== 请假记录项 ===== */
.leave-item {
  padding: 14px 16px;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

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

.leave-item-type {
  font-size: 14px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.leave-item-type.morning {
  background: #FFF3E0;
  color: #E65100;
}

.leave-item-type.full_day {
  background: #FCE4EC;
  color: #C62828;
}

.leave-item-status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
}

.leave-item-status.approved {
  background: #E8F5E9;
  color: #2E7D32;
}

.leave-item-date {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ===== 留言板 ===== */
.message-item {
  padding: 14px 16px;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

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

.message-sender {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

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

.message-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 8px;
}

.message-reply {
  margin-top: 8px;
  padding: 10px 12px;
  background: #F0F7FF;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}

.message-reply-sender {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
}

.message-reply-content {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

.message-reply-time {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ===== 留言输入区 ===== */
.message-input-area {
  position: sticky;
  bottom: 0;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.message-textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  resize: none;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
}

.message-textarea:focus {
  border-color: var(--primary);
}

#btnSend {
  align-self: flex-end;
  width: auto;
  padding: 8px 24px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  animation: toastIn 0.3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.toast.success { background: #E8F5E9; color: #2E7D32; }
.toast.error { background: #FDF2F2; color: #C62828; }
.toast.info { background: #E3F2FD; color: #1565C0; }

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

/* ===== 响应式 ===== */
@media (min-width: 768px) {
  .login-form { max-width: 400px; }
  .menu-grid { max-width: 500px; margin: 0 auto; padding: 0 0 24px; }
  .student-card { max-width: 500px; margin: 16px auto; }
  .list-container { max-width: 500px; margin: 0 auto; }
  .points-summary { max-width: 500px; margin: 16px auto; }
  .message-input-area { max-width: 500px; margin: 0 auto; }
}