/**
 * SEO Table of Contents - Styles
 * Clean, professional styling with collapsible functionality
 */

/* Container */
.seo-toc-container {
    background: #f8f9fa;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    margin: 30px 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.3s ease;
}

.seo-toc-container:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

/* Header */
.seo-toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
    border-radius: 8px 8px 0 0;
}

.seo-toc-header:hover {
    background: #f0f2f5;
}

.seo-toc-header:focus {
    outline: 2px solid #0066cc;
    outline-offset: -2px;
}

/* Title */
.seo-toc-title {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
    letter-spacing: -0.01em;
}

/* Toggle */
.seo-toc-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #586069;
    font-weight: 500;
}

.seo-toc-toggle-text {
    display: inline-block;
}

.seo-toc-icon {
    display: inline-block;
    transition: transform 0.3s ease;
    font-size: 12px;
    color: #0066cc;
}

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

.seo-toc-header[aria-expanded="true"] .seo-toc-toggle-text::after {
    content: ' to collapse';
}

/* List Container */
.seo-toc-list {
    padding: 0 20px 20px 20px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.seo-toc-list[style*="display: none"] {
    display: none !important;
}

/* Ordered List */
.seo-toc-list ol {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: toc-counter;
}

.seo-toc-list li {
    position: relative;
    margin: 0;
    padding: 8px 0 8px 30px;
    counter-increment: toc-counter;
    line-height: 1.6;
}

.seo-toc-list li::before {
    content: counter(toc-counter) ".";
    position: absolute;
    left: 0;
    top: 8px;
    font-weight: 600;
    color: #0066cc;
    font-size: 14px;
    min-width: 20px;
}

/* Links */
.seo-toc-list a {
    color: #24292e;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: color 0.2s ease, padding-left 0.2s ease;
    display: inline-block;
    position: relative;
}

.seo-toc-list a:hover {
    color: #0066cc;
    padding-left: 4px;
}

.seo-toc-list a:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Heading Level Indentation */
.seo-toc-h2 {
    padding-left: 30px;
}

.seo-toc-h3 {
    padding-left: 50px;
}

.seo-toc-h3 a {
    font-size: 14px;
    font-weight: 400;
}

.seo-toc-h4 {
    padding-left: 70px;
}

.seo-toc-h4 a {
    font-size: 14px;
    font-weight: 400;
    color: #586069;
}

.seo-toc-h5 {
    padding-left: 90px;
}

.seo-toc-h5 a {
    font-size: 13px;
    font-weight: 400;
    color: #586069;
}

.seo-toc-h6 {
    padding-left: 110px;
}

.seo-toc-h6 a {
    font-size: 13px;
    font-weight: 400;
    color: #6a737d;
}

/* Smooth Scroll Target Highlighting */
:target {
    scroll-margin-top: 20px;
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    .seo-toc-container {
        margin: 20px 0;
    }
    
    .seo-toc-header {
        padding: 14px 16px;
    }
    
    .seo-toc-title {
        font-size: 16px;
    }
    
    .seo-toc-toggle {
        font-size: 13px;
    }
    
    .seo-toc-list {
        padding: 0 16px 16px 16px;
    }
    
    .seo-toc-list li {
        padding: 6px 0 6px 25px;
    }
    
    .seo-toc-list a {
        font-size: 14px;
    }
    
    /* Reduce indentation on mobile */
    .seo-toc-h2 {
        padding-left: 25px;
    }
    
    .seo-toc-h3 {
        padding-left: 40px;
    }
    
    .seo-toc-h4 {
        padding-left: 55px;
    }
    
    .seo-toc-h5 {
        padding-left: 70px;
    }
    
    .seo-toc-h6 {
        padding-left: 85px;
    }
}

@media screen and (max-width: 480px) {
    .seo-toc-toggle-text {
        display: none;
    }
    
    .seo-toc-title {
        font-size: 15px;
    }
}

/* Print Styles */
@media print {
    .seo-toc-container {
        border: 1px solid #ccc;
        box-shadow: none;
        page-break-inside: avoid;
    }
    
    .seo-toc-header {
        cursor: default;
    }
    
    .seo-toc-list {
        display: block !important;
    }
    
    .seo-toc-toggle {
        display: none;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .seo-toc-container {
        background: #1e1e1e;
        border-color: #3a3a3a;
    }
    
    .seo-toc-header:hover {
        background: #2a2a2a;
    }
    
    .seo-toc-title {
        color: #e1e1e1;
    }
    
    .seo-toc-toggle {
        color: #a0a0a0;
    }
    
    .seo-toc-icon {
        color: #4a9eff;
    }
    
    .seo-toc-list a {
        color: #d1d1d1;
    }
    
    .seo-toc-list a:hover {
        color: #4a9eff;
    }
    
    .seo-toc-list li::before {
        color: #4a9eff;
    }
    
    .seo-toc-h4 a,
    .seo-toc-h5 a {
        color: #a0a0a0;
    }
    
    .seo-toc-h6 a {
        color: #808080;
    }
}

/* Accessibility - High Contrast Mode */
@media (prefers-contrast: high) {
    .seo-toc-container {
        border: 2px solid currentColor;
    }
    
    .seo-toc-list a:focus {
        outline-width: 3px;
    }
}

/* Animation for expanding/collapsing */
@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 2000px;
    }
}

@keyframes slideUp {
    from {
        opacity: 1;
        max-height: 2000px;
    }
    to {
        opacity: 0;
        max-height: 0;
    }
}

.seo-toc-list.expanding {
    animation: slideDown 0.3s ease forwards;
}

.seo-toc-list.collapsing {
    animation: slideUp 0.3s ease forwards;
}
