/* sc-154 Sidebar v2 — dark theme. All values via tokens; no hex literals. */

/* === Layout wrapper (kept for sidebar_controller compatibility) === */
.app-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

/* === Sidebar root === */
.sidebar-v2 {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: 13px;
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 12px;
  gap: 18px;
  box-sizing: border-box;
  transition: width 0.2s ease;
}

.app-layout.collapsed .sidebar-v2 {
  width: var(--sidebar-rail-width);
  padding: 18px 8px 12px;
}

/* === Brand === */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 4px 6px;
  color: var(--text-1);
}
.sidebar-brand-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.sidebar-brand-app {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-brand-label {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-layout.collapsed .sidebar-brand { justify-content: center; padding: 4px 0; }
.app-layout.collapsed .sidebar-brand-text { display: none; }

/* === Nav scroll region === */
.sidebar-nav-scroll {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

/* === Eyebrow section header (inside group toggle button) === */
.sidebar-eyebrow {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex: 1;
  text-align: left;
}
.app-layout.collapsed .sidebar-eyebrow { display: none; }

/* === Neutralize Pico nav defaults that center + shrink list items === */
.sidebar-v2 li::before { display: none; content: none; }
.sidebar-v2 ul { padding: 0; margin: 0; list-style: none; align-items: stretch; }
.sidebar-v2 li { display: block; padding: 0; margin: 0; }

/* === Nav item (used inside group toggles and as standalone links) === */
.sidebar-item,
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 9px 12px;
  min-height: 34px;
  box-sizing: border-box;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.2;
  background: transparent;
  border: none;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

/* Nested-item indent + connector line lives on .sidebar-group-children below */
.sidebar-item:hover,
.sidebar-item:focus-visible,
.sidebar-nav-item:hover,
.sidebar-nav-item:focus-visible {
  background: var(--surface-hover);
  color: var(--text-1);
  outline: none;
}
.sidebar-item[aria-current="page"],
.sidebar-nav-item[aria-current="page"] {
  background: var(--surface-hi);
  color: var(--text-1);
  font-weight: 500;
}
.sidebar-item-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-3);
  display: inline-flex;
}
.sidebar-item[aria-current="page"] .sidebar-item-icon,
.sidebar-nav-item[aria-current="page"] .sidebar-item-icon { color: var(--accent); }
.sidebar-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-layout.collapsed .sidebar-item-label { display: none; }
.app-layout.collapsed .sidebar-item,
.app-layout.collapsed .sidebar-nav-item { justify-content: center; padding: 7px 4px; }

/* === Badge (pending review count) === */
.sidebar-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-2);
  background: var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.4;
}
.app-layout.collapsed .sidebar-badge { display: none; }

/* === Group (collapsible) === */
.sidebar-group,
.sidebar-nav-group { display: flex; flex-direction: column; gap: 2px; }
.sidebar-v2 ul.sidebar-group-children { list-style: none; padding: 4px 0 4px 12px; margin: 0 0 0 16px; display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--border); }
.sidebar-group-children[hidden] { display: none; }
.app-layout.collapsed .sidebar-group-children { display: none !important; }
.sidebar-group-chevron {
  width: 12px; height: 12px;
  margin-left: auto;
  color: var(--text-3);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.sidebar-item[aria-expanded="true"] .sidebar-group-chevron { transform: rotate(180deg); }
.app-layout.collapsed .sidebar-group-chevron { display: none; }

/* === Footer (user identity + menu) === */
.sidebar-footer {
  margin-top: auto;
  position: relative;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.sidebar-footer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  min-width: 0;
}
.sidebar-avatar {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-1);
  flex-shrink: 0;
}
.sidebar-identity { flex: 1; min-width: 0; }
.sidebar-identity-name {
  font-size: 12.5px;
  color: var(--text-1);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-chevron-btn {
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  margin: 0;
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.sidebar-chevron-btn:hover,
.sidebar-chevron-btn:focus-visible {
  background: var(--surface-hover);
  color: var(--text-1);
  outline: none;
}
.sidebar-chevron-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.sidebar-chevron-btn svg { transition: transform 0.15s ease; }
.app-layout.collapsed .sidebar-identity { display: none; }

/* === User menu dropdown === */
.sidebar-user-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 6px;
  left: 6px;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 20;
}
.sidebar-user-menu[hidden] { display: none; }
.sidebar-user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 7px 10px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-1);
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  width: 100%;
}
.sidebar-user-menu-item:hover,
.sidebar-user-menu-item:focus-visible {
  background: var(--surface-hover);
  outline: none;
}
.sidebar-user-menu form { margin: 0; }

/* === Collapse-to-rail toggle (inside .sidebar-brand) === */
.sidebar-rail-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  margin: 0;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-3);
  cursor: pointer;
  flex-shrink: 0;
}
.sidebar-rail-toggle:hover,
.sidebar-rail-toggle:focus-visible {
  color: var(--text-1);
  background: var(--surface-hover);
  outline: none;
}
/* Pico applies a blue box-shadow on button:focus; suppress inside the sidebar */
.sidebar-v2 button:focus { box-shadow: none; }
.sidebar-rail-toggle svg { transition: transform 0.2s ease; width: 14px; height: 14px; }
.app-layout.collapsed .sidebar-rail-toggle svg { transform: rotate(180deg); }

/* === Main content === */
.main-content {
  flex: 1;
  min-width: 0;
  padding: var(--pico-spacing);
  overflow-x: auto;
}

/* === Brand switcher (sc-194) === */
.sidebar-brand-switcher {
  flex: 1;
  min-width: 0;
  margin: 0;
}
.sidebar-brand-select {
  width: 100%;
  margin: 0;
  padding: 4px 24px 4px 6px;
  height: auto;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-1);
  color: var(--text-1);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  text-overflow: ellipsis;
  cursor: pointer;
  box-shadow: none;
}
.sidebar-brand-select:hover,
.sidebar-brand-select:focus-visible {
  background: var(--surface-hover);
  border-color: var(--border);
  outline: none;
  box-shadow: none;
}
.sidebar-brand-select option {
  background: var(--surface-hi);
  color: var(--text-1);
}
.app-layout.collapsed .sidebar-brand-switcher { display: none; }
