/* ==========================================================================
   AptitudePro — Dashboard UI (ported from the approved redesign prototype)

   Presentation only. Nothing here changes questions, answers, scoring or
   payments. Colours route through the theme variables defined in main.css so
   the dark / light / blue switchers all keep working; in the light theme this
   resolves to the prototype's palette.
   ========================================================================== */

:root {
  --nx-primary: #4f5fff;
  --nx-primary-dark: #3646e5;
  --nx-lime: #cbf36a;
  --nx-teal: #1dbb84;
  --nx-amber: #ffb84d;
}

/* Panel/------- surface tokens: prototype values in light, theme-aware elsewhere */
.app-layout {
  --nx-surface: var(--bg-surface);
  --nx-line: var(--border);
  --nx-ink: var(--text-primary);
  --nx-muted: var(--text-secondary);
  --nx-faint: var(--text-muted);
  --nx-soft: var(--bg-raised);
}

/* ---------- Shell ------------------------------------------------------- */

.app-layout { min-height: 100vh; background: var(--bg-base); }

/* .main-content is a flex child, so its min-width defaults to auto and the
   activity table's min-width:640px would push the whole page wider than the
   viewport. Pinning these to 0 keeps the wide table scrolling inside its own
   container instead of scrolling the page sideways on mobile. */
.main-content, .page, .panel, .content-grid, .stats-row { min-width: 0; }
.main-content > .page { max-width: 100%; }

/* The off-canvas drawer sits at translateX(-100%); clip it so it cannot
   create a horizontal scroll region. */
.app-layout { overflow-x: clip; }

/* ---------- Sidebar ----------------------------------------------------- */

.sidebar-nav .nav-section-label {
  margin: 14px 12px 8px;
  color: var(--nx-faint);
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

/* main.css gives .sidebar-nav flex:1, so grid rows would stretch to fill the
   sidebar height and each item would balloon. Pack them to the top instead. */
.sidebar-nav { display: grid; gap: 3px; align-content: start; }

.sidebar-nav .nav-item {
  min-height: 43px;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--nx-muted);
  font-size: .84rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}

.sidebar-nav .nav-item:hover { background: var(--nx-soft); color: var(--nx-ink); }

.sidebar-nav .nav-item.active {
  background: color-mix(in srgb, var(--nx-primary) 12%, transparent);
  color: var(--nx-primary);
}

.sidebar-nav .nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  font-size: .95rem;
  font-style: normal;
}

/* ---------- Topbar ------------------------------------------------------ */

.topbar {
  height: 82px;
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(22px, 4vw, 54px);
  background: color-mix(in srgb, var(--bg-base) 90%, transparent);
  border-bottom: 1px solid var(--nx-line);
  backdrop-filter: blur(15px);
}

.nx-page-kicker {
  display: block;
  color: var(--nx-faint);
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .13em;
}

.topbar-title { font-family: "Manrope", "DM Sans", sans-serif; font-size: 1.2rem; font-weight: 800; letter-spacing: -.03em; color: var(--nx-ink); }
.topbar-sub { display: none; }

/* ---------- Page padding ------------------------------------------------ */

.nx-page-body { padding: 26px clamp(22px, 4vw, 54px) 60px; }

/* ---------- Today's focus card ------------------------------------------ */

.nx-focus-card {
  min-height: 260px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  padding: 37px 44px;
  border-radius: 18px;
  background: linear-gradient(115deg, #4f5fff 0%, #4656ed 58%, #3441bd 100%);
  color: #fff;
}

.nx-focus-card::before {
  content: "";
  position: absolute;
  width: 350px; height: 350px;
  right: -170px; top: -190px;
  border: 60px solid rgba(255,255,255,.08);
  border-radius: 50%;
}

.nx-focus-card::after {
  content: "";
  position: absolute;
  width: 180px; height: 180px;
  left: 45%; bottom: -140px;
  border: 30px solid rgba(203,243,106,.09);
  border-radius: 50%;
}

.nx-focus-body, .nx-streak-ring { position: relative; z-index: 1; }

.nx-focus-kicker { display: inline-block; color: #c8d0ff; font-size: .68rem; font-weight: 800; letter-spacing: .13em; }

.nx-focus-title {
  margin: 9px 0 7px;
  font-family: "Manrope", "DM Sans", sans-serif;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -.05em;
  color: #fff;
}

.nx-focus-sub { margin-bottom: 15px; color: #d9ddff; font-size: .95rem; }

.nx-focus-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.nx-focus-meta span { padding: 5px 11px; border-radius: 999px; background: rgba(255,255,255,.16); color: #fff; font-size: .72rem; font-weight: 500; }

.nx-focus-btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border: 0;
  border-radius: 10px;
  background: #fff;
  color: #10243e;
  font-weight: 700;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}

.nx-focus-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0,0,0,.18); }

/* Streak ring — driven by real streakCount, not a hardcoded weekly goal. */
.nx-streak-ring {
  width: 150px; height: 150px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--nx-lime) 0 var(--ring-pct, 0%), rgba(255,255,255,.13) var(--ring-pct, 0%) 100%);
}

.nx-streak-ring::before {
  content: "";
  position: absolute;
  width: 116px; height: 116px;
  border-radius: 50%;
  background: #4554e8;
}

.nx-streak-ring > div { position: relative; z-index: 1; text-align: center; }
.nx-streak-ring strong, .nx-streak-ring span { display: block; }
.nx-streak-ring strong { font-family: "Manrope", sans-serif; font-size: 1.7rem; font-weight: 800; }
.nx-streak-ring span { color: #d3d7ff; font-size: .67rem; }

/* ---------- Metric tiles ------------------------------------------------ */

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0; }

.stat-card {
  min-width: 0;
  padding: 19px 20px;
  background: var(--nx-surface);
  border: 1px solid var(--nx-line);
  border-radius: 13px;
}

.stat-head { display: flex; justify-content: space-between; gap: 8px; color: var(--nx-muted); font-size: .74rem; }
.stat-value { display: block; margin-top: 10px; font-family: "Manrope", sans-serif; font-size: 1.65rem; font-weight: 800; letter-spacing: -.04em; color: var(--nx-ink); }
.stat-sub { margin-top: -1px; color: var(--nx-faint); font-size: .69rem; }

.trend { padding: 3px 6px; border-radius: 5px; background: var(--nx-soft); color: var(--nx-muted); font-size: .6rem; font-style: normal; font-weight: 800; }
.trend.up { background: #e8f8f2; color: #11805d; }
.trend.hot { background: #fff2df; color: #a86616; }

/* ---------- Panels ------------------------------------------------------ */

.content-grid { display: grid; grid-template-columns: 1.45fr .75fr; gap: 16px; }

.panel { background: var(--nx-surface); border: 1px solid var(--nx-line); border-radius: 15px; }
.quick-start-panel, .focus-panel, .recent-panel { padding: 24px; }
.recent-panel { margin-top: 16px; }

.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 19px; }
.panel-head h2 { margin: 4px 0 0; font-family: "Manrope", sans-serif; font-size: 1.15rem; font-weight: 800; letter-spacing: -.035em; color: var(--nx-ink); }

.card-kicker { display: inline-block; color: var(--nx-primary); font-size: .68rem; font-weight: 800; letter-spacing: .13em; }

.link-button { border: 0; background: none; padding: 0; margin-top: 16px; color: var(--nx-primary); font-size: .73rem; font-weight: 700; cursor: pointer; }
.analysis-badge { margin-top: 16px; color: var(--nx-faint); font-size: .66rem; }

/* ---------- Quick-start list -------------------------------------------- */

.quick-list { display: grid; gap: 8px; }

.quick-exam {
  width: 100%;
  display: grid;
  grid-template-columns: 46px minmax(0,1fr) auto 20px;
  align-items: center;
  gap: 13px;
  padding: 12px;
  border: 1px solid var(--nx-line);
  border-radius: 11px;
  background: var(--nx-surface);
  color: var(--nx-ink);
  text-align: left;
  cursor: pointer;
  transition: border-color .18s ease, transform .18s ease;
}

.quick-exam:hover { transform: translateX(3px); border-color: color-mix(in srgb, var(--nx-primary) 45%, var(--nx-line)); }

.quick-exam > span:nth-child(2) strong,
.quick-exam > span:nth-child(2) small { display: block; }
.quick-exam > span:nth-child(2) strong { font-size: .82rem; }
.quick-exam > span:nth-child(2) small { margin-top: 2px; color: var(--nx-muted); font-size: .69rem; }
.quick-exam > i { color: var(--nx-muted); font-size: .68rem; font-style: normal; }
.quick-exam > b { color: var(--nx-primary); }

/* Exam monograms replace the emoji icons */
.exam-monogram {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 12px;
  font-family: "Manrope", sans-serif;
  font-size: .8rem;
  font-weight: 800;
}

.exam-monogram.it, .exam-monogram.IT { background: #e5e8ff; color: var(--nx-primary-dark); }
.exam-monogram.bank, .exam-monogram.banking, .exam-monogram.BANKING { background: #dcf7ec; color: #0f7a58; }
.exam-monogram.gov, .exam-monogram.government, .exam-monogram.GOVERNMENT { background: #fff0d9; color: #a86616; }

/* ---------- Topics to improve -------------------------------------------- */

.focus-item { display: grid; grid-template-columns: 1fr auto; gap: 7px 10px; margin: 17px 0; }
.focus-item > div { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 10px; }
.focus-item strong { font-size: .76rem; color: var(--nx-ink); }
.focus-item span { color: var(--nx-muted); font-size: .68rem; }
.focus-item > i { grid-column: 1 / -1; height: 6px; align-self: center; background: var(--nx-soft); border-radius: 8px; }
.focus-item > i b { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--nx-amber), #ffd27f); }
.focus-item > small { grid-column: 1 / -1; color: var(--nx-faint); font-size: .59rem; }

.weak-exam-title { margin: 20px 0 4px; color: var(--nx-faint); font-size: .62rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.weak-exam-group:first-child .weak-exam-title { margin-top: 0; }

.button-soft {
  width: 100%;
  min-height: 46px;
  margin-top: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  background: color-mix(in srgb, var(--nx-primary) 12%, transparent);
  color: var(--nx-primary);
  font-weight: 700;
  cursor: pointer;
}

/* ---------- Recent activity table ---------------------------------------- */

.activity-table { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.activity-row {
  min-width: 640px;
  display: grid;
  grid-template-columns: 1.8fr 1.1fr .7fr .7fr .6fr;
  align-items: center;
  min-height: 52px;
  border-top: 1px solid var(--nx-line);
  color: var(--nx-muted);
  font-size: .72rem;
}

.activity-row.header-row {
  min-height: 35px;
  border-top: 0;
  color: var(--nx-faint);
  font-size: .62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.activity-row > span:first-child { display: flex; align-items: center; gap: 9px; color: var(--nx-ink); }
.activity-row b { font-size: .76rem; }
.activity-row button { justify-self: end; border: 0; background: none; color: var(--nx-primary); font-size: .7rem; font-weight: 700; cursor: pointer; }

.activity-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--nx-muted); }
.activity-dot.it { background: var(--nx-primary); }
.activity-dot.banking { background: var(--nx-teal); }
.activity-dot.government { background: var(--nx-amber); }

.score-good { color: #11805d; }
.score-avg { color: #a86616; }
.score-poor { color: #c23b3b; }

/* ---------- Leaderboard --------------------------------------------------- */

.leaderboard-list { padding: 15px; }

.leader-row { display: grid; grid-template-columns: 30px 40px 1fr auto; align-items: center; gap: 12px; padding: 14px; border-bottom: 1px solid var(--nx-line); }
.leader-row:last-child { border-bottom: 0; }
.leader-row > b { color: var(--nx-muted); }
.leader-row strong, .leader-row small { display: block; }
.leader-row strong { font-size: .82rem; color: var(--nx-ink); }
.leader-row small { color: var(--nx-muted); font-size: .68rem; }
.leader-row i { color: var(--nx-primary); font-style: normal; font-weight: 800; }
.leader-row.winner { background: color-mix(in srgb, var(--nx-primary) 6%, transparent); border-radius: 10px; }

.user-avatar {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border: 0;
  border-radius: 50%;
  background: #dfe3ff;
  color: var(--nx-primary-dark);
  font-size: .7rem;
  font-weight: 800;
}

/* ---------- Upgrade card --------------------------------------------------- */

.nx-upgrade-card {
  margin: 16px 4px;
  padding: 16px;
  border-radius: 14px;
  background: linear-gradient(140deg, #131a30 0%, #1d2547 100%);
  color: #fff;
}

.nx-upgrade-badge {
  display: inline-block;
  margin-bottom: 9px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(203,243,106,.16);
  color: var(--nx-lime);
  font-size: .6rem;
  font-weight: 800;
  letter-spacing: .08em;
}

.nx-upgrade-card strong { display: block; margin-bottom: 4px; font-size: .9rem; }
.nx-upgrade-card p { margin: 0 0 12px; color: rgba(255,255,255,.72); font-size: .76rem; }
.nx-upgrade-card button { width: 100%; padding: 9px; border: 0; border-radius: 9px; background: var(--nx-lime); color: #12203a; font-size: .82rem; font-weight: 800; cursor: pointer; }

/* ---------- Empty / loading ------------------------------------------------ */

.empty-state { padding: 26px 0; text-align: center; color: var(--nx-faint); }
.empty-state p { margin: 8px 0 0; font-size: .84rem; }
.empty-icon { font-size: 1.5rem; opacity: .5; }

/* ---------- Mobile bottom nav ---------------------------------------------- */

.mobile-nav { display: none; }

/* ---------- Responsive ------------------------------------------------------ */

@media (max-width: 1100px) {
  .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 640px) {
  .topbar { height: 72px; padding: 0 15px; }
  .topbar-title { font-size: 1rem; }
  .nx-page-kicker { font-size: .55rem; }
  .nx-page-body { padding: 18px 13px 95px; }

  .nx-focus-card { min-height: 0; align-items: flex-start; padding: 27px 23px; }
  .nx-focus-title { font-size: 1.75rem; }
  .nx-streak-ring { display: none; }
  .nx-focus-btn { width: 100%; justify-content: center; }

  .stats-row { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  .stat-card { padding: 15px; }
  .stat-head { display: block; }
  .stat-head .trend { display: inline-block; margin-top: 5px; }
  .stat-value { font-size: 1.4rem; }

  .quick-start-panel, .focus-panel, .recent-panel { padding: 18px; }
  .quick-exam { grid-template-columns: 42px 1fr 15px; }
  .quick-exam > i { display: none; }
  .quick-exam > b { grid-column: 3; }
  .panel-head .analysis-badge { display: none; }
  .activity-row { min-width: 600px; }

  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 60; /* above the drawer scrim so Menu can toggle back off */
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 7px 4px calc(7px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--nx-surface) 96%, transparent);
    border-top: 1px solid var(--nx-line);
    backdrop-filter: blur(15px);
  }
  .mobile-nav button {
    min-height: 47px;
    display: grid;
    place-items: center;
    gap: 2px;
    border: 0;
    background: none;
    color: var(--nx-muted);
    font-size: .56rem;
    font-weight: 700;
    cursor: pointer;
  }
  .mobile-nav button span { font-size: 1.05rem; line-height: 1; }
  .mobile-nav button.active { color: var(--nx-primary); }

  /* The drawer must clear the bottom bar, and the top hamburger becomes
     redundant once Menu lives at the bottom. */
  .sidebar { padding-bottom: 78px; }
  .hamburger-btn { display: none; }

  /* Keep the feedback FAB from sitting on top of the Menu button. */
  #feedbackFab { bottom: calc(86px + env(safe-area-inset-bottom)) !important; }
}

@media (prefers-reduced-motion: reduce) {
  .quick-exam, .nx-focus-btn, .stat-card { transition: none; }
}
