/**
 * Table of Contents Styles
 * Beautiful and responsive design for TOC
 */

/* TOC Container */
.bloglo-toc-container {
    background: #ffffff;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    padding: 0;
    margin: 15px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.bloglo-toc-container:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

/* TOC Header */
.bloglo-toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1px 5px;
    background: linear-gradient(to right, #f5f9fc 0%, #fff9e6 100%);
    border-bottom: 1px solid #e0e0e0;
    min-height: 18px;
}

.bloglo-toc-title {
    margin: 0;
    padding: 0;
    font-size: 12px;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    line-height: 1;
}

.bloglo-toc-title:before {
    content: "📑";
    margin-right: 2px;
    font-size: 11px;
    line-height: 1;
}

/* Toggle Button - Hidden */
.bloglo-toc-toggle {
    display: none !important;
}

/* TOC Content */
.bloglo-toc-content {
    max-height: 180px;
    overflow-y: auto;
    overflow-x: hidden;
    transition: all 0.3s ease;
    position: relative;
    padding: 10px 3px 5px 20px;
}

.bloglo-toc-container.collapsed .bloglo-toc-content {
    max-height: 0;
    overflow: hidden;
}

/* TOC List */
.bloglo-toc-list,
.bloglo-toc-sublist {
    list-style: none !important;
    list-style-type: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Override theme's margin-left for TOC lists */
.bloglo-entry .bloglo-toc-container ul,
.bloglo-entry .bloglo-toc-container ol,
.bloglo-toc-container ul,
.bloglo-toc-container ol {
    margin-left: 0 !important;
    padding-left: 0 !important;
}

.bloglo-toc-sublist {
    margin-left: 20px !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-left: 0 !important;
}

/* TOC Items */
.bloglo-toc-item {
    margin: 0;
    position: relative;
    list-style: none !important;
    list-style-type: none !important;
    min-height: auto;
}

/* Level indicators */
.bloglo-toc-level-2 {
    font-weight: 500;
}

.bloglo-toc-level-3 {
    margin-left: 20px !important;
}

.bloglo-toc-level-4 {
    margin-left: 40px !important;
    font-size: 0.95em;
}

.bloglo-toc-level-5 {
    margin-left: 60px !important;
    font-size: 0.9em;
}

.bloglo-toc-level-6 {
    margin-left: 80px !important;
    font-size: 0.85em;
}

/* TOC Links */
.bloglo-toc-link {
    color: #555;
    text-decoration: none !important;
    display: block;
    padding: 1px 2px 1px 0;
    border-radius: 3px;
    transition: all 0.2s ease;
    position: relative;
    line-height: 1.25;
}

.bloglo-toc-link:before {
    content: "▸";
    display: inline-block;
    margin-right: 3px;
    color: #999;
    transition: all 0.2s ease;
    font-size: 0.75em;
}

/* Different bullets for different levels */
.bloglo-toc-level-2 .bloglo-toc-link:before {
    content: "●";
    font-size: 0.6em;
}

.bloglo-toc-level-3 .bloglo-toc-link:before {
    content: "○";
    font-size: 0.6em;
}

.bloglo-toc-level-4 .bloglo-toc-link:before {
    content: "■";
    font-size: 0.5em;
}

.bloglo-toc-level-5 .bloglo-toc-link:before {
    content: "□";
    font-size: 0.5em;
}

.bloglo-toc-level-6 .bloglo-toc-link:before {
    content: "▪";
    font-size: 0.5em;
}

.bloglo-toc-link:hover {
    background: #f8f8f8;
    color: #1e73be;
    text-decoration: none !important;
    padding-left: 2px;
}

.bloglo-toc-link:hover:before {
    color: #1e73be;
    transform: translateX(2px);
}

/* Active link */
.bloglo-toc-link.active {
    background: #e8f4ff;
    color: #0066cc;
    font-weight: 500;
    text-decoration: none !important;
    padding-left: 2px;
}

.bloglo-toc-link.active:before {
    content: "►";
    color: #0066cc;
    transform: translateX(2px);
}

/* Scrollbar styling */
.bloglo-toc-content::-webkit-scrollbar {
    width: 8px;
}

.bloglo-toc-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.bloglo-toc-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.bloglo-toc-content::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Fade effect for scrollable content */
.bloglo-toc-content:before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to top, rgba(255,255,255,1) 0%, rgba(255,255,255,0.95) 20%, rgba(255,255,255,0.7) 50%, transparent 100%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1;
}

.bloglo-toc-content.has-scroll:before {
    opacity: 1;
}

/* Expand button */
.bloglo-toc-expand {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.95);
    border: 1px solid #ddd;
    border-radius: 15px;
    padding: 3px 12px;
    cursor: pointer;
    z-index: 10;
    display: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.bloglo-toc-container.has-scroll .bloglo-toc-expand {
    display: block;
}

.bloglo-toc-container.expanded .bloglo-toc-expand {
    position: static;
    transform: none;
    margin: 10px auto 0;
    display: block;
    width: fit-content;
}

.bloglo-toc-expand:hover {
    background: #f5f5f5;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.bloglo-toc-expand-icon {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #666;
    transition: transform 0.3s ease;
}

.bloglo-toc-container.expanded .bloglo-toc-expand-icon {
    transform: rotate(180deg);
}

.bloglo-toc-container.expanded .bloglo-toc-content {
    max-height: none !important;
    overflow-y: visible !important;
}

.bloglo-toc-container.expanded .bloglo-toc-content:before {
    opacity: 0;
}

/* Sticky TOC for desktop */
@media (min-width: 1200px) {
    .bloglo-toc-sticky {
        position: sticky;
        top: 100px;
        max-width: 300px;
        float: right;
        margin-left: 30px;
        margin-bottom: 30px;
    }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .bloglo-toc-header {
        padding: 1px 3px;
        min-height: 16px;
    }
    
    .bloglo-toc-title {
        font-size: 11px;
        padding: 0;
    }
    
    .bloglo-toc-title:before {
        font-size: 10px;
        margin-right: 2px;
        line-height: 1;
    }
    
    .bloglo-toc-toggle {
        width: 24px;
        height: 24px;
    }
    
    .bloglo-toc-content {
        max-height: 150px;
        padding: 8px 2px 4px 15px;
    }
    
    .bloglo-toc-container.expanded .bloglo-toc-content {
        max-height: none !important;
        overflow-y: visible !important;
    }
    
    .bloglo-toc-expand {
        padding: 1px 8px;
        bottom: 3px;
    }
    
    .bloglo-toc-expand-icon {
        border-left-width: 5px;
        border-right-width: 5px;
        border-top-width: 5px;
    }
    
    .bloglo-toc-level-3 {
        margin-left: 15px !important;
    }
    
    .bloglo-toc-level-4 {
        margin-left: 30px !important;
    }
    
    .bloglo-toc-level-5 {
        margin-left: 45px !important;
    }
    
    .bloglo-toc-level-6 {
        margin-left: 60px !important;
    }
    
    .bloglo-toc-link {
        padding: 1px 2px 1px 0;
        font-size: 13px;
        line-height: 1.2;
    }
}

/* Dark mode support (if theme has dark mode) */
body.dark-mode .bloglo-toc-container {
    background: #1a1a1a;
    border-color: #333;
}

body.dark-mode .bloglo-toc-header {
    border-bottom-color: #333;
    background: linear-gradient(to right, #1e2837 0%, #2d2416 100%);
}

body.dark-mode .bloglo-toc-title {
    color: #eee;
}

body.dark-mode .bloglo-toc-toggle {
    border-color: #555;
}

body.dark-mode .bloglo-toc-toggle:hover {
    background: #2a2a2a;
    border-color: #777;
}

body.dark-mode .toc-toggle-icon {
    border-color: #aaa;
}

body.dark-mode .bloglo-toc-link {
    color: #bbb;
}

body.dark-mode .bloglo-toc-link:hover {
    background: #2a2a2a;
    color: #4db8ff;
}

body.dark-mode .bloglo-toc-link.active {
    background: #1a3d5c;
    color: #4db8ff;
}

body.dark-mode .bloglo-toc-content:before {
    background: linear-gradient(to top, rgba(26,26,26,1) 0%, rgba(26,26,26,0.95) 20%, rgba(26,26,26,0.7) 50%, transparent 100%);
}

body.dark-mode .bloglo-toc-expand {
    background: #2a2a2a;
    border-color: #555;
}

body.dark-mode .bloglo-toc-expand:hover {
    background: #333;
}

body.dark-mode .bloglo-toc-expand-icon {
    border-top-color: #aaa;
}

/* Print styles */
@media print {
    .bloglo-toc-container {
        border: 1px solid #000;
        box-shadow: none;
    }
    
    .bloglo-toc-toggle {
        display: none;
    }
    
    .bloglo-toc-content {
        max-height: none !important;
        overflow: visible !important;
    }
}