/*
 * home.css — Trang bài tập (lời chào, danh sách unit, bảng bài), trang hồ sơ, trang ôn tập, tự kiểm tra.
 */

/* ----- Lời chào ----- */
.hero { display: flex; align-items: center; justify-content: space-between; gap: 16px 20px; flex-wrap: wrap; margin-bottom: 18px; }
.hero h1 { margin-bottom: 2px; }
.hero p { margin: 0; }
.hero-text { flex: 1 1 320px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-actions .btn-primary { max-width: 100%; white-space: normal; text-align: left; }
.done-all { font-weight: 700; }

/* ----- Unit + bảng bài ----- */
.home-body { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
.unit-list { display: grid; gap: 6px; position: sticky; top: calc(var(--header-h) + 16px); max-height: calc(100vh - var(--header-h) - 32px); overflow-y: auto; padding-right: 4px; }
.unit-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid transparent; color: var(--text);
}
.unit-item:hover { background: var(--surface); text-decoration: none; border-color: var(--border); }
.unit-item.active { background: var(--surface); border-color: var(--primary); box-shadow: var(--shadow); }
.unit-meta { flex: 1; min-width: 0; display: grid; gap: 3px; }
.unit-meta b { font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unit-item.active .unit-num { background: var(--primary); color: var(--on-primary); }
.unit-item.complete .unit-num { background: var(--good-soft); color: var(--good); }
.unit-item.complete .unit-count { color: var(--good); }
.unit-count { font-size: 0.8rem; font-weight: 700; color: var(--muted); }

.problem-panel { padding: 0; overflow: hidden; }
.panel-head { padding: 18px 20px 12px; border-bottom: 1px solid var(--border); }
.panel-head p { margin: 0 0 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.problem-row {
  display: grid; grid-template-columns: 28px 50px minmax(0, 1fr) 130px 96px 80px; align-items: center; gap: 10px;
  padding: 11px 20px; color: var(--text); border-bottom: 1px solid var(--border);
}
.problem-row:nth-child(even) { background: var(--surface-2); }
.problem-row:hover { background: var(--primary-soft); text-decoration: none; }
.problem-row .num { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.problem-row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.problem-row .type { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.mastery { display: inline-flex; gap: 3px; align-items: center; }
.mastery i { width: 7px; height: 7px; border-radius: 50%; background: var(--surface-3); }
.mastery i.on { background: var(--easy); }
.mastery.done i.on { background: var(--medium); }

/* ----- Hồ sơ ----- */
.profiles-page { max-width: 760px; margin: 0 auto; text-align: center; }
.profiles-page .intro p { color: var(--muted); }
.profile-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin: 24px 0; }
.profile-card {
  width: 170px; display: grid; justify-items: center; gap: 4px; padding: 20px 12px; cursor: pointer;
  font: inherit; color: var(--text); background: var(--surface); border: 2px solid var(--border); border-radius: 18px;
  transition: transform 0.15s, border-color 0.15s;
}
.profile-card:hover { transform: translateY(-3px); border-color: var(--primary); text-decoration: none; }
.profile-card.current { border-color: var(--primary); }
.profile-card small { color: var(--muted); }
.profile-card.add { border-style: dashed; }
.profile-card .avatar-lg { margin-bottom: 6px; }
.profile-form { text-align: left; display: grid; gap: 16px; }
.field { display: grid; gap: 6px; font-weight: 600; }
.field input[type="text"], .field input:not([type]) , .field input[name="name"] {
  font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
}
.avatar-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.avatar-opt input, .tier-opt input { position: absolute; opacity: 0; pointer-events: none; }
.avatar-opt .avatar { width: 40px; height: 40px; font-size: 1.05rem; cursor: pointer; transition: box-shadow 0.15s; }
.avatar-opt input:checked + .avatar { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--text); }
.avatar-opt input:focus-visible + span, .tier-opt input:focus-visible + span { outline: 2px solid var(--primary); }
.tier-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tier-opt span {
  display: grid; gap: 4px; height: 100%; padding: 12px 14px; cursor: pointer; font-weight: 400;
  border-radius: 12px; border: 2px solid var(--border); background: var(--surface-2);
}
.tier-opt small { color: var(--muted); }
.tier-opt input:checked + span { border-color: var(--primary); background: var(--primary-soft); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ----- Ôn tập ----- */
.page-head { margin-bottom: 18px; }
.page-head p { max-width: 75ch; margin: 0; }
.review-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; align-items: start; }
.review-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.review-row small { display: block; }
.review-row:last-child { border-bottom: 0; }
.upcoming-day h4 { margin: 12px 0 2px; }
.box-chart { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; height: 180px; align-items: end; }
.box-col { display: grid; grid-template-rows: auto 1fr auto; justify-items: center; height: 100%; gap: 4px; text-align: center; }
.box-col small { color: var(--muted); font-size: 0.72rem; line-height: 1.2; }
.box-n { font-weight: 700; }
.box-bar { align-self: end; width: 70%; min-height: 3px; border-radius: 6px 6px 2px 2px; background: var(--primary); }
.box-bar.done { background: var(--medium); }

.selftest tr.bad td { color: var(--bad); }

@media (max-width: 900px) {
  .home-body { grid-template-columns: 1fr; }
  .unit-list { position: static; max-height: none; display: flex; overflow-x: auto; padding-bottom: 6px; }
  .unit-item { flex: 0 0 230px; background: var(--surface); border-color: var(--border); }
  .filters { gap: 6px; }
  .chip-group { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; padding-bottom: 2px; }
  .problem-row { grid-template-columns: 24px minmax(0, 1fr) auto auto; padding: 11px 14px; }
  .problem-row .num, .problem-row .mastery-cell { display: none; }
  .problem-row .type-text { display: none; }
  .tier-grid { grid-template-columns: 1fr; }
}
