/* ==========================================================================
   Base Variables - Light Theme
   ========================================================================== */
:root {
    /* Text Colors */
    --text-primary: #333;
    --text-secondary: #666;
    --text-tertiary: #4b5563;
    --text-muted: #6b7280;
    --text-bold: #111827;

    /* Background Colors */
    --background-primary: #fff;
    --background-secondary: #f8f9fa;
    --background-tertiary: #f9fafb;
    --hover-background: #f5f5f5;
    --active-background: #f0f7ff;
    --code-background: #f1f5f9;
    --tag-background: #f0f0f0;

    /* Border Colors */
    --border-color: #eee;
    --border-secondary: #e5e7eb;
    --divider-color: #e5e5e5;

    /* Link Colors */
    --link-color: #2563eb;
    --link-hover-color: #1d4ed8;

    /* Heading Colors */
    --heading-1: #1a1a1a;
    --heading-2: #2a2a2a;
    --heading-3: #3a3a3a;
    --heading-4: #4a4a4a;

    /* Utility Colors */
    --shadow-color: var(--shadow-color);

    /* Unreviewed Content Warning */
    --warning-background: #ffebee;
    --warning-color: #c62828;
    --warning-border: #ef9a9a;

    /*Alternate Content Toggle */
    --toggle-bg: #e4e4e7;
    --toggle-handle: #ffffff;
    --toggle-active-bg: #007bff;
    --toggle-handle-icon: #007bff;

    /*Image Sidebar */
    --image-sidebar-background: white;
    --image-sidebar-icon: #f0f0f0;
    --image-sidebar-icon-hover: #e0e0e0;
    --image-sidebar-icon-svg: #666;

    /*Image Sidebar - Figure Text */
    --figure-label: #666;
    --figure-title: #333;
    --figure-caption: #666;

    /*Image Sidebar Header*/
    --image-sidebar-header-background: #fff;
    --image-sidebar-header-border: #eee;
    --image-sidebar-close: #666;
    --image-sidebar-close-hover: #f0f0f0;
}

/* ==========================================================================
   Dark Theme Variables
   ========================================================================== */
[data-theme="dark"] {
    /* Text Colors */
    --text-primary: #e5e7eb;
    --text-secondary: #d1d5db;
    --text-tertiary: #9ca3af;
    --text-muted: #9ca3af;
    --text-bold: #f3f4f6;

    /* Background Colors */
    --background-primary: #1a1a1a;
    --background-secondary: #2a2a2a;
    --background-tertiary: #2d2d2d;
    --hover-background: #333333;
    --active-background: #2d3748;
    --code-background: #2d2d2d;
    --tag-background: #374151;

    /* Border Colors */
    --border-color: #2e2e2e;
    --border-secondary: #404040;
    --divider-color: #404040;

    /* Link Colors */
    --link-color: #3b82f6;
    --link-hover-color: #60a5fa;

    /* Heading Colors */
    --heading-1: #f3f4f6;
    --heading-2: #e5e7eb;
    --heading-3: #d1d5db;
    --heading-4: #9ca3af;

    /* Utility Colors */
    --shadow-color: var(--shadow-color);

    /* Unreviewed Content Warning */
    --warning-background: #331111;
    --warning-color: #ff9999;
    --warning-border: #662222;

    /*Alternate Content Toggle */
    --toggle-bg: #3f3f46;
    --toggle-handle: #d4d4d8;
    --toggle-active-bg: #0056b3;
    --toggle-handle-icon: #0056b3;

    /*Image Sidebar */
    --image-sidebar-background: #1a1a1a;
    --image-sidebar-icon: #333;
    --image-sidebar-icon-hover: #444;
    -image-sidebar-icon-svg: #999;

    /*Image Sidebar - Figure Text */
    --figure-label: #999;
    --figure-title: #fff;
    --figure-caption: #bbb;

    /*Image Sidebar Header*/
    --image-sidebar-header-background: #1a1a1a;
    --image-sidebar-header-border: #333;
    --image-sidebar-close: #999;
    --image-sidebar-close-hover: #333;
}

/* Dark theme specific overrides */
[data-theme="dark"] .control-button img,
[data-theme="dark"] .print-button img,
[data-theme="dark"] .text-size-button img {
    filter: invert(1);
}

/* ==========================================================================
   Fonts
   ========================================================================== */
@font-face {
    font-family: 'Jost';
    src: url('../fonts/Jost-Regular.woff2') format('woff2'),
        url('../fonts/Jost-Regular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Jost';
    src: url('fonts/Jost-Regular.woff2') format('woff2'),
        url('fonts/Jost-Regular.woff') format('woff');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
}

html,
body {
    background: var(--background-primary);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* ==========================================================================
   Layout Components
   ========================================================================== */

.site-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    /* This ensures the container takes up at least the full viewport height */
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: #fff;
    border-bottom: 1px solid #eee;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* Adds space before logo image */
}

.menu-button {
    position: static;
    margin-right: 1rem;
    z-index: 1001;
    padding: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-primary);
    transition: color 0.2s;
}

.menu-button:hover {
    color: #007bff;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: static;
    transform: none;
    font-family: Jost, Nunito, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.logo img {
    width: 32px;
    height: 32px;
    margin-right: 10px;
}

.logo a {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
}

#site-logo {
    margin-right: 20px;
    /* Adds space to the right of the logo image */
}

.nav-links {
    display: flex;
    gap: 2rem;
    margin-left: auto;
    align-items: center;
}

.nav-links a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    height: 100%;
}

.nav-links a:hover {
    color: #007bff;
}

.contribute-button {
    background-color: #007bff;
    color: white !important;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    transition: background-color 0.2s !important;
}

.contribute-button:hover {
    background-color: #0056b3;
    color: white !important;
}

/* ==========================================================================
   Main Content
   ========================================================================== */
main {
    flex: 1;
    /* This allows main content to grow and take up available space */
    margin-top: 64px;
    margin-left: 0;
    transition: margin-left 0.3s;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Centers content horizontally */
}

.center-logo {
    width: 100%;
    max-width: 300px;
    margin-top: 3rem;
    /* Adjust this value as needed */
    margin-bottom: 2rem;
    /* Adjust this value as needed */
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.main-logo {
    width: 100%;
    height: auto;
    max-width: 100%;
}

main.sidebar-open {
    margin-left: 250px;
}

/* ==========================================================================
   Search Component
   ========================================================================== */
.search-container {
    width: 100%;
    max-width: 600px;
    margin: 2rem auto;
    display: flex;
    flex-direction: column;
}

.search-bar {
    width: 100%;
    padding: 0.8rem 1rem;
    font-size: 1rem;
    border: 2px solid #eee;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

.search-bar:focus {
    border-color: #007bff;
}

.search-wrapper {
    position: relative;
    /* Move the relative positioning here */
    width: 100%;
}

.search-results {
    position: absolute;
    top: 100%;
    /* Position it right below the search bar */
    left: 0;
    width: 100%;
    max-height: 400px;
    overflow-y: auto;
    background: white;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-top: 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 1000;
    /* Ensure it appears above other content */
}

.search-result-item {
    display: block;
    color: inherit;
    text-decoration: none;
    padding: 0.8rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #eee;

}

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

.search-result-item:hover {
    background: #f5f5f5;
}

.search-result-title {
    font-weight: 500;
    color: #333;
}

.search-result-description {
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.25rem;
}

.search-result-tags {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.search-result-tag {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    background: #f0f0f0;
    border-radius: 4px;
    color: #666;
}

.search-result-tag.unreviewed {
    background: #d32f2f;
    color: #ffebee;
}

.search-result-tag.reviewed {
    background: #2e7d32;
    color: #e8f5e9;
}

.locked-item {
    opacity: 0.5;
}


/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
    position: fixed;
    left: -250px;
    top: 64px;
    width: 250px;
    height: calc(100vh - 64px);
    background: #fff;
    border-right: 1px solid #eee;
    transition: left 0.3s;
    overflow-y: auto;
    padding: 1rem 0;
}

.sidebar.open {
    left: 0;
}

.category {
    margin-bottom: 0.5rem;
    position: relative;
}

.category-header {
    padding: 0.8rem 1rem;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #333;
}

.category-header:hover {
    background: #f5f5f5;
}

.category-content {
    display: none;
    padding-left: 1rem;
}

.category-content.open {
    display: block;
}

.category-content a {
    display: block;
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: #666;
    transition: background 0.2s, color 0.2s;
}

.category-content a:hover {
    background: #f5f5f5;
    color: #007bff;
}

.category:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: -0.25rem;
    left: 1rem;
    right: 1rem;
    height: 1px;
    background: #eee;
}

.category:last-child {
    border-bottom: none;
}

.category-content.open+.category-header .chevron-icon,
.category-header:has(+ .category-content.open) .chevron-icon {
    transform: rotate(90deg);
}

.chevron-icon {
    display: flex;
    align-items: center;
    transition: transform 0.2s ease;
}

/* Locking content */
.locked-item {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.lock-icon {
    width: 14px;
    height: 14px;
    stroke: currentColor;
}

/* Ensure the lock icon maintains the same opacity as the text */
.locked-item .lock-icon {
    opacity: 1;
}

/* Optional hover effect for locked items */
.locked-item:hover {
    opacity: 0.7 !important;
}

/* ==========================================================================
   Footer
   ========================================================================== */
footer {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    background: var(--background-secondary);
    margin-top: auto;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-bottom: 1rem;
}

footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

footer a:hover {
    color: var(--link-color);
    text-decoration: underline;
}

.copyright {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ==========================================================================
   Media Queries
   ========================================================================== */

@media (max-width: 768px) {

    body:not(.sidebar-initialized) main {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* === Hide Search and Nav Bar in Header === */
    header .nav-links {
        display: none;
    }

    /* === Layout Structure === */
    header {
        flex-direction: column;
        padding: 0.5rem;
        z-index: 1002;
    }

    main {
        margin: 110px 0 0;
        padding: 1rem;
        width: 100% !important;
        max-width: 100% !important;
        margin-top: calc(var(--header-height, 50px));
    }

    /* === Header Components === */
    .header-left {
        align-items: center;
        gap: 1rem;
        width: 100%;
    }

    .logo {
        margin: 0 auto;
    }

    /* === Search and Navigation in Sidebar === */
    .sidebar-header {
        border-bottom: 1px solid var(--border-color);
    }

    /* Move nav links to sidebar */
    .sidebar .nav-links {
        flex-direction: column;
        width: 100%;
        gap: 0;
        padding: 0;
    }

    .sidebar .nav-links a {
        width: 100%;
        padding: 0.75rem 1rem;
        justify-content: flex-start;
        color: var(--text-secondary);
        font-family: inherit;
        font-size: inherit;
    }

    .sidebar .nav-links a:hover,
    .sidebar .contribute-button:hover {
        background: var(--hover-background);
        color: var(--link-hover-color) !important;
    }

    /* Adjust contribute button in sidebar */
    .sidebar .contribute-button {
        background-color: transparent;
        color: var(--link-color) !important;
        padding: 0.75rem 1rem;
        border-radius: 0;
        font-weight: normal;
        width: 100%;
        justify-content: flex-start;
    }

    /* === Sidebar === */
    .sidebar {
        position: fixed;
        top: 2rem;
        left: 0;
        width: 100%;
        height: 100vh;
        z-index: 1001;
        background: var(--background-primary);
        display: flex;
        flex-direction: column;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.open::before {
        opacity: 1;
    }

    .sidebar.open~main .page-metadata {
        display: none;
    }

    .sidebar.open+main,
    main.sidebar-open,
    .sidebar.open~main {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .sidebar-content {
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        position: relative;
        z-index: 1;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .category {
        display: flex;
        flex-direction: column;
    }

    .category-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem;
    }

    .category-content {
        display: none;
        flex-direction: column;
    }

    .category-content.open {
        display: flex;
    }

    .category-content a {
        display: flex;
        align-items: center;
        padding: 0.75rem 1rem 0.75rem 2rem;
    }

    .search-container {
        padding: 0 1rem;
    }

    .search-results {
        max-height: 300px;
    }

    .menu-button {
        position: absolute;
        /* Position absolutely within header-left */
        left: 0.5rem;
        /* Align to left with some padding */
        top: 50%;
        /* Center vertically */
        transform: translateY(-50%);
        /* Perfect vertical centering */
        margin-right: 0;
        /* Remove default margin */
    }


}

/* Hide sidebar versions of search and nav on larger screens */
@media (min-width: 769px) {
    .sidebar .nav-links {
        display: none;
    }

    /* Ensure header versions are visible */
    header .nav-links {
        display: flex;
    }
}

/* ==========================================================================
   Announcements
   ========================================================================== */

.update-notice {
    max-width: 600px;
    margin: 2rem auto;
    padding: 1.5rem;
    background: #f0f7ff;
    border-radius: 8px;
    border: 1px solid #cce5ff;
}

.update-notice h3 {
    color: #0066cc;
    margin-bottom: 0.5rem;
}

.update-notice h3 a {
    color: inherit;
    text-decoration: none;
}

.update-notice h3 a:hover {
    text-decoration: underline;
}

.update-notice p {
    color: #444;
}

.update-notice .date {
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.5rem;
}

/* ==========================================================================
   Disclaimer
   ========================================================================== */

.medical-disclaimer {
    margin-top: 20px;
    padding: 10px;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
    border-radius: 4px;
    text-align: center;
}