/* =============================================================
   Modern sidebar — warm carbon edition
   Uses theme tokens defined in static/css/modern-docs.css
   ============================================================= */

.modern-sidebar {
  --sidebar-width: 320px;
  --sidebar-collapsed-width: 48px;
  --row-height: 26px;
  --member-row-height: 22px;

  width: var(--sidebar-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: 12.5px;
  position: relative;
  z-index: 5;
}

.modern-sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

/* ========== HEADER ========== */
.sidebar-header {
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg);
}
.sidebar-tabs { display: flex; gap: 2px; }
.sidebar-tab {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}
.sidebar-tab:hover { background: var(--bg-2); color: var(--text-0); }
.sidebar-tab.active {
  background: var(--bg-2);
  color: var(--accent);
  border-color: var(--border);
}
.sidebar-icon-btn {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.15s;
}
.sidebar-icon-btn:hover { color: var(--text-0); background: var(--bg-2); border-color: var(--border); }

/* Current-version indicator — sits between the tabs and the collapse button,
 * pushed to the right edge. Deliberately muted (most-subdued text token) so it
 * reads as quiet metadata, not a control. Hidden when empty (non-doc routes
 * before the JS resolves a fallback year) and when the sidebar is collapsed. */
.sidebar-version {
  margin: 0 6px 0 auto;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3px;
  color: var(--text-3);
  user-select: none;
  white-space: nowrap;
}
.sidebar-version:empty { display: none; }

/* Collapsed: hide most chrome, show only the expand button */
.modern-sidebar.collapsed .sidebar-tabs,
.modern-sidebar.collapsed .sidebar-version,
.modern-sidebar.collapsed .sidebar-filter,
.modern-sidebar.collapsed .sidebar-content,
.modern-sidebar.collapsed .sidebar-extras,
.modern-sidebar.collapsed #sidebar-collapse-btn,
.modern-sidebar.collapsed .sidebar-resize-handle { display: none !important; }

/* ========== FILTER ========== */
.sidebar-filter {
  flex-shrink: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-0);
  position: relative;          /* anchors the search-settings dropdown */
}
.sidebar-filter-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sidebar-filter input {
  flex: 1;
  height: 30px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-0);
  outline: none;
  transition: all 0.15s;
  min-width: 0;
}
.sidebar-filter input::placeholder { color: var(--text-3); }
.sidebar-filter input:focus {
  border-color: var(--accent);
  background: var(--bg-1);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.sidebar-filter[hidden] { display: none; }

/* Brief glow on the filter input when an example query is dropped in from
 * the cheat-sheet page. Lets the user see where their click landed even
 * when the sidebar is far from the click target. */
.modern-sidebar.rvt-flash-input .sidebar-filter input {
  border-color: var(--accent);
  background: var(--bg-1);
  box-shadow: 0 0 0 4px var(--accent-glow);
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
}

/* Cog button — sits beside the input. Highlights when the dropdown is open. */
.sidebar-search-cog {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
}
.sidebar-search-cog:hover {
  color: var(--accent);
  border-color: var(--border-strong);
  background: var(--bg-3);
}
.sidebar-search-cog:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
/* Subtle accent dot when the user has changed any search option from its
 * default — gives a hint that "your search settings are not the defaults"
 * without recoloring the icon itself (which read as too orange before).
 * Only renders on the cog, not the reset button. */
#sidebar-search-cog.is-customized::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1.5px var(--bg-2);
}
.sidebar-search-cog { position: relative; }

/* Highlight-matches button — uses the shared .sidebar-search-cog skin but
 * gets a clear "ON" state when toggled because it's a display preference,
 * not a one-shot action. */
#sidebar-search-highlight.is-active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}
#sidebar-search-highlight.is-active:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}

/* Match highlight inside tree labels. Subtle warm-accent tint — readable on
 * the dark default theme and the light theme. No padding so the wrapped span
 * doesn't shift line metrics. Inherits font weight + size from .tree-label. */
mark.rvt-tree-hl {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
  border-radius: 2px;
  padding: 0 1px;
}
/* On an active row the label sits on the accent background already; flip the
 * mark to a translucent dark fill so the match still pops without colliding
 * with the row tint. */
.tree-row.active mark.rvt-tree-hl {
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
}

/* Settings panel — floats next to the sidebar as a draggable popover (the
 * JS reparents it to <body> on open so no sidebar overflow clips it).
 * Position is set inline by JS; this block only owns visual + sizing rules. */
.sidebar-search-settings {
  position: fixed;
  width: 280px;
  max-width: calc(100vw - 24px);
  z-index: 1000;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0 6px 6px 6px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45), 0 0 0 1px var(--accent-glow);
  display: none;
  font-family: var(--font-sans);
  text-align: left;
}
.sidebar-search-settings.open { display: block; }

/* Drag-handle header — title on the left, close button on the right.
 * cursor:move signals "grab to drag" without needing a separate hint. */
.sidebar-search-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 6px 7px 10px;
  margin: 0 -6px 4px -6px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  border-radius: 7px 7px 0 0;
  cursor: move;
  user-select: none;
}
.sidebar-search-settings-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-2);
}
.sidebar-search-settings-close {
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 2px 4px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
}
.sidebar-search-settings-close:hover {
  color: var(--accent);
  background: var(--bg-3);
}
.sidebar-search-settings.is-dragging {
  /* Drop the transition while dragging so the panel tracks the cursor. */
  transition: none;
  box-shadow: 0 16px 40px rgba(0,0,0,0.55), 0 0 0 1px var(--accent);
}
.sidebar-search-settings-heading {
  padding: 8px 10px 4px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  text-align: left;
}
.sidebar-search-settings-row {
  display: grid;
  grid-template-columns: 16px 1fr;
  align-items: center;
  column-gap: 10px;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-1);
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.sidebar-search-settings-row:hover {
  background: var(--bg-2);
  color: var(--text-0);
}
.sidebar-search-settings-row input[type="checkbox"] {
  margin: 0;
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
  justify-self: start;
}
.sidebar-search-settings-row > span {
  text-align: left;
  justify-self: start;
}
.sidebar-search-settings-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

/* Ignore-keywords input. Same skin as the main filter so it visually pairs
 * with the search box concept. Mono font + small padding so multi-token
 * lists ("BuiltInFailures Obsolete Deprecated") read cleanly. */
.sidebar-search-ignore-wrap {
  padding: 2px 10px 6px 10px;
}
.sidebar-search-ignore-wrap input {
  width: 100%;
  height: 28px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-0);
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.sidebar-search-ignore-wrap input::placeholder { color: var(--text-3); }
.sidebar-search-ignore-wrap input:focus {
  border-color: var(--accent);
  background: var(--bg-1);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Type-filter chip strip — colored [C][I][E][S][D][N][M][P][E][C][F][O]
 * buttons. Click to toggle; deactivated chips fade to gray so it's obvious
 * which types are excluded from the current search. */
.sidebar-search-types-actions {
  display: flex;
  gap: 6px;
  padding: 0 10px 4px 10px;
}
.sidebar-search-types-action {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}
.sidebar-search-types-action:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}
/* Grid of 6 columns × 2 rows so every chip is the same width and pinned to
 * its column. Wrap is naturally handled — extra chips flow into the second
 * row. The chip is still 22px tall but stretches to fill its grid cell. */
.sidebar-search-types {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  padding: 4px 10px 10px 10px;
}
.sidebar-search-types .type-icon {
  width: 100%;
  height: 24px;
  font-size: 12px;
  border: 0;
  cursor: pointer;
  padding: 0;
  transition: opacity 0.15s, filter 0.15s, transform 0.1s;
}
.sidebar-search-types .type-icon:hover {
  transform: translateY(-1px);
}
.sidebar-search-types .type-icon.is-off {
  /* Deactivated state: gray chip, no color. */
  background: var(--bg-3) !important;
  color: var(--text-3) !important;
  opacity: 0.6;
  filter: saturate(0);
}

/* Chip tooltips render ABOVE the chip (instead of below) so they stay
 * inside the panel boundary — sidesteps stacking-context clipping that
 * happens when the tooltip would have to escape the panel's z-index trap. */
.sidebar-search-types .type-icon[data-tooltip]:hover::after,
.sidebar-search-types .type-icon[data-tooltip]:focus-visible::after {
  top: auto;
  bottom: calc(100% + 6px);
}
.sidebar-search-types .type-icon[data-tooltip]:hover::before,
.sidebar-search-types .type-icon[data-tooltip]:focus-visible::before {
  top: auto;
  bottom: calc(100% + 1px);
  border-left: 0;
  border-top: 0;
  border-right: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
}

/* ========== CONTENT ========== */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  position: relative;
  padding: 4px 6px 24px 8px;
}
.sidebar-content::-webkit-scrollbar { width: 6px; }
.sidebar-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.sidebar-content::-webkit-scrollbar-track { background: transparent; }
.sidebar-pane { display: none; }
.sidebar-pane.active { display: block; }

/* ========== TREE ========== */
.rvt-tree { font-family: var(--font-mono); font-size: 12.5px; }
.tree-loading,
.tree-error {
  padding: 24px 12px;
  color: var(--text-3);
  font-size: 11.5px;
  text-align: center;
}
.tree-error button {
  margin-top: 10px;
  padding: 4px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-0);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
}

.tree-group { border-left: 1px solid transparent; margin-left: 0; }
.tree-group.nested {
  margin-left: 10px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--text-2);
  user-select: none;
  transition: background 0.1s, color 0.1s;
  position: relative;
  text-decoration: none;
  line-height: 1.3;
  min-height: var(--row-height);
}

/* Tiny red asterisk shown after a tree label when the page is marked
 * obsolete. Quiet — same height as the label, no background, no border. */
.tree-obsolete-star {
  flex-shrink: 0;
  margin-left: 2px;
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1;
  font-weight: 700;
  pointer-events: none;
}

/* Tiny blue star shown after a tree label when the page is NEW in this
 * Revit version (not present in N-1). Quiet, same line-height as the
 * label, no background. Matches the obsolete-star pattern. */
.tree-new-star {
  flex-shrink: 0;
  margin-left: 2px;
  color: var(--type-class);   /* Use the type-class blue token */
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1;
  pointer-events: none;
}

/* Tint the row label red when an obsolete star is present — gives the user
 * a stronger visual cue without going so loud it competes with the active
 * row. Light red so it stays in the warm-carbon palette. */
.tree-row:has(.tree-obsolete-star) .tree-label {
  color: #c46577;          /* Soft red, same family as --danger */
}
.dark .tree-row:has(.tree-obsolete-star) .tree-label {
  color: #d97a8c;          /* Slightly brighter for the dark surface */
}
/* Leave the active row bright white so the user can still read it clearly. */
.tree-row.active:has(.tree-obsolete-star) .tree-label {
  color: var(--text-0);
}
.tree-row:hover { background: var(--bg-2); color: var(--text-0); }
.tree-row.active { background: var(--bg-2); color: var(--text-0); }
.tree-row.active::before {
  content: '';
  position: absolute;
  left: -1px; top: 4px; bottom: 4px;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--accent-glow);
}

.tree-row .chev,
.tree-row .chev-spacer {
  width: 12px; height: 12px;
  flex-shrink: 0;
  color: var(--text-3);
  transition: transform 0.15s;
}
.tree-group.open > .tree-row > .chev { transform: rotate(90deg); color: var(--text-1); }

/* Type icons — color-coded by node kind. Uniform 16×16 box; line-height 1
 * keeps the letter glyph vertically centered regardless of font ascent. */
.type-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  border-radius: 3px;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: var(--bg-0);
  text-transform: uppercase;
  position: relative;
}

/* Hover tooltip — shows the type's full name ("Method", "Property", ...).
 * Pure CSS via ::after on the data-tooltip attr; appears below the icon
 * after a tiny delay so quick mouse passes don't fire.
 *
 * z-index 9999 keeps the tooltip above the search-settings dropdown (which
 * lives at z-index 30) and any other floating UI on the page. We also lift
 * the icon's stacking context on hover so the tooltip isn't clipped by a
 * sibling that happens to paint later. */
.type-icon:hover {
  z-index: 9998;
}
.type-icon[data-tooltip]:hover::after,
.type-icon[data-tooltip]:focus-visible::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-3);
  color: var(--text-0);
  padding: 4px 9px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  animation: rvt-icon-tip-fade 0.1s ease-out 0.25s both;
}
.type-icon[data-tooltip]:hover::before,
.type-icon[data-tooltip]:focus-visible::before {
  /* Small triangle pointing up to the icon */
  content: "";
  position: absolute;
  top: calc(100% + 1px);
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 6px;
  height: 6px;
  background: var(--bg-3);
  border-left: 1px solid var(--border-strong);
  border-top: 1px solid var(--border-strong);
  z-index: 9999;
  pointer-events: none;
  animation: rvt-icon-tip-fade 0.1s ease-out 0.25s both;
}
@keyframes rvt-icon-tip-fade {
  from { opacity: 0; transform: translateX(-50%) translateY(-2px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.type-icon[data-tooltip]:hover::before,
.type-icon[data-tooltip]:focus-visible::before {
  /* override the translate so the rotated triangle stays centered */
  animation-name: rvt-icon-tip-tri-fade;
}
@keyframes rvt-icon-tip-tri-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.type-icon.ns   { background: var(--type-namespace); }
.type-icon.cls  { background: var(--type-class); }
.type-icon.mth  { background: var(--type-method); }
.type-icon.prp  { background: var(--type-property); }
.type-icon.enm  { background: var(--type-enum); }
.type-icon.evt  { background: var(--type-event); }
.type-icon.ifc  { background: var(--type-interface); }
.type-icon.ctor { background: var(--accent); }
.type-icon.cat  { background: var(--bg-3); color: var(--text-2); border: 1px solid var(--border-strong); }

.tree-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
}
.tree-row.is-namespace .tree-label,
.tree-row.is-category  .tree-label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}
.tree-row.is-namespace:hover .tree-label,
.tree-row.is-category:hover  .tree-label,
.tree-group.open > .tree-row.is-category > .tree-label { color: var(--text-1); }
/* Namespaces are structural — keep them muted even when expanded so they
 * don't pull attention away from the active class / member inside. */
.tree-group.open > .tree-row.is-namespace > .tree-label { color: var(--text-3); }

.tree-row.is-class .tree-label,
.tree-row.is-enum  .tree-label,
.tree-row.is-interface .tree-label,
.tree-row.is-structure .tree-label,
.tree-row.is-delegate  .tree-label { color: var(--text-1); font-weight: 500; }

.tree-row.is-class.active .tree-label,
.tree-row.is-class:hover     .tree-label,
.tree-row.is-enum:hover      .tree-label,
.tree-row.is-interface:hover .tree-label { color: var(--text-0); }

.tree-row.is-member {
  min-height: var(--member-row-height);
  padding: 2px 8px 2px 4px;
  font-size: 12px;
}
.tree-row.is-member:hover { color: var(--text-0); }

.tree-meta {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-3);
  background: var(--bg-2);
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

.tree-children { overflow: hidden; max-height: 0; transition: max-height 0.18s ease; }
.tree-group.open > .tree-children { max-height: 999999px; }

.tree-row.filter-hide { display: none !important; }

/* ========== BOOKMARKS PANE ========== */
.bookmarks-empty-state {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-3);
  font-family: var(--font-sans);
}
.bookmarks-empty-state p { margin: 6px 0 0; font-size: 13px; }
.bookmarks-hint { color: var(--text-3); font-size: 11px !important; }
.bookmarks-list { padding: 8px 0; }
.bookmarks-list[hidden] { display: none; }
.bookmark-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 5px;
  color: var(--text-1);
  text-decoration: none;
  font-size: 12.5px;
  font-family: var(--font-mono);
  cursor: pointer;
}
.bookmark-item:hover { background: var(--bg-2); color: var(--text-0); }
.bookmark-remove {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: var(--text-3);
  cursor: pointer;
  padding: 2px;
  border-radius: 3px;
}
.bookmark-remove:hover { color: var(--danger); background: var(--bg-3); }

/* ========== WHATSNEW PANE ========== */
.whatsnew-wrap { padding: 12px 14px; }
.whatsnew-title {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin: 0 0 12px 0;
}
#whatsnew-toc a {
  display: block;
  padding: 5px 8px;
  font-size: 12px;
  color: var(--text-2);
  text-decoration: none;
  border-radius: 4px;
  border-left: 1px solid var(--border);
  margin-left: 6px;
  padding-left: 10px;
}
#whatsnew-toc a:hover { color: var(--text-0); border-left-color: var(--accent); }

/* ========== RESIZE / EXPAND ========== */
.sidebar-resize-handle {
  position: absolute;
  top: 0; right: -3px;
  width: 6px; height: 100%;
  cursor: col-resize;
  z-index: 10;
}
.sidebar-resize-handle:hover { background: var(--accent-glow); }

/* Lives fully INSIDE the collapsed 48px strip, centered. Hanging it half
   over the right edge (right: -16px) made it look clipped behind the main
   pane, which paints above the overhang. */
.sidebar-expand-btn {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-1);
  cursor: pointer;
  z-index: 11;
}
.sidebar-expand-btn:hover { color: var(--text-0); border-color: var(--accent); }
.sidebar-expand-btn[hidden] { display: none; }
