/* AI2U Documentation Styles */

/* Documentation Container */
.docs-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 100vh;
}

/* Documentation Layout - 3 Column Grid */
.docs-layout {
    display: grid;
    grid-template-columns: 280px 1fr 240px;
    gap: 2rem;
    position: relative;
}

/* Sidebar Styles */
.docs-sidebar {
    position: sticky;
    top: 20px;
    height: fit-content;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    border-radius: 12px;
    padding: 1.5rem;
    background: color-mix(in srgb, var(--surface-color) 60%, transparent);
    backdrop-filter: blur(10px);
    border: 1px solid color-mix(in srgb, var(--border-color) 30%, transparent);
}

.docs-sidebar-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.docs-sidebar-title {
    color: var(--primary-color);
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

/* Override Django Spellbook TOC Styles */
.docs-toc .toc-wrapper {
    font-size: 0.9rem;
}

.docs-toc .toc-link {
    color: var(--text-secondary-color);
    padding: 0.5rem 0.75rem !important;
    border-radius: 8px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.docs-toc .toc-link:hover {
    background: color-mix(in srgb, var(--primary-color) 10%, transparent);
    color: var(--primary-color);
    transform: translateX(4px);
}

.docs-toc .toc-item.active .toc-link,
.docs-toc .toc-subitem.active .toc-link {
    background: linear-gradient(135deg, 
        color-mix(in srgb, var(--primary-color) 20%, transparent),
        color-mix(in srgb, var(--accent-color) 10%, transparent));
    color: var(--primary-color) !important;
    font-weight: 600;
    border-left: 3px solid var(--accent-color);
}

.docs-toc .toc-sublist {
    border-left: 2px solid var(--border-color);
    margin-left: 1rem;
}

.docs-toc .toc-arrow {
    color: var(--text-secondary-color);
}

/* Main Content Area */
.docs-content {
    min-width: 0;
    max-width: 850px;
}

/* Breadcrumb */
.docs-breadcrumb {
    margin-bottom: 2rem;
}

.breadcrumb {
    display: flex;
    list-style: none;
    padding: 0.75rem 1rem;
    margin: 0;
    background: color-mix(in srgb, var(--surface-color) 40%, transparent);
    border-radius: 8px;
    backdrop-filter: blur(5px);
}

.breadcrumb-item {
    display: flex;
    align-items: center;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "/";
    padding: 0 0.75rem;
    color: var(--text-secondary-color);
}

.breadcrumb-item a {
    color: var(--text-secondary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.breadcrumb-item a:hover {
    color: var(--primary-color);
}

.breadcrumb-item.active {
    color: var(--text-color);
}

/* Document Header */
.docs-header {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.docs-title {
    color: var(--primary-color);
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0 0 1rem 0;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.docs-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.docs-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary-color);
    font-size: 0.9rem;
}

.docs-meta-item i {
    color: var(--accent-color);
}

.docs-description {
    color: var(--text-secondary-color);
    font-size: 1.1rem;
    line-height: 1.6;
    margin: 1rem 0 0 0;
}

/* Article Content */
.docs-article {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-color);
    scroll-behavior: smooth;
}

/* Scroll offset for anchor links */
.docs-article [id],
.content-section [id] {
    scroll-margin-top: 84px;
}

.docs-article h1,
.docs-article h2,
.docs-article h3,
.docs-article h4,
.docs-article h5,
.docs-article h6,
.content-section h1,
.content-section h2,
.content-section h3,
.content-section h4,
.content-section h5,
.content-section h6 {
    color: var(--text-color);
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-right: 0;
    font-weight: 600;
    position: relative;
    cursor: pointer;
    transition: color 0.2s ease;
}

.docs-article h2:hover,
.docs-article h3:hover,
.docs-article h4:hover,
.content-section h2:hover,
.content-section h3:hover,
.content-section h4:hover {
    color: var(--primary-color);
}

/* Header Link Button */
.header-link-button {
    position: absolute;
    right: -1.2rem;
    top: 0;
    bottom: 0;
    margin: auto 0;
    width: 1.8rem;
    height: 1.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--primary-color) 15%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid color-mix(in srgb, var(--primary-color) 25%, transparent);
    border-radius: 8px;
    color: var(--primary-color);
    font-size: 0.85rem;
    opacity: 0;
    visibility: hidden;
    transform: translateX(10px);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    z-index: 10;
}

.header-link-button:hover {
    background: linear-gradient(135deg, 
        color-mix(in srgb, var(--primary-color) 30%, transparent),
        color-mix(in srgb, var(--accent-color) 20%, transparent));
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateX(0) scale(1.05);
    box-shadow: 0 4px 16px color-mix(in srgb, var(--primary-color) 25%, transparent);
}

.header-link-button:active {
    transform: translateX(0) scale(0.95);
}

.header-link-button.copied {
    background: linear-gradient(135deg, 
        color-mix(in srgb, var(--success-color) 30%, transparent),
        color-mix(in srgb, var(--success-color) 20%, transparent));
    border-color: var(--success-color);
    color: var(--success-color);
}

.header-link-button.copied i::before {
    content: "\f00c"; /* Font Awesome check mark */
}

/* Smooth fade in animation on header hover */
.docs-article h2:hover .header-link-button,
.docs-article h3:hover .header-link-button,
.docs-article h4:hover .header-link-button,
.content-section h2:hover .header-link-button,
.content-section h3:hover .header-link-button,
.content-section h4:hover .header-link-button {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    animation: fadeSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Keyframe animations */
@keyframes fadeSlideIn {
    0% {
        opacity: 0;
        transform: translateX(15px) scale(0.8);
    }
    50% {
        transform: translateX(-2px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Header Click Animation Effects */
.header-highlight-effect {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -2px;
    height: 4px;
    pointer-events: none;
    overflow: visible;
}

.header-underline-sweep {
    position: absolute;
    height: 3px;
    background: linear-gradient(90deg, 
        transparent,
        var(--primary-color) 20%,
        var(--accent-color) 50%,
        var(--primary-color) 80%,
        transparent);
    border-radius: 2px;
    transform-origin: center;
    animation: underlineSweep 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    box-shadow: 0 0 10px color-mix(in srgb, var(--primary-color) 40%, transparent);
}

@keyframes underlineSweep {
    0% {
        width: 0;
        left: var(--click-x, 50%);
        opacity: 0;
        transform: scaleY(0);
    }
    20% {
        opacity: 1;
        transform: scaleY(1.2);
    }
    100% {
        width: 100%;
        left: 0;
        opacity: 0;
        transform: scaleY(1);
    }
}

/* Floating Particles */
.header-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-color);
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.header-particle:nth-child(odd) {
    background: var(--primary-color);
    animation-duration: 1s;
}

.header-particle:nth-child(3n) {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    animation-duration: 1.4s;
}

@keyframes particleFloat {
    0% {
        transform: translate(0, 0) scale(0);
        opacity: 1;
    }
    20% {
        transform: translate(var(--px), -10px) scale(1.5);
        opacity: 1;
    }
    100% {
        transform: translate(calc(var(--px) * 2), -40px) scale(0);
        opacity: 0;
    }
}

/* Glow Pulse Effect */
.header-glow-pulse {
    position: absolute;
    left: var(--click-x, 50%);
    top: 50%;
    width: 100px;
    height: 30px;
    background: radial-gradient(ellipse at center, 
        color-mix(in srgb, var(--primary-color) 30%, transparent),
        transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: glowPulse 0.8s ease-out forwards;
}

@keyframes glowPulse {
    0% {
        width: 20px;
        height: 20px;
        opacity: 1;
    }
    100% {
        width: 200px;
        height: 60px;
        opacity: 0;
    }
}

/* Wave Ripple for headers */
.header-wave-ripple {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: linear-gradient(90deg,
        transparent,
        var(--primary-color),
        transparent);
    transform: scaleX(0);
    transform-origin: var(--click-x, 50%) center;
    animation: waveRipple 0.6s ease-out forwards;
}

@keyframes waveRipple {
    0% {
        transform: scaleX(0) scaleY(1);
        opacity: 1;
    }
    100% {
        transform: scaleX(1) scaleY(0);
        opacity: 0;
    }
}

/* Tooltip for copy feedback */
.header-link-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-0.5rem);
    background: var(--surface-color);
    color: var(--text-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.header-link-tooltip.show {
    opacity: 1;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .header-link-button {
        opacity: 0.7;
        visibility: visible;
        transform: translateX(0);
        right: -1rem;
        width: 1.6rem;
        height: 1.6rem;
    }
    
    .docs-article h2:hover .header-link-button,
    .docs-article h3:hover .header-link-button,
    .docs-article h4:hover .header-link-button,
    .content-section h2:hover .header-link-button,
    .content-section h3:hover .header-link-button,
    .content-section h4:hover .header-link-button {
        opacity: 1;
        animation: none;
    }
}

.docs-article h1 { font-size: 2rem; }
.docs-article h2 { 
    font-size: 1.6rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.docs-article h3 { font-size: 1.3rem; }
.docs-article h4 { font-size: 1.15rem; }

.docs-article p {
    margin-bottom: 1.2rem;
}

.docs-article a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.docs-article a:hover {
    border-bottom-color: var(--accent-color);
}

.docs-article ul,
.docs-article ol {
    margin-bottom: 1.2rem;
    padding-left: 2rem;
}

.docs-article li {
    margin-bottom: 0.5rem;
}

/* Code Blocks */
.docs-article pre {
    background: var(--code-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.docs-article code {
    background: color-mix(in srgb, var(--code-color) 50%, transparent);
    color: var(--accent-color);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'JetBrains Mono', monospace;
}

.docs-article pre code {
    background: none;
    color: var(--text-color);
    padding: 0;
}

/* Tables */
.docs-article table {
    width: 100%;
    margin: 1.5rem 0;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
}

.docs-article th {
    background: color-mix(in srgb, var(--primary-color) 20%, transparent);
    color: var(--text-color);
    font-weight: 600;
    text-align: left;
    padding: 1rem;
}

.docs-article td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.docs-article tr:last-child td {
    border-bottom: none;
}

.docs-article tr:hover {
    background: color-mix(in srgb, var(--surface-color) 50%, transparent);
}

/* Blockquotes */
.docs-article blockquote {
    border-left: 4px solid var(--accent-color);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    color: var(--text-secondary-color);
    font-style: italic;
}

/* Bottom Navigation */
.docs-nav-bottom {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin: 3rem 0 2rem 0;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.docs-nav-prev,
.docs-nav-next {
    flex: 1;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    background: color-mix(in srgb, var(--surface-color) 40%, transparent);
    border: 1px solid var(--border-color);
}

.docs-nav-prev:hover,
.docs-nav-next:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    border-color: var(--primary-color);
}

.docs-nav-prev span,
.docs-nav-next span {
    display: flex;
    flex-direction: column;
}

.docs-nav-prev small,
.docs-nav-next small {
    color: var(--text-secondary-color);
    font-size: 0.8rem;
}

.docs-nav-prev strong,
.docs-nav-next strong {
    color: var(--primary-color);
    font-size: 1.1rem;
}

.docs-nav-next {
    justify-content: flex-end;
    text-align: right;
}

/* Page Table of Contents */
.docs-page-toc {
    position: sticky;
    top: 20px;
    height: fit-content;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    border-radius: 8px;
    padding: 1rem;
    background: color-mix(in srgb, var(--surface-color) 30%, transparent);
    backdrop-filter: blur(5px);
    border: 1px solid color-mix(in srgb, var(--border-color) 20%, transparent);
}

.docs-page-toc-title {
    color: var(--text-secondary-color);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 1rem 0;
}

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

.docs-page-toc-h2 {
    margin-bottom: 0.5rem;
}

.docs-page-toc-h3 {
    margin-left: 1rem;
    margin-bottom: 0.25rem;
}

.docs-page-toc-link {
    color: var(--text-secondary-color);
    text-decoration: none;
    font-size: 0.85rem;
    display: block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
}

.docs-page-toc-link:hover {
    color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 10%, transparent);
}

.docs-page-toc-link.active {
    color: var(--primary-color);
    font-weight: 600;
    border-left-color: var(--accent-color);
    background: color-mix(in srgb, var(--primary-color) 15%, transparent);
}

/* Help Section */
.docs-help {
    margin-top: 3rem;
    padding: 2rem;
    border-radius: 12px;
    background: linear-gradient(135deg, 
        color-mix(in srgb, var(--primary-color) 5%, transparent),
        color-mix(in srgb, var(--accent-color) 5%, transparent));
    border: 1px solid var(--border-color);
}

.docs-help h4 {
    color: var(--primary-color);
    margin: 0 0 0.5rem 0;
}

.docs-help p {
    color: var(--text-secondary-color);
    margin: 0 0 1rem 0;
}

.docs-help-actions {
    display: flex;
    gap: 1rem;
}

.btn-help {
    padding: 0.5rem 1rem;
    background: color-mix(in srgb, var(--primary-color) 20%, transparent);
    color: var(--primary-color);
    border-radius: 6px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.btn-help:hover {
    background: var(--primary-color);
    color: var(--background-color);
    transform: translateY(-2px);
}

/* Mobile Toggle Buttons Container */
.docs-mobile-toggles {
    display: none;
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    gap: 0.75rem;
    z-index: 1000;
}

/* Individual Toggle Buttons */
.docs-mobile-toggle {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface-color) 80%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid color-mix(in srgb, var(--primary-color) 30%, transparent);
    color: var(--primary-color);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.5rem;
}

.docs-mobile-toggle i {
    font-size: 1.2rem;
}

.docs-mobile-toggle .toggle-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.docs-mobile-toggle:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
    background: color-mix(in srgb, var(--primary-color) 20%, var(--surface-color) 80%);
}

.docs-mobile-toggle:active {
    transform: translateY(-1px);
}

.docs-mobile-toggle.active {
    background: linear-gradient(135deg, 
        color-mix(in srgb, var(--primary-color) 40%, transparent),
        color-mix(in srgb, var(--accent-color) 30%, transparent));
    color: var(--text-color);
    border-color: var(--accent-color);
}

.docs-mobile-toggle.active i {
    color: var(--accent-color);
}

/* Responsive Design */
@media (max-width: 1280px) {
    .docs-layout {
        grid-template-columns: 260px 1fr;
    }
    
    .docs-page-toc {
        position: fixed;
        top: 0;
        right: -280px;
        width: 280px;
        height: 100vh;
        max-height: 100vh;
        z-index: 999;
        border-radius: 0;
        transition: right 0.3s ease;
        padding: 2rem 1rem;
        background: color-mix(in srgb, var(--surface-color) 95%, transparent);
        display: block !important;
    }
    
    .docs-page-toc.active {
        right: 0;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    }
    
    .docs-mobile-toggles {
        display: flex;
        flex-direction: row;
    }
    
    /* Hide Nav button above 768px since sidebar is visible */
    #mobile-sidebar-toggle {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .docs-container {
        padding: 1rem 0.5rem;
    }
    
    .docs-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .docs-sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        max-height: 100vh;
        z-index: 999;
        border-radius: 0;
        transition: left 0.3s ease;
    }
    
    .docs-sidebar.active {
        left: 0;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    }
    
    /* Show Nav button below 768px */
    #mobile-sidebar-toggle {
        display: flex !important;
    }
    
    .docs-title {
        font-size: 2rem;
    }
    
    .docs-nav-bottom {
        flex-direction: column;
    }
    
    .docs-help-actions {
        flex-direction: column;
    }
}

/* Glass Panel Utility */
.glass-panel {
    background: color-mix(in srgb, var(--surface-color) 40%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid color-mix(in srgb, var(--border-color) 30%, transparent);
}

.glass-button {
    background: color-mix(in srgb, var(--surface-color) 30%, transparent);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid color-mix(in srgb, var(--border-color) 20%, transparent);
}

/* Scrollbar Styling */
.docs-sidebar::-webkit-scrollbar,
.docs-page-toc::-webkit-scrollbar {
    width: 6px;
}

.docs-sidebar::-webkit-scrollbar-track,
.docs-page-toc::-webkit-scrollbar-track {
    background: transparent;
}

.docs-sidebar::-webkit-scrollbar-thumb,
.docs-page-toc::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--primary-color) 30%, transparent);
    border-radius: 3px;
}

.docs-sidebar::-webkit-scrollbar-thumb:hover,
.docs-page-toc::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--primary-color) 50%, transparent);
}