/* Styles pour la table des matières (TOC) */

/* Version flottante - alignée à droite du contenu, juste en dessous de la première ligne horizontale */
#toc-floating {
  position: fixed;
  z-index: 1000;
  max-width: 280px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background-color: rgba(20, 20, 20, 0.6);
  border: 1px solid rgba(181, 232, 83, 0.3);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 0.25;
  transition: opacity 0.2s, background-color 0.2s, border-color 0.2s;
}

/* Rendre la TOC visible au hover du conteneur */
.container:hover #toc-floating {
  opacity: 0.9;
  background-color: rgba(20, 20, 20, 0.95);
  border-color: #b5e853;
}

/* Toujours visible au hover direct de la TOC */
#toc-floating:hover {
  opacity: 1 !important;
  background-color: rgba(20, 20, 20, 0.98) !important;
  border-color: #b5e853 !important;
}

#toc-floating .toc-details {
  width: 100%;
  margin: 0;
}

#toc-floating .toc-summary {
  cursor: pointer;
  font-weight: bold;
  color: #b5e853;
  padding: 1em;
  user-select: none;
  list-style: none;
  background-color: rgba(181, 232, 83, 0.1);
  border-bottom: 1px solid #b5e853;
}

#toc-floating .toc-summary::-webkit-details-marker {
  display: none;
}

#toc-floating .toc-summary::before {
  content: "▼ ";
  display: inline-block;
  transition: transform 0.2s;
  margin-right: 0.5em;
}

#toc-floating .toc-details[open] .toc-summary::before {
  transform: rotate(0deg);
}

#toc-floating .toc-details:not([open]) .toc-summary::before {
  transform: rotate(-90deg);
}

#toc-floating .toc-nav {
  margin: 0;
  padding: 1em;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

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

#toc-floating .toc-item {
  margin: 0.3em 0;
  padding-left: 0;
}

#toc-floating .toc-link {
  color: #b5e853;
  text-decoration: none;
  display: block;
  padding: 0.4em 0.8em;
  border-radius: 4px;
  transition: all 0.2s;
  font-size: 0.9em;
}

#toc-floating .toc-link:hover {
  color: #fff;
  background-color: rgba(181, 232, 83, 0.2);
  text-decoration: none;
}

/* Indentation pour les niveaux imbriqués */
#toc-floating .toc-level-3 {
  padding-left: 1em;
}

#toc-floating .toc-level-4 {
  padding-left: 1.5em;
}

#toc-floating .toc-level-5 {
  padding-left: 2em;
}

#toc-floating .toc-level-6 {
  padding-left: 2.5em;
}

/* Style pour les listes imbriquées */
#toc-floating .toc-list .toc-list {
  padding-left: 1em;
  margin-top: 0.2em;
}

/* Version intégrée (pour compatibilité) */
.toc-wrapper,
#toc-container {
  margin: 1.5em 0;
  padding: 1em;
  background-color: rgba(181, 232, 83, 0.1);
  border-left: 3px solid #b5e853;
  border-radius: 4px;
}

.toc-wrapper .toc-details,
#toc-container .toc-details {
  width: 100%;
}

.toc-wrapper .toc-summary,
#toc-container .toc-summary {
  cursor: pointer;
  font-weight: bold;
  color: #b5e853;
  padding: 0.5em 0;
  user-select: none;
  list-style: none;
  font-size: 1.1em;
}

.toc-wrapper .toc-summary::-webkit-details-marker,
#toc-container .toc-summary::-webkit-details-marker {
  display: none;
}

.toc-wrapper .toc-summary::before,
#toc-container .toc-summary::before {
  content: "▼ ";
  display: inline-block;
  transition: transform 0.2s;
  margin-right: 0.5em;
}

.toc-wrapper .toc-details[open] .toc-summary::before,
#toc-container .toc-details[open] .toc-summary::before {
  transform: rotate(0deg);
}

.toc-wrapper .toc-details:not([open]) .toc-summary::before,
#toc-container .toc-details:not([open]) .toc-summary::before {
  transform: rotate(-90deg);
}

.toc-wrapper .toc-nav,
#toc-container .toc-nav {
  margin-top: 0.5em;
}

.toc-wrapper .toc-list,
#toc-container .toc-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.toc-wrapper .toc-item,
#toc-container .toc-item {
  margin: 0.3em 0;
  padding-left: 0;
}

.toc-wrapper .toc-link,
#toc-container .toc-link {
  color: #b5e853;
  text-decoration: none;
  display: block;
  padding: 0.2em 0;
  transition: color 0.2s, padding-left 0.2s;
}

.toc-wrapper .toc-link:hover,
#toc-container .toc-link:hover {
  color: #fff;
  padding-left: 0.5em;
  text-decoration: underline;
}

.toc-wrapper .toc-level-3,
#toc-container .toc-level-3 {
  padding-left: 1em;
}

.toc-wrapper .toc-level-4,
#toc-container .toc-level-4 {
  padding-left: 2em;
}

.toc-wrapper .toc-level-5,
#toc-container .toc-level-5 {
  padding-left: 3em;
}

.toc-wrapper .toc-level-6,
#toc-container .toc-level-6 {
  padding-left: 4em;
}

.toc-wrapper .toc-list .toc-list,
#toc-container .toc-list .toc-list {
  padding-left: 1.5em;
  margin-top: 0.2em;
}

/* Responsive */
@media (max-width: 768px) {
  #toc-floating {
    right: 10px;
    top: 10px;
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  .toc-wrapper,
  #toc-container {
    padding: 0.8em;
  }
  
  .toc-wrapper .toc-level-4,
  .toc-wrapper .toc-level-5,
  .toc-wrapper .toc-level-6,
  #toc-container .toc-level-4,
  #toc-container .toc-level-5,
  #toc-container .toc-level-6 {
    padding-left: 1em;
  }
}
