/* ============================================================
   Vertex Academy — Parent Portal styles
   Mobile-first, brand tokens: blue #1f6dd6, gold #f5a623
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:       #1f6dd6;
  --blue-hover: #1856ad;
  --blue-light: #eaf2fd;
  --gold:       #f5a623;
  --gold-aa:    #ef9510;
  --text:       #1a2338;
  --muted:      #5a6a82;
  --border:     #dde3ec;
  --bg:         #f5f7fb;
  --card:       #ffffff;
  --radius:     12px;
  --shadow:     0 2px 8px rgba(30,50,90,.08);
  font-size: 15px;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

/* ---- Loading ---- */
.p-loading {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 14px;
  color: var(--muted);
}
.p-loading svg { display: block; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Login stage ---- */
.p-login-stage {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, #e9f1fc 0%, #f5f7fb 60%);
}
.p-login-card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(31,109,214,.10);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
}
.p-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  font-family: 'Fredoka', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--blue);
}
.p-login-card h1 {
  font-family: 'Fredoka', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.p-sub {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 24px;
}
.p-auth-msg {
  font-size: 13px;
  border-radius: 8px;
  margin-bottom: 12px;
  min-height: 0;
  transition: all .2s;
}
.p-auth-msg.error { background: #fdecea; color: #a32b1f; padding: 10px 12px; }
.p-auth-msg.ok    { background: #e7f6eb; color: #1a6932; padding: 10px 12px; }
.p-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.p-form label { font-size: 13px; font-weight: 600; color: var(--muted); }
.p-form input[type="email"] {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
.p-form input[type="email"]:focus { border-color: var(--blue); }
.p-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 14px;
  text-align: center;
  line-height: 1.5;
}

/* ---- Buttons ---- */
.p-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 20px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 9px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  width: 100%;
}
.p-btn:hover:not(:disabled) { background: var(--blue-hover); }
.p-btn:disabled { opacity: .55; cursor: not-allowed; }
.p-btn-ghost {
  background: transparent;
  color: var(--blue);
  border: 1.5px solid var(--border);
}
.p-btn-ghost:hover:not(:disabled) { background: var(--blue-light); }
.p-btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 7px;
  width: auto;
}
.p-link {
  background: none;
  border: none;
  color: var(--blue);
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  text-decoration: underline;
  padding: 0;
}
.p-icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,.8);
  display: flex;
  align-items: center;
  padding: 6px;
  border-radius: 6px;
  transition: color .15s;
}
.p-icon-btn:hover { color: #fff; }

/* ---- App shell ---- */
.p-app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
.p-header {
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 54px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(31,109,214,.25);
}
.p-header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Fredoka', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.p-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.p-student-name {
  font-size: 13px;
  opacity: .85;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.p-main {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 72px;
}

/* ---- Bottom tab nav ---- */
.p-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.p-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  font-family: inherit;
  font-weight: 500;
  padding: 4px 0 2px;
  transition: color .15s;
}
.p-tab.active { color: var(--blue); }
.p-tab svg { flex-shrink: 0; }

/* ---- Views ---- */
.p-view {
  padding: 20px 16px;
  max-width: 600px;
  margin: 0 auto;
}
.p-view h2 {
  font-family: 'Fredoka', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}
.p-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin: 20px 0 10px;
}

/* ---- Student picker ---- */
.p-student-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.p-pill {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.p-pill.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* ---- Welcome header ---- */
.p-welcome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.p-welcome h2 {
  font-family: 'Fredoka', sans-serif;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 2px;
}
.p-welcome p { font-size: 13px; color: var(--muted); }
.p-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--blue-light);
  color: var(--blue);
  display: grid;
  place-items: center;
  font-family: 'Fredoka', sans-serif;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---- Cards ---- */
.p-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.p-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 14px;
}
.p-card-row + .p-card-row { border-top: 1px solid var(--border); }
.p-label { color: var(--muted); font-size: 13px; }

/* ---- Badges ---- */
.p-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.p-badge.active  { background: #e7f6eb; color: #1a6932; }
.p-badge.paused  { background: #fdf6e0; color: #8a6100; }
.p-badge.cancelled { background: #f5f5f5; color: #666; }
.p-badge.paid    { background: #e7f6eb; color: #1a6932; }
.p-badge.pending { background: #fdf6e0; color: #8a6100; }
.p-badge.lost    { background: #fdecea; color: #a32b1f; }

/* ---- Session cards ---- */
.p-sessions-list { display: flex; flex-direction: column; gap: 10px; }
.p-session-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.p-session-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.p-session-subject {
  font-weight: 700;
  font-size: 15px;
  color: var(--blue);
}
.p-session-day {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.p-session-time {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 2px;
}
.p-session-year {
  font-size: 12px;
  color: var(--muted);
}
.p-session-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.p-spots {
  font-size: 12px;
  color: var(--muted);
}
.p-spots.full { color: #a32b1f; }

/* ---- Empty states ---- */
.p-empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: 14px;
}
.p-empty-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  border: 1.5px dashed var(--border);
}

/* ---- Attendance ---- */
.p-attend-list { display: flex; flex-direction: column; gap: 10px; }
.p-attend-row {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ---- Results ---- */
.p-result-card { margin-bottom: 16px; }
.p-score-row {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 0;
}
.p-score-big {
  font-family: 'Fredoka', sans-serif;
  font-size: 48px;
  font-weight: 700;
  color: var(--blue);
  line-height: 1;
}
.p-score-detail { font-size: 13px; color: var(--muted); }
.p-recommended {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.p-topics { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.p-topic-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 6px;
}
.p-topic-row span:first-child { width: 120px; flex-shrink: 0; color: var(--muted); }
.p-topic-row span:last-child  { width: 36px;  flex-shrink: 0; text-align: right; font-weight: 600; }
.p-topic-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.p-topic-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 4px;
  transition: width .4s ease;
}

/* ---- NZC progress (Progress tab) ---- */
.p-prog-row { margin-bottom: 14px; }
.p-prog-row:last-of-type { margin-bottom: 6px; }
.p-prog-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}
.p-prog-count { font-size: 12px; font-weight: 500; color: var(--muted); }
.p-prog-bar {
  display: flex;
  height: 8px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
}
.p-prog-fill { height: 100%; transition: width .4s ease; }
.p-prog-fill.secure  { background: #3bb55a; }
.p-prog-fill.working { background: var(--gold); }
.p-prog-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}
.p-prog-legend span { display: inline-flex; align-items: center; gap: 5px; }
.p-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.p-dot.secure  { background: #3bb55a; }
.p-dot.working { background: var(--gold); }
.p-prog-obj {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  line-height: 1.5;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.p-prog-obj:last-child { border-bottom: none; }
.p-note-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.p-note-row:last-child { border-bottom: none; }
.p-note-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
}
.p-note-author { font-size: 13px; font-weight: 700; color: var(--text); }
.p-note-body {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
}
.p-prog-tag {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--blue);
  background: var(--blue-light);
  border-radius: 6px;
  padding: 2px 8px;
  margin-top: 1px;
}
.p-attr { font-size: 11.5px; color: var(--muted); margin-top: 14px; }

/* ---- Desktop ---- */
@media (min-width: 640px) {
  .p-view { padding: 28px 24px; }
  .p-tabs {
    top: 54px;
    bottom: auto;
    height: 52px;
    border-top: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    background: var(--card);
  }
  .p-tab { flex-direction: row; gap: 6px; font-size: 13px; }
  .p-main { padding-bottom: 0; padding-top: 52px; }
}

/* ---- worksheets ---- */
.p-ws-intro {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}
.p-ws-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.p-ws-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow .18s, transform .18s;
}
.p-ws-card:hover {
  box-shadow: 0 4px 14px rgba(30,50,90,.14);
  transform: translateY(-1px);
}
.p-ws-icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--blue-light);
  color: var(--blue);
  display: grid;
  place-items: center;
}
.p-ws-body { flex: 1; min-width: 0; }
.p-ws-title { font-weight: 700; font-size: 14.5px; }
.p-ws-meta { font-size: 12.5px; color: var(--blue); font-weight: 600; margin-top: 1px; }
.p-ws-desc { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.p-ws-arrow { flex-shrink: 0; color: var(--muted); }

/* ---- Install (Add to home screen) banner ---- */
.p-install {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(76px + env(safe-area-inset-bottom));   /* clear the bottom tab bar */
  z-index: 200;
  max-width: 460px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(30,50,90,.18);
  padding: 12px 14px;
  transform: translateY(140%);
  opacity: 0;
  transition: transform .28s ease, opacity .28s ease;
}
.p-install.show { transform: translateY(0); opacity: 1; }
.p-install-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 11px;
  box-shadow: 0 1px 4px rgba(30,50,90,.12);
}
.p-install-text { flex: 1; min-width: 0; line-height: 1.35; }
.p-install-text strong { display: block; font-size: 14.5px; color: var(--text); }
.p-install-text span { display: block; font-size: 12.5px; color: var(--muted); }
.p-install-actions { flex-shrink: 0; display: flex; align-items: center; gap: 4px; }
.p-install-add {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 9px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .15s;
}
.p-install-add:hover { background: var(--blue-hover); }
.p-install-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 8px;
}
.p-install-close:hover { background: var(--bg); color: var(--text); }

@media (min-width: 640px) {
  .p-install {
    left: auto;
    right: 20px;
    bottom: 20px;
    margin: 0;
    max-width: 400px;
  }
}

/* ============================================================
   LMS tests — runner, results, attendance-gating lock
   ============================================================ */
.p-quiz-stem {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 16px;
}
.p-quiz-opts { display: grid; gap: 8px; }
.p-quiz-opt {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 15px;
  padding: 13px 14px;
  border-radius: 12px;
  border: 2px solid #dfe5ee;
  background: #fff;
  color: inherit;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.p-quiz-opt b { color: var(--muted); }
.p-quiz-opt:hover { border-color: var(--blue); }
.p-quiz-opt.sel {
  border-color: var(--blue);
  background: var(--blue-light);
}
.p-quiz-opt.sel b { color: var(--blue); }
.p-quiz-num {
  width: 100%;
  max-width: 240px;
  font: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border: 2px solid #dfe5ee;
  border-radius: 12px;
}
.p-quiz-num:focus { border-color: var(--blue); outline: none; }
.p-quiz-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}
.p-quiz-footer .p-btn-sm:first-child { margin-right: auto; }
.p-lock-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: #fdf6e0;
  border: 1px solid #f0dfae;
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 18px;
}
.p-lock-card p { font-size: 13.5px; color: #6b5a17; margin-top: 3px; line-height: 1.55; }
.p-lock-icon { color: #8a6100; flex-shrink: 0; margin-top: 2px; }

/* 7 bottom tabs: keep labels one-line and shrinkable on narrow phones */
.p-tab { min-width: 0; }
.p-tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 420px) {
  .p-tab { font-size: 10px; }
}
