<!DOCTYPE html>
<html lang="en" class="day-mode">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>scRNA-seq Analysis Report | DeepSeek Style</title>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <style>
        :root {
            /* Day mode variables */
            --primary: #1f6912;
            --primary-light: #e8f0fe;
            --secondary: #6c757d;
            --background: #f8f9fa;
            --card: #ffffff;
            --text: #212529;
            --text-light: #5c6670;
            --border: #dee2e6;
            --success: #198754;
            --warning: #ffc107;
            --danger: #dc3545;
            --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
            --transition: all 0.3s ease;
        }

        .night-mode {
            /* Night mode variables */
            --primary: #1c9519;
            --primary-light: #1e293b;
            --secondary: #94a3b8;
            --background: #0f172a;
            --card: #1e293b;
            --text: #e2e8f0;
            --text-light: #94a3b8;
            --border: #334155;
            --success: #22c55e;
            --warning: #f59e0b;
            --danger: #ef4444;
            --shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
        }

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

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background-color: var(--background);
            color: var(--text);
            line-height: 1.6;
            font-size: 14px;
            transition: var(--transition);
            -webkit-font-smoothing: antialiased;
            display: flex;
            min-height: 100vh;
        }

        /* Sidebar */
        .sidebar {
            width: 240px;
            background: var(--card);
            border-right: 1px solid var(--border);
            padding: 20px 0;
            height: 100vh;
            position: sticky;
            top: 0;
            overflow-y: auto;
            transition: var(--transition);
            box-shadow: var(--shadow);
            z-index: 100;
        }

        .logo-container {
            padding: 0 20px 20px;
            border-bottom: 1px solid var(--border);
            margin-bottom: 20px;
        }

        .logo {
            font-size: 20px;
            font-weight: 700;
            color: var(--primary);
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .logo-icon {
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;
            overflow: hidden;
            background: var(--primary-light);
        }

        .logo-icon img {
            width: 100%;
            height: 100%;
            object-fit: contain;
            display: block;
        }

        .nav-section {
            margin-bottom: 25px;
        }

        .nav-title {
            font-size: 12px;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: var(--text-light);
            padding: 0 20px 10px;
            margin-bottom: 10px;
            border-bottom: 1px solid var(--border);
        }

        .nav-menu {
            list-style: none;
        }

        .nav-item {
            margin-bottom: 2px;
        }

        .nav-link {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 20px;
            color: var(--text);
            text-decoration: none;
            font-weight: 500;
            border-left: 3px solid transparent;
            transition: var(--transition);
        }

        .nav-link:hover, .nav-link.active {
            background: var(--primary-light);
            border-left-color: var(--primary);
            color: var(--primary);
        }

        .nav-icon {
            width: 20px;
            text-align: center;
        }

        /* Main content */
        .main-content {
            flex: 1;
            padding: 30px;
            overflow-y: auto;
        }

        .header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 25px;
        }

        .page-title {
            font-size: 22px;
            font-weight: 600;
            color: var(--text);
        }

        .header-actions {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .theme-toggle {
            background: var(--card);
            border: 1px solid var(--border);
            color: var(--text);
            padding: 8px 12px;
            border-radius: 6px;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 13px;
            font-weight: 500;
            transition: var(--transition);
        }

        .theme-toggle:hover {
            border-color: var(--primary);
            color: var(--primary);
        }

        /* Cards */
        .card {
            background: var(--card);
            border-radius: 10px;
            padding: 20px;
            box-shadow: var(--shadow);
            border: 1px solid var(--border);
            transition: var(--transition);
            margin-bottom: 20px;
        }

        .card:hover {
            box-shadow: 0 8px 15px rgba(0, 0, 0, 0.08);
        }

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

        .card-title {
            font-size: 16px;
            font-weight: 600;
            color: var(--text);
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .card-icon {
            color: var(--primary);
        }

        .card-badge {
            background: var(--primary-light);
            color: var(--primary);
            padding: 3px 8px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 500;
        }

        /* Stats */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
            gap: 15px;
            margin-bottom: 20px;
        }

        .stat-item {
            text-align: center;
            padding: 15px;
            background: var(--primary-light);
            border-radius: 8px;
        }

        .stat-value {
            font-size: 22px;
            font-weight: 700;
            color: var(--primary);
            margin-bottom: 5px;
        }

        .stat-label {
            font-size: 13px;
            color: var(--text-light);
        }

        /* Plots */
        .plot-container {
            text-align: center;
            margin-top: 15px;
        }

        .plot-img {
            max-width: 100%;
            max-height: 400px;
            border-radius: 8px;
            border: 1px solid var(--border);
        }

        /* Info boxes */
        .info-box {
            background: var(--primary-light);
            border-left: 3px solid var(--primary);
            padding: 15px;
            border-radius: 0 6px 6px 0;
            margin: 20px 0;
            font-size: 14px;
        }

        /* Progress bar */
        .progress-container {
            margin: 20px 0;
        }

        .progress-bar {
            height: 8px;
            background: rgba(31, 105, 18, 0.1);
            border-radius: 4px;
            overflow: hidden;
            margin-bottom: 8px;
        }

        .progress-fill {
            height: 100%;
            background: var(--primary);
            border-radius: 4px;
            transition: width 0.8s ease;
        }

        .progress-text {
            font-size: 13px;
            color: var(--text-light);
            display: flex;
            justify-content: space-between;
        }

        /* Tables */
        .data-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 13px;
            margin: 15px 0;
        }

        .data-table th {
            background: var(--primary-light);
            color: var(--text);
            text-align: left;
            padding: 10px 15px;
            font-weight: 600;
            border-bottom: 1px solid var(--border);
        }

        .data-table td {
            padding: 10px 15px;
            border-bottom: 1px solid var(--border);
            color: var(--text);
        }

        .data-table tr:last-child td {
            border-bottom: none;
        }

        .status-badge {
            display: inline-block;
            padding: 4px 10px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 500;
        }

        .status-success {
            background: rgba(25, 135, 84, 0.1);
            color: var(--success);
        }

        .status-warning {
            background: rgba(255, 193, 7, 0.1);
            color: var(--warning);
        }

        .status-danger {
            background: rgba(220, 53, 69, 0.1);
            color: var(--danger);
        }

        /* University Logos Section */
        .university-logos {
            margin: 40px 0 20px;
            padding: 30px 20px;
            background: var(--card);
            border-radius: 10px;
            border: 1px solid var(--border);
            box-shadow: var(--shadow);
        }

        .university-logos h3 {
            text-align: center;
            margin-bottom: 25px;
            color: var(--text);
            font-size: 18px;
            font-weight: 600;
        }

        .logos-container {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 40px;
            flex-wrap: wrap;
        }

        .university-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 12px;
            transition: var(--transition);
            padding: 15px;
            border-radius: 8px;
        }

        .university-item:hover {
            background: var(--primary-light);
            transform: translateY(-2px);
        }

        .university-logo {
            width: 80px;
            height: 80px;
            object-fit: contain;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            transition: var(--transition);
        }

        .university-logo:hover {
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
        }

        .university-logo-fallback {
            width: 80px;
            height: 80px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 40px;
            background: var(--primary-light);
            border-radius: 8px;
            border: 2px dashed var(--border);
            transition: var(--transition);
        }

        .university-logo-fallback:hover {
            background: var(--primary);
            color: white;
        }

        .university-name {
            font-size: 12px;
            color: var(--text-light);
            text-align: center;
            font-weight: 500;
            line-height: 1.3;
        }

        /* Footer */
        .footer {
            text-align: center;
            padding: 20px 0;
            color: var(--text-light);
            font-size: 13px;
            margin-top: 20px;
            border-top: 1px solid var(--border);
        }

        .footer-logos {
            margin-bottom: 20px;
        }

        .footer-logos-title {
            font-size: 12px;
            color: var(--text-light);
            margin-bottom: 15px;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .footer-logos-container {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 25px;
            flex-wrap: wrap;
        }

        .footer-logo {
            height: 60px;
            border-radius: 6px;
            /*box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);*/
            transition: var(--transition);
        }

        .footer-logo:hover {
            transform: scale(1.1);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        }

        .footer-logo-fallback {
            display: inline-flex;
            width: 40px;
            height: 40px;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            background: var(--primary-light);
            border-radius: 6px;
            border: 1px dashed var(--border);
            transition: var(--transition);
        }

        .mt-3 {
            margin-top: 1rem;
        }

        /* Animation */
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .fade-in {
            animation: fadeIn 0.4s ease-out forwards;
        }

        /* Responsive design */
        @media (max-width: 1024px) {
            .sidebar {
                width: 200px;
            }
        }

        @media (max-width: 768px) {
            body {
                flex-direction: column;
            }
            
            .sidebar {
                width: 100%;
                height: auto;
                position: static;
            }
            
            .main-content {
                padding: 20px;
            }

            .logos-container {
                gap: 20px;
            }

            .university-logo {
                width: 60px;
                height: 60px;
            }

            .university-name {
                font-size: 11px;
            }
        }

        @media (max-width: 480px) {
            .logos-container {
                flex-direction: column;
                gap: 15px;
            }
        }
    </style>
</head>
<body>
    <!-- Sidebar -->
    <div class="sidebar">
        <div class="logo-container">
            <div class="logo">
                <div class="logo-icon">
                    <img src="https://omicverse.readthedocs.io/en/latest/img/logo.png" 
                        alt="OmicVerse Logo" class="logo">
                </div>
                <span>OmicVerse Report</span>
            </div>
        </div>
        
        <div class="nav-section">
            <div class="nav-title">Analysis Sections</div>
            <ul class="nav-menu">
                <li class="nav-item"><a href="#overview" class="nav-link active"><span class="nav-icon">📊</span>Overview</a></li>
                <li class="nav-item"><a href="#quality" class="nav-link"><span class="nav-icon">🔍</span>Quality Control</a></li>
                <li class="nav-item"><a href="#expression" class="nav-link"><span class="nav-icon">🧬</span>Gene Expression</a></li>
                <li class="nav-item"><a href="#pca" class="nav-link"><span class="nav-icon">📈</span>Dimensionality</a></li>
                <li class="nav-item"><a href="#batch" class="nav-link"><span class="nav-icon">🔄</span>Batch Correction</a></li>
                <li class="nav-item"><a href="#clustering" class="nav-link"><span class="nav-icon">🎯</span>Clustering</a></li>
                <li class="nav-item"><a href="#cellcycle" class="nav-link"><span class="nav-icon">⏰</span>Cell Cycle</a></li>
                <li class="nav-item"><a href="#benchmark" class="nav-link"><span class="nav-icon">🏆</span>Benchmark</a></li>
                <li class="nav-item"><a href="#pipeline" class="nav-link"><span class="nav-icon">⚙️</span>Pipeline</a></li>
            </ul>
        </div>
        
        <div class="nav-section">
            <div class="nav-title">Report Info</div>
            <ul class="nav-menu">
                <li class="nav-item"><div class="nav-link"><span class="nav-icon">📅</span>Date: {{date}}</div></li>
                <li class="nav-item"><div class="nav-link"><span class="nav-icon">🧬</span>Species: {{species}}</div></li>
                <li class="nav-item"><div class="nav-link"><span class="nav-icon">🔬</span>Cells: {{n_cells}}</div></li>
                <li class="nav-item"><div class="nav-link"><span class="nav-icon">🧪</span>Genes: {{n_genes}}</div></li>
            </ul>
        </div>
    </div>
    
    <!-- Main Content -->
    <div class="main-content">
        <div class="header">
            <h1 class="page-title">scRNA-seq Analysis Report</h1>
            <div class="header-actions">
                <button class="theme-toggle">
                    <i>🌙</i> Dark Mode
                </button>
            </div>
        </div>
        
        <!-- Overview Section -->
        <div id="overview" class="card fade-in">
            <div class="card-header">
                <h2 class="card-title"><i class="card-icon">📊</i> Dataset Overview</h2>
                <span class="card-badge">Summary</span>
            </div>
            
            <div class="stats-grid">
                <div class="stat-item">
                    <div class="stat-value">{{n_cells}}</div>
                    <div class="stat-label">Total Cells</div>
                </div>
                
                <div class="stat-item">
                    <div class="stat-value">{{n_genes}}</div>
                    <div class="stat-label">Total Genes</div>
                </div>
                
                <div class="stat-item">
                    <div class="stat-value">{{n_hvgs}}</div>
                    <div class="stat-label">HVGs</div>
                </div>
                
                <div class="stat-item">
                    <div class="stat-value">{{median_genes}}</div>
                    <div class="stat-label">Med. Genes/Cell</div>
                </div>
                
                <div class="stat-item">
                    <div class="stat-value">{{median_umis}}</div>
                    <div class="stat-label">Med. UMIs/Cell</div>
                </div>
                
                <div class="stat-item">
                    <div class="stat-value">{{n_clusters}}</div>
                    <div class="stat-label">Clusters</div>
                </div>
            </div>
            
            <div class="info-box">
                This single-cell RNA-seq dataset contains <strong>{{n_cells}} cells</strong> and 
                <strong>{{n_genes}} genes</strong>. After quality control, <strong>{{n_hvgs}} highly variable genes</strong> 
                ({{hvg_percentage}}% of total) were used for downstream analysis.
            </div>
            
            <div class="progress-container">
                <div class="progress-bar">
                    <div class="progress-fill" style="width: {{progress_percentage}}%"></div>
                </div>
                <div class="progress-text">
                    <span>Analysis Progress</span>
                    <span>{{completed_steps}}/{{total_steps}} Steps</span>
                </div>
            </div>
        </div>

        <!-- Quality Control Section -->
        {{qc_section}}

        <!-- Gene Expression Section -->
        {{expression_section}}

        <!-- PCA Section -->
        {{pca_section}}

        <!-- Batch Correction Section -->
        {{batch_section}}

        <!-- Clustering Section -->
        {{clustering_section}}

        <!-- Cell Cycle Section -->
        {{cellcycle_section}}

        <!-- Benchmark Section -->
        {{benchmark_section}}

        <!-- Pipeline Section -->
        <div id="pipeline" class="card fade-in">
            <div class="card-header">
                <h2 class="card-title"><i class="card-icon">⚙️</i> Analysis Pipeline</h2>
                <span class="card-badge">Status</span>
            </div>
            
            <div class="mt-3">
                <table class="data-table">
                    <thead>
                        <tr>
                            <th>Step</th>
                            <th>Status</th>
                            <th>Parameters</th>
                        </tr>
                    </thead>
                    <tbody>
                        {{pipeline_steps}}
                    </tbody>
                </table>
            </div>
        </div>
        
        
        <div class="footer">
            <!-- Institutional Collaborations -->
            <div class="footer-logos">
                <div class="footer-logos-title">Institutional Collaborations</div>
                <div class="footer-logos-container">
                    {{university_logos_html}}
                </div>
            </div>
            <p>Generated by OmicVerse with Primordecode Team • {{timestamp}}</p>
        </div>
    </div>
    
    <script>
        // Convert hex to RGB
        function hexToRgb(hex) {
            var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
            return result ? {
                r: parseInt(result[1], 16),
                g: parseInt(result[2], 16),
                b: parseInt(result[3], 16)
            } : null;
        }

        // Theme management
        document.addEventListener('DOMContentLoaded', function() {
            // Theme toggle functionality
            const themeToggleBtn = document.querySelector('.theme-toggle');
            if (themeToggleBtn) {
                // Set initial theme based on system preference
                const prefersDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
                const savedTheme = localStorage.getItem('theme');
                const initialTheme = savedTheme || (prefersDarkMode ? 'night' : 'day');
                
                if (initialTheme === 'night') {
                    document.documentElement.classList.add('night-mode');
                    themeToggleBtn.innerHTML = '<i>☀️</i> Light Mode';
                } else {
                    themeToggleBtn.innerHTML = '<i>🌙</i> Dark Mode';
                }
                
                themeToggleBtn.addEventListener('click', function() {
                    const isNightMode = document.documentElement.classList.toggle('night-mode');
                    localStorage.setItem('theme', isNightMode ? 'night' : 'day');
                    themeToggleBtn.innerHTML = isNightMode ? '<i>☀️</i> Light Mode' : '<i>🌙</i> Dark Mode';
                    
                    // Switch plot images
                    document.querySelectorAll('.plot-img.day-mode').forEach(img => {
                        img.style.display = isNightMode ? 'none' : 'block';
                    });
                    document.querySelectorAll('.plot-img.night-mode').forEach(img => {
                        img.style.display = isNightMode ? 'block' : 'none';
                    });
                });
            }
            
            // Navigation functionality
            const navLinks = document.querySelectorAll('.nav-link');
            navLinks.forEach(link => {
                link.addEventListener('click', function(e) {
                    e.preventDefault();
                    const targetId = this.getAttribute('href').substring(1);
                    const targetElement = document.getElementById(targetId);
                    if (targetElement) {
                        targetElement.scrollIntoView({ 
                            behavior: 'smooth',
                            block: 'start'
                        });
                        
                        // Update active link
                        navLinks.forEach(l => l.classList.remove('active'));
                        this.classList.add('active');
                    }
                });
            });
            
            // Apply fade-in animations
            document.querySelectorAll('.card, .university-logos').forEach((el, index) => {
                el.style.animationDelay = `${index * 0.1}s`;
                el.classList.add('fade-in');
            });
        });
    </script>
</body>
</html> 