/* Right sidebar table of contents */
.right-toc {
  position: fixed;
  top: 4rem;
  right: 1rem;
  width: 20rem;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
  padding: 1rem;
  background: var(--sidebar-color);
  border-left: 1px solid var(--border-color);
  font-size: 0.85rem;
  display: none; /* Hidden by default, shown on large screens */
}

/* Only show on very wide screens */
@media (min-width: 90rem) {
  .right-toc {
    display: block;
  }
  
  /* Adjust main content to make room */
  .main-content-wrap {
    padding-right: 22rem !important;
  }
}

.right-toc-title {
  font-weight: bold;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--body-heading-color);
}

.right-toc ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.right-toc ul ul {
  padding-left: 1rem;
  margin-top: 0.25rem;
}

.right-toc li {
  margin: 0.25rem 0;
}

.right-toc a {
  color: var(--body-text-color);
  text-decoration: none;
  display: block;
  padding: 0.15rem 0;
  border-left: 2px solid transparent;
  padding-left: 0.5rem;
  transition: all 0.2s ease;
}

.right-toc a:hover {
  color: var(--link-color);
  border-left-color: var(--link-color);
}

.right-toc a.active {
  color: var(--link-color);
  border-left-color: var(--link-color);
  font-weight: 600;
  background-color: rgba(0, 0, 0, 0.03);
}

/* Dark mode adjustments */
[data-color-mode="dark"] .right-toc a.active {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Scrollbar styling for TOC */
.right-toc::-webkit-scrollbar {
  width: 6px;
}

.right-toc::-webkit-scrollbar-track {
  background: transparent;
}

.right-toc::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.right-toc::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Property groups styling */
.toc-groups {
  padding-left: 0 !important;
}

.toc-group-item {
  margin: 0.5rem 0;
}

.toc-group {
  font-weight: 600;
  color: var(--body-heading-color) !important;
  cursor: pointer;
  position: relative;
}

.toc-toggle {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
  position: relative;
  top: -2px;
}

/* Collapsed state - point right */
.toc-group-item.collapsed .toc-toggle {
  transform: rotate(-135deg);
  top: 0;
}

.toc-properties {
  padding-left: 1.5rem !important;
  margin-top: 0.25rem;
  max-height: 500px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

/* Collapsed state */
.toc-group-item.collapsed .toc-properties {
  max-height: 0;
  margin-top: 0;
}

.toc-property {
  font-size: 0.8rem;
  color: var(--body-text-color) !important;
  opacity: 0.8;
}

.toc-property:hover {
  opacity: 1;
}

/* Highlight effect for table rows */
@keyframes highlight-flash {
  0% {
    background-color: rgba(0, 123, 255, 0.2);
  }
  100% {
    background-color: transparent;
  }
}

tr.highlight-row {
  animation: highlight-flash 2s ease;
}

tr.highlight-row th,
tr.highlight-row td {
  background-color: rgba(0, 123, 255, 0.1);
}
