<!doctype html>
<html lang="{{ current_locale() }}" class="h-100">
    {% set current_theme = current_theme() %} {% set config = config() %}

    <head>
        {{ current_theme.headertags() }} {{ current_theme.local_style() }}
        <title>{{ title }} - {{ config.titulo }}</title>
    </head>

    <body>
        {{ current_theme.navbar() }}

        <main>
            {{ current_theme.notify() }}

            <div class="container">
                <div class="row">
                    <div class="col-12">
                        <div class="d-flex justify-content-between align-items-center mb-4">
                            <h1>{{ title }}</h1>
                            <a href="{{ url_for('masterclass.instructor_create') }}" class="btn btn-primary">
                                <i class="fas fa-plus"></i> {{ _('Nueva Clase Magistral') }}
                            </a>
                        </div>

                        {% if master_classes.items %}
                        <div class="table-responsive">
                            <table class="table table-striped">
                                <thead>
                                    <tr>
                                        <th>{{ _('Título') }}</th>
                                        <th>{{ _('Fecha') }}</th>
                                        <th>{{ _('Horario') }}</th>
                                        <th>{{ _('Estado') }}</th>
                                        <th>{{ _('Inscritos') }}</th>
                                        <th>{{ _('Precio') }}</th>
                                        <th>{{ _('Acciones') }}</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {% for master_class in master_classes.items %}
                                    <tr>
                                        <td>
                                            <strong>{{ master_class.title }}</strong>
                                            <br />
                                            <small class="text-muted">{{ master_class.platform_name }}</small>
                                        </td>
                                        <td>{{ master_class.date.strftime('%d/%m/%Y') }}</td>
                                        <td>
                                            {{ master_class.start_time.strftime('%H:%M') }} - {{
                                            master_class.end_time.strftime('%H:%M') }}
                                        </td>
                                        <td>
                                            {% if master_class.is_ongoing() %}
                                            <span class="badge bg-warning">{{ _('En Vivo') }}</span>
                                            {% elif master_class.is_finished() %}
                                            <span class="badge bg-secondary">{{ _('Finalizada') }}</span>
                                            {% else %}
                                            <span class="badge bg-success">{{ _('Próxima') }}</span>
                                            {% endif %}
                                        </td>
                                        <td>
                                            <span class="badge bg-info">{{ master_class.enrollments|length }}</span>
                                        </td>
                                        <td>
                                            {% if master_class.is_paid %} ${{ "%.2f"|format(master_class.price) }} {% else %}
                                            <span class="text-success">{{ _('Gratis') }}</span>
                                            {% endif %}
                                        </td>
                                        <td>
                                            <div class="btn-group" role="group">
                                                <a
                                                    href="{{ url_for('masterclass.detail_public', slug=master_class.slug) }}"
                                                    class="btn btn-outline-primary btn-sm"
                                                    title="{{ _('Ver') }}"
                                                >
                                                    <i class="fas fa-eye"></i>
                                                </a>
                                                <a
                                                    href="{{ url_for('masterclass.instructor_edit', master_class_id=master_class.id) }}"
                                                    class="btn btn-outline-secondary btn-sm"
                                                    title="{{ _('Editar') }}"
                                                >
                                                    <i class="fas fa-edit"></i>
                                                </a>
                                                <a
                                                    href="{{ url_for('masterclass.instructor_students', master_class_id=master_class.id) }}"
                                                    class="btn btn-outline-info btn-sm"
                                                    title="{{ _('Estudiantes') }}"
                                                >
                                                    <i class="fas fa-users"></i>
                                                </a>
                                            </div>
                                        </td>
                                    </tr>
                                    {% endfor %}
                                </tbody>
                            </table>
                        </div>

                        <!-- Pagination -->
                        {% if master_classes.pages > 1 %}
                        <nav aria-label="{{ _('Navegación de páginas') }}">
                            <ul class="pagination justify-content-center">
                                {% if master_classes.has_prev %}
                                <li class="page-item">
                                    <a
                                        class="page-link"
                                        href="{{ url_for('masterclass.instructor_list', page=master_classes.prev_num) }}"
                                        >{{ _('Anterior') }}</a
                                    >
                                </li>
                                {% endif %} {% for page_num in master_classes.iter_pages() %} {% if page_num %} {% if page_num
                                != master_classes.page %}
                                <li class="page-item">
                                    <a class="page-link" href="{{ url_for('masterclass.instructor_list', page=page_num) }}"
                                        >{{ page_num }}</a
                                    >
                                </li>
                                {% else %}
                                <li class="page-item active">
                                    <span class="page-link">{{ page_num }}</span>
                                </li>
                                {% endif %} {% else %}
                                <li class="page-item disabled">
                                    <span class="page-link">…</span>
                                </li>
                                {% endif %} {% endfor %} {% if master_classes.has_next %}
                                <li class="page-item">
                                    <a
                                        class="page-link"
                                        href="{{ url_for('masterclass.instructor_list', page=master_classes.next_num) }}"
                                        >{{ _('Siguiente') }}</a
                                    >
                                </li>
                                {% endif %}
                            </ul>
                        </nav>
                        {% endif %} {% else %}
                        <div class="text-center py-5">
                            <i class="fas fa-chalkboard-teacher fa-4x text-muted mb-3"></i>
                            <h3 class="text-muted">{{ _('No tienes clases magistrales') }}</h3>
                            <p class="text-muted">{{ _('Crea tu primera clase magistral para empezar.') }}</p>
                            <a href="{{ url_for('masterclass.instructor_create') }}" class="btn btn-primary">
                                <i class="fas fa-plus"></i> {{ _('Crear Clase Magistral') }}
                            </a>
                        </div>
                        {% endif %}
                    </div>
                </div>
            </div>
        </main>
    </body>
</html>
