/**
 * Table of Contents Styles
 *
 * @package Niche_Blog_Pro
 */

.table-of-contents-widget {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 30px;
  transition: all 0.3s ease;
}

.table-of-contents-widget.toc-sticky {
  position: sticky;
  top: 100px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.toc-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 15px 0;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-primary);
}

.toc-title svg {
  color: var(--primary-color);
}

.toc-nav {
  position: relative;
}

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

.toc-item {
  margin: 0;
  padding: 0;
  transition: all 0.2s ease;
}

.toc-item-h2 {
  margin-bottom: 8px;
}

.toc-item-h3 {
  padding-left: 20px;
  margin-bottom: 6px;
}

.toc-link {
  display: block;
  padding: 8px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
  border-radius: 4px;
  transition: all 0.2s ease;
  position: relative;
}

.toc-link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background-color: var(--primary-color);
  border-radius: 2px;
  transition: height 0.2s ease;
}

.toc-link:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  padding-left: 16px;
}

.toc-link:hover::before {
  height: 70%;
}

.toc-link.active {
  background-color: var(--bg-tertiary);
  color: var(--primary-color);
  font-weight: 600;
  padding-left: 16px;
}

.toc-link.active::before {
  height: 100%;
}

.toc-item-h3 .toc-link {
  font-size: 13px;
  padding-left: 8px;
}

.toc-item-h3 .toc-link:hover,
.toc-item-h3 .toc-link.active {
  padding-left: 12px;
}

/* Progress Indicator */
.toc-progress-indicator {
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 0%;
  background: linear-gradient(to bottom, var(--primary-color), var(--secondary-color, #6f42c1));
  border-radius: 2px;
  transition: height 0.3s ease;
  opacity: 0.5;
}

/* Scrollbar */
.table-of-contents-widget.toc-sticky::-webkit-scrollbar {
  width: 6px;
}

.table-of-contents-widget.toc-sticky::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 3px;
}

.table-of-contents-widget.toc-sticky::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.table-of-contents-widget.toc-sticky::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Dark mode adjustments */
.dark-mode .table-of-contents-widget {
  box-shadow: var(--shadow-md);
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .table-of-contents-widget.toc-sticky {
    position: relative;
    top: 0;
    max-height: none;
    overflow-y: visible;
  }

  .toc-title {
    font-size: 16px;
  }

  .toc-link {
    font-size: 13px;
    padding: 6px 10px;
  }

  .toc-item-h3 .toc-link {
    font-size: 12px;
  }
}

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

/* Heading offset for sticky header */
.single h2[id],
.single h3[id] {
  scroll-margin-top: 100px;
}
