/* Hide the default TOC but keep margin sidebar visible */
.toc-content,
#toc,
.toc,
nav[role="doc-toc"] {
  display: none !important;
}

/* Create floating dropdown container */
.dropdown-toc {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  opacity: 1;
  visibility: visible;
  transform: translateY(-10px);
  transition: all 0.3s ease-in-out;
}

/* Hide dropdown when scrolling */
.dropdown-toc.show-on-scroll {
  opacity: 0;
  visibility: visible;
  transform: translateY(0);
}

/* Dropdown button styling - more compact for floating */
.dropdown-btn {
  background-color: rgba(248, 249, 250, 0.95);
  color: #333;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid rgba(221, 221, 221, 0.8);
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  min-width: 120px;
  justify-content: center;
}

.dropdown-btn:hover {
  background-color: rgba(233, 236, 239, 0.95);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Arrow icon */
.dropdown-btn::after {
  content: "▼";
  font-size: 10px;
  transition: transform 0.3s ease;
}

.dropdown-btn.active::after {
  transform: rotate(180deg);
}

/* Dropdown content */
.dropdown-content {
  display: none;
  position: absolute;
  background-color: rgba(255, 255, 255, 0.98);
  min-width: 280px;
  max-width: 350px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(221, 221, 221, 0.8);
  border-radius: 8px;
  z-index: 10000;
  max-height: 400px;
  overflow-y: auto;
  top: calc(100% + 8px);
  right: 0;
  backdrop-filter: blur(15px);
}

.dropdown-content.show {
  display: block;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Style the TOC links inside dropdown */
.dropdown-content ul {
  list-style: none;
  padding: 8px 0;
  margin: 0;
}

/* Ensure all nested lists are flush */
.dropdown-content ul ul {
  padding-left: 0;
}

.dropdown-content li {
  border-bottom: 1px solid rgba(240, 240, 240, 0.8);
}

.dropdown-content li:last-child {
  border-bottom: none;
}

/* Base link style (Level 1) */
.dropdown-content a {
  color: #333;
  padding: 10px 16px;
  text-decoration: none;
  display: block;
  transition: all 0.2s ease;
  font-size: 14px;
  line-height: 1.4;
  position: relative; /* Required for ::before elements */
}

.dropdown-content a:hover {
  background-color: rgba(248, 249, 250, 0.8);
  color: #0066cc;
}

/* --- HIERARCHICAL STYLES (for toc-depth) --- */

/* Level 2 (e.g., H3) */
.dropdown-content ul ul > li > a {
  font-size: 13.5px;
  color: #555;
  padding-left: 32px; /* 16px base + 16px indent */
}

.dropdown-content ul ul > li > a::before {
  content: "↳";
  position: absolute;
  left: 16px;
  color: #999;
  font-size: 12px;
  /* Vertically center the icon */
  top: 50%;
  transform: translateY(-50%);
}

/* Level 3 (e.g., H4) */
.dropdown-content ul ul ul > li > a {
  font-size: 13px;
  color: #666;
  padding-left: 48px; /* 32px + 16px indent */
}
        
.dropdown-content ul ul ul > li > a::before {
  content: "·"; /* Use a simple dot */
  position: absolute;
  left: 36px;
  color: #aaa;
  font-weight: bold;
  font-size: 14px;
  top: 50%;
  transform: translateY(-50%);
}
        
/* Level 4 (e.g., H5) */
.dropdown-content ul ul ul ul > li > a {
  font-size: 12.5px;
  color: #777;
  padding-left: 64px; /* 48px + 16px indent */
}
        
.dropdown-content ul ul ul ul > li > a::before {
  content: "–"; /* Use a dash */
  position: absolute;
  left: 52px;
  color: #bbb;
  top: 50%;
  transform: translateY(-50%);
}

/* --- END HIERARCHICAL STYLES --- */


/* Scrollbar styling for dropdown */
.dropdown-content::-webkit-scrollbar {
  width: 4px;
}

.dropdown-content::-webkit-scrollbar-track {
  background: rgba(241, 241, 241, 0.5);
  border-radius: 2px;
}

.dropdown-content::-webkit-scrollbar-thumb {
  background: rgba(136, 136, 136, 0.5);
  border-radius: 2px;
}

.dropdown-content::-webkit-scrollbar-thumb:hover {
  background: rgba(136, 136, 136, 0.8);
}

/* Mobile responsiveness */
@media screen and (max-width: 768px) {
  .dropdown-toc {
    top: 10px;
    right: 10px;
  }
  
  .dropdown-btn {
    padding: 6px 10px;
    font-size: 13px;
    min-width: 100px;
  }
  
  .dropdown-content {
    min-width: 250px;
    max-width: calc(100vw - 40px);
    max-height: 300px;
  }
}

/* Ultra small screens */
@media screen and (max-width: 480px) {
  .dropdown-content {
    right: -10px;
    min-width: 200px;
  }
}