/* ============================================================
   Study Decoder — Student App Shell
   A persistent left sidebar injected by app-shell.js on the
   dashboard and every student tool page. Linked AFTER each
   page's inline <style>. Intentionally scoped to .sd-* classes
   (plus a body padding shift) so it never restyles a tool
   page's own body/cards/buttons — only the shell chrome.
   ============================================================ */
:root {
  --sd-primary: #6C63FF;
  --sd-primary-2: #a78bfa;
  --sd-sb-bg: rgba(10, 9, 16, 0.94);
  --sd-sb-border: rgba(255, 255, 255, 0.08);
  --sd-sb-text: rgba(255, 255, 255, 0.74);
  --sd-sb-width: 248px;
}

/* ── Body shift so fixed sidebar never overlaps content ── */
body.sd-shell-shifted { padding-left: var(--sd-sb-width); }
/* Hide the legacy per-page back buttons once the shell is present */
body.sd-shell-shifted .header .back-btn,
body.sd-shell-shifted .back-btn-container { display: none !important; }

/* ── Sidebar ── */
.sd-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sd-sb-width);
  z-index: 1000; display: flex; flex-direction: column;
  background: var(--sd-sb-bg);
  backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  border-right: 1px solid var(--sd-sb-border);
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.16) transparent;
  transition: transform .25s cubic-bezier(.2, .7, .2, 1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.sd-sidebar::-webkit-scrollbar { width: 8px; }
.sd-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 8px; }
.sd-sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.24); }
.sd-sidebar * { box-sizing: border-box; }

.sd-sb-top { display: flex; align-items: center; justify-content: space-between; }
.sd-sb-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 10px; text-decoration: none; }
.sd-sb-brand img { width: 30px; height: 30px; border-radius: 8px; }
.sd-sb-brand b { color: #fff; font-size: 16px; font-weight: 800; letter-spacing: -0.3px; }
.sd-collapse {
  flex: none; margin-right: 14px; width: 28px; height: 28px; border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 16px; line-height: 1;
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.6); transition: background .15s, color .15s;
}
.sd-collapse:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
@media (max-width: 1024px) { .sd-collapse { display: none; } }

/* ── Desktop: collapse / hide the sidebar ── */
@media (min-width: 1025px) {
  body.sd-shell-collapsed.sd-shell-shifted { padding-left: 0; }
  body.sd-shell-collapsed .sd-sidebar { transform: translateX(-100%); }
  body.sd-shell-collapsed .sd-hamb { display: flex; }
}

.sd-streak-chip {
  margin: 0 18px 8px; align-self: flex-start; display: none;
  align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px;
  background: rgba(108, 99, 255, 0.16); color: #c4b5fd; font-size: 12px; font-weight: 700;
}
.sd-streak-chip.show { display: inline-flex; }
.sd-streak-chip .n { color: #fff; }

.sd-sb-nav { flex: 1 1 auto; padding: 4px 12px 12px; }
.sd-sb-sec {
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.36); padding: 14px 10px 6px;
}
.sd-nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; margin-bottom: 1px;
  border-radius: 10px; text-decoration: none; color: var(--sd-sb-text);
  font-size: 14px; font-weight: 600; position: relative;
  transition: background .15s ease, color .15s ease;
}
.sd-nav-item .ic { width: 20px; flex: none; text-align: center; font-size: 15px; }
.sd-nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sd-nav-item.active { background: rgba(108, 99, 255, 0.16); color: #fff; }
.sd-nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 3px 3px 0; background: linear-gradient(180deg, var(--sd-primary), var(--sd-primary-2));
}
.sd-nav-item[hidden] { display: none; }

.sd-sb-foot { padding: 10px 12px 16px; border-top: 1px solid var(--sd-sb-border); }
.sd-upgrade {
  display: none; text-decoration: none; margin-bottom: 10px; padding: 13px 14px; border-radius: 12px;
  background: linear-gradient(135deg, var(--sd-primary), var(--sd-primary-2));
  color: #fff; box-shadow: 0 6px 18px rgba(108, 99, 255, 0.35); transition: transform .2s ease;
}
.sd-upgrade.show { display: block; }
.sd-upgrade:hover { transform: translateY(-2px); }
.sd-upgrade b { display: block; font-size: 13px; font-weight: 800; }
.sd-upgrade span { display: block; font-size: 11px; opacity: .85; margin-top: 2px; }

/* ── Mobile: off-canvas drawer + hamburger + scrim ── */
.sd-hamb {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 1001;
  width: 42px; height: 42px; border-radius: 10px; cursor: pointer;
  align-items: center; justify-content: center; font-size: 19px; color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(10, 9, 16, 0.82);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.sd-scrim { display: none; position: fixed; inset: 0; z-index: 999; background: rgba(0, 0, 0, 0.5); }

@media (max-width: 1024px) {
  body.sd-shell-shifted { padding-left: 0; }
  /* Clear the fixed hamburger so page headers/back areas don't sit under it */
  body.sd-shell-shifted .header { padding-left: 62px; }
  .sd-sidebar {
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.2, .7, .2, 1);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.55);
  }
  .sd-sidebar.open { transform: none; }
  .sd-hamb { display: flex; }
  .sd-scrim.open { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .sd-sidebar { transition: none; }
  .sd-upgrade:hover { transform: none; }
}
