/* Shared left sidebar of the SHgen hub (index.html and shgen.html).
   Colours follow nocturne.css; they are repeated here because shgen.html
   (Tailwind) does not load nocturne.css, and both pages must look the same.
   Pattern taken from large dashboards (CHARMM-GUI's module tree, Supabase,
   GitHub, Linear): sections with small headings, a module tree under each
   engine, the active item marked by a bar and a tint, counters on the
   right, service status and account at the bottom, an icon rail when
   collapsed, a drawer on narrow screens. */
:root {
  --sb-w: 260px;
  --sb-w-rail: 64px;
  --sb-top-h: 52px;
  --sb-bg: #12141f;
  --sb-surface: #1d2030;
  --sb-text: #e9e9ed;
  --sb-muted: #a3a7bb;
  --sb-faint: #8a8ea2;   /* 4.97:1 on the surface, 5.65:1 on the bar (WCAG AA) */
  --sb-accent: #9184d9;
  --sb-accent-bg: rgba(145, 132, 217, 0.16);
  --sb-hover: rgba(233, 233, 237, 0.06);
  --sb-divider: rgba(233, 233, 237, 0.09);
  --sb-ok: #7fc79b;
  --sb-warn: #e0b86b;
  --sb-bad: #d98080;
}

body.has-sb { padding-left: var(--sb-w); transition: padding-left .18s ease; }
body.has-sb.sb-rail { padding-left: var(--sb-w-rail); }

.sb {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 60;
  width: var(--sb-w); display: flex; flex-direction: column;
  background: var(--sb-bg); color: var(--sb-text);
  border-right: 1px solid var(--sb-divider);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 13.5px; line-height: 1.35;
  transition: width .18s ease, transform .2s ease;
}
body.sb-rail .sb { width: var(--sb-w-rail); }
.sb * { box-sizing: border-box; }
.sb a { color: inherit; text-decoration: none; }

/* head: logo, name, collapse */
.sb-head {
  display: flex; align-items: center; gap: 10px;
  height: var(--sb-top-h); padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--sb-divider); flex: none;
}
.sb-logo {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #a497ee, #5d5294);
  color: #fff; font-weight: 700; font-size: 12px; letter-spacing: .3px;
}
.sb-brand { font-weight: 600; font-size: 15px; white-space: nowrap; }
.sb-btn {
  border: 0; background: none; color: var(--sb-faint); cursor: pointer;
  width: 30px; height: 30px; border-radius: 7px; display: grid;
  place-items: center; flex: none;
}
.sb-btn:hover { background: var(--sb-hover); color: var(--sb-text); }
.sb-btn:focus-visible, .sb-item:focus-visible, .sb-lang button:focus-visible {
  outline: 2px solid var(--sb-accent); outline-offset: 1px;
}
.sb-collapse { margin-left: auto; }
body.sb-rail .sb-collapse svg { transform: rotate(180deg); }

/* the tree */
.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 10px 14px; }
.sb-sec + .sb-sec {               /* separate tools: a rule between them */
  margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--sb-divider);
}
.sb-sec-h {
  display: flex; align-items: center; gap: 8px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--sb-faint); padding: 8px 10px 6px;
  white-space: nowrap;
}
.sb-sec-h .sb-ico { width: 14px; height: 14px; }
.sb-item {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; margin: 1px 0; border-radius: 7px;
  color: var(--sb-muted); white-space: nowrap; cursor: pointer;
}
.sb-item:hover { background: var(--sb-hover); color: var(--sb-text); }
.sb-item[aria-current="page"] { background: var(--sb-accent-bg); color: var(--sb-text); }
.sb-item[aria-current="page"]::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px;
  width: 3px; border-radius: 2px; background: var(--sb-accent);
}
.sb-item[aria-current="page"] .sb-ico { color: var(--sb-accent); }
.sb-ico {
  width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.sb-label { overflow: hidden; text-overflow: ellipsis; }
.sb-badge {
  margin-left: auto; min-width: 20px; padding: 1px 7px; border-radius: 10px;
  font-size: 11px; font-weight: 600; text-align: center;
  background: var(--sb-surface); color: var(--sb-muted);
}
.sb-badge.run { background: var(--sb-accent-bg); color: var(--sb-accent); }
.sb-badge.bad { background: rgba(217, 128, 128, .16); color: var(--sb-bad); }
.sb-badge:empty { display: none; }
.sb-ext { margin-left: auto; font-size: 11px; color: var(--sb-faint); }

/* foot: service status, language, account */
.sb-foot {
  flex: none; border-top: 1px solid var(--sb-divider);
  padding: 10px 14px 12px; display: flex; flex-direction: column; gap: 9px;
  font-size: 12px; color: var(--sb-muted);
}
.sb-stat { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.sb-stat[hidden] { display: none; }
.sb-stat b { font-weight: 500; color: var(--sb-text); }
.sb-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--sb-faint); }
.sb-dot.ok { background: var(--sb-ok); box-shadow: 0 0 0 3px rgba(127, 199, 155, .16); }
.sb-dot.warn { background: var(--sb-warn); }
.sb-dot.bad { background: var(--sb-bad); }
.sb-row { display: flex; align-items: center; gap: 8px; }
.sb-lang { display: inline-flex; border: 1px solid var(--sb-divider); border-radius: 7px; overflow: hidden; }
.sb-lang label { position: relative; cursor: pointer; }
.sb-lang input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.sb-lang span { display: block; padding: 3px 10px; font-size: 11.5px; color: var(--sb-muted); }
.sb-lang input:checked + span { background: var(--sb-accent-bg); color: var(--sb-text); }
.sb-lang input:focus-visible + span { outline: 2px solid var(--sb-accent); }
#who { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
#who:empty { display: none; }
#who > span:first-child { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* top bar of the content: breadcrumb (and the menu button on phones) */
.sb-top {
  position: sticky; top: 0; z-index: 50; height: var(--sb-top-h);
  display: flex; align-items: center; gap: 10px; padding: 0 28px;
  background: color-mix(in srgb, var(--sb-bg) 86%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--sb-divider);
  font-family: Inter, system-ui, sans-serif; font-size: 13.5px; color: var(--sb-muted);
}
.sb-crumb { display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; }
.sb-crumb b { color: var(--sb-text); font-weight: 500; }
.sb-crumb i { font-style: normal; color: var(--sb-faint); }
.sb-burger { display: none; }
#jobsCard { scroll-margin-top: calc(var(--sb-top-h) + 12px); }   /* below the sticky bar */

/* icon rail (collapsed): icons only, names in the tooltips */
body.sb-rail .sb-brand, body.sb-rail .sb-sec-h,
body.sb-rail .sb-label, body.sb-rail .sb-badge,
body.sb-rail .sb-ext, body.sb-rail .sb-foot { display: none; }
body.sb-rail .sb-head { padding: 0; justify-content: center; }
body.sb-rail .sb-logo { display: none; }
body.sb-rail .sb-collapse { margin: 0; }
body.sb-rail .sb-nav { padding: 8px 8px; }
body.sb-rail .sb-item { justify-content: center; padding: 9px 0; }
body.sb-rail .sb-sec + .sb-sec { margin-top: 6px; padding-top: 6px; }

/* narrow screens: the sidebar is a drawer behind a menu button */
.sb-scrim { display: none; }
@media (max-width: 900px) {
  body.has-sb, body.has-sb.sb-rail { padding-left: 0; }
  .sb, body.sb-rail .sb { width: min(84vw, var(--sb-w)); transform: translateX(-102%); }
  body.sb-open .sb { transform: none; box-shadow: 0 0 48px rgba(0, 0, 0, .55); }
  .sb-collapse { display: none; }
  .sb-burger { display: grid; margin-left: -10px; }
  .sb-top { padding: 0 16px; }
  .sb-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .45); }
  body.sb-open .sb-scrim { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  .sb, body.has-sb { transition: none; }
}

/* Before a tool is entered (the landing, the sign-in, the account gate)
   there is no sidebar (`SB.show`, sidebar.js): the top bar alone carries
   the name, the language switch and the signed-in user. This block comes
   last: it must win over the drawer rules above. */
body:not(.has-sb) .sb, body:not(.has-sb) .sb-scrim,
body:not(.has-sb) .sb-burger, body:not(.has-sb) .sb-crumb { display: none; }
.sb-top-brand {
  display: none; align-items: center; gap: 10px; flex: none; white-space: nowrap;
  color: var(--sb-text); text-decoration: none; font-weight: 600; font-size: 15px;
}
.sb-top-brand:focus-visible { outline: 2px solid var(--sb-accent); outline-offset: 3px; }
.sb-top-side {
  display: none; margin-left: auto; align-items: center; gap: 12px;
  min-width: 0; font-size: 12px;
}
body:not(.has-sb) .sb-top-brand, body:not(.has-sb) .sb-top-side { display: flex; }
body:not(.has-sb) .sb-top-brand .sb-logo { display: grid; }
.sb-top-side #who { flex-wrap: nowrap; }
.sb-top-side #who > span:first-child { white-space: nowrap; }
.sb-top-side .sb-lang { flex: none; }

/* The tool's name: SHgen on shgen.html, CHARMM-GUI on the CHARMM-GUI
   dashboard (two sidebars, 2026-10-09). The CHARMM-GUI side has a neutral
   icon in a neutral tile, not CHARMM-GUI's logo (docs/LEGAL.md). */
.sb-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sb-name { display: flex; flex-direction: column; line-height: 1.1; white-space: nowrap; }
.sb-name small { font-size: 11px; font-weight: 400; color: var(--sb-faint); margin-top: 2px; }
.sb-logo-cg { background: #3a3f56; }
.sb-logo-cg .sb-ico { width: 17px; height: 17px; color: #e9e9ed; }
body.sb-rail .sb-brand .sb-name { display: none; }
body.sb-rail .sb-brand { display: none; }
