/* ToC */

.toc-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: calc(100% / 12 * 3);  /* Bootstrap col-3: 3/12 = 25% */
  height: 100vh;
  background: white;
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  z-index: 1100;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

/* Desktop: Keep ToC visible and toggleable */
@media (min-width: 768px) {
  .toc-sidebar {
    width: calc(100% / 12 * 3);  /* Bootstrap col-3: 3/12 of viewport */
  }
}

.toc-sidebar.active {
  transform: translateX(0);
}

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.25rem;
  background: var(--colorSundK-primary-blue, #162e59);
  color: white;
}

.toc-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toc-close-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toc-close-btn:hover {
  background: rgba(255,255,255,0.25);
}

.toc-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-item {
  margin: 0;
}

.toc-item-row {
  display: flex;
  align-items: flex-start;
}

.toc-toggle {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.35rem;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.toc-toggle:hover {
  background: #f0f0f0;
  color: var(--colorSundK-primary-blue, #162e59);
}

.toc-toggle i {
  transition: transform 0.2s ease;
  font-size: 0.75rem;
}

.toc-item.collapsed > .toc-item-row .toc-toggle i {
  transform: rotate(-90deg);
}

.toc-toggle-spacer {
  width: 24px;
  flex-shrink: 0;
}

.toc-item.collapsed > .toc-list {
  display: none;
}

.toc-link {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem 0.4rem 0;
  color: #333;
  text-decoration: none;
  transition: all 0.15s ease;
  flex: 1;
  border-radius: 4px;
}

.toc-link:hover {
  color: var(--colorSundK-primary-blue, #162e59);
  background: #f5f7fa;
}

.toc-link.active {
  color: var(--colorSundK-primary-blue, #162e59);
  background: #e8f0ff;
  font-weight: 600;
}

.toc-number {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  background: var(--colorSundK-primary-blue, #162e59);
  color: white;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 600;
  flex-shrink: 0;
}

.toc-link.active .toc-number {
  background: var(--colorSundK-secondary-yellow, #f9c74f);
  color: #162e59;
}

.toc-title {
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Niveau 1 - Hovedsektioner (h2) */

.toc-level-1 > .toc-item > .toc-item-row {
  padding-left: 0.5rem;
}

.toc-link-level-1 {
  font-weight: 500;
}

.toc-link-level-1 .toc-title {
  font-size: 0.9rem;
}

/* Niveau 2 (h3) */

.toc-level-2 {
  margin-left: 1.5rem;
  border-left: 2px solid #e8e8e8;
}

.toc-link-level-2 .toc-title {
  font-size: 0.85rem;
  color: #444;
}

/* Niveau 3 (h4) */

.toc-level-3 {
  margin-left: 1.5rem;
  border-left: 2px solid #f0f0f0;
}

.toc-link-level-3 .toc-title {
  color: #555;
}

/* Niveau 4 (h5) */

.toc-level-4 {
  margin-left: 1.5rem;
  border-left: 2px solid #f5f5f5;
}

.toc-link-level-4 .toc-title {
  font-size: 0.75rem;
  color: #666;
}

.toc-item.has-children > .toc-list {
  position: relative;
}

.toc-link.active {
  position: relative;
}

/* Open Button */

.toc-open-btn {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%) translateX(-100%);
  width: 40px;
  height: 80px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: var(--colorSundK-primary-blue, #162e59);
  color: white;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 0 10px rgba(0,0,0,0.15);
  z-index: 1050;
  transition: all 0.3s ease;
  font-size: 1.2rem;
}

.toc-open-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: transparent;
  border-radius: 0 8px 8px 0;
  transition: background 0.3s ease;
}

.toc-open-btn i {
  position: relative;
  z-index: 1;
}

.toc-open-btn.visible {
  transform: translateY(-50%) translateX(0);
}

.toc-open-btn.visible:hover::before {
  background: rgba(255, 255, 255, 0.25);
}

