/**
 * Auto Table of Contents - Frontend Styles
 * Layout 1: Breadcrumbs + Dropdown
 * Layout 2: Background Image
 * Layout 3: Background + Featured Image
 */

/* Base TOC Container */
.auto-toc-container {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border-radius: 0;
    --toc-title-color: #333333;
    --toc-link-color: #007cba;
    --toc-layout1-bg-color: #f8f9fa;
    --toc-layout1-breadcrumb-color: #495057;
    --toc-layout1-dropdown-button-color: #007cba;
    --toc-layout1-dropdown-button-text-color: #ffffff;
    --toc-layout1-dropdown-button-font-size: 14px;
    --toc-layout2-bg-color: #e9ecef;
    --toc-layout3-bg-color: #e9ecef;
}


/* Layout 1: Breadcrumbs + Dropdown */
.auto-toc-layout1 {
    background: var(--toc-layout1-bg-color);
    border: none;
    border-radius: 0;
    padding: 0 5px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 15px;
    width: 100%;
}

.auto-toc-breadcrumbs {
    color: var(--toc-layout1-breadcrumb-color);
    font-size: 14px;
    font-weight: 500;
    padding: 20px 0px 20px 20px;
    flex: 1;
}

.auto-toc-breadcrumbs a {
    color: var(--toc-link-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.auto-toc-breadcrumbs a:hover {
    color: var(--toc-link-hover-color, #005a87);
    text-decoration: underline;
}

.auto-toc-dropdown {
    position: relative;
    flex-shrink: 0;
}

.auto-toc-dropdown-toggle {
    background: var(--toc-layout1-dropdown-button-color);
    color: var(--toc-layout1-dropdown-button-text-color);
    border: none;
    padding: 10px 20px;
    border-radius: 0;
    cursor: pointer;
    font-size: var(--toc-layout1-dropdown-button-font-size);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease;
    white-space: nowrap;
    margin-left: auto;
}

/* When breadcrumbs are not present, ensure dropdown has proper spacing */
.auto-toc-layout1.no-breadcrumbs .auto-toc-dropdown-toggle {
    margin: 10px;
}

/* When breadcrumbs are not present, align dropdown with left edge of button */
.auto-toc-layout1.no-breadcrumbs .auto-toc-dropdown-content {
    right: auto;
    left: 0;
}

.auto-toc-dropdown-toggle:hover {
    background: var(--toc-layout1-dropdown-button-hover-color, #005a87);
}

.auto-toc-dropdown-toggle[aria-expanded="true"] .auto-toc-chevron {
    transform: rotate(90deg);
}

.auto-toc-chevron {
    transition: transform 0.2s ease;
    font-size: 12px;
}

.auto-toc-dropdown-content {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 250px;
    max-width: 400px;
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

/* Force Layout 1 dropdown content to remain white background */
.auto-toc-layout1 .auto-toc-dropdown-content {
    background: #ffffff !important;
}

.auto-toc-dropdown-content.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

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

.auto-toc-list li {
    margin: 0;
    padding-bottom: 10px;
}

.auto-toc-link {
    display: block;
    padding: 8px 15px;
    color: #000000;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

/* Force Layout 1 dropdown links to remain black text */
.auto-toc-layout1 .auto-toc-dropdown-content .auto-toc-link {
    color: #000000 !important;
}

.auto-toc-link:hover {
    color: var(--toc-link-hover-color, #005a87);
}

/* Layout 1 dropdown links should use default hover styles, not the custom hover color */
.auto-toc-layout1 .auto-toc-dropdown-content .auto-toc-link:hover {
    background: #f8f9fa;
    color: #000000;
    border-left-color: #000000;
}

/* Active link highlighting - Layout 1 only */
.auto-toc-layout1 .auto-toc-dropdown-content .auto-toc-link.active {
    background: #f0f0f0 !important;
    color: #000000 !important;
    border-left-color: #000000 !important;
    font-weight: 500;
}

/* Layout 2: Background Image */
.auto-toc-layout2 {
    background: var(--toc-layout2-bg-color);
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-attachment: scroll !important;
    border-radius: 0;
    overflow: hidden;
    position: relative;
    min-height: 300px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auto-toc-layout2::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    pointer-events: none;
}

/* Ensure background image spans entire container */
.auto-toc-container.auto-toc-layout2 {
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-attachment: scroll !important;
}

.auto-toc-overlay {
    position: relative;
    z-index: 2;
    text-align: center;
    color: white;
    padding: 40px 20px;
    max-width: 600px;
    width: 100%;
    background: transparent;
}

/* Layout 2 specific overlay padding */
.auto-toc-layout2 .auto-toc-overlay {
    padding: 75px 40px;
}

/* Show title for all layouts */

.auto-toc-layout1 .auto-toc-title,
.auto-toc-layout2 .auto-toc-title,
.auto-toc-layout3 .auto-toc-title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 30px 0;
    color: var(--toc-title-color);
    text-transform: uppercase;
    letter-spacing: 1px;
    /* Prevent highlighting when jumplinks are clicked */
    outline: none !important;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}

/* Prevent any focus, active, or hover states on TOC title */
.auto-toc-layout1 .auto-toc-title:focus,
.auto-toc-layout1 .auto-toc-title:active,
.auto-toc-layout1 .auto-toc-title:hover,
.auto-toc-layout2 .auto-toc-title:focus,
.auto-toc-layout2 .auto-toc-title:active,
.auto-toc-layout2 .auto-toc-title:hover,
.auto-toc-layout3 .auto-toc-title:focus,
.auto-toc-layout3 .auto-toc-title:active,
.auto-toc-layout3 .auto-toc-title:hover {
    outline: none !important;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    color: var(--toc-title-color) !important;
}

.auto-toc-layout2 .auto-toc-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-align: center;
}

.auto-toc-layout2 .auto-toc-link {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 2px 0;
    color: var(--toc-link-color);
    text-decoration: underline;
    font-size: 16px;
    font-weight: 400;
    transition: all 0.3s ease;
    display: inline-block;
}

.auto-toc-layout2 .auto-toc-link:hover {
    color: var(--toc-link-hover-color, #005a87);
}

/* Layout 3: Background + Featured Image */
.auto-toc-layout3 {
    background: var(--toc-layout3-bg-color);
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    border-radius: 0;
    overflow: hidden;
    position: relative;
    min-height: 400px;
    display: flex;
    align-items: stretch;
    padding: 0;
    width: 100%;
}

.auto-toc-layout3::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 1;
}

.auto-toc-featured-image {
    position: relative;
    z-index: 2;
    flex: 0 0 45%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.auto-toc-content {
    position: relative;
    z-index: 2;
    flex: 1;
    padding: 75px 40px;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
}


.auto-toc-layout3 .auto-toc-list {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    text-align: left;
}

.auto-toc-layout3 .auto-toc-link {
    background: none;
    border: none;
    border-radius: 0;
    padding: 2px 0;
    color: var(--toc-link-color);
    text-decoration: underline;
    font-size: 16px;
    font-weight: 400;
    transition: all 0.3s ease;
    text-align: left;
}

.auto-toc-layout3 .auto-toc-link:hover {
    color: var(--toc-link-hover-color, #005a87);
}

/* TOC Block Error and Placeholder Styles */
.auto-toc-error {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 14px;
}

.auto-toc-placeholder {
    background: #d1ecf1;
    color: #0c5460;
    padding: 15px;
    border: 1px solid #bee5eb;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 14px;
    text-align: center;
    font-style: italic;
}

/* Back to Top Button */
.auto-toc-back-to-top {
    position: fixed;
    bottom: 10px;
    right: 10px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #802BB1, #0024C0);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(128, 43, 177, 0.3);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    opacity: 0;
    transform: translateY(30px) scale(0.8);
    pointer-events: none;
}

.auto-toc-back-to-top.position-bottom-left {
    right: auto;
    left: 10px;
}

.auto-toc-back-to-top.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.auto-toc-back-to-top:hover {
    background: linear-gradient(135deg, #6a1f9a, #001a9e);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(128, 43, 177, 0.4);
}

.auto-toc-back-to-top:active {
    transform: translateY(-1px) scale(0.98);
    box-shadow: 0 2px 10px rgba(128, 43, 177, 0.3);
}

/* Arrow Styles */
.auto-toc-back-to-top.arrow-arrow::before {
    content: "↑";
    font-size: 20px;
    line-height: 1;
}

.auto-toc-back-to-top.arrow-chevron::before {
    content: "⌃";
    font-size: 20px;
    line-height: 1;
}

.auto-toc-back-to-top.arrow-caret::before {
    content: "▲";
    font-size: 20px;
    margin-bottom: 5px;
}

/* Default arrow style (for backward compatibility) */
.auto-toc-back-to-top::before {
    content: "↑";
    font-size: 20px;
    line-height: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .auto-toc-back-to-top {
        bottom: 10px;
        right: 10px;
        width: 45px;
        height: 45px;
        font-size: 16px;
    }
    
    .auto-toc-back-to-top.position-bottom-left {
        right: auto;
        left: 10px;
    }
    
    .auto-toc-back-to-top.arrow-arrow::before,
    .auto-toc-back-to-top.arrow-chevron::before,
    .auto-toc-back-to-top.arrow-caret::before,
    .auto-toc-back-to-top::before {
        font-size: 18px;
    }
    
    .auto-toc-layout1 {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        padding: 0;
        gap: 0;
    }
    
    .auto-toc-layout1 .auto-toc-breadcrumbs {
        width: 100%;
        text-align: center;
        padding: 15px 20px;
        box-sizing: border-box;
    }
    
    .auto-toc-layout1 .auto-toc-dropdown-toggle {
        width: 100%;
        margin: 0;
        padding: 15px 20px;
        box-sizing: border-box;
    }
    
    .auto-toc-dropdown-content {
        right: auto;
        left: 0;
        transform: translateY(-10px);
        min-width: 100%;
        width: 100%;
    }
    
    .auto-toc-dropdown-content.active {
        transform: translateY(0);
    }
    
    .auto-toc-dropdown-content .auto-toc-list {
        text-align: left;
    }
    
    .auto-toc-dropdown-content .auto-toc-link {
        text-align: left;
    }
    
    
    .auto-toc-layout2 .auto-toc-list {
        grid-template-columns: 1fr;
    }
    
    .auto-toc-layout3 {
        flex-direction: column;
        text-align: center;
        padding: 0;
    }
    
    .auto-toc-layout3 .auto-toc-featured-image {
        flex: none !important;
        max-width: none !important;
        margin: 0 0 20px 0 !important;
        display: block !important;
        position: relative !important;
        z-index: 2 !important;
        height: 400px !important;
        width: 100% !important;
        min-height: 400px !important;
        background-size: cover !important;
        background-position: top center !important;
        background-repeat: no-repeat !important;
    }
    
    .auto-toc-layout3 .auto-toc-content {
        padding: 20px;
    }
    
    .auto-toc-layout3 .auto-toc-list {
        text-align: center !important;
        align-items: center !important;
    }
    
    .auto-toc-layout3 .auto-toc-link {
        text-align: center !important;
    }
    
    
    .auto-toc-layout3 .auto-toc-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .auto-toc-container {
        margin: 15px 0;
    }
    
    .auto-toc-layout1 {
        padding: 0;
        gap: 0;
    }
    
    .auto-toc-layout1 .auto-toc-breadcrumbs {
        width: 100%;
        text-align: center;
        padding: 12px 15px;
        font-size: 13px;
        box-sizing: border-box;
    }
    
    .auto-toc-layout1 .auto-toc-dropdown-toggle {
        width: 100%;
        margin: 0;
        padding: 12px 15px;
        font-size: 13px;
        box-sizing: border-box;
    }
    
    .auto-toc-layout2,
    .auto-toc-layout3 {
        min-height: 250px;
        padding: 20px 15px;
    }
    
    .auto-toc-layout3 {
        padding: 0 !important;
    }
    
    .auto-toc-layout3 .auto-toc-featured-image {
        display: block !important;
        max-width: none !important;
        margin: 0 0 15px 0 !important;
        flex: none !important;
        position: relative !important;
        z-index: 2 !important;
        height: 400px !important;
        width: 100% !important;
        min-height: 400px !important;
        background-size: cover !important;
        background-position: top center !important;
        background-repeat: no-repeat !important;
    }
    
    .auto-toc-layout3 .auto-toc-content {
        padding: 15px;
    }
    
    .auto-toc-layout3 .auto-toc-list {
        text-align: center !important;
        align-items: center !important;
    }
    
    .auto-toc-layout3 .auto-toc-link {
        text-align: center !important;
    }
    
    
    .auto-toc-featured-image {
        max-width: 200px;
    }
}

/* Smooth Scroll Enhancement */
html {
    scroll-behavior: smooth;
}

/* Focus styles for accessibility - match hover state */
.auto-toc-link:focus {
    color: var(--toc-link-hover-color, #005a87);
    outline: none;
}

.auto-toc-layout2 .auto-toc-link:focus {
    color: var(--toc-link-hover-color, #005a87);
    outline: none;
}

.auto-toc-layout3 .auto-toc-link:focus {
    color: var(--toc-link-hover-color, #005a87);
    outline: none;
}

.auto-toc-dropdown-toggle:focus {
    background: var(--toc-layout1-dropdown-button-hover-color, #005a87);
    outline: none;
}

/* Print styles */
@media print {
    .auto-toc-container {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .auto-toc-dropdown-content {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .auto-toc-dropdown-toggle {
        display: none;
    }
}

