/* TOC 相关样式 - 深色主题版本 */
.page-container {
  display: flex;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  position: relative;
}

.toc-card {
  position: sticky;
  top: 100px;
  width: 280px;
  height: auto;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: 1.5rem;
  border-radius: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  scrollbar-width: thin;
  scrollbar-color: var(--primary-color) var(--card-bg);
  align-self: flex-start;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* 美化滚动条 */
.toc-card::-webkit-scrollbar {
  width: 6px;
}

.toc-card::-webkit-scrollbar-track {
  background: var(--card-bg);
  border-radius: 3px;
}

.toc-card::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #7fff00, #6bdb00);
  border-radius: 3px;
}

.toc-card::-webkit-scrollbar-thumb:hover {
  background: var(--hover-color);
}

.toc-content {
  font-size: 0.9rem;
}

.toc-content h2 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 1.2rem;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.8rem;
  text-align: center;
}

.toc-content ol {
  padding-left: 0;
  margin: 0;
  list-style-type: none;
}

.toc-content ol ol {
  margin: 0.3rem 0;
  padding-left: 1rem;
  border-left: 2px solid rgba(127, 255, 0, 0.2);
}

.toc-content li {
  line-height: 1.6;
  margin: 0.5rem 0;
  position: relative;
}

.toc-content li::before {
  content: "";
  position: absolute;
  left: -0.8rem;
  top: 0.6rem;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(127, 255, 0, 0.4);
  transition: all 0.3s ease;
}

.toc-content a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 0.9rem;
  display: block;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

.toc-content a::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: rgba(127, 255, 0, 0.1);
  transition: width 0.3s ease;
  z-index: -1;
}

.toc-content a:hover {
  color: var(--primary-color);
  transform: translateX(4px);
  background: rgba(127, 255, 0, 0.05);
}

.toc-content a:hover::before {
  width: 100%;
}

.toc-content a:hover + li::before {
  background: var(--primary-color);
  transform: scale(1.2);
}

/* 激活状态的链接样式 */
.toc-content .active {
  color: var(--primary-color);
  background: rgba(127, 255, 0, 0.15);
  font-weight: 600;
  transform: translateX(6px);
  border-left: 3px solid var(--primary-color);
  box-shadow: 0 2px 8px rgba(127, 255, 0, 0.2);
}

.toc-content .active::before {
  width: 100%;
  background: rgba(127, 255, 0, 0.2);
}

.toc-content li:has(.active)::before {
  background: var(--primary-color);
  transform: scale(1.5);
  box-shadow: 0 0 8px rgba(127, 255, 0, 0.6);
}

/* 嵌套级别样式 */
.toc-content ol ol a {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.3rem 0.6rem;
}

.toc-content ol ol ol a {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
}

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

/* TOC 收起/展开按钮 */
.toc-toggle {
  display: none;
  position: fixed;
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
  background: var(--primary-gradient);
  color: var(--bg-color);
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  cursor: pointer;
  z-index: 1000;
  box-shadow: var(--shadow-medium);
  transition: var(--transition);
}

.toc-toggle:hover {
  transform: translateY(-50%) scale(1.1);
  box-shadow: var(--shadow-heavy);
}

.toc-toggle i {
  font-size: 1.2rem;
}

/* 响应式设计 */
@media (max-width: 1024px) {
  main {
    padding: 0 0;
  }
  .page-container {
    /* flex-direction: column; */
    /* padding: 0 1rem; */
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    padding-top: 0;
  }
  
  .toc-card {
    display: none;
    position: fixed;
    top: 100px;
    right: 1rem;
    width: 300px;
    max-height: calc(100vh - 120px);
    z-index: 999;
    background: rgba(17, 17, 17, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
  
  .toc-card.show {
    display: block;
    animation: slideInRight 0.3s ease;
  }
  
  .toc-toggle {
    display: block;
  }

  .page-content {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 1rem 0.5rem !important;
  }
}

@media (max-width: 768px) {
  .toc-card {
    width: calc(100vw - 2rem);
    right: 1rem;
    left: 1rem;
  }
  
  .toc-toggle {
    right: 1rem;
    bottom: 6rem;
    top: auto;
    transform: none;
  }
  
  .toc-toggle:hover {
    transform: scale(1.1);
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* 移除旧的样式 */
.toc-link {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: block;
  padding: 0.5rem 0.8rem;
  color: var(--text-secondary);
  border-radius: 8px;
}

.toc-link.active {
  color: var(--primary-color);
  background: rgba(127, 255, 0, 0.15);
  font-weight: 600;
  transform: translateX(6px);
  border-left: 3px solid var(--primary-color);
}