<aside class="ldr-sidebar" aria-label="Site navigation sidebar">
    <div class="ldr-sidebar-header">
        <h2 id="logo-link" style="cursor: pointer;"><i aria-hidden="true" class="fas fa-atom"></i> Deep Research</h2>
    </div>
    <nav class="ldr-sidebar-nav" aria-label="Primary">
        <!-- Research Section -->
        <div class="ldr-sidebar-section" role="group" aria-labelledby="sidebar-research-label">
            <div class="ldr-sidebar-section-label" id="sidebar-research-label" role="heading" aria-level="2">Research</div>
            <ul>
                <li {% if active_page == 'new-research' %}class="active"{% endif %} data-page="new-research">
                    <a href="/" title="New Research (Ctrl+Shift+1)" aria-label="New Research">
                        <i aria-hidden="true" class="fas fa-search"></i>
                        <span class="ldr-nav-text">New Research</span>
                    </a>
                </li>
                <li {% if active_page == 'chat' %}class="active"{% endif %} data-page="chat">
                    <a href="{{ url_for('chat.chat_page') }}" title="Chat Research" aria-label="Chat Research">
                        <i aria-hidden="true" class="fas fa-comments"></i>
                        <span class="ldr-nav-text">Chat</span>
                    </a>
                </li>
                <li {% if active_page == 'history' %}class="active"{% endif %} data-page="history">
                    <a href="{{ url_for('history.history_page') }}" title="History (Ctrl+Shift+2)" aria-label="History">
                        <i aria-hidden="true" class="fas fa-history"></i>
                        <span class="ldr-nav-text">History</span>
                    </a>
                </li>
            </ul>
        </div>

        <!-- Knowledge Base Section -->
        <div class="ldr-sidebar-section" role="group" aria-labelledby="sidebar-kb-label">
            <div class="ldr-sidebar-section-label" id="sidebar-kb-label" role="heading" aria-level="2">Knowledge Base</div>
            <ul>
                <li {% if active_page == 'library' %}class="active"{% endif %} data-page="library">
                    <a href="{{ url_for('library.library_page') }}" title="Library" aria-label="Library">
                        <i aria-hidden="true" class="fas fa-book"></i>
                        <span class="ldr-nav-text">Library</span>
                    </a>
                </li>
                <li {% if active_page == 'collections' %}class="active ldr-sidebar-item--nested"{% else %}class="ldr-sidebar-item--nested"{% endif %} data-page="collections">
                    <a href="{{ url_for('rag.collections_page') }}" title="Collections" aria-label="Collections">
                        <i aria-hidden="true" class="fas fa-folder-open"></i>
                        <span class="ldr-nav-text">Collections</span>
                    </a>
                </li>
                <li {% if active_page == 'download-manager' %}class="active ldr-sidebar-item--nested"{% else %}class="ldr-sidebar-item--nested"{% endif %} data-page="download-manager">
                    <a href="{{ url_for('library.download_manager_page') }}" title="Download Manager" aria-label="Downloads">
                        <i aria-hidden="true" class="fas fa-download"></i>
                        <span class="ldr-nav-text">Downloads</span>
                    </a>
                </li>
            </ul>
        </div>

        <!-- News Section -->
        <div class="ldr-sidebar-section" role="group" aria-labelledby="sidebar-news-label">
            <div class="ldr-sidebar-section-label" id="sidebar-news-label" role="heading" aria-level="2">News</div>
            <ul>
                <li {% if active_page == 'news' %}class="active"{% endif %} data-page="news">
                    <a href="{{ url_for('news.news_page') }}" title="News" aria-label="News">
                        <i aria-hidden="true" class="fas fa-newspaper"></i>
                        <span class="ldr-nav-text">News</span>
                    </a>
                </li>
                <li {% if active_page == 'subscriptions' %}class="active"{% endif %} data-page="subscriptions">
                    <a href="{{ url_for('news.subscriptions_page') }}" title="Subscriptions" aria-label="Subscriptions">
                        <i aria-hidden="true" class="fas fa-bell"></i>
                        <span class="ldr-nav-text">Subscriptions</span>
                    </a>
                </li>
            </ul>
        </div>

        <!-- Analytics Section -->
        <div class="ldr-sidebar-section" role="group" aria-labelledby="sidebar-analytics-label">
            <div class="ldr-sidebar-section-label" id="sidebar-analytics-label" role="heading" aria-level="2">Analytics</div>
            <ul>
                <li {% if active_page == 'metrics' %}class="active"{% endif %} data-page="metrics">
                    <a href="{{ url_for('metrics.metrics_dashboard') }}" title="Metrics (Ctrl+Shift+3)" aria-label="Metrics">
                        <i aria-hidden="true" class="fas fa-chart-bar"></i>
                        <span class="ldr-nav-text">Metrics</span>
                    </a>
                </li>
                <li {% if active_page == 'benchmark' %}class="active"{% endif %} data-page="benchmark">
                    <a href="{{ url_for('benchmark.index') }}" title="Benchmark" aria-label="Benchmark">
                        <i aria-hidden="true" class="fas fa-tachometer-alt"></i>
                        <span class="ldr-nav-text">Benchmark</span>
                    </a>
                </li>
                <li {% if active_page == 'benchmark-results' %}class="active ldr-sidebar-item--nested"{% else %}class="ldr-sidebar-item--nested"{% endif %} data-page="benchmark-results">
                    <a href="{{ url_for('benchmark.results') }}" title="Benchmark Results" aria-label="Results">
                        <i aria-hidden="true" class="fas fa-chart-line"></i>
                        <span class="ldr-nav-text">Results</span>
                    </a>
                </li>
                {# KNOWN-DEFERRED: add aria-label="Journals" to match the
                   pattern used by other nav items in this file (see line 86).
                   Accessibility-only, non-blocking. Tracked as post-merge. #}
                <li {% if active_page == 'journal-quality' %}class="active"{% endif %} data-page="journal-quality">
                    <a href="{{ url_for('metrics.journal_quality') }}" title="Journal Quality">
                        <i class="fas fa-graduation-cap" aria-hidden="true"></i>
                        <span class="ldr-nav-text">Journals</span>
                    </a>
                </li>
            </ul>
        </div>

        <!-- Settings Section -->
        <div class="ldr-sidebar-section" role="group" aria-labelledby="sidebar-settings-label">
            <div class="ldr-sidebar-section-label" id="sidebar-settings-label" role="heading" aria-level="2">Settings</div>
            <ul>
                <li {% if active_page == 'embedding-settings' %}class="active"{% endif %} data-page="embedding-settings">
                    <a href="{{ url_for('rag.embedding_settings_page') }}" title="Embedding Settings" aria-label="Embeddings">
                        <i aria-hidden="true" class="fas fa-brain"></i>
                        <span class="ldr-nav-text">Embeddings</span>
                    </a>
                </li>
                <li {% if active_page == 'settings' %}class="active"{% endif %} data-page="settings">
                    <a href="{{ url_for('settings.settings_page') }}" title="Settings (Ctrl+Shift+4)" aria-label="Configuration">
                        <i aria-hidden="true" class="fas fa-cog"></i>
                        <span class="ldr-nav-text">Configuration</span>
                    </a>
                </li>
            </ul>
        </div>
    </nav>
    <div class="ldr-sidebar-footer">
        <p>
            <a href="https://github.com/LearningCircuit/local-deep-research/releases/tag/v{{ version }}"
               target="_blank"
               rel="noopener noreferrer"
               class="ldr-sidebar-version-link"
               title="View release notes for v{{ version }}"
               aria-label="View release notes for version {{ version }}">{{ version }}</a>
        </p>
        <div class="ldr-sidebar-links">
            <a href="https://github.com/LearningCircuit/local-deep-research/issues" target="_blank" rel="noopener noreferrer" title="Report an issue" aria-label="Report an issue">
                <i aria-hidden="true" class="fas fa-bug" ></i>
            </a>
            <a href="https://discord.gg/ttcqQeFcJ3" target="_blank" rel="noopener noreferrer" title="Join Discord" aria-label="Join Discord">
                <i aria-hidden="true" class="fab fa-discord" ></i>
            </a>
            <a href="https://www.reddit.com/r/LocalDeepResearch/" target="_blank" rel="noopener noreferrer" title="Reddit community" aria-label="Reddit community">
                <i aria-hidden="true" class="fab fa-reddit" ></i>
            </a>
        </div>
    </div>
</aside>
