{# bedrock_server_manager/web/templates/manage_plugins.html #}
{% extends "base.html" %}

{% block title %}{{ super() }} - Manage Plugins{% endblock %}

{% block head_scripts %}
<script src="{{ request.url_for('static', path='js/utils.js') }}" defer></script>
<script src="{{ request.url_for('static', path='js/manage_plugins.js') }}" defer></script>
{% endblock %}

{% block content %}
<div class="content-container">
    <div id="setup-banner-container"></div>

    <header class="page-header">
        <h2>Manage Plugins</h2>
        <p>Enable or disable plugins for the Bedrock Server Manager. Reload Plugins for chages to apply.</p>
    </header>

    <div id="status-message-area" class="message-box" style="opacity: 0; transition: opacity 0.5s ease-out;">
        <!-- Status messages from save actions will appear here -->
    </div>

    <section class="list-section">
        <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;">
            <h3>Available Plugins</h3>
            {% if current_user.role == 'admin' %}
            <button id="reload-plugins-btn" class="action-button">
                <i class="fas fa-sync-alt"></i> Reload Plugins {# Assuming Font Awesome is available #}
            </button>
            {% endif %}
        </div>
        <ul id="plugin-list" class="item-list">
            <li id="plugin-loader" class="list-item-status" role="status">
                <div class="loader-container-small">
                    <div class="spinner"></div>
                    <p>Loading plugins...</p>
                </div>
            </li>
        </ul>
    </section>

    <template id="plugin-item-template">
        <li>
            <div class="plugin-details">
                <strong class="plugin-name"></strong>
                <small class="plugin-version" style="margin-left: 8px; color: #bbb;"></small>
            </div>
            <div class="plugin-controls">
                {% if current_user.role == 'admin' %}
                <label class="toggle-switch-container">
                    <input type="checkbox" class="toggle-input plugin-toggle-switch" data-plugin-name="">
                    <span class="toggle-switch"></span>
                </label>
                {% endif %}
            </div>
        </li>
    </template>

    <template id="no-plugins-template">
        <li id="no-players-message">
            {# Original ID was no-players-message, might be a typo in original #}
            No plugins found or available to configure.
        </li>
    </template>

    <template id="load-error-template">
        <li class="list-item-error">
            <p>Error loading plugin information. Please check the application logs or try again later.</p>
        </li>
    </template>
</div>

<div class="page-actions">
    <a href="{{ request.url_for('index') if request else '/' }}" class="action-link">
        Back to Dashboard
    </a>
</div>
{% endblock %}

{% block body_scripts %}
{% endblock %}