/* ============================================================
   SutraHub — repository shell, matched to the reference design.
   Sidebar is our own markup (see custom/templates/repo/header.tmpl);
   this file only positions it and styles the content column.
   ============================================================ */

:root {
  --sh-rail: 262px;
  --sh-topbar: 64px;
}

/* ---------- TOP BAR ---------- */
#navbar {
  position: sticky; top: 0; z-index: 500;
  height: var(--sh-topbar);
  padding: 0 18px !important;
  display: flex; align-items: center; gap: 14px;
  background: var(--sh-surface) !important;
  border-bottom: 1px solid var(--sh-border) !important;
}
#navbar .brand { display: flex; align-items: center; gap: 9px; padding: 0 !important; }
#navbar .brand img, #navbar .brand .logo { width: 28px !important; height: 28px !important; object-fit: contain; }
#navbar .ui.search, #navbar form[action*="search"] { flex: 1 1 auto; max-width: 520px; margin: 0 auto; }
#navbar input[type="search"], #navbar input[name="q"] {
  width: 100%; height: 36px; border-radius: 8px !important;
  background: var(--sh-surface-2) !important; border: 1px solid var(--sh-border) !important;
}

/* breadcrumb injected into the top bar */
.sh-crumb {
  display: flex; align-items: center; gap: 7px;
  font-size: 14.5px; color: var(--sh-text);
  padding-left: 15px; border-left: 1px solid var(--sh-border);
  white-space: nowrap;
}
.sh-crumb a { color: var(--sh-text); }
.sh-crumb .sh-sep { color: var(--sh-text-dim); }
.sh-crumb strong { font-weight: 650; }
.sh-crumb .sh-vis {
  font-size: 11.5px; font-weight: 500; padding: 2px 9px;
  border: 1px solid var(--sh-border); border-radius: 999px; color: var(--sh-text-dim);
}
@media (max-width: 900px) { .sh-crumb { display: none; } }

/* ---------- SHELL: sidebar column + content column ----------
   .secondary-nav (our .sh-nav-root) holds the sidebar and repo header.
   We make the whole page a grid and span the sidebar down the full height. */
.page-content.repository {
  display: grid;
  grid-template-columns: var(--sh-rail) minmax(0, 1fr);
  align-items: start;
  gap: 0;
  max-width: none;
  margin: 0;
  padding: 0;
}

/* the nav root is display:contents so its two children become grid items */
.page-content.repository > .sh-nav-root {
  display: contents;
}

/* ---------- SIDEBAR ---------- */
.sh-side {
  grid-column: 1;
  grid-row: 1 / span 99;
  display: flex; flex-direction: column;
  width: var(--sh-rail);
  min-height: calc(100vh - var(--sh-topbar));
  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;
}
.sh-side-nav { display: flex; flex-direction: column; gap: 1px; }

.sh-nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--sh-text-dim);
  font-size: 14px; font-weight: 500; line-height: 1.25;
  transition: background-color 140ms ease, color 140ms ease;
}
.sh-nav-item .svg { flex: none; opacity: .9; }
.sh-nav-text { flex: 1 1 auto; }
.sh-nav-count { font-size: 13px; color: var(--sh-text-dim); font-variant-numeric: tabular-nums; }
.sh-nav-item:hover { background: var(--sh-surface-2); color: var(--sh-text); }
.sh-nav-item.active {
  background: color-mix(in srgb, var(--sh-violet) 20%, transparent);
  color: var(--sh-text); font-weight: 600;
}
.sh-nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 22%; bottom: 22%;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--sh-gradient);
}

.sh-nav-group {
  margin-top: 18px; padding: 0 12px 8px;
  font-size: 12px; font-weight: 600; color: var(--sh-text-dim);
  border-top: 1px solid var(--sh-border);
  padding-top: 16px;
}

/* owner card pinned to the bottom */
.sh-owner { margin-top: auto; padding-top: 18px; }
.sh-owner-label { font-size: 12px; color: var(--sh-text-dim); padding: 0 4px 8px; }
.sh-owner-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--sh-border); border-radius: 11px;
  background: var(--sh-surface);
  transition: background-color 140ms ease, border-color 140ms ease;
}
.sh-owner-row:hover { background: var(--sh-surface-2); border-color: var(--sh-violet); }
.sh-owner-row img { border-radius: 50%; flex: none; }
.sh-owner-meta { display: flex; flex-direction: column; line-height: 1.3; flex: 1 1 auto; }
.sh-owner-meta strong { font-size: 13.5px; color: var(--sh-text); font-weight: 600; }
.sh-owner-meta small { font-size: 12px; color: var(--sh-text-dim); }
.sh-owner-row .svg { color: var(--sh-text-dim); flex: none; }

/* ---------- REPO HEADER (content column, row 1) ---------- */
.sh-repo-head {
  grid-column: 2; grid-row: 1;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 22px 28px 20px;
  border-bottom: 1px solid var(--sh-border);
}
.sh-repo-id { display: flex; align-items: center; gap: 10px; }
.sh-repo-id .svg, .sh-repo-id img { color: var(--sh-text-dim); }
.sh-repo-name { font-size: 21px; font-weight: 650; letter-spacing: -.01em; color: var(--sh-text); }
.sh-chip {
  font-size: 11.5px; font-weight: 500; padding: 2px 9px;
  border: 1px solid var(--sh-border); border-radius: 999px; color: var(--sh-text-dim);
}
.sh-repo-actions { margin-left: auto; display: flex; gap: 8px; }
.sh-act { display: flex; align-items: stretch; }
.sh-act-btn, .sh-act-num {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--sh-border);
  background: var(--sh-surface);
  color: var(--sh-text);
  font-size: 13.5px; font-weight: 500;
  transition: background-color 140ms ease;
}
.sh-act-btn { border-radius: 8px 0 0 8px; border-right: none; }
.sh-act-num { border-radius: 0 8px 8px 0; color: var(--sh-text-dim); font-variant-numeric: tabular-nums; }
.sh-act-btn:hover, .sh-act-num:hover { background: var(--sh-surface-2); }

/* ---------- CONTENT COLUMN ---------- */
.page-content.repository > *:not(.sh-nav-root) {
  grid-column: 2;
  min-width: 0;
  padding-left: 28px; padding-right: 28px;
}
.page-content.repository > .ui.container {
  width: 100% !important; max-width: 1180px !important; margin: 0 !important;
  padding-top: 20px; padding-bottom: 40px;
}

/* ---------- CARDS ---------- */
.repository #repo-files-table, .repository .file-list {
  border: 1px solid var(--sh-border) !important;
  border-radius: 12px !important; overflow: hidden !important;
  background: var(--sh-surface) !important;
  border-collapse: separate !important; border-spacing: 0 !important;
}
.repository #repo-files-table td, .repository .file-list td {
  padding: 12px 16px !important; border-top: none !important;
}
.repository #repo-files-table tr:not(:last-child) td,
.repository .file-list tr:not(:last-child) td { border-bottom: 1px solid var(--sh-border) !important; }
.repository .latest-commit { background: var(--sh-surface-2) !important; }
.repository #readme, .repository .file-view.markup, .repository .markup-body-wrapper {
  border: 1px solid var(--sh-border) !important;
  border-radius: 12px !important; overflow: hidden;
  background: var(--sh-surface) !important;
}

/* the reference keeps Code green */
.ui.green.button, .ui.primary.button {
  background: #238636 !important; border-color: transparent !important; color: #fff !important;
}
.ui.green.button:hover, .ui.primary.button:hover { background: #2ea043 !important; }

/* ---------- GLOBAL PAGES (no repo sidebar) ---------- */
.page-content.dashboard, .page-content.explore,
.page-content.user, .page-content.admin, .page-content.organization {
  max-width: 1400px; margin: 0 auto; padding: 22px 24px 48px;
}

/* ---------- FOOTER ---------- */
.page-footer {
  max-width: none; margin: 0;
  padding: 18px 28px !important;
  border-top: 1px solid var(--sh-border);
  display: flex; align-items: center; gap: 18px;
  font-size: 13px; color: var(--sh-text-dim);
}
.page-footer .right-links { margin-left: auto; display: flex; gap: 16px; align-items: center; }

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