/* ==========================================================================
   LMS additions: accounts, progress, admin dashboard. Builds on styles.css.
   ========================================================================== */

/* ---------------------------------------------------------------- header */

.main-nav { display: flex; align-items: center; gap: 22px; }
.header-link.is-current { color: var(--navy); box-shadow: inset 0 -3px 0 var(--sky); }
.linklike { background: none; border: 0; padding: 0; color: var(--navy); cursor: pointer; font: inherit; text-decoration: underline; }
.header-link.linklike { text-decoration: none; }

.user-menu { position: relative; margin-left: 6px; }
.user-menu summary {
  list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 6px 10px 6px 6px; border-radius: 999px; color: var(--navy);
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover, .user-menu[open] summary { background: var(--page); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: var(--white);
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.user-name { font-size: 15px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; min-width: 240px;
  background: var(--white); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 14px 40px rgba(17, 20, 24, 0.14); padding: 8px; display: grid;
}
.user-menu-email { margin: 6px 10px 8px; font-size: 13px; color: var(--ink-3); word-break: break-all; }
.user-menu-panel a, .user-menu-panel button {
  display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 8px;
  color: var(--ink); text-decoration: none; background: none; border: 0; font-size: 15px;
}
.user-menu-panel a:hover, .user-menu-panel button:hover { background: var(--page); }

/* ---------------------------------------------------------------- flash messages */

.flash-wrap { max-width: 1480px; margin: 16px auto 0; padding: 0 32px; display: grid; gap: 8px; }
.auth-page .flash-wrap { max-width: 520px; }
.flash {
  margin: 0; padding: 12px 16px; border-radius: 10px; background: #e8f1f7; color: var(--navy-deep);
  border-left: 4px solid var(--sky); font-size: 15px;
}
.flash-success { background: #ecf4ec; color: #2f5a2f; border-color: var(--green); }
.flash-warning { background: #fff6e5; color: #6b4a00; border-color: #e0a100; }
.flash-error { background: #fdecec; color: #8a1014; border-color: var(--red); }

/* ---------------------------------------------------------------- buttons & forms */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px; border-radius: 10px; border: 2px solid var(--navy);
  background: var(--navy); color: var(--white); text-decoration: none; font-weight: 700; font-size: 15px;
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--navy-deep); border-color: var(--navy-deep); }
.btn-quiet { background: var(--white); color: var(--navy); border-color: var(--line); }
.btn-quiet:hover { background: var(--page); border-color: var(--sky); }
.btn-danger { background: var(--white); color: var(--red); border-color: #f0c4c6; }
.btn-danger:hover { background: #fdecec; border-color: var(--red); }
.btn-small { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.btn-wide { width: 100%; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-group { display: flex; flex-wrap: wrap; gap: 10px; }

.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; margin: 0; border: 0; padding: 0; min-width: 0; }
.field label, .field legend { font-size: 14px; color: var(--ink-2); font-weight: 700; }
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .field select, .field textarea,
.filters input, .filters select, .danger-zone input {
  width: 100%; min-height: 46px; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--white); font-weight: 600; font-size: 16px;
}
.field textarea { min-height: 0; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus, .filters input:focus, .filters select:focus {
  outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(94, 159, 191, 0.25);
}
.field input[disabled] { background: var(--page); color: var(--ink-3); }
.field-check { display: flex; align-items: center; gap: 10px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; color: var(--ink); }
.field-help { margin: 0; font-size: 13px; color: var(--ink-3); font-weight: 400; }
.field-error { margin: 0; font-size: 14px; color: var(--red); }
.has-error input, .has-error textarea { border-color: var(--red) !important; }
.form-error { background: #fdecec; color: #8a1014; border-radius: 10px; padding: 10px 14px; font-size: 15px; }
.form-error p { margin: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.code-input { font-size: 24px !important; letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---------------------------------------------------------------- sign-in pages */

.auth-page { background: var(--page); }
.auth-page .site-header .brand-series, .auth-page .site-header .brand-divider { display: none; }
.auth-main { min-height: calc(100vh - var(--header-h) - 60px); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 16px 64px; }
.auth-card {
  width: min(460px, 100%); background: var(--white); border-radius: 18px; padding: 36px 36px 30px;
  box-shadow: 0 1px 2px rgba(17, 20, 24, 0.05), 0 18px 50px rgba(31, 78, 140, 0.10);
}
.auth-card-wide { width: min(640px, 100%); }
.auth-title { font-size: 44px; color: var(--navy); margin: 0 0 8px; }
.auth-subtitle { font-size: 26px; color: var(--navy); margin: 20px 0 8px; }
.auth-text { margin: 0 0 20px; color: var(--ink-2); font-weight: 400; font-size: 16px; }
.auth-text.small { font-size: 14px; }
.auth-foot { margin: 18px 0 0; text-align: center; font-size: 15px; }
.auth-note { text-align: center; color: var(--ink-3); font-size: 14px; font-weight: 400; max-width: 420px; margin: 18px auto 0; }
.rule { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

.setup-steps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 26px; counter-reset: step; }
.setup-steps li {
  flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700;
}
.setup-steps li::before { content: ""; height: 4px; border-radius: 2px; background: var(--line); }
.setup-steps li span { display: none; }
.setup-steps .is-current { color: var(--navy); }
.setup-steps .is-current::before { background: var(--sky); }
.setup-steps .is-done { color: var(--green); }
.setup-steps .is-done::before { background: var(--green); }

.howto { margin: 0 0 20px; padding-left: 22px; color: var(--ink-2); font-weight: 400; display: grid; gap: 6px; }
.howto strong { font-weight: 700; color: var(--ink); }
.totp-setup { display: grid; grid-template-columns: 200px 1fr; gap: 28px; align-items: start; }
.qr { width: 200px; height: 200px; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: var(--white); }
.secret summary { cursor: pointer; font-size: 14px; color: var(--navy); }
.secret code { display: block; margin-top: 8px; padding: 10px 12px; background: var(--page); border-radius: 8px; word-break: break-all; font-size: 14px; }
.recovery-codes {
  list-style: none; padding: 18px; margin: 0 0 12px; background: var(--page); border-radius: 12px;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 24px; font-size: 18px; letter-spacing: 0.06em;
}

.choice-list { display: grid; gap: 10px; }
.choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 16px 18px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--white); text-align: left;
}
.choice:hover { border-color: var(--sky); background: var(--page); }
.choice .display { font-size: 28px; color: var(--navy); }
.choice small { color: var(--ink-3); }

/* ---------------------------------------------------------------- generic pages */

.page { max-width: 1480px; margin: 0 auto; padding: 32px 32px 80px; }
.page.narrow { max-width: 760px; }
.page-head { margin-bottom: 20px; }
.page-head.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.page-title { font-size: clamp(38px, 4vw, 54px); color: var(--navy); margin: 0 0 6px; }
.grow { flex: 1; }
.muted { color: var(--ink-3); font-weight: 400; }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.crumbs { margin: 0 0 8px; font-size: 14px; }
.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

.panel {
  background: var(--white); border-radius: var(--radius); padding: 22px 24px; margin: 0 0 20px;
  border: 1px solid var(--line);
}
.panel-title { font-size: 26px; color: var(--navy); margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
.panel > p { margin: 0 0 10px; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.two-col > .panel { margin: 0; }
.two-col + .panel, .two-col + section { margin-top: 20px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 22px; margin: 0 0 10px; }
.facts dt { color: var(--ink-3); font-weight: 600; }
.facts dd { margin: 0; }

.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: var(--page); color: var(--ink-2); white-space: nowrap;
  border: 1px solid var(--line);
}
.tag-green { background: #ecf4ec; color: #2f5a2f; border-color: #cfe2cf; }
.tag-sky { background: #e8f1f7; color: var(--navy-deep); border-color: #cfe1ec; }
.tag-red { background: #fdecec; color: #8a1014; border-color: #f5cfd0; }
.tag-soon { background: transparent; color: var(--ink-3); border-style: dashed; }

/* ---------------------------------------------------------------- course status */

.course-status {
  display: flex; align-items: center; gap: 22px; background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 22px; margin: 0 0 28px;
}
.cs-meter {
  --pct: 0%; flex: none; width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--green) var(--pct), var(--line) 0);
  position: relative;
}
.cs-meter::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--white); }
.cs-meter span { position: relative; font-weight: 700; color: var(--navy); font-size: 17px; }
.cs-text { flex: 1; min-width: 0; }
.cs-line { margin: 0; font-size: 28px; color: var(--navy); }
.cs-sub { margin: 4px 0 0; color: var(--ink-2); font-weight: 400; }
.course-status.is-complete { border-color: #cfe2cf; background: linear-gradient(90deg, #f4f9f4, var(--white)); }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 20px; }
.panel .table-wrap { border: 0; margin: 0 -8px; }
table.data { width: 100%; border-collapse: collapse; font-size: 15px; }
.data th, .data td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data thead th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); background: #fafbfc; position: sticky; top: 0; }
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr:hover td { background: #fafbfc; }
.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data a { font-weight: 700; text-decoration: none; }
.data a:hover { text-decoration: underline; }
.group-row th { background: var(--page); color: var(--navy); font-size: 20px; padding-top: 14px; padding-bottom: 8px; }
.lesson-num { display: inline-block; min-width: 42px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.state-soon td { color: var(--ink-3); }
.is-idle td { color: var(--ink-3); }

.bar { --pct: 0%; display: inline-block; width: 110px; height: 8px; border-radius: 4px; background: var(--line); vertical-align: middle; overflow: hidden; }
.bar i { display: block; height: 100%; width: var(--pct); background: var(--sky); border-radius: 4px; }
.state-done .bar i { background: var(--green); }
.bar-num { margin-left: 8px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.curve { display: inline-flex; align-items: flex-end; gap: 2px; height: 30px; width: 160px; }
.curve i { --h: 0%; flex: 1; height: max(2px, var(--h)); background: var(--sky); border-radius: 2px 2px 0 0; }

/* ---------------------------------------------------------------- dashboard */

.dash-nav {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0 0 26px; padding: 6px;
  background: var(--white); border: 1px solid var(--line); border-radius: 12px;
}
.dash-nav > a:not(.btn) { padding: 8px 14px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-weight: 700; font-size: 15px; }
.dash-nav > a:not(.btn):hover { background: var(--page); }
.dash-nav > a.is-current { background: var(--navy); color: var(--white); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 0 0 22px; }
.stat {
  display: flex; flex-direction: column; gap: 2px; padding: 18px 20px; background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius); text-decoration: none; color: inherit;
}
a.stat:hover { border-color: var(--sky); }
.stat b { font-family: var(--font-display); font-weight: 400; font-size: 52px; line-height: 1; color: var(--navy); }
.stat span { color: var(--ink-2); }
.stat small { color: var(--ink-3); font-weight: 400; font-size: 13px; }

.feed { list-style: none; margin: 0; padding: 0; display: grid; }
.feed li { padding: 9px 0; border-bottom: 1px solid var(--line); line-height: 1.4; }
.feed li:last-child { border-bottom: 0; }
.feed a { font-weight: 700; text-decoration: none; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 16px; }
.filters input { flex: 1 1 260px; width: auto; }
.filters select { width: auto; flex: 0 1 auto; }

.pager { display: flex; gap: 18px; justify-content: center; align-items: center; margin: 10px 0; }

.result-panel { border-color: #cfe1ec; }
.narrow-form { max-width: 620px; }
.manage-grid { display: grid; grid-template-columns: minmax(280px, 1fr) 1fr; gap: 32px; }
.action-list { display: grid; gap: 14px; align-content: start; }
.action-list form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.danger-zone { border-top: 1px solid var(--line); padding-top: 12px; }
.danger-zone summary { cursor: pointer; color: var(--red); font-size: 14px; }
.danger-zone form { display: grid !important; gap: 10px; margin-top: 10px; max-width: 420px; }

.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(103, 153, 103, 0.6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(103, 153, 103, 0); } 100% { box-shadow: 0 0 0 0 rgba(103, 153, 103, 0); } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* ---------------------------------------------------------------- small screens */

@media (max-width: 1100px) {
  .main-nav { gap: 14px; }
  .main-nav .header-link { font-size: 19px; }
  .user-name { display: none; }
}
@media (max-width: 899px) {
  .site-header { height: auto; min-height: var(--header-h); flex-wrap: wrap; padding: 12px 16px 16px; gap: 10px 16px; }
  .brand-logo { height: 40px; }
  .brand-divider, .brand-series { display: none; }
  .main-nav { order: 3; width: 100%; overflow-x: auto; gap: 18px; }
  .page, .flash-wrap { padding-left: 16px; padding-right: 16px; }
  .two-col, .manage-grid, .totp-setup, .field-row { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 22px 24px; }
  .auth-title { font-size: 38px; }
  .qr { margin: 0 auto; }
  .course-status { flex-wrap: wrap; }
  .cs-cert { width: 100%; }
  .data th, .data td { padding: 10px 12px; }
  .recovery-codes { grid-template-columns: 1fr; }
}
