<!-- ===== Subjects Tab ===== -->
<div class="card create-card">
    <h2>Новая дисциплина</h2>
    <form id="create-subject-form">
        <div class="form-row">
            <div class="form-group">
                <label for="new-subject-name">Название дисциплины</label>
                <input type="text" id="new-subject-name" placeholder="Высшая математика" required>
            </div>
            <div class="form-group">
                <label for="new-subject-code">Код предмета</label>
                <input type="text" id="new-subject-code" placeholder="Например: MATH101" required>
            </div>
            <div class="form-group">
                <label for="new-subject-department">Кафедра</label>
                <select id="new-subject-department" required>
                    <option value="">Загрузка...</option>
                </select>
            </div>
            <button type="submit" class="btn btn-md btn-primary">Добавить</button>
        </div>
        <div class="form-alert" id="create-subject-alert" role="alert"></div>
    </form>
</div>

<div class="card">
    <h2>Все дисциплины</h2>
    <div class="table-wrap">
        <table id="subjects-table">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Название</th>
                    <th>Код предмета</th>
                    <th>Кафедра</th>
                    <th>Преподаватели</th>
                    <th style="text-align: right;">Действия</th>
                </tr>
            </thead>
            <tbody id="subjects-tbody">
                <tr>
                    <td colspan="6" class="loading-row">Загрузка...</td>
                </tr>
            </tbody>
        </table>
    </div>
</div>

<!-- Модальное окно привязки Преподавателей -->
<div class="modal-overlay" id="modal-manage-teachers">
    <div class="modal-content card" style="max-width: 600px; width: 90%;">
        <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem;">
            <div>
                <h2>Преподаватели дисциплины</h2>
                <div id="subject-teachers-context" style="color: var(--text-secondary); font-size: 0.9rem; margin-top: 0.25rem;"></div>
            </div>
            <button class="modal-close" id="modal-manage-teachers-close" style="position: static; font-size: 2rem; background: none; border: none; cursor: pointer; color: var(--text-secondary);">&times;</button>
        </div>
        
        <!-- Форма -->
        <div class="card create-card" style="margin-bottom: 1.5rem; background: var(--bg-secondary);">
            <h3 style="margin-top: 0;">Добавить привязку</h3>
            <form id="manage-teacher-subject-form">
                <input type="hidden" id="manage-ts-subject-id">
                <div class="form-row" style="align-items: flex-end;">
                    <div class="form-group" style="margin-bottom: 0;">
                        <label for="manage-ts-teacher-select">Преподаватель</label>
                        <select id="manage-ts-teacher-select" required>
                            <option value="">Загрузка...</option>
                        </select>
                    </div>
                    <button type="submit" class="btn btn-md btn-primary" style="height: fit-content; margin-bottom: 0;">Привязать</button>
                </div>
                <div class="form-alert" id="manage-ts-alert" role="alert"></div>
            </form>
        </div>

        <!-- Таблица -->
        <div class="table-wrap">
            <table id="manage-ts-table">
                <thead>
                    <tr>
                        <th>Преподаватель</th>
                        <th>Действия</th>
                    </tr>
                </thead>
                <tbody id="manage-ts-tbody">
                    <tr>
                        <td colspan="2" class="loading-row">Загрузка...</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
