/* repo-sidebar — persistent left repository list for Gitea
 * Injected globally via templates/custom/{header,footer}.tmpl.
 * Styled entirely with Gitea theme CSS variables so it adapts to
 * whatever theme the user is on (light / dark / colourblind variants).
 * Remove the two template files + these assets to fully revert.
 */

:root {
  /* px, not rem: Gitea's `.full.height` resolves a rem padding-left to 0
   * (rem works for width/font elsewhere, just not this padding). px is
   * reliable, so the whole sidebar is sized from this one px value. */
  --grsb-w: 250px;     /* sidebar width when open */
}

/* Shift the whole app + footer to the right to make room. The sidebar
 * itself is position:fixed in the freed gutter, so nothing overlaps. */
body.grsb-on .full.height,
body.grsb-on .page-footer {
  /* NOTE: no `transition` here on purpose. Transitioning a padding whose
   * value is a var() prevents the value from resolving in Chromium (it
   * settles at 0). The sidebar's own transform transition covers the
   * open/close animation; the content shift is instant. */
  padding-left: var(--grsb-w);
}
body.grsb-on.grsb-collapsed .full.height,
body.grsb-on.grsb-collapsed .page-footer {
  padding-left: 0;
}

/* ---- sidebar shell ---- */
#grsb {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--grsb-w);
  z-index: 500;                 /* above content, below Gitea modals/tippy (~1000+) */
  display: flex;
  flex-direction: column;
  background: var(--color-nav-bg, var(--color-menu, var(--color-body)));
  border-right: 1px solid var(--color-secondary, rgba(128,128,128,.3));
  color: var(--color-text);
  font-size: .85rem;
  transform: translateX(0);
  transition: transform .15s ease;
}
body.grsb-collapsed #grsb {
  transform: translateX(-100%);
}

/* ---- header ---- */
#grsb .grsb-head {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem .6rem;
  border-bottom: 1px solid var(--color-secondary, rgba(128,128,128,.25));
  flex: 0 0 auto;
}
#grsb .grsb-title {
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--color-text-light-2, var(--color-text-light));
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#grsb .grsb-count {
  font-weight: 400;
  opacity: .7;
  margin-left: .25rem;
}
#grsb .grsb-btn {
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--color-text-light, var(--color-text));
  padding: .15rem .3rem;
  border-radius: var(--border-radius, 4px);
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
#grsb .grsb-btn:hover {
  background: var(--color-hover, rgba(128,128,128,.15));
  color: var(--color-text);
}

/* ---- filter box ---- */
#grsb .grsb-filter {
  flex: 0 0 auto;
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--color-secondary, rgba(128,128,128,.2));
}
#grsb .grsb-filter input {
  width: 100%;
  box-sizing: border-box;
  padding: .35rem .5rem;
  font-size: .82rem;
  color: var(--color-text);
  background: var(--color-input-background, var(--color-body));
  border: 1px solid var(--color-input-border, var(--color-secondary));
  border-radius: var(--border-radius, 4px);
}
#grsb .grsb-filter input:focus {
  outline: none;
  border-color: var(--color-primary, #4183c4);
}

/* ---- scrollable list ---- */
#grsb .grsb-list {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: .25rem 0 1rem;
}
#grsb .grsb-list::-webkit-scrollbar { width: 8px; }
#grsb .grsb-list::-webkit-scrollbar-thumb {
  background: var(--color-secondary, rgba(128,128,128,.4));
  border-radius: 4px;
}

/* ---- owner group ---- */
#grsb .grsb-owner {
  display: flex;
  align-items: center;
  gap: .35rem;
  width: 100%;
  box-sizing: border-box;
  padding: .35rem .6rem;
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--color-text-light, var(--color-text));
  font-weight: 600;
  font-size: .78rem;
  text-align: left;
}
#grsb .grsb-owner:hover { background: var(--color-hover, rgba(128,128,128,.1)); }
#grsb .grsb-owner .grsb-caret {
  transition: transform .12s ease;
  flex: 0 0 auto;
  opacity: .8;
}
#grsb .grsb-owner.collapsed .grsb-caret { transform: rotate(-90deg); }
#grsb .grsb-owner .grsb-oname {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#grsb .grsb-owner .grsb-ocount { opacity: .55; font-weight: 400; }
#grsb .grsb-owner img.grsb-oavatar {
  width: 16px; height: 16px; border-radius: 3px; flex: 0 0 auto;
}

/* ---- repo row ---- */
#grsb .grsb-repos { display: block; }
#grsb .grsb-owner.collapsed + .grsb-repos { display: none; }
#grsb a.grsb-repo {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .28rem .6rem .28rem 1.65rem;
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;
  border-left: 2px solid transparent;
}
#grsb a.grsb-repo:hover {
  background: var(--color-hover, rgba(128,128,128,.12));
}
#grsb a.grsb-repo.grsb-current {
  background: var(--color-active, rgba(65,131,196,.15));
  border-left-color: var(--color-primary, #4183c4);
}
#grsb a.grsb-repo .grsb-rname {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}
#grsb a.grsb-repo svg { flex: 0 0 auto; opacity: .7; }
#grsb a.grsb-repo.grsb-archived .grsb-rname { opacity: .55; font-style: italic; }
#grsb .grsb-badge {
  flex: 0 0 auto;
  font-size: .62rem;
  padding: .02rem .28rem;
  border-radius: 3px;
  background: var(--color-secondary, rgba(128,128,128,.25));
  color: var(--color-text-light, var(--color-text));
  text-transform: uppercase;
  letter-spacing: .02em;
}

/* ---- footer actions ---- */
#grsb .grsb-foot {
  flex: 0 0 auto;
  display: flex;
  gap: .4rem;
  padding: .45rem .6rem;
  border-top: 1px solid var(--color-secondary, rgba(128,128,128,.25));
}
#grsb .grsb-foot a {
  flex: 1 1 auto;
  text-align: center;
  padding: .3rem;
  font-size: .78rem;
  color: var(--color-text-light, var(--color-text));
  text-decoration: none;
  border: 1px solid var(--color-secondary, rgba(128,128,128,.3));
  border-radius: var(--border-radius, 4px);
}
#grsb .grsb-foot a:hover {
  background: var(--color-hover, rgba(128,128,128,.12));
  color: var(--color-text);
}

#grsb .grsb-empty {
  padding: 1rem .6rem;
  color: var(--color-text-light-2, var(--color-text-light));
  font-size: .8rem;
  text-align: center;
}

/* ---- reopen pill (shown only when collapsed) ---- */
#grsb-reopen {
  position: fixed;
  left: 0;
  bottom: 1rem;
  z-index: 500;
  display: none;
  align-items: center;
  gap: .35rem;
  padding: .4rem .6rem .4rem .5rem;
  background: var(--color-primary, #4183c4);
  color: var(--color-primary-contrast, #fff);
  border: none;
  border-radius: 0 var(--border-radius, 6px) var(--border-radius, 6px) 0;
  cursor: pointer;
  font-size: .78rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
body.grsb-collapsed #grsb-reopen { display: inline-flex; }

/* ---- small screens: default to collapsed behaviour, overlay when open ---- */
@media (max-width: 767px) {
  body.grsb-on .full.height,
  body.grsb-on .page-footer { padding-left: 0; }
  #grsb { box-shadow: 2px 0 12px rgba(0,0,0,.35); }
}
