/* ===========================================
   TABLE DES MATIÈRES - STYLES
   =========================================== */

:root {
  --toc-primary-color: #4f7792;
  /* color: #343e45; */
  --toc-panel-width: 400px;
  --toc-transition: 0.3s ease;
  --toc-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  --toc-shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* Bouton Toggle */
.toc-toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 900;
  background: white;
  border: 2px solid var(--toc-primary-color);
  border-radius: 25px;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--toc-primary-color);
  cursor: pointer;
  box-shadow: var(--toc-shadow);
  transition: all var(--toc-transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toc-toggle:hover {
  /* background: var(--toc-primary-color); */
  background: #3498db;
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--toc-shadow-hover);
}

.toc-toggle:active {
  transform: translateY(0);
}

/* Panneau latéral */
.toc-panel {
  position: fixed;
  top: 0;
  left: calc(-1 * var(--toc-panel-width));
  width: var(--toc-panel-width);
  height: 100vh;
  /* background: white; */
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  transition: left var(--toc-transition);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toc-panel.open {
  left: 0;
}

/* Header */
.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 2px solid #e9ecef;
  background: linear-gradient(135deg, #3498db, #5dade2);
  color: white;
  flex-shrink: 0;
}

.toc-header h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
}

.toc-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  line-height: 1;
  transition: transform 0.2s;
  border-radius: 4px;
}

.toc-close:hover {
  transform: rotate(90deg);
  background: rgba(255, 255, 255, 0.2);
}

/* Recherche */
.toc-search {
  padding: 1rem;
  /* border-bottom: 1px solid #e9ecef; */
  border-bottom-right-radius: 16px;
  background: #9cc2e7;
  flex-shrink: 0;
}

.toc-search input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #dee2e6;
  border-radius: 20px;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.3s;
  font-family: inherit;
}

.toc-search input:focus {
  border-color: var(--toc-primary-color);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.toc-search input::placeholder {
  color: #adb5bd;
}

/* Contenu scrollable */
.toc-content {
  /* background-color: var(--toc-primary-color); */
  border-top-right-radius: 16px;
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.toc-content::-webkit-scrollbar {
  width: 6px;
  margin-top: 16px;
}

.toc-content::-webkit-scrollbar-track {
  background: #064686;
  margin-top: 16px;
}

.toc-content::-webkit-scrollbar-thumb {
  /* background: var(--toc-primary-color); */
  background: #4faae7;
  border-radius: 3px;
  margin-top: 16px;
}

.toc-content::-webkit-scrollbar-thumb:hover {
  background: #2980b9;
  margin-top: 16px;
}

/* Section */
.toc-section {
  margin-bottom: 0.5rem;
}

.toc-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: #f8f9fa;
  border-radius: 8px;
  text-decoration: none;
  color: #2c3e50;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
  cursor: pointer;
}

.toc-link:hover {
  background: #e9ecef;
  border-left-color: var(--toc-primary-color);
  transform: translateX(4px);
}

.toc-link.active {
  background: #e3f2fd;
  border-left-color: var(--toc-primary-color);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.2);
}

.toc-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  width: 1.5rem;
  text-align: center;
}

.toc-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.toc-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-subtitle {
  font-size: 0.8rem;
  color: #6c757d;
  font-style: italic;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-pages {
  font-size: 0.85rem;
  color: #6c757d;
  font-weight: 600;
  flex-shrink: 0;
  background: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
}

/* Sous-sections */
.toc-subsections {
  margin-left: 2rem;
  margin-top: 0.5rem;
  padding-left: 1rem;
  border-left: 2px solid #dee2e6;
}

.toc-sublink {
  background: white;
  font-size: 0.9rem;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
}

.toc-sublink .toc-icon {
  font-size: 1.1rem;
}

.toc-sublink .toc-title {
  font-size: 0.85rem;
}

.toc-sublink:hover {
  background: #f8f9fa;
}

/* Overlay quand panel ouvert */
body.toc-open::before {
  content: "";
  position: fixed;
  top: 0;
  left: -100%;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: 999;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Badge catégorie (optionnel) */
.toc-category-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 10px;
  background: var(--toc-primary-color);
  color: white;
  font-weight: 600;
  text-transform: uppercase;
}

/* États vides */
.toc-content:empty::after {
  content: "Aucune section trouvée";
  display: block;
  text-align: center;
  padding: 2rem;
  color: #adb5bd;
  font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
  :root {
    --toc-panel-width: 100%;
  }

  .toc-panel {
    left: -100%;
  }

  .toc-toggle {
    left: 10px;
    top: 10px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .toc-header h2 {
    font-size: 1.1rem;
  }

  .toc-subsections {
    margin-left: 1rem;
    padding-left: 0.5rem;
  }
}

@media (max-width: 480px) {
  .toc-link {
    padding: 0.6rem 0.75rem;
    gap: 0.5rem;
  }

  .toc-icon {
    font-size: 1.1rem;
  }

  .toc-title {
    font-size: 0.85rem;
  }

  .toc-subtitle {
    font-size: 0.75rem;
  }

  .toc-pages {
    font-size: 0.75rem;
    padding: 0.2rem 0.4rem;
  }
}

/* Animations */
@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toc-section {
  animation: slideInLeft 0.3s ease;
}

/* Print styles */
@media print {
  .toc-toggle,
  .toc-panel {
    display: none !important;
  }
}
