{% extends "crowdsec_base.html" %}

{% block title %}Dashboard - RealNAS Security{% endblock %}

{% block style %}
<style>
    /* Keep existing styles */

    button.remove-btn {
        background-color: #3498db; /* Blue */
        color: white;
        border: none;
        padding: 6px 12px;
        cursor: pointer;
        border-radius: 3px;
        font-weight: bold;
    }
    button.remove-btn:hover {
        background-color: #2980b9;
    }

    button.install-btn {
        background-color: #e74c3c; /* Red */
        color: white;
        border: none;
        padding: 6px 12px;
        cursor: pointer;
        border-radius: 3px;
        font-weight: bold;
    }
    button.install-btn:hover {
        background-color: #c0392b;
    }

    .status-installed {
        color: #3498db; /* Blue */
        font-weight: bold;
    }
    .status-removed {
        color: #e74c3c; /* Red */
        font-weight: bold;
    }

    .flash-message {
        background-color: #f0f8ff;
        border: 1px solid #3498db;
        padding: 10px;
        margin-bottom: 15px;
        border-radius: 4px;
        color: #333;
    }
</style>
{% endblock %}

{% block content %}

<h1>RealNAS Security Scenario Management</h1>

{% with messages = get_flashed_messages() %}
  {% if messages %}
    <div class="flash-message">
      {% for message in messages %}
        <div>{{ message }}</div>
      {% endfor %}
    </div>
  {% endif %}
{% endwith %}

<table>
    <thead>
        <tr>
            <th>Scenario Description</th>
            <th>Status</th>
            <th>Action</th>
        </tr>
    </thead>
    <tbody>
        {% for scenario in scenarios %}
        <tr>
            <td>{{ scenario.description }}</td>
            <td>
                {% if scenario.installed %}
                    <span class="status-installed">Installed</span>
                {% else %}
                    <span class="status-removed">Removed</span>
                {% endif %}
            </td>
            <td>
                <form method="POST" action="{{ url_for('crowdsec_toggle_scenario') }}">
                    <input type="hidden" name="scenario_name" value="{{ scenario.name }}">
                    {% if scenario.installed %}
                        <button type="submit" name="action" value="remove" class="remove-btn">Remove</button>
                    {% else %}
                        <button type="submit" name="action" value="install" class="install-btn">Install</button>
                    {% endif %}
                </form>
            </td>
        </tr>
        {% endfor %}
    </tbody>
</table>

{% endblock %}
