/**
 * Premium Smart TOC Styling
 * Branding: Geely Blue & Glassmorphism
 */

.premium-toc {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(235, 10, 30, 0.1);
    border-radius: 12px;
    margin: 30px 0;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.premium-toc:hover {
    box-shadow: 0 15px 40px rgba(0, 102, 204, 0.1);
    border-color: rgba(235, 10, 30, 0.3);
}

.toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(90deg, rgba(235, 10, 30, 0.05) 0%, rgba(255, 255, 255, 0) 100%);
    border-bottom: 1px solid rgba(235, 10, 30, 0.05);
}

.toc-title {
    font-weight: 800;
    font-size: 14px;
    color: var(--clr-primary, #14397B);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#toc-toggle {
    background: none;
    border: none;
    color: var(--clr-primary, #14397B);
    cursor: pointer;
    font-size: 14px;
    transition: transform 0.3s ease;
    padding: 5px;
}

#toc-toggle.collapsed {
    transform: rotate(180deg);
}

.toc-body {
    padding: 15px 20px;
    max-height: 1000px;
    transition: max-height 0.4s ease-in-out, padding 0.4s ease;
    overflow: hidden;
}

.toc-body.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-item {
    margin-bottom: 8px;
    line-height: 1.4;
}

.toc-link {
    text-decoration: none;
    color: #444;
    font-size: 15px;
    transition: all 0.2s ease;
    display: block;
    padding: 4px 0;
    position: relative;
    padding-left: 15px;
}

.toc-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    background: #ccc;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.toc-link:hover {
    color: var(--clr-primary, #14397B);
    padding-left: 20px;
}

.toc-link:hover::before {
    background: var(--clr-primary, #14397B);
    width: 6px;
    border-radius: 2px;
}

/* Depth Styling */
.toc-depth-3 { margin-left: 20px; font-size: 14px; }
.toc-depth-4 { margin-left: 40px; font-size: 13.5px; }

/* Active State (Scrollspy) */
.toc-link.active {
    color: var(--clr-primary, #14397B);
    font-weight: 700;
    padding-left: 20px;
}

.toc-link.active::before {
    background: var(--clr-primary, #14397B);
    height: 70%;
    width: 3px;
    border-radius: 0;
}

/* Sticky TOC Icon (Floating Button) */
.toc-floating-btn {
    position: fixed;
    top: 50%;
    right: 20px !important;
    left: auto !important;
    transform: translateY(-50%) scale(0) rotate(-180deg);
    width: 50px;
    height: 50px;
    background: var(--clr-primary, #14397B);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: -5px 5px 20px rgba(0, 102, 204, 0.3);
    cursor: pointer;
    z-index: 99999 !important; /* Higher than header for mobile */
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
}

.toc-floating-btn.visible {
    transform: translateY(-50%) scale(1) rotate(0);
    opacity: 1;
}

.toc-floating-btn:hover {
    transform: scale(1.1);
    background: #c30819;
}

.toc-floating-btn i {
    font-size: 20px;
}

/* Sticky Modal Overlay for TOC */
.premium-toc.floating-mode {
    position: fixed;
    top: 50%;
    right: 85px !important;
    left: auto !important;
    width: 320px;
    max-width: 90vw;
    z-index: 100000;
    margin: 0;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
    transform: translateY(-50%) translateX(20px);
    opacity: 0;
    pointer-events: none;
}

.premium-toc.floating-mode.active {
    transform: translateY(-50%) translateX(0);
    opacity: 1;
    pointer-events: all;
}

@media (max-width: 768px) {
    .toc-floating-btn {
        top: 60%; /* Slightly lower on mobile to avoid other UI elements */
        right: 10px;
        width: 45px;
        height: 45px;
    }
    .premium-toc.floating-mode {
        top: 50%;
        right: 10px;
        width: calc(100% - 20px);
    }
}
