/*!
 * TL Smart TOC - 11 Distinct Templates
 * Version: 1.0.2
 */

/* Base Wrapper */
.tl-toc-wrapper {
    margin: 2rem 0;
}

/* ============================================ */
/* TEMPLATE 1: MINIMAL CLEAN */
/* ============================================ */
.tl-toc-minimal {
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
    --tl-text: #2c3e50;
    --tl-border: #e2e8f0;
}
.tl-toc-minimal .tl-toc-header { border-bottom: 1px solid #e2e8f0; }
.tl-toc-minimal .tl-toc-title { color: var(--tl-primary, #0073aa); }
.tl-toc-minimal .tl-toc-link { border-left: 3px solid transparent; }
.tl-toc-minimal .tl-toc-link:hover { background: #f8fafc; }
.tl-toc-minimal .tl-toc-link.active { border-left-color: var(--tl-primary, #0073aa); background: #f0f9ff; }

/* ============================================ */
/* TEMPLATE 2: CARD STYLE */
/* ============================================ */
.tl-toc-card {
    background: #ffffff;
    border: none;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --tl-text: #1e293b;
}
.tl-toc-card .tl-toc-header { border-bottom: 2px solid var(--tl-primary, #0073aa); }
.tl-toc-card .tl-toc-title { font-size: 1.4em; letter-spacing: -0.02em; }
.tl-toc-card .tl-toc-link { border-radius: 12px; margin: 4px 0; }
.tl-toc-card .tl-toc-link:hover { background: #f1f5f9; transform: translateX(5px); }
.tl-toc-card .tl-toc-link.active { background: var(--tl-primary, #0073aa); color: white; font-weight: 600; }

/* ============================================ */
/* TEMPLATE 3: GRADIENT BOX */
/* ============================================ */
.tl-toc-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 24px;
    padding: 2rem;
    --tl-text: #ffffff;
    --tl-border: rgba(255,255,255,0.2);
    color: white;
}
.tl-toc-gradient .tl-toc-header { border-bottom-color: rgba(255,255,255,0.3); }
.tl-toc-gradient .tl-toc-title { color: #ffd700; font-weight: 700; }
.tl-toc-gradient .tl-toc-link { color: rgba(255,255,255,0.9); border-radius: 8px; }
.tl-toc-gradient .tl-toc-link:hover { background: rgba(255,255,255,0.15); color: white; }
.tl-toc-gradient .tl-toc-link.active { background: rgba(255,215,0,0.2); border-left: 4px solid #ffd700; color: #ffd700; }
.tl-toc-gradient .tl-toc-toggle { color: white; }

/* ============================================ */
/* TEMPLATE 4: DARK MODE */
/* ============================================ */
.tl-toc-dark {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 16px;
    padding: 1.75rem;
    --tl-text: #e2e8f0;
    --tl-border: #334155;
}
.tl-toc-dark .tl-toc-header { border-bottom-color: #334155; }
.tl-toc-dark .tl-toc-title { color: #38bdf8; }
.tl-toc-dark .tl-toc-link { color: #94a3b8; }
.tl-toc-dark .tl-toc-link:hover { background: #1e293b; color: #f1f5f9; }
.tl-toc-dark .tl-toc-link.active { background: #1e293b; color: #38bdf8; border-left: 4px solid #38bdf8; }
.tl-toc-dark .tl-toc-toggle { color: #64748b; }
.tl-toc-dark .tl-toc-progress { background: #334155; }

/* ============================================ */
/* TEMPLATE 5: NUMBERED LIST */
/* ============================================ */
.tl-toc-numbered {
    background: #fffbeb;
    border: 3px solid #f59e0b;
    border-radius: 16px;
    padding: 1.5rem;
    --tl-text: #78350f;
}
.tl-toc-numbered .tl-toc-header { border-bottom: 2px dashed #fbbf24; }
.tl-toc-numbered .tl-toc-title { color: #b45309; }
.tl-toc-numbered .tl-toc-list { counter-reset: toc-counter; }
.tl-toc-numbered .tl-toc-link { counter-increment: toc-counter; border-left: none; }
.tl-toc-numbered .tl-toc-text::before {
    content: counter(toc-counter) ". ";
    font-weight: 800;
    color: #d97706;
    margin-right: 12px;
}
.tl-toc-numbered .tl-toc-link:hover { background: #fef3c7; }
.tl-toc-numbered .tl-toc-link.active { background: #f59e0b; color: white; }
.tl-toc-numbered .tl-toc-link.active .tl-toc-text::before { color: white; }

/* ============================================ */
/* TEMPLATE 6: ACCORDION */
/* ============================================ */
.tl-toc-accordion {
    background: #f0fdf4;
    border: 2px solid #22c55e;
    border-radius: 20px;
    padding: 1.5rem;
    --tl-text: #166534;
}
.tl-toc-accordion .tl-toc-title { color: #15803d; }
.tl-toc-accordion .tl-toc-child { 
    max-height: 0; 
    overflow: hidden; 
    transition: max-height 0.5s ease-out;
    padding-left: 0;
}
.tl-toc-accordion li { position: relative; }
.tl-toc-accordion li::before {
    content: "▶";
    position: absolute;
    left: -20px;
    top: 12px;
    font-size: 10px;
    color: #22c55e;
    transition: transform 0.3s;
}
.tl-toc-accordion li:hover::before { transform: rotate(90deg); }
.tl-toc-accordion li:hover > .tl-toc-child { max-height: 500px; }
.tl-toc-accordion .tl-toc-link { border-left: none; }
.tl-toc-accordion .tl-toc-link:hover { background: #dcfce7; }
.tl-toc-accordion .tl-toc-link.active { background: #22c55e; color: white; font-weight: 700; }

/* ============================================ */
/* TEMPLATE 7: SIDEBAR STICKY */
/* ============================================ */
.tl-toc-sidebar {
    background: #ffffff;
    border: none;
    border-left: 6px solid var(--tl-primary, #0073aa);
    border-radius: 0 16px 16px 0;
    padding: 1.5rem;
    box-shadow: -5px 5px 20px rgba(0,0,0,0.08);
    max-width: 350px;
}
.tl-toc-sidebar .tl-toc-header { border-bottom: 1px solid #f1f5f9; }
.tl-toc-sidebar .tl-toc-title { font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; font-size: 1em; }
.tl-toc-sidebar .tl-toc-link { font-size: 0.95em; padding: 0.4rem 0.5rem; }
.tl-toc-sidebar .tl-toc-link.active { background: #eff6ff; border-left: 3px solid var(--tl-primary, #0073aa); }

/* ============================================ */
/* TEMPLATE 8: FLOATING BUTTON */
/* ============================================ */
.tl-toc-floating {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999;
    padding: 0;
    background: transparent;
    border: none;
    width: auto;
}
.tl-toc-floating .tl-toc-header { display: none; }
.tl-toc-floating .tl-toc-nav {
    display: none;
    position: absolute;
    bottom: 60px;
    right: 0;
    width: 320px;
    max-height: 450px;
    background: white;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    padding: 1.5rem;
    border: 1px solid #e2e8f0;
}
.tl-toc-floating.active .tl-toc-nav { display: block; }
.tl-toc-floating .tl-toc-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 48px !important;
    height: 48px !important;
    background: var(--tl-primary, #0073aa) !important;
    color: white !important;
    border-radius: 50% !important;
    box-shadow: 0 10px 20px rgba(0,115,170,0.3) !important;
    border: none;
    cursor: pointer;
    margin: 0;
    padding: 0;
}
.tl-toc-floating .tl-toc-icon::after {
    content: "☰" !important;
    font-size: 24px !important;
    line-height: 1;
}
.tl-toc-floating .tl-toc-progress { display: none; }

/* ============================================ */
/* TEMPLATE 9: GLASSMORPHISM */
/* ============================================ */
.tl-toc-glass {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 32px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    --tl-text: #1e1e2f;
}
.tl-toc-glass .tl-toc-header { border-bottom: 1px solid rgba(0,0,0,0.1); }
.tl-toc-glass .tl-toc-title { font-weight: 700; text-shadow: 0 1px 2px rgba(255,255,255,0.5); }
.tl-toc-glass .tl-toc-link { border-radius: 40px; }
.tl-toc-glass .tl-toc-link:hover { background: rgba(255,255,255,0.5); }
.tl-toc-glass .tl-toc-link.active { background: rgba(255,255,255,0.8); box-shadow: 0 2px 8px rgba(0,0,0,0.05); }

/* ============================================ */
/* TEMPLATE 10: BORDER LEFT INDICATOR */
/* ============================================ */
.tl-toc-border-left {
    background: #ffffff;
    border: none;
    border-left: 6px solid;
    border-image: linear-gradient(180deg, #3b82f6, #8b5cf6, #ec4899) 1;
    border-radius: 0 12px 12px 0;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}
.tl-toc-border-left .tl-toc-header { border-bottom: none; padding-bottom: 0.5rem; }
.tl-toc-border-left .tl-toc-title { color: #1e293b; font-size: 1.1em; }
.tl-toc-border-left .tl-toc-link { border-left: none; margin-left: 0; }
.tl-toc-border-left .tl-toc-link.active { 
    background: linear-gradient(90deg, #eff6ff 0%, transparent 100%);
    font-weight: 600;
    color: #2563eb;
}

/* ============================================ */
/* TEMPLATE 11: TIMELINE STYLE */
/* ============================================ */
.tl-toc-timeline {
    background: #faf9f6;
    border: 1px solid #e7e5e4;
    border-radius: 0;
    padding: 1.5rem 1.5rem 1.5rem 3rem;
    position: relative;
}
.tl-toc-timeline::before {
    content: '';
    position: absolute;
    left: 30px;
    top: 70px;
    bottom: 40px;
    width: 3px;
    background: linear-gradient(180deg, #d4d4d8, #a1a1aa, #71717a);
}
.tl-toc-timeline .tl-toc-header { border-bottom: 1px solid #e7e5e4; }
.tl-toc-timeline .tl-toc-link {
    position: relative;
    border-left: none;
    padding-left: 20px;
}
.tl-toc-timeline .tl-toc-link::before {
    content: '';
    position: absolute;
    left: -44px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    border: 3px solid #a1a1aa;
    transition: all 0.3s;
    z-index: 1;
}
.tl-toc-timeline .tl-toc-link:hover::before { border-color: #3b82f6; background: #dbeafe; }
.tl-toc-timeline .tl-toc-link.active::before {
    background: #3b82f6;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59,130,246,0.2);
}
.tl-toc-timeline .tl-toc-link.active {
    color: #1e40af;
    font-weight: 600;
    background: transparent;
}

/* ============================================ */
/* COMMON STYLES */
/* ============================================ */
.tl-toc-container {
    position: relative;
    font-size: var(--tl-font-size, 14px);
    color: var(--tl-text, #2c3e50);
    box-sizing: border-box;
    width: 100%;
    transition: all 0.3s ease;
}

.tl-toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
}

.tl-toc-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
}
.tl-toc-toggle:hover { opacity: 0.8; }

.tl-toc-icon::after {
    content: "▼";
    font-size: 12px;
    display: inline-block;
    transition: transform 0.3s;
}
.tl-toc-container.collapsed .tl-toc-nav { display: none; }
.tl-toc-container.collapsed .tl-toc-icon::after { transform: rotate(-90deg); }

.tl-toc-nav { max-height: 70vh; overflow-y: auto; }
.tl-toc-list, .tl-toc-child { list-style: none; margin: 0; padding-left: 0; }
.tl-toc-child { padding-left: 1.5rem; }

.tl-toc-link {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.5rem 0.5rem 12px;
    text-decoration: none;
    transition: all 0.2s;
    margin: 2px 0;
    cursor: pointer;
}

.tl-toc-text { flex: 1; }

.tl-toc-copy {
    background: none;
    border: none;
    margin-left: 8px;
    opacity: 0;
    cursor: pointer;
    padding: 4px 6px;
    font-size: 14px;
    border-radius: 4px;
    transition: all 0.2s;
}
.tl-toc-link:hover .tl-toc-copy { opacity: 0.6; }
.tl-toc-copy:hover { opacity: 1 !important; background: rgba(0,0,0,0.05); }

.tl-toc-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(0,0,0,0.05);
    overflow: hidden;
}
.tl-toc-progress span {
    display: block;
    height: 100%;
    background: var(--tl-primary, #0073aa);
    width: 0%;
    transition: width 0.1s;
}

/* Sticky */
.tl-toc-container.sticky-enabled { position: sticky; top: 20px; z-index: 10; }

/* Mobile */
.tl-toc-mobile-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--tl-primary, #0073aa);
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    border: none;
    z-index: 9999;
    cursor: pointer;
    font-size: 22px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.tl-toc-mobile-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 360px;
    height: 100vh;
    background: white;
    box-shadow: -10px 0 30px rgba(0,0,0,0.15);
    transition: right 0.3s;
    z-index: 10000;
    overflow-y: auto;
}
.tl-toc-mobile-panel.active { right: 0; }
.tl-toc-mobile-panel .tl-toc-container { display: block !important; margin: 0; border-radius: 0; }

h2[id], h3[id], h4[id] { scroll-margin-top: 80px; }

@media (max-width: 768px) {
    .tl-toc-mobile-toggle { display: flex; }
    .tl-toc-container:not(.tl-toc-floating):not(.tl-toc-sidebar) { display: none; }
    .tl-toc-sidebar { max-width: 100%; float: none; }
}