/**
 * Styles pour le Menu Sticky - Table des Matières
 * Design moderne et élégant compatible avec BleuPiment
 * 
 * @author BleuPiment
 * @version 1.0
 */

/* ============================================
   CONTENEUR PRINCIPAL
============================================ */

.sticky-toc {
    position: fixed;
    top: 120px;
    right: 30px;
    width: 280px;
    max-height: calc(100vh - 160px);
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    z-index: 999;
    transition: all 0.3s ease;
    overflow: hidden;
}

/* État collapsé */
.sticky-toc.collapsed .sticky-toc-list {
    display: none;
}

/* ============================================
   HEADER DU MENU
============================================ */

.sticky-toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px 12px 0 0;
    cursor: pointer;
    user-select: none;
}

.sticky-toc-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.3px;
}

.sticky-toc-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sticky-toc-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.toggle-icon {
    color: #ffffff;
    font-size: 20px;
    font-weight: 300;
    line-height: 1;
}

/* ============================================
   LISTE DES LIENS
============================================ */

.sticky-toc-list {
    list-style: none;
    margin: 0;
    padding: 12px 0;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #e0e0e0 #f5f5f5;
}

/* Scrollbar personnalisée (Webkit) */
.sticky-toc-list::-webkit-scrollbar {
    width: 6px;
}

.sticky-toc-list::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 0 0 12px 0;
}

.sticky-toc-list::-webkit-scrollbar-thumb {
    background: #e0e0e0;
    border-radius: 3px;
}

.sticky-toc-list::-webkit-scrollbar-thumb:hover {
    background: #d0d0d0;
}

/* ============================================
   ITEMS DE MENU
============================================ */

.sticky-toc-item {
    margin: 0;
    padding: 0;
}

.sticky-toc-link {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 20px;
    text-decoration: none;
    color: #4a5568;
    font-size: 14px;
    line-height: 1.5;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    position: relative;
}

.sticky-toc-link:hover {
    background: #f7fafc;
    color: #667eea;
    border-left-color: #667eea;
}

/* État actif */
.sticky-toc-link.active {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.1) 0%, rgba(255, 255, 255, 0) 100%);
    color: #667eea;
    font-weight: 600;
    border-left-color: #667eea;
}

.sticky-toc-link.active .toc-number {
    color: #667eea;
}

/* ============================================
   NUMÉROS ET TEXTE
============================================ */

.toc-number {
    flex-shrink: 0;
    color: #a0aec0;
    font-weight: 600;
    font-size: 13px;
    min-width: 22px;
}

.toc-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ============================================
   ANIMATIONS
============================================ */

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.sticky-toc {
    animation: slideInRight 0.4s ease-out;
}

/* ============================================
   RESPONSIVE
============================================ */

/* Tablettes */
@media (max-width: 1024px) {
    .sticky-toc {
        width: 240px;
        right: 20px;
        top: 100px;
    }

    .sticky-toc-link {
        font-size: 13px;
        padding: 8px 16px;
    }
}

/* Mobile - Caché par défaut (géré par JS) */
@media (max-width: 768px) {
    .sticky-toc {
        display: none;
    }
}

/* Très petits écrans */
@media (max-width: 480px) {
    .sticky-toc {
        display: none !important;
    }
}

/* ============================================
   PRINT - Masquer à l'impression
============================================ */

@media print {
    .sticky-toc {
        display: none !important;
    }
}

/* ============================================
   ACCESSIBILITÉ
============================================ */

/* Focus visible pour la navigation au clavier */
.sticky-toc-link:focus {
    outline: 2px solid #667eea;
    outline-offset: -2px;
}

.sticky-toc-toggle:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* Réduction du mouvement pour les utilisateurs sensibles */
@media (prefers-reduced-motion: reduce) {
    .sticky-toc,
    .sticky-toc-link,
    .sticky-toc-toggle {
        animation: none;
        transition: none;
    }
}

/* ============================================
   VARIANTES DE COULEURS (Optionnel)
============================================ */

/* Version avec thème BleuPiment personnalisé */
.sticky-toc.theme-bleupiment .sticky-toc-header {
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
}

.sticky-toc.theme-bleupiment .sticky-toc-link:hover,
.sticky-toc.theme-bleupiment .sticky-toc-link.active {
    color: #4F46E5;
    border-left-color: #4F46E5;
}

/* Version sombre (si besoin) */
.sticky-toc.theme-dark {
    background: #1a202c;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.sticky-toc.theme-dark .sticky-toc-link {
    color: #e2e8f0;
}

.sticky-toc.theme-dark .sticky-toc-link:hover {
    background: #2d3748;
    color: #667eea;
}

/* ============================================
   AMÉLIORATION PROGRESSIVE
============================================ */

/* Si JavaScript est désactivé, on cache le menu */
.no-js .sticky-toc {
    display: none;
}
