/* Table of Contents Block Styles */
.wp-block-child-theme-table-of-contents {
    background: #FAFAFA;
    border-top: 1px solid #E1E3E8;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    max-height: 70vh;
    overflow-y: scroll;
    scrollbar-width: thin;
    scrollbar-color: #0875FF #ffffff;
}

/* Webkit browsers */
.wp-block-child-theme-table-of-contents::-webkit-scrollbar {
    width: 8px;
}

.wp-block-child-theme-table-of-contents::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.wp-block-child-theme-table-of-contents::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.wp-block-child-theme-table-of-contents::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Header */
.toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 15px;
    border-bottom: 1px solid #f0f0f0;
}

.toc-title {
    margin: 0;
    color: #0B0C0E;
}

.toc-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.toc-close:hover {
    color: #666;
}

/* Content */
.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-item {
    margin: 0;
    padding: 0;
    position: relative;
}

.toc-link {
    display: block;
    padding: 8px 20px;
    color: #2A2F39;
    font-family: var(--fb-global-body--font-family);
    font-weight: var(--fb-global-body--font-weight);
    font-size: var(--fb-global-body--font-size);
    line-height: var(--fb-global-body--line-height);
    text-decoration: none;
    transition: all 0.2s ease;
}

.toc-link:hover {
    color: #0875FF;
    text-decoration: none;
}

/* Current/Active Link */
.toc-item.toc-current .toc-link,
.toc-link.active {
    color: #0875FF;
    font-weight: 500;
}

/* Heading Levels */
.toc-level-h1 .toc-link {
    padding-left: 20px;
}

.toc-level-h2 .toc-link {
    padding-left: 20px;
}

.toc-level-h3 .toc-link {
    padding-left: 35px;
}

.toc-level-h4 .toc-link {
    padding-left: 50px;
}

.toc-level-h5 .toc-link {
    padding-left: 65px;
}

.toc-level-h6 .toc-link {
    padding-left: 80px;
}

/* Hidden state */
.toc-container.toc-hidden {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
}

.toc-container {
    transition: all 0.3s ease;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .wp-block-child-theme-table-of-contents {
        max-width: 100%;
    }

    .toc-header {
        padding: 15px 15px 12px;
    }

    .toc-content {
        padding: 8px 0 15px;
    }

    .toc-link {
        padding: 6px 15px;
        font-size: 13px;
    }

    .toc-level-h3 .toc-link {
        padding-left: 30px;
    }

    .toc-level-h4 .toc-link {
        padding-left: 45px;
    }

    .toc-level-h5 .toc-link {
        padding-left: 60px;
    }

    .toc-level-h6 .toc-link {
        padding-left: 75px;
    }
}

/* Fixed/Sticky Position (Optional) */
.toc-sticky {
    position: fixed;
    top: 100px;
    right: 20px;
    z-index: 999;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.toc-sticky .toc-content {
    max-height: 400px;
    overflow-y: auto;
}

/* Smooth scrolling for anchor links */
html {
    scroll-behavior: smooth;
}

/* Editor Preview Styles */
.toc-editor-preview {
    opacity: 0.8;
}

.toc-editor-preview .toc-link {
    pointer-events: none;
}

/* Print Styles */
@media print {
    .wp-block-child-theme-table-of-contents {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .toc-close {
        display: none;
    }
}