/**
 * Table of Contents Block - Frontend Styles
 */

.wpa-toc-block {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Details/Summary for collapse functionality */
.wpa-toc-block .toc-details {
    margin: -1.5rem;
}

.wpa-toc-block .toc-details summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    position: relative;
}

/* Hide default marker */
.wpa-toc-block .toc-details summary::-webkit-details-marker {
    display: none;
}

.wpa-toc-block .toc-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    padding: 1.5rem 3rem 1rem 1.5rem;
    color: #212529;
    border-bottom: 2px solid #dee2e6;
}

/* Toggle arrow in right corner */
.wpa-toc-block .toc-toggle {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid #495057;
    transition: transform 0.2s ease;
}

/* Rotate arrow when expanded */
.wpa-toc-block .toc-details[open] .toc-toggle {
    transform: translateY(-50%) rotate(180deg);
}

/* Content wrapper */
.wpa-toc-block .toc-content {
    padding: 0 1.5rem 1.5rem 1.5rem;
}

/* Article title in TOC heading */
.wpa-toc-block .toc-title .toc-article-title {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: #212529;
    margin-bottom: 0.25rem;
}

.wpa-toc-block .toc-title .toc-separator {
    display: none;
}

/* When article title is shown, make TOC subtitle smaller */
.wpa-toc-block .toc-title:has(.toc-article-title) {
    font-size: 0.9rem;
    font-weight: 400;
    color: #6c757d;
}

/* List styles */
.wpa-toc-block .toc-list {
    padding-left: 1rem;
}

.wpa-toc-block .toc-item {
    margin: 0;
}

.wpa-toc-block .toc-link {
    color: #495057;
    text-decoration: none;
    display: block;
    padding: 0.25rem 0;
    transition: color 0.2s ease, padding-left 0.2s ease;
}

.wpa-toc-block .toc-link:hover {
    color: #007bff;
    padding-left: 0.25rem;
}

.wpa-toc-block .toc-link:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Active state */
.wpa-toc-block .toc-link.is-active {
    color: #007bff;
    font-weight: 600;
}

/* Nested lists indentation */
.wpa-toc-block .toc-depth-0 {
    padding-left: 0;
}

.wpa-toc-block .toc-depth-1 {
    padding-left: .5rem;

}

.wpa-toc-block .toc-depth-2 {
    padding-left: 1rem;
    font-size: 0.9em;
}

/* Position: Static (default) */
.wpa-toc-block.toc-position-static {
    position: relative;
}

/* Position: Sticky */
.wpa-toc-block.toc-position-sticky {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 2rem !important;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    align-self: flex-start;
    /* Important for flexbox parents */
}

/* Position: Float */
.wpa-toc-block.toc-position-float {
    float: right;
    width: 300px;
    margin: 0 0 1.5rem 1.5rem;
}

/* Scrollbar styling for sticky TOC */
.wpa-toc-block.toc-position-sticky::-webkit-scrollbar {
    width: 6px;
}

.wpa-toc-block.toc-position-sticky::-webkit-scrollbar-track {
    background: transparent;
}

.wpa-toc-block.toc-position-sticky::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 3px;
}

.wpa-toc-block.toc-position-sticky::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* Responsive behavior */
@media (max-width: 768px) {

    /* Disable sticky on mobile */
    .wpa-toc-block.toc-position-sticky {
        position: static;
        max-height: none;
        overflow-y: visible;
    }

    /* Disable float on mobile */
    .wpa-toc-block.toc-position-float {
        float: none;
        width: 100%;
        margin: 1.5rem 0;
    }

    /* Compact spacing on mobile */
    .wpa-toc-block {
        padding: 1rem;
        font-size: 0.9rem;
    }

    .wpa-toc-block .toc-title {
        font-size: 1rem;
    }

    .wpa-toc-block .toc-depth-1,
    .wpa-toc-block .toc-depth-2 {
        padding-left: 1rem;
    }
}

/* Print styles */
@media print {
    .wpa-toc-block {
        position: static !important;
        float: none !important;
        page-break-inside: avoid;
    }
}

/* Editor preview styles */
.wpa-toc-block-preview {
    background: #e7f3ff;
    border: 2px dashed #0066cc;
    border-radius: 8px;
    min-height: 200px;
    margin: 1rem 0;
}

.wpa-toc-block-preview .toc-title {
    background: #0066cc;
    color: #fff;
    margin: 0;
    padding: 0.75rem 1rem;
    border-radius: 6px 6px 0 0;
    border-bottom: none;
    font-size: 1rem;
    font-weight: 700;
}

.wpa-toc-block-preview .toc-preview-info {
    padding: 1.5rem;
    text-align: left;
    line-height: 1.6;
}

.wpa-toc-block-preview .toc-preview-info p {
    margin: 0 0 1rem 0;
    color: #333;
    font-style: normal;
}

.wpa-toc-block-preview .toc-preview-info strong {
    color: #0066cc;
}

.wpa-toc-block-preview .toc-preview-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 0;
    color: #666;
    font-size: 0.9rem;
}

.wpa-toc-block-preview .toc-preview-list li {
    padding: 0.25rem 0;
}

/* Smooth scroll behavior */
html.toc-smooth-scroll {
    scroll-behavior: smooth;
}

/* Alternative: numbered list style */
.wpa-toc-block .toc-list[style*="list-style-type: decimal"] {
    list-style-position: inside;
}

.wpa-toc-block .toc-list ol {
    list-style-type: decimal;
}

.wpa-toc-block .toc-list ol ol {
    list-style-type: lower-alpha;
}

.wpa-toc-block .toc-list ol ol ol {
    list-style-type: lower-roman;
}