{% extends "base.html" %}

{% block title %}About - Stegasoo{% endblock %}

{% block content %}
<div class="row justify-content-center">
    <div class="col-lg-10">
        <div class="card mb-4">
            <div class="card-header">
                <h5 class="mb-0"><i class="bi bi-info-circle me-2"></i>About Stegasoo</h5>
            </div>
            <div class="card-body">
                <p class="lead">
                    Stegasoo is a steganography tool that hides encrypted messages and files 
                    inside ordinary images using multi-factor authentication.
                </p>
                
                <h6 class="text-primary mt-4 mb-3">Features</h6>
                <div class="row">
                    <div class="col-md-6">
                        <ul class="list-unstyled">
                            <li class="mb-2">
                                <i class="bi bi-check-circle text-success me-2"></i>
                                <strong>Text &amp; File Embedding</strong>
                                <br><small class="text-muted">Hide messages or any file type (PDF, ZIP, documents)</small>
                            </li>
                            <li class="mb-2">
                                <i class="bi bi-check-circle text-success me-2"></i>
                                <strong>Multi-Factor Security</strong>
                                <br><small class="text-muted">Combines photo + passphrase + PIN/RSA key</small>
                            </li>
                            <li class="mb-2">
                                <i class="bi bi-check-circle text-success me-2"></i>
                                <strong>AES-256-GCM Encryption</strong>
                                <br><small class="text-muted">Authenticated encryption with integrity verification</small>
                            </li>
                            <li class="mb-2">
                                <i class="bi bi-check-circle text-success me-2"></i>
                                <strong>LSB &amp; DCT Modes</strong>
                                <br><small class="text-muted">Choose capacity (LSB) or JPEG resilience (DCT)</small>
                            </li>
                        </ul>
                    </div>
                    <div class="col-md-6">
                        <ul class="list-unstyled">
                            <li class="mb-2">
                                <i class="bi bi-check-circle text-success me-2"></i>
                                <strong>Random Pixel Embedding</strong>
                                <br><small class="text-muted">Key-derived selection defeats statistical analysis</small>
                            </li>
                            <li class="mb-2">
                                <i class="bi bi-check-circle text-success me-2"></i>
                                <strong>Large Image Support</strong>
                                <br><small class="text-muted">Up to {{ max_payload_kb }} KB payload, tested with 14MB+ images</small>
                            </li>
                            <li class="mb-2">
                                <i class="bi bi-check-circle text-success me-2"></i>
                                <strong>Zero Server Storage</strong>
                                <br><small class="text-muted">Nothing saved, files auto-expire</small>
                            </li>
                            <li class="mb-2">
                                <i class="bi bi-check-circle text-success me-2"></i>
                                <strong>QR Code Keys</strong>
                                <br><small class="text-muted">Import/export RSA keys via QR codes</small>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- Embedding Modes -->
        <div class="card mb-4">
            <div class="card-header">
                <h5 class="mb-0"><i class="bi bi-cpu me-2"></i>Embedding Modes</h5>
            </div>
            <div class="card-body">
                <p>
                    Stegasoo supports two embedding modes, each optimized for different use cases.
                </p>
                
                <div class="row mt-4">
                    <!-- LSB Mode -->
                    <div class="col-md-6 mb-4">
                        <div class="card bg-dark h-100">
                            <div class="card-header">
                                <i class="bi bi-grid-3x3-gap text-primary me-2"></i>
                                <strong>LSB Mode</strong>
                                <span class="badge bg-success ms-2">Default</span>
                            </div>
                            <div class="card-body">
                                <p class="small">
                                    <strong>LSB (Least Significant Bit)</strong> embeds data in the lowest bit 
                                    of each color channel. Changing the LSB changes pixel values by at most 1, 
                                    which is imperceptible to the human eye.
                                </p>
                                <ul class="small mb-0">
                                    <li><strong>Capacity:</strong> ~375 KB per megapixel</li>
                                    <li><strong>Output:</strong> PNG (lossless)</li>
                                    <li><strong>Color:</strong> Full color preserved</li>
                                    <li><strong>Speed:</strong> Fast (~0.5s)</li>
                                </ul>
                                <hr>
                                <div class="small">
                                    <i class="bi bi-check-circle text-success me-1"></i> Email attachments<br>
                                    <i class="bi bi-check-circle text-success me-1"></i> Cloud storage (Dropbox, Drive)<br>
                                    <i class="bi bi-check-circle text-success me-1"></i> Direct file transfer<br>
                                    <i class="bi bi-x-circle text-danger me-1"></i> Social media (recompresses)
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- DCT Mode -->
                    <div class="col-md-6 mb-4">
                        <div class="card bg-dark h-100">
                            <div class="card-header">
                                <i class="bi bi-soundwave text-warning me-2"></i>
                                <strong>DCT Mode</strong>
                            </div>
                            <div class="card-body">
                                <p class="small">
                                    <strong>DCT (Discrete Cosine Transform)</strong> embeds data in frequency 
                                    coefficients rather than raw pixels. This survives JPEG recompression 
                                    because coefficients are preserved during re-encoding.
                                </p>
                                <ul class="small mb-0">
                                    <li><strong>Capacity:</strong> ~75 KB per megapixel</li>
                                    <li><strong>Output:</strong> JPEG or PNG</li>
                                    <li><strong>Color:</strong> Color or grayscale</li>
                                    <li><strong>Speed:</strong> Slower (~2s)</li>
                                </ul>
                                <hr>
                                <div class="small">
                                    <i class="bi bi-check-circle text-success me-1"></i> Instagram, Facebook<br>
                                    <i class="bi bi-check-circle text-success me-1"></i> WhatsApp, Signal, Telegram<br>
                                    <i class="bi bi-check-circle text-success me-1"></i> Twitter/X<br>
                                    <i class="bi bi-check-circle text-success me-1"></i> Any platform that recompresses
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Mode Comparison Table -->
                <h6 class="mt-3"><i class="bi bi-table me-2"></i>Comparison</h6>
                <div class="table-responsive">
                    <table class="table table-dark table-sm small">
                        <thead>
                            <tr>
                                <th>Aspect</th>
                                <th>LSB Mode</th>
                                <th>DCT Mode</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td>Capacity (1080p)</td>
                                <td class="text-success">~770 KB</td>
                                <td class="text-warning">~50 KB</td>
                            </tr>
                            <tr>
                                <td>Survives JPEG</td>
                                <td class="text-danger">❌ No</td>
                                <td class="text-success">✅ Yes</td>
                            </tr>
                            <tr>
                                <td>Social Media</td>
                                <td class="text-danger">❌ Broken</td>
                                <td class="text-success">✅ Works</td>
                            </tr>
                            <tr>
                                <td>Detection Resistance</td>
                                <td>Moderate</td>
                                <td>Better</td>
                            </tr>
                            <tr>
                                <td>Dependencies</td>
                                <td>Pillow, NumPy</td>
                                <td>+ scipy, jpegio</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                
                <div class="alert alert-info small mt-3 mb-0">
                    <i class="bi bi-lightbulb me-2"></i>
                    <strong>Auto-Detection:</strong> When decoding, Stegasoo automatically detects whether 
                    LSB or DCT mode was used. You don't need to specify the mode during decoding.
                </div>
            </div>
        </div>
        
        <div class="card mb-4">
            <div class="card-header">
                <h5 class="mb-0"><i class="bi bi-shield-lock me-2"></i>How Security Works</h5>
            </div>
            <div class="card-body">
                <p>Stegasoo uses <strong>multi-factor authentication</strong> to derive encryption keys:</p>
                
                <div class="row text-center my-4">
                    <div class="col-md-3 mb-3">
                        <div class="p-3 bg-dark rounded">
                            <i class="bi bi-image text-info fs-2 d-block mb-2"></i>
                            <strong>Reference Photo</strong>
                            <div class="small text-muted mt-1">Something you have</div>
                            <div class="small text-success">~80-256 bits</div>
                        </div>
                    </div>
                    <div class="col-md-3 mb-3">
                        <div class="p-3 bg-dark rounded">
                            <i class="bi bi-chat-quote text-warning fs-2 d-block mb-2"></i>
                            <strong>Passphrase</strong>
                            <div class="small text-muted mt-1">Something you know</div>
                            <div class="small text-success">~44 bits (4 words)</div>
                        </div>
                    </div>
                    <div class="col-md-3 mb-3">
                        <div class="p-3 bg-dark rounded">
                            <i class="bi bi-123 text-danger fs-2 d-block mb-2"></i>
                            <strong>Static PIN</strong>
                            <div class="small text-muted mt-1">Something you know</div>
                            <div class="small text-success">~20 bits (6 digits)</div>
                        </div>
                    </div>
                    <div class="col-md-3 mb-3">
                        <div class="p-3 bg-dark rounded">
                            <i class="bi bi-key text-primary fs-2 d-block mb-2"></i>
                            <strong>RSA Key</strong>
                            <div class="small text-muted mt-1">Something you have (optional)</div>
                            <div class="small text-success">~128 bits</div>
                        </div>
                    </div>
                </div>
                
                <div class="alert alert-secondary">
                    <i class="bi bi-calculator me-2"></i>
                    <strong>Combined entropy:</strong> 144-424+ bits depending on configuration.
                    For reference, 128 bits is considered computationally infeasible to brute force.
                </div>
                
                <h6 class="mt-4">Key Derivation</h6>
                <p>
                    {% if has_argon2 %}
                    <span class="badge bg-success me-1"><i class="bi bi-check"></i> Argon2id</span>
                    Using <strong>Argon2id</strong> with 256MB memory cost — memory-hard KDF that 
                    makes GPU/ASIC attacks infeasible.
                    {% else %}
                    <span class="badge bg-warning text-dark me-1"><i class="bi bi-exclamation-triangle"></i> Argon2 Not Available</span>
                    Falling back to <strong>PBKDF2-SHA512</strong> with 600,000 iterations.
                    Install <code>argon2-cffi</code> for stronger security.
                    {% endif %}
                </p>
            </div>
        </div>
        
        <!-- Version History -->
        <div class="card mb-4">
            <div class="card-header">
                <h5 class="mb-0"><i class="bi bi-clock-history me-2"></i>Version History</h5>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="table table-dark table-sm small">
                        <thead>
                            <tr>
                                <th>Version</th>
                                <th>Changes</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td><strong>4.0.0</strong></td>
                                <td>
                                    Simplified auth (no date dependency), passphrase replaces day_phrase, 
                                    4-word default, JPEG normalization fix, large image support (14MB+ tested),
                                    subprocess isolation for stability, Python 3.10-3.12 required
                                </td>
                            </tr>
                            <tr>
                                <td>3.2.0</td>
                                <td>Single passphrase (removed day-of-week rotation), increased default words</td>
                            </tr>
                            <tr>
                                <td>3.0.0</td>
                                <td>DCT steganography mode, JPEG output, color preservation option</td>
                            </tr>
                            <tr>
                                <td>2.2.0</td>
                                <td>QR code RSA key import/export</td>
                            </tr>
                            <tr>
                                <td>2.1.0</td>
                                <td>File embedding, compression support</td>
                            </tr>
                            <tr>
                                <td>2.0.0</td>
                                <td>Web UI, REST API, RSA key support</td>
                            </tr>
                            <tr>
                                <td>1.0.0</td>
                                <td>Initial release, CLI only, LSB mode</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                
                <div class="alert alert-warning small mt-3 mb-0">
                    <i class="bi bi-exclamation-triangle me-2"></i>
                    <strong>Compatibility:</strong> v4.0 cannot decode messages from v3.1 or earlier (different format).
                    Messages encoded with v3.2 should decode correctly.
                </div>
            </div>
        </div>
        
        <div class="card mb-4">
            <div class="card-header">
                <h5 class="mb-0"><i class="bi bi-question-circle me-2"></i>Usage Guide</h5>
            </div>
            <div class="card-body">
                <div class="accordion" id="usageAccordion">
                    <div class="accordion-item bg-dark">
                        <h2 class="accordion-header">
                            <button class="accordion-button bg-dark text-light" type="button" 
                                    data-bs-toggle="collapse" data-bs-target="#setup">
                                <i class="bi bi-1-circle me-2"></i>Initial Setup
                            </button>
                        </h2>
                        <div id="setup" class="accordion-collapse collapse show" data-bs-parent="#usageAccordion">
                            <div class="accordion-body">
                                <ol>
                                    <li>Both parties agree on a <strong>reference photo</strong> (shared secretly, never transmitted)</li>
                                    <li>Go to <a href="/generate">Generate</a> and create credentials</li>
                                    <li><strong>Memorize</strong> the passphrase and PIN</li>
                                    <li>If using RSA, download and securely store the key file</li>
                                    <li>Share credentials with your contact through a secure channel</li>
                                </ol>
                            </div>
                        </div>
                    </div>
                    
                    <div class="accordion-item bg-dark">
                        <h2 class="accordion-header">
                            <button class="accordion-button collapsed bg-dark text-light" type="button" 
                                    data-bs-toggle="collapse" data-bs-target="#encoding">
                                <i class="bi bi-2-circle me-2"></i>Encoding a Message
                            </button>
                        </h2>
                        <div id="encoding" class="accordion-collapse collapse" data-bs-parent="#usageAccordion">
                            <div class="accordion-body">
                                <ol>
                                    <li>Go to <a href="/encode">Encode</a></li>
                                    <li>Choose your <strong>embedding mode</strong>:
                                        <ul>
                                            <li><strong>LSB</strong> – for email, cloud storage, direct transfer</li>
                                            <li><strong>DCT</strong> – for social media (Instagram, WhatsApp, etc.)</li>
                                        </ul>
                                    </li>
                                    <li>Upload your <strong>reference photo</strong> and <strong>carrier image</strong></li>
                                    <li>Enter your message or select a file to embed</li>
                                    <li>Enter your <strong>passphrase</strong> and PIN/key</li>
                                    <li>Download the resulting stego image</li>
                                    <li>Send through any channel!</li>
                                </ol>
                            </div>
                        </div>
                    </div>
                    
                    <div class="accordion-item bg-dark">
                        <h2 class="accordion-header">
                            <button class="accordion-button collapsed bg-dark text-light" type="button" 
                                    data-bs-toggle="collapse" data-bs-target="#decoding">
                                <i class="bi bi-3-circle me-2"></i>Decoding a Message
                            </button>
                        </h2>
                        <div id="decoding" class="accordion-collapse collapse" data-bs-parent="#usageAccordion">
                            <div class="accordion-body">
                                <ol>
                                    <li>Go to <a href="/decode">Decode</a></li>
                                    <li>Upload your <strong>reference photo</strong> (same one used for encoding)</li>
                                    <li>Upload the <strong>stego image</strong> you received</li>
                                    <li>Enter your <strong>passphrase</strong></li>
                                    <li>Enter your PIN and/or RSA key</li>
                                    <li>View the decoded message or download the extracted file</li>
                                </ol>
                                <div class="alert alert-info small mt-3 mb-0">
                                    <i class="bi bi-magic me-2"></i>
                                    <strong>Auto-detection:</strong> Stegasoo automatically detects LSB vs DCT mode.
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="card mb-4">
            <div class="card-header">
                <h5 class="mb-0"><i class="bi bi-speedometer2 me-2"></i>Limits &amp; Specifications</h5>
            </div>
            <div class="card-body">
                <table class="table table-dark table-striped small">
                    <tbody>
                        <tr>
                            <td><i class="bi bi-file-text me-2"></i>Max text message</td>
                            <td><strong>2 million characters</strong></td>
                        </tr>
                        <tr>
                            <td><i class="bi bi-file-earmark me-2"></i>Max file payload</td>
                            <td><strong>{{ max_payload_kb }} KB</strong></td>
                        </tr>
                        <tr>
                            <td><i class="bi bi-image me-2"></i>Max carrier image</td>
                            <td><strong>24 megapixels</strong> (~6000×4000)</td>
                        </tr>
                        <tr>
                            <td><i class="bi bi-grid-3x3 me-2"></i>LSB capacity</td>
                            <td><strong>~375 KB/megapixel</strong></td>
                        </tr>
                        <tr>
                            <td><i class="bi bi-soundwave me-2"></i>DCT capacity</td>
                            <td><strong>~75 KB/megapixel</strong></td>
                        </tr>
                        <tr>
                            <td><i class="bi bi-upload me-2"></i>Max upload size</td>
                            <td><strong>30 MB</strong></td>
                        </tr>
                        <tr>
                            <td><i class="bi bi-clock me-2"></i>Temp file expiry</td>
                            <td><strong>5 minutes</strong></td>
                        </tr>
                        <tr>
                            <td><i class="bi bi-key me-2"></i>PIN length</td>
                            <td><strong>6-9 digits</strong></td>
                        </tr>
                        <tr>
                            <td><i class="bi bi-shield me-2"></i>RSA key sizes</td>
                            <td><strong>2048, 3072, 4096 bits</strong></td>
                        </tr>
                        <tr>
                            <td><i class="bi bi-chat-quote me-2"></i>Passphrase length</td>
                            <td><strong>3-12 words</strong> (BIP-39, recommended: 4+ words)</td>
                        </tr>
                        <tr>
                            <td><i class="bi bi-code me-2"></i>Python version</td>
                            <td><strong>3.10-3.12</strong> (3.13 not supported)</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        
        <div class="text-center mt-4 text-muted small">
            <p>
                Stegasoo v{{ version }} &bull; 
                <i class="bi bi-github me-1"></i>Open Source &bull;
                Built with Python, Flask, and cryptography
            </p>
        </div>
    </div>
</div>
{% endblock %}
