/* Foldable TOC Styles */

/* Style for expandable TOC items */
#toc ul li {
    position: relative;
}

/* Style for items that have sub-items */
#toc ul li.has-children > a {
    padding-right: 25px;
    font-weight: 500;
}

/* Toggle button styling */
.toc-toggle {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    line-height: 16px;
    text-align: center;
    color: #7a2518;
    font-weight: bold;
    border: 1px solid #ddd;
    background: #f8f8f8;
    border-radius: 3px;
    padding: 0;
    margin: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.toc-toggle:hover {
    color: #a53221;
    background: #fff;
    border-color: #7a2518;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* Collapsed state - hide sub-lists */
#toc ul li.collapsed > ul {
    display: none;
}

/* Visual hint for collapsed sections */
#toc ul li.collapsed > a::after {
    content: " (...)";
    color: #999;
    font-size: 0.8em;
    font-style: italic;
}

/* Expanded state indicator */
.toc-toggle.expanded::before {
    content: "▼";
    font-size: 10px;
}

/* Collapsed state indicator */
.toc-toggle.collapsed::before {
    content: "▶";
    font-size: 10px;
}

/* Smooth transitions for expand/collapse */
#toc ul ul {
    transition: max-height 0.3s ease-out, opacity 0.2s ease-out;
    overflow: hidden;
}

/* Animation for expanding */
#toc ul li.expanding > ul {
    max-height: 1000px;
    opacity: 1;
}

/* Animation for collapsing */
#toc ul li.collapsing > ul {
    max-height: 0;
    opacity: 0;
}

/* Indent adjustment for nested items with toggles */
#toc.toc2 ul ul {
    margin-left: 0;
    padding-left: 1.2em;
}

/* Better spacing for toggle buttons in toc2 layout */
body.toc2 .toc-toggle {
    right: 5px;
}

/* Ensure proper positioning in different screen sizes */
@media screen and (min-width: 768px) {
    .toc-toggle {
        right: 8px;
    }
}

@media screen and (min-width: 1280px) {
    .toc-toggle {
        right: 10px;
    }
}

/* Style for top-level sections - make them more prominent */
#toc ul.sectlevel0 > li > .toc-toggle {
    width: 18px;
    height: 18px;
    font-size: 14px;
    font-weight: bold;
    line-height: 18px;
}

#toc ul.sectlevel1 > li > .toc-toggle {
    width: 16px;
    height: 16px;
    font-size: 12px;
    line-height: 16px;
}

/* Hover effects for better UX */
#toc ul li:hover > .toc-toggle {
    opacity: 1;
}

.toc-toggle {
    opacity: 0.9;
    transition: all 0.2s ease;
}

/* Focus styles for accessibility */
.toc-toggle:focus {
    outline: 2px solid #2156a5;
    outline-offset: 1px;
}