/* Enhanced TOC Styling for AI2U Documentation and Blog */
/* Applies to both Django Spellbook TOC and custom blog TOC */

.toc-wrapper {
  font-size: 0.95rem !important;
  background-color: var(--surface-color, #151d28) !important;  /* AI2U surface background */
  border-radius: 8px !important;
  padding: 1rem !important;
  border: 1px solid var(--border-color, #394a50) !important;  /* AI2U border color */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

.toc-list,
.toc-sublist {
  list-style: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.toc-sublist {
  margin-left: 1.5rem !important;
  border-left: 2px solid var(--neutral-color, #577277) !important;  /* AI2U neutral border */
  overflow: hidden !important;
  transition: max-height 0.3s ease-out !important;
  padding-left: 0.5rem !important;
}

.toc-sublist .toc-sublist {
  margin-left: 1rem !important;
  border-left-style: dashed !important;
  border-left-color: var(--neutral-color-50, rgba(87, 114, 119, 0.5)) !important;
}

.toc-sublist .toc-sublist .toc-sublist {
  border-left-color: var(--neutral-color-25, rgba(87, 114, 119, 0.25)) !important;
}

.toc-item,
.toc-subitem {
  margin: 0.3rem 0 !important;
}

.toc-item:first-child {
  margin-top: 0 !important;
}

.toc-item:last-child {
  margin-bottom: 0 !important;
}

.toc-link {
  text-decoration: none !important;
  color: var(--text-secondary-color, #a8b5b2) !important;  /* AI2U secondary text color */
  display: block !important;
  padding: 0.4rem 0.75rem !important;
  width: 100% !important;
  border-radius: 6px !important;
  transition: all 0.25s ease !important;
  font-weight: 400 !important;
}

.toc-link:hover {
  background-color: var(--subtle-color, #202e37) !important;  /* AI2U subtle background */
  color: var(--primary-color, #73bed3) !important;  /* AI2U primary cyan-blue */
  transform: translateX(2px) !important;
  text-decoration: none !important;
}

.toc-section {
  font-weight: 600 !important;
  color: var(--text-color, #ebede9) !important;
  display: block !important;
  padding: 0.25rem 0.5rem !important;
  margin-top: 1rem !important;
}

.toc-item.active div a,
.toc-subitem.active div a {
  background-color: var(--primary-color-25, rgba(115, 190, 211, 0.25)) !important;  /* AI2U primary with 25% opacity */
  color: var(--text-color, #ebede9) !important;  /* AI2U primary text color */
  font-weight: 600 !important;
  border-left: 3px solid var(--accent-color, #de9e41) !important;  /* Golden accent border */
  box-shadow: 0 2px 8px var(--primary-color-25, rgba(115, 190, 211, 0.25)) !important;
}

.toc-item.active div a:hover,
.toc-subitem.active div a:hover {
  background-color: var(--primary-color-50, rgba(115, 190, 211, 0.5)) !important;  /* Slightly more opacity on hover */
  color: var(--text-color, #ebede9) !important;
  transform: translateX(4px) !important;
  box-shadow: 0 4px 12px var(--primary-color-50, rgba(115, 190, 211, 0.5)) !important;
}

@media (max-width: 767px) {
  .toc-wrapper {
    max-height: 300px !important;
    overflow-y: auto !important;
    border: 1px solid #eee !important;
    border-radius: 4px !important;
    padding: 0.5rem !important;
  }
}

.toc-item-header {
  display: flex !important;
  align-items: center !important;
  gap: 0.25rem !important;
  cursor: pointer !important;
  padding: 0.25rem !important;
}

.toc-item-header .toc-link {
  pointer-events: auto !important;
  padding: 0 !important;
}

.toc-toggle {
  background: none !important;
  border: none !important;
  padding: 0.25rem !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: var(--text-secondary-color, #a8b5b2) !important;
}

.toc-toggle:hover {
  color: var(--primary-color, #73bed3) !important;
}

.toc-arrow {
  transition: transform 0.3s ease !important;
  fill: currentColor !important;
}

.toc-toggle.collapsed .toc-arrow {
  transform: rotate(-90deg) !important;
}

.toc-sublist.collapsed {
  max-height: 0 !important;
}

/* Debug style to confirm CSS is loading */
.toc-wrapper::before {
  content: "✅ Enhanced TOC CSS Loaded";
  position: absolute;
  top: -30px;
  left: 0;
  font-size: 0.7rem;
  color: var(--success-color, #75a743);
  background: var(--background-color, #10141f);
  padding: 2px 6px;
  border-radius: 3px;
  z-index: 1000;
  opacity: 0.7;
}

/* Enhanced visual hierarchy */
.toc-list > .toc-item > .toc-item-header > .toc-link {
  font-weight: 500 !important;
  font-size: 0.95rem !important;
}

.toc-sublist .toc-link {
  font-size: 0.9rem !important;
  padding-left: 1rem !important;
}

/* Better visual feedback */
.toc-item-header:hover {
  background-color: var(--hover-color-25, rgba(37, 58, 94, 0.25)) !important;
  border-radius: 4px !important;
}

/* Improved spacing for nested items */
.toc-sublist .toc-item-header {
  margin-left: 0.5rem !important;
}