/* R127 班级考勤签到 style.css */

:root {
  --brand: #2563EB;
  --brand-dark: #1D4ED8;
  --brand-light: #DBEAFE;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --text: #0F172A;
  --muted: #64748B;
  --present: #16A34A;
  --late: #F59E0B;
  --absent: #DC2626;
  --leave: #6B7280;
  --absent-bg: #FEE2E2;
  --contact-footer-h: 72px;
  --radius: 12px;
  --shadow: 0 4px 12px rgba(15,23,42,0.08);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
body.has-contact-footer { padding-bottom: calc(var(--contact-footer-h) + env(safe-area-inset-bottom)); }
body.has-contact-footer .zw-root .zw-fab { bottom: calc(var(--contact-footer-h) + 12px + env(safe-area-inset-bottom)); }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

.skeleton { padding: 16px; }
.sk-bar { height: 48px; background: #e2e8f0; border-radius: 8px; margin-bottom: 12px; animation: shimmer 1.2s infinite; }
.sk-card { height: 120px; background: #e2e8f0; border-radius: 12px; margin-bottom: 10px; animation: shimmer 1.2s infinite; }
@keyframes shimmer { 0% { opacity: 0.6; } 50% { opacity: 1; } 100% { opacity: 0.6; } }

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--brand); color: #fff;
}
.app-header h1 { margin: 0; font-size: 1.1rem; }
.role-switch { display: flex; gap: 4px; background: rgba(255,255,255,0.2); border-radius: 999px; padding: 3px; }
.role-btn { padding: 6px 12px; border-radius: 999px; font-size: 0.8rem; color: #fff; opacity: 0.85; }
.role-btn:hover { background: rgba(255,255,255,0.15); }

.tab-nav { display: flex; background: var(--card); border-bottom: 1px solid var(--brand-light); position: sticky; top: 0; z-index: 20; }
.tab-btn { flex: 1; padding: 12px 8px; font-size: 0.9rem; color: var(--muted); border-bottom: 2px solid transparent; }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.tab-content { display: none; padding: 16px; padding-bottom: 88px; animation: fadeInUp 0.35s ease; }
.tab-content.active { display: block; }
#teacher-view .tab-content { max-width: 720px; margin: 0 auto; }

.section-title { margin: 20px 0 12px; font-size: 1rem; }
.section-sub { margin: 0 0 10px; font-size: 0.95rem; color: var(--muted); }
.toolbar-row, .class-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.select-input, .code-input {
  width: 100%; padding: 12px; border: 1px solid var(--brand-light); border-radius: var(--radius);
  font-size: 1rem; background: var(--card); margin-bottom: 10px;
}
.code-input { font-size: 1.5rem; letter-spacing: 0.3em; text-align: center; font-weight: 700; }

.mode-selector { display: flex; gap: 8px; margin-bottom: 16px; }
.mode-btn { flex: 1; padding: 10px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--brand-light); color: var(--muted); }
.mode-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.qr-box { text-align: center; background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.qr-box canvas { border-radius: 8px; }
.qr-countdown { position: relative; width: 64px; height: 64px; margin: 12px auto 0; }
.qr-countdown svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.qr-countdown span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.ring-bg { fill: none; stroke: var(--brand-light); stroke-width: 8; }
.ring-fg { fill: none; stroke: var(--brand); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 0.3s; }
.btn-text { color: var(--brand); font-size: 0.9rem; margin-top: 8px; }

.code-box { text-align: center; background: var(--card); padding: 24px; border-radius: var(--radius); margin-bottom: 16px; }
.sign-code { font-size: 2.5rem; font-weight: 800; letter-spacing: 0.2em; color: var(--brand); }

.roster-table { display: flex; flex-direction: column; gap: 8px; }
.roster-row {
  display: flex; align-items: center; gap: 12px; background: var(--card); padding: 12px 14px;
  border-radius: var(--radius); box-shadow: var(--shadow); position: relative;
}
.roster-row.blink-absent { animation: breathe 2s infinite; }
.stu-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand-light); color: var(--brand);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.stu-info { flex: 1; display: flex; flex-direction: column; }
.stu-status { font-size: 0.8rem; font-weight: 600; }
.stu-actions { display: flex; gap: 6px; }
.stu-actions button { padding: 4px 8px; font-size: 0.75rem; background: var(--brand-light); color: var(--brand); border-radius: 6px; }

.stat-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 16px; text-align: center; box-shadow: var(--shadow);
}
.stat-card .stat-num { display: block; font-size: 1.75rem; font-weight: 800; color: var(--brand); }
.stat-card.warn .stat-num { color: var(--absent); }

.progress-rings { margin-bottom: 20px; }
.ring-card { display: flex; align-items: center; gap: 16px; background: var(--card); padding: 16px; border-radius: var(--radius); }
.ring-card svg { width: 100px; height: 100px; flex-shrink: 0; }
.ring-rate { font-size: 1.5rem; font-weight: 800; color: var(--brand); display: block; }

.heatmap-wrap { overflow-x: auto; margin-bottom: 20px; }
.heatmap-grid { display: grid; gap: 3px; min-width: 600px; font-size: 0.65rem; }
.hm-corner, .hm-head, .hm-name, .hm-cell { padding: 4px; text-align: center; }
.hm-name { text-align: left; font-weight: 600; }
.hm-cell { border-radius: 3px; min-height: 18px; }
.hm-cell.level-high { background: #16A34A; }
.hm-cell.level-mid { background: #9CA3AF; }
.hm-cell.level-low { background: #FCA5A5; }
.hm-cell.level-none { background: #E5E7EB; }
.hm-head { color: var(--muted); }

.trend-wrap { margin-bottom: 16px; background: var(--card); padding: 12px; border-radius: var(--radius); }
.trend-svg { width: 100%; height: auto; }
.trend-labels { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--muted); margin-top: 8px; text-align: center; }

.semester-box, .weekly-box { background: var(--card); padding: 14px; border-radius: var(--radius); margin-bottom: 12px; font-size: 0.9rem; }
.reason-pie { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.pie-tag { padding: 6px 10px; border-radius: 999px; border: 2px solid; font-size: 0.8rem; background: var(--card); }

.schedule-timeline { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.schedule-block { background: var(--brand-light); color: var(--brand-dark); padding: 10px 14px; border-radius: var(--radius); font-size: 0.85rem; }
.sb-name { font-weight: 700; margin-right: 6px; }

.leave-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.leave-card {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--card); padding: 14px; border-radius: var(--radius); box-shadow: var(--shadow);
  animation: fadeInUp 0.3s ease;
}
.leave-meta { font-size: 0.8rem; color: var(--muted); }
.leave-btns { display: flex; flex-direction: column; gap: 6px; }
.leave-btns button { padding: 6px 12px; border-radius: 8px; background: var(--present); color: #fff; font-size: 0.8rem; }
.leave-btns .reject { background: var(--absent); }

.notification-list { margin-top: 16px; }
.ntf-item { padding: 10px; background: var(--card); border-left: 3px solid var(--brand); margin-bottom: 6px; font-size: 0.85rem; border-radius: 0 8px 8px 0; }

.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--contact-footer-h) + env(safe-area-inset-bottom));
  display: flex; gap: 8px; padding: 10px 16px; background: var(--card); box-shadow: 0 -2px 10px rgba(0,0,0,0.08); z-index: 30;
}
.bottom-bar button { flex: 1; padding: 12px; border-radius: var(--radius); background: var(--brand-light); color: var(--brand); font-weight: 600; }
.bottom-primary { flex: 2 !important; background: var(--brand) !important; color: #fff !important; }

.student-hero { background: var(--brand); color: #fff; padding: 20px 16px; border-radius: 0 0 var(--radius) var(--radius); margin: -0px -0px 16px; }
.student-form, .leave-form { padding: 0 16px 16px; max-width: 480px; margin: 0 auto; }
.session-code { margin-top: 8px; font-size: 0.95rem; }
.success-banner { margin: 12px 16px; padding: 14px; background: #DCFCE7; color: #166534; border-radius: var(--radius); text-align: center; font-weight: 700; animation: bounceIn 0.5s ease; }
.student-history { padding: 0 16px; max-width: 480px; margin: 0 auto 20px; }
.hist-item { display: flex; justify-content: space-between; padding: 10px; background: var(--card); border-radius: 8px; margin-bottom: 6px; font-size: 0.9rem; }

.btn-primary-block, .btn-outline-block, .btn-outline-sm {
  display: block; width: 100%; padding: 14px; border-radius: var(--radius); font-weight: 600; font-size: 1rem; margin-bottom: 10px;
}
.btn-primary-block { background: var(--brand); color: #fff; }
.btn-outline-block { background: var(--card); color: var(--brand); border: 1px solid var(--brand); }
.btn-outline-sm { width: auto; padding: 8px 14px; font-size: 0.85rem; background: var(--brand-light); color: var(--brand); }

.empty-tip { text-align: center; color: var(--muted); padding: 24px; font-size: 0.9rem; }

.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.5); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--card); border-radius: var(--radius); padding: 24px; max-width: 400px; width: 100%; max-height: 85vh; overflow-y: auto; position: relative; }
.modal-close { position: absolute; top: 8px; right: 12px; font-size: 1.5rem; color: var(--muted); }
.modal-hint { font-size: 0.8rem; color: var(--muted); margin-top: 10px; }
.auth-modal input { width: 100%; padding: 12px; margin-bottom: 12px; border: 1px solid #ddd; border-radius: 8px; }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-list li { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; padding: 10px 0; border-bottom: 1px solid #eee; font-size: 0.85rem; }
.history-sub { color: var(--muted); margin: 0 0 12px; }

#toast-container { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 300; pointer-events: none; }
.toast-item { background: #0F172A; color: #fff; padding: 10px 18px; border-radius: 8px; margin-bottom: 8px; animation: slideDown 0.3s ease; font-size: 0.9rem; }
.toast-item.toast-out { animation: slideUp 0.3s ease forwards; }
.toast-success { background: #166534; }
.toast-error { background: #991B1B; }
.toast-warn { background: #92400E; }

.contact-footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 100; background: #fff; border-top: 1px solid #eee; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
.contact-footer__btns { display: flex; gap: 8px; justify-content: center; }
.contact-footer__cta, .contact-footer__btn { flex: 1; max-width: 120px; text-align: center; padding: 8px 6px; border-radius: 8px; font-size: 0.8rem; font-weight: 600; }
.contact-footer__cta { background: #E53E3E; color: #fff; }
.contact-footer__btn { background: #f5f5f5; color: #333; }
.contact-footer__brand { margin: 6px 0 0; text-align: center; font-size: 0.65rem; color: #999; }

.share-page .share-main { max-width: 480px; margin: 0 auto; padding: 24px 16px; }
.share-hero { text-align: center; padding: 28px 16px; border-radius: var(--radius); color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); margin-bottom: 20px; }
.share-cta { display: block; text-align: center; padding: 14px; background: var(--brand); color: #fff !important; border-radius: var(--radius); font-weight: 700; margin: 16px 0; }

@keyframes bounceIn { 0% { transform: scale(0); opacity: 0; } 50% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }
@keyframes shake { 10%,90% { transform: translateX(-4px); } 20%,80% { transform: translateX(4px); } 30%,50%,70% { transform: translateX(-6px); } 40%,60% { transform: translateX(6px); } }
.shake { animation: shake 0.4s; }
@keyframes breathe { 0%,100% { background-color: transparent; } 50% { background-color: var(--absent-bg); } }
@keyframes slideDown { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideUp { from { opacity: 1; } to { transform: translateY(-20px); opacity: 0; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (min-width: 768px) {
  .stat-cards { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
