/*
 * Over — Sidebar / navigation
 *
 * Layout: a top header band (logo + window controls) that matches the tab-bar
 * height, then the menu body, then the user footer.
 *
 * Icon-column rule: every icon (logo, menu icons, footer avatar, collapsed
 * toggle) sits at the SAME x = rail-pad + navitem-pad. Collapsing only hides
 * labels and shrinks the rail to --sidebar-collapsed (sized so the column x is
 * unchanged) — icons never move. Do NOT re-justify or re-pad rows on collapse.
 */

.sidebar {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--border-soft);
  overflow: hidden;
  user-select: none;
  transition: width 0.14s ease; /* animates collapse/expand only */
}
/* During drag-resize the width is driven per-frame — no transition, or it lags.
   Both side blocks therefore track the cursor identically. */
.sidebar.is-resizing { transition: none; }

/* ── Header band (matches tab-bar height) ── */
.sidebar__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  height: var(--topbar-h);
  flex-shrink: 0;
  padding: 0 var(--rail-pad);
  border-bottom: 1px solid var(--border-soft);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  flex: 1;
  padding-left: var(--sp-2); /* aligns logo to the icon column (rail-pad + this) */
  overflow: hidden;
}
.sidebar__logo {
  flex-shrink: 0;
  width: var(--icon);
  height: var(--icon);
  display: grid;
  place-items: center;
}
.sidebar__brand-name {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semi);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__winctrls {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* ── Body (menu + spacer + footer), inset by rail-pad ── */
.sidebar__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: var(--rail-pad);
}

.navlist {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* One menu-row size. Icon at rail-pad + navitem-pad. */
.navitem {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  height: var(--navitem-h);
  padding: 0 var(--sp-2);
  border-radius: var(--r-sm);
  color: var(--text-dim);
  font-size: var(--fs-base);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.12s, color 0.12s;
}
.navitem:hover { background: var(--surface-hover); color: var(--text); }
.navitem.is-active { background: var(--surface); color: var(--text); }

.navitem__icon {
  flex-shrink: 0;
  width: var(--icon);
  height: var(--icon);
  display: grid;
  place-items: center;
}
.navitem__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.1s ease;
}

/* ── Expandable group (Development > Database / DB Setup) ── */
.navgroup { display: flex; flex-direction: column; gap: 2px; }
.navsub { display: flex; flex-direction: column; gap: 2px; }

/* Disclosure chevron on the parent row: right-aligned, rotates when open.
   Points right when closed, down when open. Hidden when the rail is collapsed. */
.navitem__chevron {
  flex-shrink: 0;
  width: var(--icon);
  height: var(--icon);
  display: grid;
  place-items: center;
  color: var(--text-faint);
  transform: rotate(-90deg);
  transition: transform 0.12s ease, opacity 0.1s ease;
}
.navitem__chevron.is-open { transform: rotate(0deg); }

/* Sub-item: icon stays in the shared column (never indented), so collapsing
   the rail doesn't move it. Nesting is signalled by indenting the LABEL only. */
.navitem--sub .navitem__label { padding-left: var(--sp-3); color: var(--text-dim); }

/* Spacer + footer */
.sidebar__spacer { flex: 1; }

.sidebar__foot {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--navitem-h);
  padding: 0 var(--sp-2);
  border-radius: var(--r-sm);
  overflow: hidden;
  transition: background 0.12s;
}
.sidebar__foot:hover { background: var(--surface-hover); }

.avatar {
  flex-shrink: 0;
  width: var(--icon);
  height: var(--icon);
  border-radius: 50%;
  background: var(--accent);
  color: var(--white);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  display: grid;
  place-items: center;
}
.sidebar__user {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text);
  font-size: var(--fs-base);
  transition: opacity 0.1s ease;
}
.sidebar__settings {
  flex-shrink: 0;
  color: var(--text-faint);
  display: grid;
  place-items: center;
  width: var(--icon);
  height: var(--icon);
  transition: color 0.12s;
}
.sidebar__settings:hover { color: var(--text-dim); }

/* ── Collapsed: hide labels only; icons keep their x (no flinch) ── */
.sidebar.is-collapsed { width: var(--sidebar-collapsed) !important; }

/* Header: drop brand + back/forward, centre the remaining toggle in the column */
.sidebar.is-collapsed .sidebar__brand,
.sidebar.is-collapsed .winbtn--nav { display: none; }
.sidebar.is-collapsed .sidebar__winctrls { flex: 1; justify-content: center; }

/* Body: hide text, keep icons/avatar exactly where they were */
.sidebar.is-collapsed .navitem__label,
.sidebar.is-collapsed .sidebar__user,
.sidebar.is-collapsed .sidebar__settings {
  opacity: 0;
  width: 0;
  flex: 0;
  pointer-events: none;
}
/* Sub-label carries a left indent when expanded — zero it so the collapsed
   width stays exact and the icon column doesn't shift. */
.sidebar.is-collapsed .navitem--sub .navitem__label { padding-left: 0; }
/* The disclosure chevron is meaningless with no labels — remove it. */
.sidebar.is-collapsed .navitem__chevron { display: none; }
