:root {
    /* Light Theme Variables */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border-color: #e2e8f0;
    --accent-color: #2563eb;
    --accent-hover: #1d4ed8;
    --code-bg: #f1f5f9;
    --sidebar-width: 280px;
    --header-height: 60px;
}

[data-theme="dark"] {
    /* Dark Theme Variables */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --accent-color: #38bdf8;
    --accent-hover: #0ea5e9;
    --code-bg: #1e293b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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


/* Layout */

.app-container {
    display: flex;
    min-height: 100vh;
}


/* Sidebar */

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    padding: 1.5rem;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-header {
    margin-bottom: 1.5rem;
}


/* Search Bar */

.search-wrapper {
    position: relative;
    margin-bottom: 2rem;
}

#docs-search {
    width: 100%;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

#docs-search:focus {
    outline: none;
    border-color: var(--accent-color);
}

.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    margin-top: 0.5rem;
}

.search-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.search-item:hover {
    background-color: var(--bg-tertiary);
}

.search-item-title {
    font-weight: 500;
    color: var(--text-primary);
}

.search-item-tag {
    font-size: 0.7rem;
    padding: 2px 6px;
    background-color: var(--bg-primary);
    border-radius: 4px;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.nav-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
    letter-spacing: 0.05em;
}

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

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

.sidebar-nav a {
    display: block;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a:focus {
    color: var(--accent-color);
    background-color: var(--bg-tertiary);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}


/* Theme Toggle Button */

.theme-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    transition: all 0.2s;
}

.theme-btn:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--text-secondary);
}

[data-theme="dark"] .icon-sun {
    display: inline;
}

[data-theme="dark"] .icon-moon {
    display: none;
}

[data-theme="light"] .icon-sun {
    display: none;
}

[data-theme="light"] .icon-moon {
    display: inline;
}


/* Main Content */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    /* Offset for fixed sidebar */
    padding: 2rem 4rem;
    max-width: 100%;
}

.content-wrapper {
    max-width: 800px;
    margin: 0 auto;
    min-height: 80vh;
}


/* Typography */

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    letter-spacing: -1px;
    color: var(--text-primary);
}

h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-top: 3rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

p {
    margin-bottom: 1.25rem;
    color: var(--text-secondary);
    font-size: 1.05rem;
}

ul,
ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

li {
    margin-bottom: 0.5rem;
}


/* Code Blocks */

pre {
    margin: 1.5rem 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

code {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.9rem;
}

.equation-read-as {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-style: italic;
    opacity: 0.8;
    margin-top: -1rem;
    margin-bottom: 2rem;
}


/* Inline Code */

p code,
li code {
    background-color: var(--bg-tertiary);
    /* Use theme bg for inline */
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--accent-color);
}


/* Helper Classes */

.subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
}

.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: border-color 0.2s;
}

.card:hover {
    border-color: var(--accent-color);
}

.card h3 {
    margin-top: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.6rem 1.2rem;
    background-color: var(--accent-color);
    color: #fff;
    border-radius: 6px;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.2s;
}

.btn:hover {
    background-color: var(--accent-hover);
    color: #fff;
}

footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}


/* Mobile Responsiveness */

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    padding: 0 1rem;
    z-index: 1001;
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
    margin-right: 1rem;
}

.mobile-logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }
    .sidebar {
        top: 60px;
        /* Below header */
        height: calc(100vh - 60px);
        transform: translateX(-100%);
        z-index: 1000;
        width: 100%;
        /* Full width on very small screens? Or keep 280px */
        max-width: 300px;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        margin-top: 60px;
        /* Offset for header */
        padding: 1.5rem;
    }
}