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

/* ===== TOC CONTAINER ===== */
.toc-container {
  background: white;
  border: 1px solid #f0f0f0;
  border-radius: 15px;
  margin: 30px 0;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.03);
  overflow: hidden;
  transition: all var(--transition-normal);
}

/* ===== TOC HEADER ===== */
.toc-header {
  background: linear-gradient(135deg, #fff9f5 0%, #ffffff 100%);
  color: #2c3e50;
  padding: 18px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid #f8f9fa;
}

.toc-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: var(--font-weight-semibold);
  font-size: 1.1rem;
  color: var(--primary-color);
  font-family: var(--font-primary);
}

.toc-title i {
  font-size: 1.2rem;
  color: var(--primary-color);
}

.toc-toggle {
  background: rgba(255, 122, 89, 0.1);
  border: none;
  color: var(--primary-color);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: all var(--transition-normal);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toc-toggle:hover {
  background: rgba(255, 122, 89, 0.15);
  transform: scale(1.05);
}

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

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

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

.toc-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #9ca3af;
  font-size: 0.9rem;
  justify-content: center;
  padding: 20px 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: 12px;
  color: #6b7280;
  text-decoration: none;
  padding: 10px 15px;
  border-radius: 10px;
  transition: all var(--transition-normal);
  font-size: 0.95rem;
  line-height: 1.5;
  border: 1px solid transparent;
  font-family: var(--font-primary);
}

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

.toc-link.active {
  background: linear-gradient(135deg, rgba(255, 122, 89, 0.08), rgba(255, 143, 115, 0.05));
  color: var(--primary-color);
  font-weight: var(--font-weight-semibold);
  border-color: rgba(255, 122, 89, 0.3);
  box-shadow: 0 2px 8px rgba(255, 122, 89, 0.1);
}

.toc-number {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: var(--font-weight-semibold);
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(255, 122, 89, 0.2);
}

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

/* ===== 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 {
  background: linear-gradient(135deg, #9ca3af, #6b7280);
  width: 22px;
  height: 22px;
  font-size: 0.7rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.toc-h3 .toc-link,
.toc-h4 .toc-link {
  font-size: 0.9rem;
  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 -15px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

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

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

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

  .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"] {
  animation: none !important;
  transform: none !important;
}

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