/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    --border-color: #cbd5e1;
    --border-hover: #94a3b8;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    
    --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #e2e8f0;
    --text-muted: #94a3b8;
    
    --border-color: #334155;
    --border-hover: #475569;
}

[data-theme="dark"] .content code {
    background-color: #334155;
    color: #f8fafc;
    border-color: #475569;
}

[data-theme="dark"] .content pre {
    background-color: #1e293b;
    border-color: #475569;
}

[data-theme="dark"] .content pre code {
    color: #f8fafc;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Container Layout */
.container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    overflow-y: auto;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

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

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.sidebar-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.nav-section {
    margin-bottom: 2rem;
}

.nav-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.nav-section ul {
    list-style: none;
}

.nav-section li {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.nav-link:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-link.active {
    background-color: var(--primary-color);
    color: white;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2rem;
    max-width: calc(100vw - 280px);
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.breadcrumb {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.content-actions {
    display: flex;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-hover);
}

/* Search Bar */
.search-bar {
    margin-bottom: 2rem;
    position: relative;
}

.search-bar.hidden {
    display: none;
}

#search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
}

#search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    max-height: 300px;
    overflow-y: auto;
    z-index: 10;
}

.search-result {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-result:hover {
    background-color: var(--bg-secondary);
}

.search-result:last-child {
    border-bottom: none;
}

.search-result-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.search-result-excerpt {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.search-result-excerpt mark {
    background-color: var(--warning-color);
    color: var(--text-primary);
    padding: 0.125rem 0.25rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

/* Content Styles */
.content {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    min-height: 600px;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Markdown Content Styles */
.content h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
    position: relative;
}

.content h1::before {
    content: '⚡';
    margin-right: 0.5rem;
    color: var(--primary-color);
}

.content h2 {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.content h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 1.5rem 0 0.75rem 0;
}

.content h4 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 1.25rem 0 0.5rem 0;
}

.content h5 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 1rem 0 0.5rem 0;
}

.content h6 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 1rem 0 0.5rem 0;
}

.content p {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.content ul, .content ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.content li {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    margin: 1.5rem 0;
    background-color: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--radius-md);
    position: relative;
    box-shadow: var(--shadow-sm);
}

.content blockquote::before {
    content: '💡';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 1.2rem;
}

.content blockquote p {
    margin-bottom: 0;
    color: var(--text-secondary);
    font-style: italic;
}

.content code {
    background-color: #f1f5f9;
    color: #1e293b;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    border: 1px solid #cbd5e1;
    font-weight: 600;
}

.content pre {
    background-color: #f8fafc;
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;
    border: 1px solid #cbd5e1;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.content pre::before {
    content: '📋';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    opacity: 0.5;
}

.content pre code {
    background: none;
    color: #d67d08;
    padding: 0;
    font-size: 0.875rem;
    font-weight: 600;
}

.content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background-color: var(--bg-primary);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.content th {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.content td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.content tr:hover {
    background-color: var(--bg-secondary);
}

.content a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.content a:hover {
    text-decoration: underline;
}

.content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: 1rem 0;
}

.content hr {
    border: none;
    height: 1px;
    background-color: var(--border-color);
    margin: 2rem 0;
}

/* Table of Contents */
.toc {
    position: fixed;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    width: 200px;
    max-height: 50vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    opacity: 0.9;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.toc:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.02);
}

.toc.hidden {
    display: none;
}

.toc h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

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

.toc li {
    margin-bottom: 0.25rem;
}

.toc a {
    display: block;
    padding: 0.25rem 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    line-height: 1.3;
}

.toc a:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.toc-level-h1 {
    font-weight: 600;
    font-size: 0.8rem;
}

.toc-level-h2 {
    font-weight: 500;
    font-size: 0.75rem;
    padding-left: 0.75rem;
}

.toc-level-h3 {
    font-weight: 400;
    font-size: 0.7rem;
    padding-left: 1.5rem;
}

.toc-level-h4 {
    font-weight: 400;
    font-size: 0.65rem;
    padding-left: 2.25rem;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 200;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.75rem;
    cursor: pointer;
    flex-direction: column;
    gap: 4px;
}

.mobile-menu-toggle span {
    width: 20px;
    height: 2px;
    background-color: white;
    transition: all 0.3s ease;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    z-index: 100;
}

.back-to-top:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
}

.back-to-top.hidden {
    opacity: 0;
    visibility: hidden;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }
.mb-6 { margin-bottom: 1.5rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; }
.mt-6 { margin-top: 1.5rem; }

/* Responsive Design */
@media (max-width: 1024px) {
    .toc {
        display: none;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        max-width: 100vw;
        padding: 1rem;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .content-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .content-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .content {
        padding: 1.5rem;
    }
    
    .content h1 {
        font-size: 2rem;
    }
    
    .content h2 {
        font-size: 1.75rem;
    }
    
    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 45px;
        height: 45px;
    }
}

@media (max-width: 480px) {
    .content {
        padding: 1rem;
    }
    
    .content h1 {
        font-size: 1.75rem;
    }
    
    .content h2 {
        font-size: 1.5rem;
    }
    
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
}
