<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Gestion des Concours - EST</title>
    <!-- Font Awesome for icons -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <!-- Separate CSS file (employee-styles.css) -->
    <link rel="stylesheet" href="../../../../../css/employee-styles.css">
</head>
<body>
<?php include "../../../../../layouts/employee/header.php" ?>

<?php include "../../../../../layouts/employee/concours/nav-second-level.php" ?>


<!-- ====== MAIN CONTENT ====== -->
<main class="main-content">
    <div class="container">
        <!-- Header interne (page) -->
             <!-- Stats Cards -->
<div class="stats-grid" id="statsGrid">

    <div class="stat-card">
        <div class="stat-icon">🏆</div>
        <div class="stat-info">
            <span class="stat-label">Total Concours</span>
            <span class="stat-value" id="statTotal">0</span>
        </div>
    </div>

    <div class="stat-card">
        <div class="stat-icon">🟢</div>
        <div class="stat-info">
            <span class="stat-label">Ouverts</span>
            <span class="stat-value" id="statOuvert">0</span>
        </div>
    </div>

    <div class="stat-card">
        <div class="stat-icon">🟡</div>
        <div class="stat-info">
            <span class="stat-label">En cours</span>
            <span class="stat-value" id="statEnCours">0</span>
        </div>
    </div>

    <div class="stat-card">
        <div class="stat-icon">🔵</div>
        <div class="stat-info">
            <span class="stat-label">Terminés</span>
            <span class="stat-value" id="statTermine">0</span>
        </div>
    </div>

     </div>

        <!-- Search Section -->
        <div class="search-section">
            <form id="searchForm" class="search-form">
                <div class="form-group">
                    <label for="searchCode">Code</label>
                    <input type="text" id="searchCode" placeholder="Rechercher par code...">
                </div>
                <div class="form-group">
                    <label for="searchLabel">Libellé</label>
                    <input type="text" id="searchLabel" placeholder="Rechercher par libellé...">
                </div>
                <div class="form-group">
                    <label for="searchFilliere">Filière</label>
                    <input type="text" id="searchFilliere" placeholder="Rechercher par filière...">
                </div>
                <div class="form-group">
                    <label for="searchEtat">État</label>
                    <select id="searchEtat">
                        <option value="">Tous</option>
                        <option value="OUVERT">Ouvert</option>
                        <option value="FERME">Fermé</option>
                        <option value="EN_COURS">En cours</option>
                        <option value="TERMINE">Terminé</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="searchActive">Statut</label>
                    <select id="searchActive">
                        <option value="">Tous</option>
                        <option value="1">Actif</option>
                        <option value="0">Inactif</option>
                    </select>
                </div>
                <div class="search-actions">
                    <button type="submit" class="btn btn-primary">
                        <i class="fas fa-search"></i> Rechercher
                    </button>
                    <button type="reset" class="btn btn-secondary" onclick="resetSearch()">
                        <i class="fas fa-undo"></i> Réinitialiser
                    </button>
                    <button type="button" class="btn btn-success" onclick="openCreateModal()">
                        <i class="fas fa-plus"></i> Nouveau Concours
                    </button>
                </div>
            </form>
        </div>

        <!-- Table -->
        <div class="table-container">
            <div class="table-wrapper">
                <table>
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>Code</th>
                        <th>Libellé</th>
                        <th>Filière</th>
                        <th>Date Lancement</th>
                        <th>Date Fin</th>
                        <th>État</th>
                        <th>Statut</th>
                        <th>Actions</th>
                    </tr>
                    </thead>
                    <tbody id="tableBody">
                    <tr>
                        <td colspan="9" style="text-align: center; padding: 40px;">
                            <div class="loading active">
                                <div class="spinner"></div>
                                <p style="margin-top: 10px;">Chargement des données...</p>
                            </div>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div class="pagination">
                <div class="pagination-info" id="paginationInfo">Affichage de 0 à 0 sur 0</div>
                <div class="pagination-buttons" id="paginationButtons">
                    <button onclick="changePage('prev')" id="prevBtn">◀ Précédent</button>
                    <span id="pageNumbers"></span>
                    <button onclick="changePage('next')" id="nextBtn">Suivant ▶</button>
                </div>
            </div>
        </div>
    </div>
</main>
<!-- ====== FOOTER ====== -->
<?php include "../../../../../layouts/employee/footer.php" ?>



<!-- Modal for Create/Update -->
<?php include "../create-edit/modal.php" ?>

<!-- Detail Modal -->
<?php include "../view/modal.php" ?>

<!-- Toast Container -->
<div class="toast-container" id="toastContainer"></div>

<!-- Script JS (external) -->
<script src="main.js?v=2"></script>
</body>
</html>
