/* Table of Contents Panel */
.toc-panel {
    position: sticky;
    top: 2rem;
    border: 1px solid rgba(30, 35, 41, 0.1);
    max-width: 100%;
    overflow: hidden;
}

.panel-heading {
    background-color: var(--aa-navy);
    color: var(--aa-light);
    padding: 1rem;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

.toc {
    padding: 1rem 0;
    background: white;
    max-width: 100%;
    overflow: hidden;
}

/* Override Bulma's content styles */
.content .toc ol:not([type]),
.content .toc ol,
.toc ol {
    list-style-type: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Override Bulma's li margin */
.content .toc li + li,
.toc li + li {
    margin-top: 0 !important;
}

/* Style all toc items */
.toc-item {
    margin: 0 !important;
    padding: 0;
    transition: background-color 0.2s ease;
}

/* Hide nested items by default */
.toc-child {
    margin-left: 0 !important;
    display: none;
}

/* Show child items when parent is hovered, active, or active-parent */
.toc-item:hover > .toc-child,
.toc-item.active > .toc-child,
.toc-item.active-parent > .toc-child {
    display: block;
}

/* Link styling */
.toc-link {
    color: var(--aa-gray);
    text-decoration: none;
    display: block;
    padding: 0.5rem 1.5rem;
    padding-right: 2rem;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Hover state */
.toc-link:hover {
    color: var(--aa-navy);
    background-color: rgba(255, 214, 107, 0.08);
    border-left-color: rgba(255, 214, 107, 0.5);
}

/* Active state */
.toc-item.active > .toc-link {
    color: var(--aa-navy);
    background-color: rgba(255, 214, 107, 0.12);
    border-left-color: var(--aa-gold);
    font-weight: 500;
}

/* Parent of active item */
.toc-item.active-parent > .toc-link {
    color: var(--aa-navy);
    border-left-color: rgba(255, 214, 107, 0.5);
}

/* Level-specific styling */
.toc-level-1 > .toc-link {
    font-weight: 500;
    font-size: 1rem;
}

.toc-level-2 > .toc-link {
    font-size: 0.9rem;
    padding-left: 2rem;
}

.toc-level-3 > .toc-link {
    font-size: 0.85rem;
    padding-left: 3rem;
}

/* Add dropdown indicators for parent items */
.toc-item:has(> .toc-child) > .toc-link {
    position: relative;
}

.toc-item:has(> .toc-child) > .toc-link::after {
    content: '▾';
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.2s ease;
}

/* Rotate indicator when expanded */
.toc-item:hover > .toc-link::after,
.toc-item.active > .toc-link::after, 
.toc-item.active-parent > .toc-link::after {
    transform: translateY(-50%) rotate(180deg);
}

/* Text wrapper */
.toc-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}