/**
 * sidebar-layout.css
 * App-shell layout for logged-in pages (dashboard, practice, pyq, notes,
 * syllabus, mocktest, rules, updates, settings...). Structure matches the
 * DiploMate sidebar pattern (fixed left sidebar, collapsible on mobile,
 * sticky topbar), reskinned to RailStudy's navy/amber palette.
 *
 * The public landing page (index.html) does NOT use this — it keeps a
 * simple top nav, same split DiploMate itself uses.
 */

.rh-app-page {
  min-height: 100vh;
  background: var(--rh-surface-1);
  display: flex;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.rh-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--rh-navy-800) 0%, var(--rh-navy-950) 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}
.rh-sidebar-logo {
  padding: 18px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.rh-sidebar-logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
}
.rh-sidebar-logo-img {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 10px;
  background: #fff;
  padding: 3px;
  flex-shrink: 0;
}
.rh-sidebar-logo-col { display: flex; flex-direction: column; }
.rh-sidebar-logo-text {
  font-family: var(--rh-font-display);
  font-size: var(--rh-fs-lg);
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.rh-sidebar-logo-railway { color: #fff; }
.rh-sidebar-logo-help { color: var(--rh-amber-500); }
.rh-sidebar-logo .rh-sidebar-tagline {
  display: block;
  font-size: 10px;
  color: rgba(245,181,89,0.68);
  margin-top: 2px;
  font-weight: 400;
}

.rh-sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}
.rh-sidebar-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rh-navy-100);
  opacity: 0.55;
  padding: 14px 12px 6px;
}
.rh-sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--rh-radius-sm);
  font-size: var(--rh-fs-sm);
  font-weight: 500;
  color: var(--rh-navy-100);
  margin-bottom: 2px;
  text-decoration: none;
  transition: background var(--rh-transition), color var(--rh-transition), transform var(--rh-transition);
}
.rh-sidebar-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
  text-decoration: none;
  transform: translateX(2px);
}
.rh-sidebar-link.active {
  background: linear-gradient(90deg, rgba(239,159,39,0.2) 0%, rgba(239,159,39,0.08) 100%);
  color: var(--rh-amber-400);
  font-weight: 700;
  box-shadow: inset 2px 0 0 var(--rh-amber-500);
}
.rh-sidebar-link .s-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.rh-sidebar-link .s-badge {
  margin-left: auto;
  background: var(--rh-amber-500);
  color: var(--rh-amber-text);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 100px;
}

.rh-sidebar-bottom {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,0.12);
}
.rh-sidebar-lang {
  width: 100%;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  border-radius: var(--rh-radius-sm);
  padding: 8px;
  font-size: var(--rh-fs-xs);
  margin-bottom: 8px;
}
.rh-sidebar-legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 4px 2px 0;
}
.rh-sidebar-legal-links a {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
}
.rh-sidebar-legal-links a:hover {
  color: rgba(255,255,255,0.9);
  text-decoration: underline;
}

/* ── Mobile toggle + overlay ──────────────────────────────── */
.rh-sidebar-toggle {
  display: none;
  background: transparent;
  border: none;
  font-size: 1.3rem;
  color: var(--rh-text-primary);
  padding: 6px;
}
.rh-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4,44,83,0.5);
  z-index: 90;
}
.rh-sidebar-overlay.open { display: block; }

/* ── Main content ─────────────────────────────────────────── */
.rh-app-main {
  flex: 1;
  min-width: 0; /* lets wide children (e.g. the Home course row) scroll inside themselves instead of widening the page */
  margin-left: 240px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.rh-app-topbar {
  height: 56px;
  border-bottom: 1px solid var(--rh-border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 var(--rh-space-5);
  background: rgba(15,32,53,0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.rh-app-topbar-title {
  font-size: var(--rh-fs-lg);
  font-weight: 600;
  color: var(--rh-text-primary);
}
.rh-app-content { padding: var(--rh-space-5); flex: 1; }

@media (max-width: 768px) {
  .rh-sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,0.25);
  }
  .rh-sidebar.open { transform: translateX(0); }
  .rh-app-main { margin-left: 0; }
  .rh-sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .rh-app-content { padding: var(--rh-space-4) var(--rh-space-3) 60px; }
}


/* ── Sidebar: grouped sub-links (My Learning → Practice/PYQ/Notes) ── */
.rh-sidebar-sub {
  margin: 0 0 4px 22px;
  padding-left: 6px;
  border-left: 1px solid rgba(255,255,255,0.14);
}
.rh-sidebar-link--sub {
  padding: 8px 10px;
  font-size: 13px;
  margin-bottom: 1px;
}

/* ── Bottom nav + top-bar actions (signed-in, phones & tablets) ─────
   Everything here hangs off body.rh-bn, which sidebar.js sets only when a
   real session exists. Signed-out visitors on public pages keep the old
   drawer + hamburger untouched. */
.rh-bottom-nav,
.rh-topbar-actions { display: none; }

.rh-bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 80;
  justify-content: center;
  background: var(--rh-navy-950);
  border-top: 1px solid var(--rh-border-strong);
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -6px 20px rgba(0,0,0,0.28);
}
.rh-bn-item {
  flex: 1 1 0;
  max-width: 200px;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: var(--rh-radius-sm);
  color: var(--rh-text-secondary);
  text-decoration: none;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.rh-bn-item:hover { text-decoration: none; color: var(--rh-text-primary); }
.rh-bn-item:focus-visible { outline: 2px solid var(--rh-amber-400); outline-offset: -2px; }
.rh-bn-item.active { color: var(--rh-amber-400); font-weight: 700; }
.rh-bn-item.active::before {
  content: "";
  position: absolute;
  top: 0; left: 28%; right: 28%;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--rh-amber-500);
}
.rh-bn-icon { position: relative; display: inline-flex; }
.rh-bn-label {
  font-size: 11px;
  line-height: 1.15;
  text-align: center;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.rh-bn-badge {
  position: absolute;
  top: -5px; left: calc(100% - 6px);
  background: var(--rh-amber-500);
  color: var(--rh-amber-text);
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 100px;
  white-space: nowrap;
}

.rh-topbar-actions {
  margin-left: auto;
  align-items: center;
  gap: 8px;
}
.rh-tb-lang {
  min-width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--rh-border-strong);
  background: var(--rh-surface-2);
  color: var(--rh-text-primary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.rh-tb-lang:focus-visible { outline: 2px solid var(--rh-amber-400); outline-offset: 2px; }

/* Drawer: phones (all visitors) and tablets/phones for signed-in users.
   A closed drawer is visibility:hidden so its links can't be tabbed to
   while it is off-screen. */
@media (max-width: 768px) {
  .rh-sidebar { visibility: hidden; transition: transform 0.25s ease, visibility 0s linear 0.25s; }
  .rh-sidebar.open { visibility: visible; transition-delay: 0s; }
}
@media (max-width: 1024px) {
  body.rh-bn .rh-sidebar {
    width: min(300px, 86vw);
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,0.35);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  body.rh-bn .rh-sidebar.open { transform: translateX(0); visibility: visible; transition-delay: 0s; }
  body.rh-bn .rh-app-main { margin-left: 0; }
  body.rh-bn .rh-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-left: -8px;
  }
  body.rh-bn .rh-bottom-nav { display: flex; }
  body.rh-bn .rh-topbar-actions { display: flex; }
  body.rh-bn .rh-app-content { padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
}

/* Compact drawer: keep every link (incl. the Account group) on screen on a
   typical phone. Tighter rows, and Language + Log Out share one row. Only
   applies where the sidebar is a drawer. */
@media (max-width: 768px) {
  .rh-sidebar-logo { padding: 12px 16px 10px; }
  .rh-sidebar-nav { padding: 6px 10px; }
  .rh-sidebar-section-label { padding: 9px 12px 3px; }
  .rh-sidebar-link { padding: 8px 12px; margin-bottom: 1px; }
  .rh-sidebar-link--sub { padding: 6px 10px; }
  .rh-sidebar-bottom { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; }
  .rh-sidebar-bottom .rh-sidebar-lang { flex: 1 1 0; width: auto; margin-bottom: 0; min-height: 40px; }
  .rh-sidebar-legal-links { flex-basis: 100%; }
}
@media (max-width: 1024px) {
  body.rh-bn .rh-sidebar-logo { padding: 12px 16px 10px; }
  body.rh-bn .rh-sidebar-nav { padding: 6px 10px; }
  body.rh-bn .rh-sidebar-section-label { padding: 9px 12px 3px; }
  body.rh-bn .rh-sidebar-link { padding: 8px 12px; margin-bottom: 1px; }
  body.rh-bn .rh-sidebar-link--sub { padding: 6px 10px; }
  body.rh-bn .rh-sidebar-bottom { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; }
  body.rh-bn .rh-sidebar-bottom .rh-sidebar-lang { flex: 1 1 0; width: auto; margin-bottom: 0; min-height: 40px; }
  body.rh-bn .rh-sidebar-legal-links { flex-basis: 100%; }
}

/* Scrolling inside the drawer must not scroll the page behind it. */
.rh-sidebar-nav { overscroll-behavior: contain; }
