<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Levify - Algorithm Transformation - MHA Flow</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
    <!-- Navigation -->
    <nav class="navbar navbar-dark bg-dark sticky-top">
        <div class="container-fluid">
            <span class="navbar-brand mb-0 h1">
                <i class="fas fa-brain"></i> MHA Flow
            </span>
            <ul class="nav navbar-nav ms-auto">
                <li class="nav-item"><a class="nav-link" href="/">Home</a></li>
                <li class="nav-item"><a class="nav-link" href="/dashboard">Dashboard</a></li>
                <li class="nav-item"><a class="nav-link" href="/dataset-upload">Upload Data</a></li>
                <li class="nav-item"><a class="nav-link" href="/levify">Levify</a></li>
                <li class="nav-item"><a class="nav-link" href="/results">Results</a></li>
            </ul>
        </div>
    </nav>

    <div class="container py-5">
        <div class="row">
            <div class="col-lg-10 mx-auto">
                <h1 class="mb-4"><i class="fas fa-magic"></i> Levify - Algorithm Transformation</h1>

                <!-- Levify Explanation -->
                <div class="alert alert-info mb-4">
                    <h6>What is Levify?</h6>
                    <p class="mb-0">
                        Levify is our revolutionary technology that transforms optimization algorithms between exploration and exploitation phases.
                        Convert exploration-based algorithms (like GA, PSO) to exploitation-focused versions, and vice versa, to match your problem requirements.
                    </p>
                </div>

                <div class="row">
                    <!-- Algorithm Selection -->
                    <div class="col-lg-6 mb-4">
                        <div class="card shadow-sm">
                            <div class="card-header bg-light">
                                <h6 class="mb-0"><i class="fas fa-robot"></i> Select Algorithm</h6>
                            </div>
                            <div class="card-body">
                                <div class="mb-3">
                                    <label for="algorithmSelect" class="form-label">Algorithm</label>
                                    <select class="form-select" id="algorithmSelect">
                                        <option value="">-- Select Algorithm --</option>
                                    </select>
                                </div>

                                <div class="mb-3">
                                    <label for="transformType" class="form-label">Transformation Type</label>
                                    <select class="form-select" id="transformType">
                                        <option value="exploration">Increase Exploration</option>
                                        <option value="exploitation">Increase Exploitation</option>
                                        <option value="balanced">Balanced</option>
                                    </select>
                                </div>

                                <div class="mb-3">
                                    <label for="intensity" class="form-label">Transformation Intensity</label>
                                    <input type="range" class="form-range" id="intensity" min="0" max="1" step="0.1" value="0.5">
                                    <small class="text-muted">Current: <span id="intensityValue">0.5</span></small>
                                </div>

                                <button class="btn btn-primary w-100" id="transformBtn">
                                    <i class="fas fa-wand-magic-sparkles"></i> Apply Levify Transformation
                                </button>
                            </div>
                        </div>
                    </div>

                    <!-- Algorithm Characteristics -->
                    <div class="col-lg-6 mb-4">
                        <div class="card shadow-sm">
                            <div class="card-header bg-light">
                                <h6 class="mb-0"><i class="fas fa-chart-bar"></i> Algorithm Characteristics</h6>
                            </div>
                            <div class="card-body" id="characteristicsPanel">
                                <p class="text-muted">Select an algorithm to view its characteristics</p>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Transformation Results -->
                <div id="resultsSection" class="d-none mt-4">
                    <h3 class="mb-3">Transformation Results</h3>

                    <div class="row mb-4">
                        <div class="col-lg-6">
                            <div class="card">
                                <div class="card-header bg-light">
                                    <h6 class="mb-0">Original Algorithm</h6>
                                </div>
                                <div class="card-body" id="originalCharacteristics"></div>
                            </div>
                        </div>
                        <div class="col-lg-6">
                            <div class="card">
                                <div class="card-header bg-light">
                                    <h6 class="mb-0">Transformed Algorithm</h6>
                                </div>
                                <div class="card-body" id="transformedCharacteristics"></div>
                            </div>
                        </div>
                    </div>

                    <!-- Parameter Adjustments -->
                    <div class="card mb-4">
                        <div class="card-header bg-light">
                            <h6 class="mb-0"><i class="fas fa-sliders-h"></i> Parameter Adjustments</h6>
                        </div>
                        <div class="card-body" id="parameterAdjustments"></div>
                    </div>

                    <!-- Action Buttons -->
                    <div class="d-flex gap-3">
                        <button class="btn btn-success btn-lg" id="applyBtn">
                            <i class="fas fa-check"></i> Apply & Run Optimization
                        </button>
                        <button class="btn btn-secondary btn-lg" id="resetBtn">
                            <i class="fas fa-redo"></i> Try Another Transform
                        </button>
                    </div>
                </div>

                <!-- Status Messages -->
                <div id="statusAlert" class="alert alert-info d-none mt-4" role="alert">
                    <div class="spinner-border spinner-border-sm me-2" role="status">
                        <span class="visually-hidden">Loading...</span>
                    </div>
                    <span id="statusMessage">Processing...</span>
                </div>

                <div id="errorAlert" class="alert alert-danger d-none mt-4" role="alert">
                    <strong>Error:</strong> <span id="errorMessage"></span>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="{{ url_for('static', filename='js/levify.js') }}"></script>
</body>
</html>
