/* ===================================================================
   Table of Contents Component
   Reusable TOC component for articles and long content
   =================================================================== */

/* ===== TOC CONTAINER ===== */
.toc-container {
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  margin: 24px 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: all var(--transition-normal);
}

/* ===== TOC HEADER ===== */
.toc-header {
  background: #f8f9fa;
  color: #2c3e50;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid #e9ecef;
}

.toc-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 0.95rem;
  color: #495057;
  font-family: var(--font-primary);
}

.toc-title i {
  font-size: 1rem;
  color: #6c757d;
}

.toc-toggle {
  background: transparent;
  border: none;
  color: #6c757d;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  transition: all var(--transition-normal);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toc-toggle:hover {
  background: #e9ecef;
  color: #495057;
}

.toc-toggle.collapsed i {
  transform: rotate(180deg);
}

/* ===== TOC CONTENT ===== */
.toc-content {
  padding: 16px;
  background: white;
  transition: all var(--transition-normal);
  overflow: hidden;
}

.toc-content.collapsed {
  max-height: 0;
  padding: 0 16px;
}

.toc-loading {
  display: flex;
  align-items: center;
  color: #9ca3af;
  font-size: 0.9rem;
  justify-content: center;
  padding: 16px 0;
  font-family: var(--font-primary);
}

.loading-spinner {
  display: none;
}

/* ===== TOC LIST ===== */
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-item {
  margin-bottom: 6px;
}

.toc-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #6b7280;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
  transition: all var(--transition-normal);
  font-size: 0.9rem;
  line-height: 1.4;
  border: 1px solid transparent;
  font-family: var(--font-primary);
}

.toc-link:hover {
  background: #f8f9fa;
  color: var(--primary-color);
  text-decoration: none;
  transform: translateX(2px);
  border-color: rgba(255, 122, 89, 0.15);
}

.toc-link.active {
  background: rgba(255, 122, 89, 0.1);
  color: var(--primary-color);
  font-weight: 500;
  border-color: rgba(255, 122, 89, 0.2);
}

.toc-number {
  display: none;
}

.toc-text {
  flex-grow: 1;
  font-weight: 400;
}

/* ===== TOC HIERARCHY ===== */
.toc-h2 {
  margin-left: 0;
}

.toc-h3 {
  margin-left: 20px;
}

.toc-h4 {
  margin-left: 40px;
}

.toc-h3 .toc-number,
.toc-h4 .toc-number {
  display: none;
}

.toc-h3 .toc-link,
.toc-h4 .toc-link {
  font-size: 0.85rem;
  color: #9ca3af;
}

.toc-h3 .toc-link:hover,
.toc-h4 .toc-link:hover {
  color: #6b7280;
}

/* ===== PROGRESS INDICATOR ===== */
.progress-indicator {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  z-index: 9999;
  transition: width var(--transition-normal);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .toc-container {
    margin: 20px 0;
    border-radius: 8px;
    border-left: 1px solid #e9ecef;
    border-right: 1px solid #e9ecef;
  }

  .toc-header {
    padding: 12px 16px;
  }

  .toc-title {
    font-size: 1rem;
  }

  .toc-content {
    padding: 15px 16px;
  }

  .toc-h3 {
    margin-left: 15px;
  }

  .toc-h4 {
    margin-left: 30px;
  }
}

/* ===== DISABLE ANIMATIONS FOR ACCESSIBILITY ===== */
/* Disable all spinner animations globally to prevent annoyance */
.loading-spinner,
.spinner,
.spinner-border,
.spinner-grow,
[class*="spin"],
[class*="loading"],
.toc-loading,
.toc-loading *,
.toc-loading::before,
.toc-loading::after,
.toc-container *,
.toc-container *::before,
.toc-container *::after,
.bi-list-ul,
.bi-chevron-up,
i[class*="bi-"] {
  animation: none !important;
  transform: none !important;
}

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* FORCE DISABLE ALL ANIMATIONS IN TOC */
.toc-container,
.toc-container *,
.toc-loading,
.toc-loading *,
.toc-header,
.toc-header *,
.toc-content,
.toc-content *,
.toc-title,
.toc-title *,
.toc-toggle,
.toc-toggle *,
.toc-list,
.toc-list *,
.toc-item,
.toc-item *,
.toc-link,
.toc-link *,
.toc-number,
.toc-number *,
.toc-text,
.toc-text * {
  animation: none !important;
  transform: none !important;
  transition: none !important;
}
