/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --progress-color: rgba(0, 123, 255, 0.6);
    --progress-background: #f0f3f6;
    --header-height: 64px;
    --accent-color: #4c8bf5;
    --hover-bg: rgba(76, 139, 245, 0.05);
    --active-bg: rgba(76, 139, 245, 0.08);
    --border-color: #e9ecef;
    --sidebar-width: 360px;
}

/* Main layout */
body {
    font-family: 'Geist Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    padding-top: var(--header-height);
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

/* Top header styles */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 1000;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: #1a1a1a;
    text-decoration: none;
}

.logo svg {
    width: 32px;
    height: 32px;
}

.download-button {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-family: 'Geist Sans', sans-serif;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(76, 139, 245, 0.1);
}

.download-button:hover {
    background: #3b7de9;
    box-shadow: 0 4px 8px rgba(76, 139, 245, 0.2);
    transform: translateY(-1px);
}

/* Sidebar styles */
.sidebar {
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    position: fixed;
    left: 0;
    overflow-y: auto;
    top: var(--header-height);
    /* Hide scrollbar while maintaining functionality */
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;     /* Firefox */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.sidebar::-webkit-scrollbar {
    display: none;
}

.progress-container {
    position: sticky;
    top: 0;
    width: 100%;
    height: 2px;
    background-color: var(--progress-background);
    z-index: 1000;
}

.progress-bar {
    height: 100%;
    background-color: var(--accent-color);
    opacity: 0.7;
    width: 0%;
    transition: width 0.2s ease;
}

.sidebar-nav {
    list-style: none;
    padding: 2rem;
}

.sidebar-nav li {
    margin-bottom: 0.5rem;
    position: relative;
}

.sidebar-nav a {
    color: #566b8c;
    text-decoration: none;
    font-size: 0.875rem;
    display: block;
    padding: 0.5rem;
    transition: all 0.3s ease;
    border-radius: 6px;
    position: relative;
    margin: 2px 0;
}

/* Navigation Hierarchy Styles */
.sidebar-nav > li > a {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1a1a1a;
    padding: 0.8rem 1rem;
    border-left: 3px solid transparent;
    background: #f8f9fa;
    margin: 0.5rem 0;
    border-radius: 6px;
}

/* Style for subsections (h2) only - using data attribute or class to identify h2 sections */
.sidebar-nav > li > a[data-level="2"],
.sidebar-nav > li > a.subsection {
    font-size: 0.95rem;
    font-weight: 500;
    color: #4a5568;
    padding: 0.4rem 1rem;
    margin-left: 0.5rem;
    margin-top: 0;
    margin-bottom: 0;
    border-left-width: 2px;
}

/* Third level navigation (h3) */
.sidebar-nav > li > ul > li > a {
    font-size: 0.875rem;
    color: #718096;
    padding: 0.35rem 0.75rem;
    font-weight: 400;
    opacity: 0.9;
    letter-spacing: 0.2px;
}

.sidebar-nav > li > a:hover {
    background: var(--hover-bg);
    border-left-color: var(--accent-color);
}

.sidebar-nav > li > ul > li > a:hover {
    background: none;
    color: var(--accent-color);
}

.sidebar-nav > li > a.active {
    background: var(--active-bg);
    border-left-color: var(--accent-color);
    color: var(--accent-color);
}

.sidebar-nav > li > ul > li > a.active {
    background: none;
    color: var(--accent-color);
    font-weight: 500;
}

/* Collapsible navigation */
.sidebar-nav ul {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.2s ease-out;
    opacity: 0;
}

.sidebar-nav li.active > ul {
    max-height: 500px;
    opacity: 1;
}

.sidebar-nav li:not(.active) > a {
    opacity: 0.7;
}

.sidebar-nav li.active > a {
    opacity: 1;
}

/* Nested navigation items */
.sidebar-nav ul {
    list-style: none;
    margin-left: 1rem;
    margin-top: 0.25rem;
}

/* Updated content styles for centering */
.content-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-left: var(--sidebar-width);
}

.content {
    width: 100%;
    max-width: 800px;
    padding: 2rem;
    font-family: 'Geist Sans', sans-serif;
    color: #3c4858;
    line-height: 1.7;
}

/* Content Formatting */
.section {
    margin-bottom: 3rem;
}

h1, h2, h3 {
    margin-bottom: 1rem;
    margin-top: 2rem;
}

h1 {
    font-size: 2.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    font-weight: 800;
    color: #2c3e50;
    margin-bottom: 2rem;
}

h2 {
    font-size: 1.75rem;
    font-weight: 600;
    font-family: 'Geist Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    letter-spacing: -0.02em;
    color: #1a1a1a;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    position: relative;
}

h2::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, var(--accent-color) 0%, transparent 100%);
    opacity: 0.5;
}

h3 {
    font-size: 1.3rem;
    color: #2c3e50;
    margin-top: 2rem;
}

h4 {
    font-size: 1.1rem;
    color: #34495e;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

p {
    margin-bottom: 1rem;
    line-height: 1.7;
}

/* Lists */
ul, ol {
    margin-bottom: -0.5rem;
    padding-left: 1.5rem;
}

li {
    margin-bottom: 0.5rem;
}

/* Code blocks */
pre {
    background-color: #fafbfc;
    padding: 1rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    overflow-x: auto;
    margin-bottom: 1rem;
}

code {
    font-family: 'Fira Code', 'Consolas', monospace;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}

th, td {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
}

th {
    background-color: #fafbfc;
    font-weight: 600;
}

/* Blockquotes */
blockquote {
    border-left: 4px solid var(--accent-color);
    margin: 1rem 0;
    padding: 0.5rem 0 0.5rem 1rem;
    color: #666;
    background: #f8f9fa;
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 1rem 0;
}

/* Links */
a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #3b7de9;
    text-decoration: underline;
}

/* Definition Lists */
dl {
    margin-bottom: 1rem;
}

dt {
    font-weight: 600;
    margin-top: 0.5rem;
}

dd {
    margin-left: 1rem;
    margin-bottom: 0.5rem;
}

/* Keyboard */
kbd {
    background-color: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 0.9em;
}

/* Reduce space between collapsed level 2 sections */
.sidebar-nav > li {
    margin-bottom: 0.5rem;
    position: relative;
}

/* Special handling for items containing level 2 headings */
.sidebar-nav > li > a[data-level="2"] {
    margin-bottom: 0;
}

/* Make the list item itself have less margin when it contains a level 2 heading */
.sidebar-nav > li:has(> a[data-level="2"]) {
    margin-bottom: 0.15rem;
}

/* Media queries for mobile responsiveness */
@media screen and (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }

    body {
        padding-top: var(--header-height);
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .content-wrapper {
        margin-left: 0;
    }

    .content {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    .top-header {
        padding: 0 1rem;
    }
}