/* Shikshak Sahyog — application shell: sidebar + topbar + dashboard layout */

body.app-shell { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
  width: 240px;
  background: var(--ink);
  color: #fff;
  padding: var(--sp-6) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: var(--sp-8); padding: 0 var(--sp-2); min-width: 0; }
.brand .logo {
  width: 40px; height: 40px; border-radius: 50%;
  background: #fff; padding: 3px; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(21, 26, 45, .35);
}
.brand .logo img { width: 100%; height: 100%; border-radius: 50%; display: block; }
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-text b { font-weight: 700; font-size: 15px; line-height: 1.2; color: var(--ink); white-space: nowrap; }
.brand-text .tagline { font-size: 8.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.brand.on-dark .brand-text b { color: #fff; }
.brand.on-dark .brand-text .tagline { color: #8b92a8; }

.nav-link {
  font-size: var(--fs-sm);
  color: #b6bcce;
  padding: 11px 12px;
  border-radius: var(--radius-control);
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  font-weight: 500;
  transition: .15s;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link i { width: 18px; text-align: center; font-style: normal; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #5a6178; margin: 18px 8px 6px; }

/* Mobile bottom nav */
.bottom-nav { display: none; }

/* ---- Main / topbar ---- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 64px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-6);
  gap: var(--sp-5);
}
.topbar .search {
  flex: 1; max-width: 420px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-control); padding: 9px 14px; font-size: var(--fs-sm); color: var(--muted);
  display: flex; align-items: center; gap: 9px;
}
.credits {
  margin-left: auto; background: #FEF3C7; color: #92400E; border-radius: var(--radius-control);
  padding: 8px 14px; font-size: var(--fs-sm); font-weight: 600; display: flex; align-items: center; gap: 7px;
  transition: transform .15s ease;
}
.credits b { font-size: 15px; }
.credits.credit-bump { animation: credit-bump .4s ease; }
@keyframes credit-bump { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }

.hamburger { display: none; background: none; border: none; color: var(--ink); font-size: 22px; cursor: pointer; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: var(--fs-sm);
  flex-shrink: 0; text-decoration: none; border: none; cursor: pointer; font-family: inherit;
}

.user-menu { position: relative; }
.user-menu-dropdown {
  position: absolute; top: calc(100% + 10px); right: 0; min-width: 240px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card);
  box-shadow: var(--shadow); padding: var(--sp-2); z-index: 200;
}
.user-menu-header { padding: var(--sp-3) var(--sp-3) var(--sp-2); }
.user-menu-header b { display: block; font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }
.user-menu-header span { display: block; font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; word-break: break-all; }
.user-menu-divider { height: 1px; background: var(--line); margin: var(--sp-2) 0; }
.user-menu-item {
  display: flex; align-items: center; gap: 10px; padding: 9px var(--sp-3); border-radius: var(--radius-control);
  font-size: var(--fs-sm); font-weight: 500; color: var(--ink); text-decoration: none;
}
.user-menu-item:hover { background: var(--surface); text-decoration: none; }
.user-menu-item i { width: 16px; text-align: center; font-style: normal; color: var(--muted); }

.content { padding: var(--sp-6); overflow: auto; flex: 1; }
.pagehead { margin-bottom: var(--sp-6); }
.pagehead h1 { font-size: var(--fs-2xl); font-weight: 700; }
.pagehead p { color: var(--muted); font-size: var(--fs-sm); margin-top: 3px; }

.grid { display: grid; gap: var(--sp-5); }
.stats { grid-template-columns: repeat(4, 1fr); margin-bottom: var(--sp-5); }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card);
  padding: var(--sp-5); box-shadow: var(--shadow); transition: transform .15s ease;
}
.stat:hover { transform: translateY(-2px); }
.stat .lbl { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat .val { font-size: 30px; font-weight: 700; margin-top: var(--sp-2); line-height: 1; }
.stat .delta { font-size: var(--fs-xs); font-weight: 600; margin-top: 6px; }
.up { color: var(--teal); }
.down { color: var(--danger); }

.cols { grid-template-columns: 2fr 1fr; }

/* Unlock ring */
.unlock { display: flex; align-items: center; gap: var(--sp-6); padding: var(--sp-6) var(--sp-5); flex-wrap: wrap; }
.ring { width: 96px; height: 96px; flex-shrink: 0; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring .ctr { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring .ctr b { font-size: 22px; font-weight: 700; }
.ring .ctr span { font-size: 10px; color: var(--muted); }
.ring.unlocked .ring-progress { stroke: var(--accent); }
.unlock .txt h3 { font-size: var(--fs-md); font-weight: 600; }
.unlock .txt p { font-size: var(--fs-sm); color: var(--muted); margin: 5px 0 12px; line-height: 1.5; }

/* Resource rows */
.res { display: flex; align-items: center; gap: var(--sp-4); padding: 13px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.res:last-child { border-bottom: none; }
.spine { width: 4px; height: 38px; border-radius: 2px; flex-shrink: 0; }
.res .meta { flex: 1; min-width: 160px; }
.res .meta b { font-size: var(--fs-sm); font-weight: 600; display: block; }
.res .meta span { font-size: var(--fs-xs); color: var(--muted); }
.res .dl { font-size: var(--fs-xs); color: var(--muted); display: flex; align-items: center; gap: 5px; min-width: 64px; }

/* Leaderboard */
.lb { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.lb:last-child { border-bottom: none; }
.rank { width: 26px; font-weight: 700; font-size: var(--fs-md); text-align: center; color: var(--muted); }
.rank.g { color: var(--accent); }
.lbav { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: #fff; flex-shrink: 0; }
.lb .who { flex: 1; min-width: 0; }
.lb .who b { font-size: var(--fs-sm); font-weight: 600; display: block; }
.lb .who span { font-size: 11px; color: var(--muted); }
.score { font-weight: 700; font-size: var(--fs-sm); }

.footer { padding: var(--sp-4) var(--sp-6); text-align: center; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); }

.auth-shell {
  min-height: 100vh; width: 100%; display: flex; align-items: center; justify-content: center;
  background: var(--surface); padding: var(--sp-5);
}
.auth-card { width: 100%; max-width: 460px; background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow); padding: var(--sp-8); }
.auth-card .brand { color: var(--ink); margin-bottom: var(--sp-6); }
.auth-card .brand span { color: var(--muted); }
.auth-foot { text-align: center; font-size: var(--fs-sm); color: var(--muted); margin-top: var(--sp-5); }

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

@media (max-width: 768px) {
  .sidebar { display: none; }
  .hamburger { display: block; }
  .content { padding: var(--sp-4); }
  .stats { grid-template-columns: 1fr 1fr; gap: var(--sp-3); }

  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 60px;
    background: var(--ink); z-index: 900; border-top: 1px solid rgba(255,255,255,.08);
  }
  .bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: #b6bcce; font-size: 10px; gap: 3px; text-decoration: none;
  }
  .bottom-nav a.active { color: #fff; }
  .bottom-nav a i { font-style: normal; font-size: 18px; }
  body.app-shell { padding-bottom: 60px; }

  .res { flex-direction: column; align-items: flex-start; gap: 6px; }
  .res .spine { width: 100%; height: 4px; }
}

/* Sidebar drawer for mobile hamburger */
.sidebar-drawer-open .sidebar {
  display: flex; position: fixed; inset: 0 20% 0 0; z-index: 950; height: 100vh; overflow-y: auto;
}
.sidebar-scrim { display: none; }
.sidebar-drawer-open .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(21,26,45,.5); z-index: 940; }
