{{!
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template aiprovider_datacurso/webservice_config

    TODO describe template webservice_config

    Example context (json):
    {
        "isconfigured": true,
        "needsrepair": false,
        "webservicesenabled": true,
        "restenabled": true,
        "user": {
            "username": "datacurso_user",
            "email": "datacurso@example.com"
        },
        "role": {
            "shortname": "datacurso_role",
            "name": "Datacurso AI Role"
        },
        "service": {
            "name": "Datacurso AI Service"
        },
        "userassigned": true,
        "tokenexists": true,
        "tokencreated": "2025-01-15 10:30:00",
        "registration": {
            "verified": true,
            "lastsent": "2025-01-15 10:30:00"
        },
        "messages": []
    }
}}

<div data-region="aiprovider_datacurso/webservice-root">
    <div class="mb-4">
        <h3>{{#str}} webserviceconfig_heading, aiprovider_datacurso {{/str}}</h3>
        <p class="text-muted">{{#str}} webserviceconfig_desc, aiprovider_datacurso {{/str}}</p>
    </div>

    <!-- Status Overview Card -->
    <div class="card mb-4">
        <div class="card-header d-flex justify-content-between align-items-center">
            <h5 class="mb-0">{{#str}} webserviceconfig_current, aiprovider_datacurso {{/str}}</h5>
            {{#isconfigured}}
                <span class="badge badge-success" data-region="aiprovider_datacurso/header-badge">{{#str}} configured, aiprovider_datacurso{{/str}}</span>
            {{/isconfigured}}
            {{^isconfigured}}
                {{#retryonly}}
                    <span class="badge badge-warning" data-region="aiprovider_datacurso/header-badge">{{#str}} needs_repair, aiprovider_datacurso{{/str}}</span>
                {{/retryonly}}
                {{^retryonly}}
                    {{#registration.lastsent}}
                        {{#needsrepair}}
                            <span class="badge badge-warning" data-region="aiprovider_datacurso/header-badge">{{#str}} needs_repair, aiprovider_datacurso{{/str}}</span>
                        {{/needsrepair}}
                        {{^needsrepair}}
                            <span class="badge badge-danger" data-region="aiprovider_datacurso/header-badge">{{#str}} not_configured, aiprovider_datacurso{{/str}}</span>
                        {{/needsrepair}}
                    {{/registration.lastsent}}
                    {{^registration.lastsent}}
                        <span class="badge badge-danger" data-region="aiprovider_datacurso/header-badge">{{#str}} not_configured, aiprovider_datacurso{{/str}}</span>
                    {{/registration.lastsent}}
                {{/retryonly}}
            {{/isconfigured}}
        </div>
        <div class="card-body">
            {{> aiprovider_datacurso/webservice/status }}

            {{> aiprovider_datacurso/webservice/user_role }}

            {{> aiprovider_datacurso/webservice/service_assignment }}

            {{> aiprovider_datacurso/webservice/token_registration }}
        </div>
    </div>

    <!-- Action Buttons -->
    {{> aiprovider_datacurso/webservice/actions }}

    <!-- Activity Log -->
    <div class="card">
        <div class="card-header d-flex justify-content-between align-items-center">
            <small class="text-muted">{{#str}} live_log, aiprovider_datacurso{{/str}}</small>
        </div>
        <div class="card-body">
            <ul class="list-unstyled mb-0" data-region="aiprovider_datacurso/webservice-log">
                <!-- Activity log entries will be populated here -->
            </ul>
        </div>
    </div>
</div>
