{% extends "page.html" %}
{% block breadcrumb %}Документация{% endblock %}
{% block page_content %}
<div class="card">
    <div class="card-header"><h2>Документация</h2></div>
    <div class="docs-list">
        {% for doc in docs %}
        <div class="doc-item">
            <a href="/service/documents/{{ doc.filename | replace('.md', '') }}">{{ doc.title }}</a>
        </div>
        {% else %}
        <p>Нет доступных документов</p>
        {% endfor %}
    </div>
    {% if user.role == "owner" %}
    <div class="docs-actions" style="margin-top:12px;">
        <a href="/service/documents/admin/permissions" class="btn btn-secondary btn-sm">Управление доступами</a>
        <button class="btn btn-primary btn-sm" onclick="document.getElementById('create-form').style.display='block'">Создать документ</button>
    </div>
    <form id="create-form" method="post" action="/service/documents/admin/create" style="display:none; margin-top: 1rem;">
        <div class="form-group">
            <label for="title">Название документа</label>
            <input type="text" id="title" name="title" required>
        </div>
        <button type="submit" class="btn btn-primary btn-sm">Создать</button>
        <button type="button" class="btn btn-secondary btn-sm" onclick="document.getElementById('create-form').style.display='none'">Отмена</button>
    </form>
    {% endif %}
</div>
{% endblock %}