/* Sidebar Styles for GitHub Pages Wiki */

.container-wrapper {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  gap: 2rem;
}

.sidebar-container {
  flex: 0 0 250px;
  position: sticky;
  top: 2rem;
  align-self: flex-start;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
}

.main-content-wrapper {
  flex: 1;
  min-width: 0;
}

.sidebar {
  background: #f5f5f5;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sidebar-nav h1 {
  font-size: 1rem;
  font-weight: 700;
  color: #333;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #ddd;
}

.sidebar-nav h1:first-child {
  margin-top: 0;
}

.sidebar-nav h2 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #555;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.sidebar-nav ul {
  list-style: none;
  padding-left: 0;
  margin: 0 0 1rem 0;
}

.sidebar-nav li {
  margin: 0.25rem 0;
}

.sidebar-nav a {
  display: block;
  padding: 0.4rem 0.8rem;
  color: #0366d6;
  text-decoration: none;
  border-radius: 4px;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.sidebar-nav a:hover {
  background: #e1e4e8;
  color: #0366d6;
  text-decoration: none;
  padding-left: 1rem;
}

.sidebar-nav a:active,
.sidebar-nav a.active {
  background: #0366d6;
  color: white;
}

.sidebar-nav hr {
  border: none;
  border-top: 1px solid #ddd;
  margin: 1rem 0;
}

/* Scrollbar styling */
.sidebar-container::-webkit-scrollbar {
  width: 6px;
}

.sidebar-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.sidebar-container::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

.sidebar-container::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Responsive design */
@media (max-width: 768px) {
  .container-wrapper {
    flex-direction: column;
  }

  .sidebar-container {
    position: static;
    flex: none;
    max-height: none;
    margin-bottom: 2rem;
  }

  .sidebar {
    padding: 1rem;
  }

  .sidebar-nav {
    column-count: 2;
    column-gap: 1rem;
  }

  .sidebar-nav h1,
  .sidebar-nav h2 {
    break-after: avoid;
  }

  .sidebar-nav ul {
    break-inside: avoid;
  }
}

@media (max-width: 480px) {
  .sidebar-nav {
    column-count: 1;
  }
}

/* Right TOC Sidebar Styles */
.toc-container {
  flex: 0 0 280px;
  position: sticky;
  top: 2rem;
  align-self: flex-start;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  margin-left: 2rem;
}

.toc-sidebar {
  background: #f8f9fa;
  border-left: 3px solid #0366d6;
  border-radius: 6px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.toc-sidebar h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #333;
  margin-top: 0;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #ddd;
}

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

.toc-sidebar li {
  margin: 0.3rem 0;
}

.toc-sidebar > ul > li > ul {
  padding-left: 1rem;
  margin-top: 0.3rem;
}

.toc-sidebar > ul > li > ul > li > ul {
  padding-left: 1rem;
  margin-top: 0.2rem;
}

.toc-sidebar a {
  display: block;
  padding: 0.3rem 0.6rem;
  color: #0366d6;
  text-decoration: none;
  border-radius: 4px;
  transition: all 0.2s ease;
  font-size: 0.85rem;
  line-height: 1.4;
}

.toc-sidebar a:hover {
  background: #e8f4ff;
  color: #0366d6;
  text-decoration: none;
  padding-left: 0.8rem;
}

.toc-sidebar a.active {
  background: #0366d6;
  color: white;
  font-weight: 600;
}

/* Toggle arrow styles */
.toc-toggle {
  display: inline-block;
  cursor: pointer;
  user-select: none;
  color: #666;
  font-size: 0.7rem;
  margin-left: 0.5rem;
  transition: transform 0.2s ease;
  float: right;
  line-height: 1.4;
}

.toc-toggle:hover {
  color: #0366d6;
}

.toc-sidebar li.has-children {
  position: relative;
}

.toc-sidebar li.has-children > a {
  display: inline-block;
  width: calc(100% - 20px);
}

.toc-sidebar .toc-nested {
  transition: all 0.3s ease;
  overflow: hidden;
  padding-left: 1.2rem;
  margin-top: 0.4rem;
  border-left: 2px solid #e1e4e8;
}

/* Layout with TOC */
.container-wrapper-with-toc {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  gap: 0;
}

.container-wrapper-with-toc .main-content-wrapper {
  flex: 1;
  min-width: 0;
}

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

.toc-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.toc-container::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

.toc-container::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Responsive design for TOC */
@media (max-width: 1200px) {
  .toc-container {
    display: none;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .sidebar {
    background: #2d2d2d;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }

  .sidebar-nav h1 {
    color: #e1e4e8;
    border-bottom-color: #444;
  }

  .sidebar-nav h2 {
    color: #c9d1d9;
  }

  .sidebar-nav a {
    color: #58a6ff;
  }

  .sidebar-nav a:hover {
    background: #444;
    color: #58a6ff;
  }

  .sidebar-nav a:active,
  .sidebar-nav a.active {
    background: #58a6ff;
    color: #0d1117;
  }

  .sidebar-nav hr {
    border-top-color: #444;
  }

  .sidebar-container::-webkit-scrollbar-track {
    background: #2d2d2d;
  }

  .sidebar-container::-webkit-scrollbar-thumb {
    background: #666;
  }

  .sidebar-container::-webkit-scrollbar-thumb:hover {
    background: #888;
  }

  /* Dark mode for TOC */
  .toc-sidebar {
    background: #2d2d2d;
    border-left-color: #58a6ff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }

  .toc-sidebar h2 {
    color: #e1e4e8;
    border-bottom-color: #444;
  }

  .toc-sidebar a {
    color: #58a6ff;
  }

  .toc-sidebar a:hover {
    background: #444;
    color: #58a6ff;
  }

  .toc-sidebar a.active {
    background: #58a6ff;
    color: #0d1117;
  }

  .toc-container::-webkit-scrollbar-track {
    background: #2d2d2d;
  }

  .toc-container::-webkit-scrollbar-thumb {
    background: #666;
  }

  .toc-container::-webkit-scrollbar-thumb:hover {
    background: #888;
  }

  /* Dark mode for toggle arrows */
  .toc-toggle {
    color: #aaa;
  }

  .toc-toggle:hover {
    color: #58a6ff;
  }

  .toc-sidebar .toc-nested {
    border-left-color: #444;
  }
}
