/* ==========================================================================
   Tutorial & Documentation Specialized Layout Stylesheet
   GeeksforGeeks / TutorialsPoint / W3Schools Inspired UI
   ========================================================================== */

/* Sticky Reading Progress Bar */
.reading-progress-bar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    z-index: 1045;
    transition: width 0.1s linear;
}

/* Tutorial Page Structure */
.tutorial-layout-wrapper {
    display: flex;
    min-height: calc(100vh - var(--navbar-height));
    position: relative;
}

/* Left Sidebar - Curriculum / Topics Tree */
.tutorial-sidebar-left {
    width: 290px;
    flex-shrink: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    position: sticky;
    top: var(--navbar-height);
    height: calc(100vh - var(--navbar-height));
    overflow-y: auto;
    padding: 1.25rem 0.85rem 3rem;
    transition: all 0.3s ease;
    z-index: 1020;
}

.tutorial-sidebar-left::-webkit-scrollbar {
    width: 5px;
}
.tutorial-sidebar-left::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.sidebar-category-header {
    padding: 0.75rem 0.5rem 1rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 1rem;
}

.sidebar-topic-group {
    margin-bottom: 1rem;
}

.sidebar-topic-title {
    font-size: 0.78rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.5rem 0.65rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    border-radius: 6px;
    user-select: none;
}

.sidebar-topic-title:hover {
    background: var(--bg-subtle);
    color: var(--text-main);
}

.sidebar-topic-title i.chevron-icon {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.sidebar-topic-title.collapsed i.chevron-icon {
    transform: rotate(-90deg);
}

.sidebar-nav-list {
    list-style: none;
    padding: 0;
    margin: 0.25rem 0 0.5rem;
}

.sidebar-nav-item {
    margin-bottom: 2px;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    padding: 0.42rem 0.65rem;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s ease;
    position: relative;
}

.sidebar-nav-link:hover {
    color: var(--primary-color);
    background: var(--primary-light);
    transform: translateX(3px);
}

.sidebar-nav-link.active {
    color: var(--primary-color);
    background: var(--primary-light);
    font-weight: 600;
}

.sidebar-nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    background: var(--primary-color);
    border-radius: 0 4px 4px 0;
}

/* Main Tutorial Content Column */
.tutorial-main-content {
    flex-grow: 1;
    min-width: 0;
    padding: 2.25rem 3rem 4rem;
}

@media (max-width: 992px) {
    .tutorial-sidebar-left {
        position: fixed;
        left: -300px;
        top: var(--navbar-height);
        bottom: 0;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    }
    .tutorial-sidebar-left.show-mobile {
        left: 0;
    }
    .tutorial-main-content {
        padding: 1.5rem 1rem 3rem;
    }
}

/* Right Sidebar - On-Page TOC & Actions */
.tutorial-sidebar-right {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: var(--navbar-height);
    height: calc(100vh - var(--navbar-height));
    overflow-y: auto;
    padding: 2rem 1rem 2rem 1.5rem;
    border-left: 1px solid var(--border-color);
}

@media (max-width: 1200px) {
    .tutorial-sidebar-right {
        display: none;
    }
}

.toc-title {
    font-size: 0.82rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.85rem;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border-left: 2px solid var(--border-color);
}

.toc-item {
    margin-bottom: 0.5rem;
}

.toc-link {
    display: block;
    padding: 0.2rem 0 0.2rem 0.85rem;
    color: var(--text-muted);
    font-size: 0.84rem;
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
    margin-left: -2px;
}

.toc-link:hover, .toc-link.active {
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

/* Article Header & Typography */
.article-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
}

.article-title {
    font-size: 2.35rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 0.85rem;
}

.article-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.article-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Callout Boxes */
.callout {
    padding: 1.25rem 1.5rem;
    margin: 1.75rem 0;
    border-radius: var(--border-radius-base);
    border-left: 5px solid;
    background: var(--bg-surface);
    box-shadow: var(--card-shadow);
}

.callout h5 {
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.callout p {
    color: var(--text-body, #cbd5e1);
}

.callout p:last-child {
    margin-bottom: 0;
}

.callout-info {
    border-left-color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
}
.callout-info h5 { color: #60a5fa; }

.callout-tip {
    border-left-color: #10b981;
    background: rgba(16, 185, 129, 0.08);
}
.callout-tip h5 { color: #34d399; }

.callout-warning {
    border-left-color: #f59e0b;
    background: rgba(245, 158, 11, 0.08);
}
.callout-warning h5 { color: #fbbf24; }

.callout-danger {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}
.callout-danger h5 { color: #f87171; }

[data-theme="light"] .callout-info h5 { color: #2563eb; }
[data-theme="light"] .callout-tip h5 { color: #059669; }
[data-theme="light"] .callout-warning h5 { color: #d97706; }
[data-theme="light"] .callout-danger h5 { color: #dc2626; }
[data-theme="light"] .callout p { color: #334155; }

/* Tutorial Content Body Typography */
.tutorial-body {
    color: var(--text-body, #cbd5e1);
    font-size: 1.05rem;
    line-height: 1.85;
}

.tutorial-body p {
    color: var(--text-body, #cbd5e1);
    margin-bottom: 1.4rem;
}

.tutorial-body h2 {
    color: var(--text-main, #f8fafc);
    font-size: 1.75rem;
    font-weight: 800;
    margin-top: 2.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.tutorial-body h3 {
    color: var(--text-main, #f8fafc);
    font-size: 1.35rem;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 0.85rem;
}

.tutorial-body h4, 
.tutorial-body h5, 
.tutorial-body h6 {
    color: var(--text-main, #f8fafc);
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.tutorial-body ul, 
.tutorial-body ol {
    color: var(--text-body, #cbd5e1);
    margin-bottom: 1.4rem;
    padding-left: 1.5rem;
}

.tutorial-body li {
    margin-bottom: 0.5rem;
    line-height: 1.7;
}

.tutorial-body strong, 
.tutorial-body b {
    color: #ffffff;
    font-weight: 600;
}

[data-theme="light"] .tutorial-body strong,
[data-theme="light"] .tutorial-body b {
    color: #0f172a;
}

.tutorial-body blockquote {
    border-left: 4px solid var(--primary-color);
    background: var(--bg-subtle);
    padding: 1.1rem 1.5rem;
    border-radius: 0 10px 10px 0;
    color: var(--text-body, #cbd5e1);
    margin: 1.75rem 0;
    font-style: italic;
}

.tutorial-body code:not([class*="language-"]) {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    padding: 0.2rem 0.45rem;
    border-radius: 6px;
    font-family: var(--font-family-code);
    font-size: 0.88em;
}

[data-theme="light"] .tutorial-body code:not([class*="language-"]) {
    background: #f1f5f9;
    color: #2563eb;
}

[data-theme="light"] .tutorial-body {
    color: #334155;
}

[data-theme="light"] .tutorial-body p {
    color: #334155;
}

/* Sidebar Topics & Curriculum High-Contrast Links */
[data-theme="dark"] .sidebar-topic-title {
    color: #cbd5e1;
}

[data-theme="dark"] .sidebar-topic-title:hover {
    color: #ffffff;
    background: var(--bg-subtle);
}

[data-theme="dark"] .sidebar-nav-link {
    color: #94a3b8;
}

[data-theme="dark"] .sidebar-nav-link:hover {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.12);
}

[data-theme="dark"] .sidebar-nav-link.active {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.18);
    font-weight: 600;
}

/* On-Page TOC Links in Dark Mode */
[data-theme="dark"] .toc-title {
    color: #cbd5e1;
}

[data-theme="dark"] .toc-link {
    color: #94a3b8;
}

[data-theme="dark"] .toc-link:hover,
[data-theme="dark"] .toc-link.active {
    color: #60a5fa;
    border-left-color: #60a5fa;
}

/* Code Blocks & Syntax Highlighter Containers */
.code-block-container {
    background: #1e1e1e;
    border-radius: 12px;
    margin: 1.75rem 0;
    overflow: hidden;
    border: 1px solid #333333;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.code-header {
    background: #252526;
    padding: 8px 16px;
    font-size: 0.84rem;
    color: #cccccc;
    font-family: var(--font-family-code);
    border-bottom: 1px solid #333333;
}

.code-block-container pre {
    margin: 0;
    padding: 1.25rem 1.5rem;
    font-family: var(--font-family-code);
    font-size: 0.88rem;
    line-height: 1.6;
    overflow-x: auto;
    background: transparent !important;
}

.copy-code-btn {
    font-size: 0.78rem;
    padding: 3px 10px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.copy-code-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* KaTeX Formulas Container */
.katex-formula {
    padding: 1.25rem;
    margin: 1.5rem 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-base);
    overflow-x: auto;
    text-align: center;
    box-shadow: var(--card-shadow);
}

/* Tutorial Tables */
.tutorial-table {
    border-radius: var(--border-radius-base);
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
}

.tutorial-table th {
    background: var(--bg-subtle);
    color: var(--text-main);
    font-weight: 600;
}

/* Previous / Next Article Navigation */
.tutorial-pagination {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 3.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.pagination-nav-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-base);
    padding: 1rem 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    text-decoration: none !important;
    transition: all 0.2s ease;
    box-shadow: var(--card-shadow);
}

.pagination-nav-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: var(--card-shadow-hover);
}

.pagination-nav-card .nav-direction {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.pagination-nav-card .nav-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Attached Quiz Card */
.attached-quiz-card {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(139, 92, 246, 0.08));
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--border-radius-base);
    padding: 1.75rem;
    margin: 3rem 0;
    box-shadow: var(--card-shadow);
}
