/* =====================================================
   T-Endless 学习打卡系统 · 样式表
   ===================================================== */

:root {
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-dark: #1d4ed8;
  --text: #1e293b;
  --text-sub: #64748b;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --white: #ffffff;
  --success: #16a34a;
  --error: #dc2626;
  --warning: #d97706;
  --heat0: #f1f5f9;
  --heat1: #bfdbfe;
  --heat2: #60a5fa;
  --heat3: #2563eb;
  --heat4: #1e3a8a;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 900px; margin: 0 auto; padding: 0 20px; }
.section { padding: 40px 0 60px; }

/* ---- Header ---- */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.header-inner { display: flex; align-items: center; gap: 24px; height: 56px; }
.logo { font-weight: 700; font-size: 1.1rem; color: var(--text); flex-shrink: 0; }
.nav-links { display: flex; gap: 20px; flex: 1; }
.nav-links a { color: var(--text-sub); font-size: .93rem; transition: color .2s; }
.nav-links a:hover, .nav-links a.active { color: var(--primary); text-decoration: none; }
.header-auth { display: flex; gap: 8px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 18px; border-radius: 6px; font-size: .9rem; font-weight: 500;
  cursor: pointer; border: 1.5px solid transparent; transition: all .18s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-sm { padding: 5px 12px; font-size: .82rem; }
.btn-block { width: 100%; margin-top: 4px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Hero ---- */
.hero { text-align: center; padding: 60px 0 50px; }
.hero-title { font-size: 2.2rem; font-weight: 700; margin-bottom: 12px; }
.hero-sub { color: var(--text-sub); font-size: 1.05rem; margin-bottom: 32px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---- Section Title ---- */
.section-title {
  font-size: 1.25rem; font-weight: 700;
  margin-bottom: 20px; padding-bottom: 10px;
  border-bottom: 2px solid var(--primary-light);
}
.section-title .sub { font-size: .85rem; font-weight: 400; color: var(--text-sub); }

/* ---- Level Cards ---- */
.level-intro { margin-bottom: 48px; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; }
.level-card {
  background: var(--white); border: 1px solid var(--border); border-radius: 10px;
  padding: 18px 12px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: box-shadow .2s;
}
.level-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.level-card.highlight { border-color: #0369a1; box-shadow: 0 0 0 2px rgba(3,105,161,.15); }

/* ---- Level Badge Circles ---- */
.lv-badge {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-block; vertical-align: middle;
  box-shadow: inset 0 2px 4px rgba(255,255,255,.4), 0 2px 6px rgba(0,0,0,.1);
  transition: transform .2s;
}
.lv-badge.lv1 { background: #e2e8f0; }
.lv-badge.lv2 { background: #bae6fd; }
.lv-badge.lv3 { background: #7dd3fc; }
.lv-badge.lv4 { background: #38bdf8; }
.lv-badge.lv5 { background: #0ea5e9; }
.lv-badge.lv6 { background: #0369a1; }
/* Also add a subtle inner glow for deeper colors */
.lv-badge.lv5,
.lv-badge.lv6 { box-shadow: inset 0 2px 6px rgba(255,255,255,.3), 0 2px 8px rgba(14,165,233,.25); }

/* In level cards, make badge slightly larger */
.level-card .lv-badge { width: 42px; height: 42px; margin-bottom: 4px; }
.level-card:hover .lv-badge { transform: scale(1.1); }
.level-badge { font-size: 1.8rem; }
.level-badge { font-size: 1.8rem; }
.level-card strong { font-size: .92rem; }
.level-range { font-size: .8rem; color: var(--text-sub); }

/* ---- User Dashboard ---- */
.user-dashboard { margin-bottom: 36px; }
.user-card {
  background: var(--white); border: 1px solid var(--border); border-radius: 12px;
  padding: 22px 24px; display: flex; align-items: center; gap: 18px; margin-bottom: 14px;
}
.user-avatar {
  width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: #fff;
  font-size: 1.4rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-info { flex: 1; }
.user-info h2 { font-size: 1.15rem; margin-bottom: 4px; }
.user-level { font-size: .9rem; color: var(--primary); font-weight: 600; margin-bottom: 6px; }
.user-stats { font-size: .85rem; color: var(--text-sub); display: flex; gap: 8px; flex-wrap: wrap; }
.user-stats strong { color: var(--text); font-weight: 600; }

/* ---- Level Progress ---- */
.level-progress-wrap {
  background: var(--white); border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px;
}
.level-progress-labels { display: flex; justify-content: space-between; font-size: .85rem; color: var(--text-sub); margin-bottom: 8px; }
.level-progress-bar { height: 10px; background: var(--border); border-radius: 99px; overflow: hidden; margin-bottom: 6px; }
.level-progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--primary), #60a5fa);
  border-radius: 99px; transition: width .6s ease;
}
.level-progress-hint { font-size: .82rem; color: var(--text-sub); text-align: right; }

/* ---- Checkin Card ---- */
.checkin-section { margin-bottom: 40px; }
.checkin-card { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 28px; }
.checkin-date { font-size: .9rem; color: var(--text-sub); margin-bottom: 18px; }
.input-label { display: block; font-size: .88rem; font-weight: 500; margin-bottom: 6px; }
.input-field {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 7px;
  font-size: .95rem; color: var(--text); background: var(--white); outline: none; transition: border-color .18s;
}
.input-field:focus { border-color: var(--primary); }
.textarea { min-height: 90px; resize: vertical; }
.input-row { display: flex; gap: 10px; margin-bottom: 12px; }
.input-row .input-field { flex: 1; }
.quick-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.quick-btn {
  padding: 5px 14px; border: 1.5px solid var(--border); border-radius: 20px;
  background: transparent; color: var(--text-sub); font-size: .84rem; cursor: pointer; transition: all .18s;
}
.quick-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.checkin-note-wrap { margin-top: 4px; }
.checkin-done { text-align: center; padding: 30px 20px; }
.done-icon { font-size: 2.8rem; margin-bottom: 10px; }
.checkin-done p { color: var(--text-sub); }
.done-sub { font-size: 1rem; margin-top: 6px; }
.done-sub strong { color: var(--success); }
.done-note { font-size: .88rem; margin-top: 8px; max-width: 400px; margin-left: auto; margin-right: auto; font-style: italic; }

/* ---- Calendar ---- */
.calendar-section { margin-bottom: 40px; }
.calendar-nav { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.calendar-nav span { font-weight: 600; flex: 1; text-align: center; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-header { text-align: center; font-size: .75rem; color: var(--text-sub); padding: 4px; font-weight: 500; }
.cal-day {
  aspect-ratio: 1; border-radius: 4px; background: var(--heat0);
  cursor: pointer; transition: transform .15s;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; color: var(--text-sub); position: relative;
}
.cal-day:hover { transform: scale(1.12); z-index: 1; }
.cal-day.cal-0 { background: var(--heat0); }
.cal-day.cal-1 { background: var(--heat1); color: #1e40af; }
.cal-day.cal-2 { background: var(--heat2); color: #fff; }
.cal-day.cal-3 { background: var(--heat3); color: #fff; }
.cal-day.cal-4 { background: var(--heat4); color: #fff; }
.cal-day.cal-empty { background: transparent; cursor: default; }
.cal-day.cal-today { outline: 2px solid var(--primary); outline-offset: 1px; }
.calendar-legend { display: flex; gap: 14px; margin-top: 10px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--text-sub); }
.legend-item .cal-day { width: 16px; height: 16px; aspect-ratio: 1; font-size: 0; }

/* ---- Leaderboard ---- */
.leaderboard-section { margin-bottom: 40px; }
.lb-table-wrap { background: var(--white); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th { background: var(--bg); font-size: .82rem; font-weight: 600; color: var(--text-sub); padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.lb-table td { padding: 12px 16px; font-size: .9rem; border-bottom: 1px solid var(--border); }
.lb-table tr:last-child td { border-bottom: none; }
.lb-table tr:hover td { background: var(--bg); }
.lb-table .lb-rank { font-weight: 700; color: var(--text-sub); width: 40px; }
.lb-table .rank-1 { color: #ca8a04; font-size: 1.1rem; }
.lb-table .rank-2 { color: #94a3b8; font-size: 1.05rem; }
.lb-table .rank-3 { color: #92400e; font-size: 1rem; }
.lb-loading { text-align: center; color: var(--text-sub); font-size: .88rem; padding: 24px; }
.lb-me td { background: var(--primary-light) !important; }

/* ---- History ---- */
.history-section { margin-bottom: 40px; }
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  background: var(--white); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 18px; display: flex; align-items: center; gap: 14px;
}
.history-date { font-size: .88rem; font-weight: 600; color: var(--text-sub); width: 90px; flex-shrink: 0; }
.history-hours { font-size: .95rem; font-weight: 600; color: var(--primary); width: 80px; flex-shrink: 0; }
.history-note { font-size: .85rem; color: var(--text-sub); flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ---- Modals ---- */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 999; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white); border-radius: 14px; padding: 32px 28px;
  width: 100%; max-width: 420px; position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  animation: modalIn .22s ease;
}
.modal-sm { max-width: 360px; }
@keyframes modalIn { from { opacity: 0; transform: scale(.95) translateY(-10px); } to { opacity: 1; transform: none; } }
.modal-close {
  position: absolute; top: 14px; right: 14px; background: none;
  border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-sub); line-height: 1;
}
.modal-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 14px; }
.modal-hint { font-size: .88rem; color: var(--text-sub); margin-bottom: 14px; background: var(--bg); border-radius: 6px; padding: 8px 12px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: .88rem; font-weight: 500; margin-bottom: 5px; }
.form-error { background: #fef2f2; border: 1px solid #fecaca; color: var(--error); border-radius: 6px; padding: 8px 12px; font-size: .85rem; margin-bottom: 10px; }
.form-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: var(--success); border-radius: 6px; padding: 8px 12px; font-size: .85rem; margin-bottom: 10px; }
.modal-footer-text { text-align: center; font-size: .85rem; color: var(--text-sub); margin-top: 14px; }

/* ---- Footer ---- */
.site-footer { border-top: 1px solid var(--border); background: var(--white); padding: 20px 0; text-align: center; }
.site-footer p { font-size: .85rem; color: var(--text-sub); }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #1e293b; color: #fff; padding: 12px 24px; border-radius: 30px;
  font-size: .9rem; z-index: 9999; opacity: 0; transition: all .3s;
  white-space: nowrap; box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-error { background: var(--error); }
.toast.toast-success { background: var(--success); }

/* ---- Admin badge ---- */
.admin-badge { display: inline-block; background: #7c3aed; color: #fff; font-size: .7rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; margin-left: 6px; vertical-align: middle; }

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .hero-title { font-size: 1.6rem; }
  .user-card { flex-wrap: wrap; }
  .user-card .btn-sm { margin-left: auto; }
  .history-item { flex-wrap: wrap; }
  .lb-table th:nth-child(5), .lb-table td:nth-child(5) { display: none; }
}
