/* ============================================================
   SutraHub — GLOBAL shell (non-repo pages).

   Repo pages already get their rail from custom/templates/repo/header.tmpl
   and are laid out by sutrahub-layout.css. This file does the same job for
   the other five page families (dashboard, explore, user, org, admin), whose
   rail is emitted by custom/templates/custom/body_inner_pre.tmpl.

   The rail is a SIBLING of .page-content (Forgejo gives us no shared wrapper
   inside it), so we lay out the common parent `.full.height` as the grid.
   ============================================================ */

/* The rail sits inside `.full height` alongside #navbar and .page-content.
   Grid template: navbar spans both columns, then rail | content. */
.full.height:has(> [data-sh-global-rail]) {
  display: grid;
  grid-template-columns: var(--sh-rail) minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  align-items: start;
  min-height: 100vh;
}

/* navbar and footer span the full width, above and below the split */
.full.height:has(> [data-sh-global-rail]) > #navbar { grid-column: 1 / -1; grid-row: 1; }
.full.height:has(> [data-sh-global-rail]) > .page-footer { grid-column: 1 / -1; grid-row: 3; }

/* everything else (the actual page body, alerts, etc.) sits in column 2 */
.full.height:has(> [data-sh-global-rail]) > *:not(#navbar):not(.page-footer):not([data-sh-global-rail]) {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
}

/* ---------- THE RAIL ---------- */
.sh-gside {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  width: var(--sh-rail);
  padding: 16px 12px 16px 16px;
  border-right: 1px solid var(--sh-border);
  background: var(--sh-bg);
  position: sticky;
  top: var(--sh-topbar);
  max-height: calc(100vh - var(--sh-topbar));
  overflow-y: auto;
}

/* Reuse the repo rail's item styling verbatim — .sh-nav-item, .sh-nav-group,
   .sh-owner* are all defined in sutrahub-layout.css. One visual language,
   one place to change it. */

/* Non-repo pages centre their content in a max-width container by default
   (sutrahub-layout.css "GLOBAL PAGES"). Inside the grid that double-margins
   the content, so flatten it to the column. */
.full.height:has(> [data-sh-global-rail]) > .page-content {
  max-width: none;
  margin: 0;
  padding: 22px 28px 48px;
}
.full.height:has(> [data-sh-global-rail]) > .page-content > .ui.container {
  width: 100% !important;
  max-width: 1180px !important;
  margin: 0 !important;
}

/* Forgejo's own secondary nav (dashboard context switcher, explore tabs)
   duplicates what the rail now shows. Keep the dashboard one — it carries the
   org switcher — but drop the explore tab strip, which is pure duplication. */
.page-content.explore > .secondary-nav { display: none; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1000px) {
  .full.height:has(> [data-sh-global-rail]) {
    grid-template-columns: minmax(0, 1fr);
  }
  .full.height:has(> [data-sh-global-rail]) > *:not(#navbar):not(.page-footer):not([data-sh-global-rail]) {
    grid-column: 1;
    grid-row: auto;
  }
  .sh-gside {
    grid-column: 1;
    grid-row: auto;
    position: static;
    width: 100%;
    max-height: none;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--sh-border);
    padding: 8px 12px;
  }
  .sh-gside .sh-side-nav { flex-direction: row; gap: 4px; }
  .sh-gside .sh-nav-item { white-space: nowrap; min-height: 44px; }
  .sh-gside .sh-nav-item.active::before { display: none; }
  .sh-gside .sh-nav-group,
  .sh-gside .sh-owner { display: none; }
  .full.height:has(> [data-sh-global-rail]) > .page-content { padding: 16px; }
}
