/* Smart TOC Styles */
.smart-toc-container {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin: 40px 0px 60px 0px!important;
    padding: 0;
    max-width: 100%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.smart-toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #fff;
    border-bottom: 1px solid #eee;
    border-radius: 8px 8px 0 0;
}

.smart-toc-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.smart-toc-toggle {
    background: #145dd9!important;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.smart-toc-toggle:hover {
    background: #005a87;
}

.toggle-icon {
    transition: transform 0.3s ease;
    font-size: 12px;
}

.smart-toc-toggle[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
}

.smart-toc-content {
    padding: 20px;
    overflow: hidden;
}

.smart-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.smart-toc-list li {
    margin: 8px 0;
    transition: all 0.3s ease;
}

.smart-toc-list li.toc-item-hidden {
    opacity: 0;
    max-height: 0;
    margin: 0;
    overflow: hidden;
}

.smart-toc-content.expanded .smart-toc-list li.toc-item-hidden {
    opacity: 1;
    max-height: 50px;
    margin: 8px 0;
}

.smart-toc-list a {
    color: #145dd9;
    text-decoration: none;
    display: block;
    padding: 5px 0;
    border-left: 3px solid transparent;
    padding-left: 10px;
    transition: all 0.2s ease;
}

.smart-toc-list a:hover {
    color: #005a87;
    border-left-color: #0073aa;
    background: rgba(0, 115, 170, 0.1);
    padding-left: 15px;
}

.smart-toc-list a.active {
    color: #005a87;
    border-left-color: #0073aa;
    background: rgba(0, 115, 170, 0.1);
    font-weight: 600;
}

/* Indentazione e simboli per livelli di heading */
.toc-level-1 { 
    margin-left: 0; 
}

.toc-level-2 { 
    margin-left: 20px; 
}

.toc-level-3 { 
    margin-left: 40px; 
}

.toc-level-4 { 
    margin-left: 60px; 
}

.toc-level-5 { 
    margin-left: 80px; 
}

.toc-level-6 { 
    margin-left: 100px; 
}

/* Simboli per i diversi livelli - Trattini progressivi */
.toc-level-1 a::before {
    content: "";
    margin-right: 0;
}

.toc-level-2 a::before {
    content: "- ";
    margin-right: 10px;
    color: #0073aa !important;
    font-weight: bold;
    font-size: 14px;
}

.toc-level-3 a::before {
    content: "-- ";
    margin-right: 10px;
    color: #0073aa !important;
    font-weight: bold;
    font-size: 14px;
}

.toc-level-4 a::before {
    content: "--- ";
    margin-right: 10px;
    color: #0073aa !important;
    font-weight: bold;
    font-size: 14px;
}

.toc-level-5 a::before {
    content: "---- ";
    margin-right: 10px;
    color: #0073aa !important;
    font-weight: bold;
    font-size: 14px;
}

.toc-level-6 a::before {
    content: "----- ";
    margin-right: 10px;
    color: #0073aa !important;
    font-weight: bold;
    font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
    .smart-toc-container {
        margin: 15px 0;
    }
    
    .smart-toc-header {
        padding: 12px 15px;
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .smart-toc-title {
        font-size: 16px;
    }
    
    .smart-toc-toggle {
        align-self: flex-end;
    }
    
    .toc-level-2, .toc-level-3, .toc-level-4, .toc-level-5, .toc-level-6 {
        margin-left: 15px;
    }
}

/* Animazione per scroll smooth */
html {
    scroll-behavior: smooth;
}

/* Highlight per heading target */
:target {
    scroll-margin-top: 20px;
    animation: highlight 2s ease-in-out;
}

@keyframes highlight {
    0% { background-color: rgba(255, 255, 0, 0.3); }
    100% { background-color: transparent; }
}
