/* CSS Variables for Theme Management */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #334155;
    --code-bg: #f1f5f9;
    --code-text: #1e293b;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"], .dark-theme {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --accent-color: #60a5fa;
    --accent-hover: #3b82f6;
    --sidebar-bg: #020617;
    --sidebar-text: #94a3b8;
    --sidebar-active: #1e293b;
    --code-bg: #1e293b;
    --code-text: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'SF Pro Display', Roboto, sans-serif;
    line-height: 1.7;
    color: var(--text-primary);
    background: var(--bg-secondary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* App Layout */
.app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
    border-right: 1px solid var(--border-color);
    display: flex; /* Added */
    flex-direction: column; /* Added */
    justify-content: space-between; /* Added */
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 2rem 1.5rem 1.5rem;
    border-bottom: 1px solid var(--sidebar-active);
}

.logo h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: white;
}

.logo p {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 1.2rem;
}

.theme-toggle:hover {
    background: var(--sidebar-active);
    transform: scale(1.1);
}

.nav-menu {
    list-style: none;
    padding: 1rem 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
    border-radius: 0;
    position: relative;
}

.nav-link:hover {
    background: var(--sidebar-active);
    color: white;
    padding-left: 2rem;
}

.nav-link.active {
    background: var(--sidebar-active);
    color: white;
    border-right: 3px solid var(--accent-color);
    font-weight: 600;
}

.sidebar-footer {
    padding: 1.5rem;
    font-size: 0.8rem;
    text-align: center;
    color: var(--sidebar-text);
    border-top: 1px solid var(--sidebar-active); /* Optional: add a subtle separator */
    margin-top: auto; /* Pushes it to the bottom */
}

.sidebar-footer a {
    color: var(--accent-color); /* Use accent color for the link */
    text-decoration: none;
    font-weight: 500;
}

.sidebar-footer a:hover {
    text-decoration: underline;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    display: flex;
    flex-direction: column;
}

.mobile-header {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.menu-toggle:hover {
    background: var(--bg-tertiary);
}

.mobile-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.mobile-theme-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 1.2rem;
}

.mobile-theme-toggle:hover {
    background: var(--bg-tertiary);
}

.content-wrapper {
    flex: 1;
    padding: 2rem;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* Markdown Content Styling */
.markdown-content {
    background: var(--bg-primary);
    padding: 3rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.markdown-content:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* Typography */
.markdown-content h1 {
    color: var(--text-primary);
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    letter-spacing: -0.025em;
}

.markdown-content h2 {
    color: var(--text-primary);
    font-size: 1.875rem;
    font-weight: 700;
    margin: 3rem 0 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
    letter-spacing: -0.025em;
}

.markdown-content h3 {
    color: var(--text-secondary);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 2rem 0 1rem;
    letter-spacing: -0.025em;
}

.markdown-content h4 {
    color: var(--text-secondary);
    font-size: 1.25rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
}

.markdown-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 1rem;
    line-height: 1.8;
}

.markdown-content ul, .markdown-content ol {
    margin: 1.5rem 0;
    padding-left: 2rem;
}

.markdown-content li {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.7;
}

.markdown-content li::marker {
    color: var(--accent-color);
}

/* Code Styling */
.markdown-content code {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
}

.markdown-content pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 1.5rem;
    border-radius: 12px;
    overflow-x: auto;
    margin: 2rem 0;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.markdown-content pre code {
    background: none;
    padding: 0;
    border: none;
    color: inherit;
    font-size: 0.875rem;
}

/* Tables */
.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    background: var(--bg-primary);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.markdown-content th,
.markdown-content td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.markdown-content th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
}

.markdown-content td {
    color: var(--text-secondary);
}

/* Blockquotes */
.markdown-content blockquote {
    border-left: 4px solid var(--accent-color);
    padding: 1rem 1.5rem;
    margin: 2rem 0;
    background: var(--bg-tertiary);
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* Links */
.markdown-content a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    border-bottom: 1px solid transparent;
}

.markdown-content a:hover {
    color: var(--accent-hover);
    border-bottom-color: var(--accent-hover);
}

/* Interactive Elements */
.loading {
    text-align: center;
    padding: 4rem;
    color: var(--text-muted);
    font-size: 1.125rem;
}

.error {
    text-align: center;
    padding: 4rem;
    color: var(--text-muted);
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .app {
        flex-direction: column;
    }
    
    .sidebar {
        transform: translateX(-100%);
        width: 100%;
        max-width: 320px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-header {
        display: flex;
    }
    
    .content-wrapper {
        padding: 1rem;
    }
    
    .markdown-content {
        padding: 2rem 1.5rem;
    }
    
    .markdown-content h1 {
        font-size: 2rem;
    }
    
    .markdown-content h2 {
        font-size: 1.5rem;
    }
    
    .markdown-content h3 {
        font-size: 1.25rem;
    }
}

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

/* Focus States for Accessibility */
.nav-link:focus,
.theme-toggle:focus,
.menu-toggle:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Animation for Theme Transitions */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}