<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Configuration Types d'Avancement</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <link rel="stylesheet" href="../../../../../css/admin-styles.css">
    <style>
        /* CSS darori bach les modals ybano melli tcliqui 3la les boutons */
        .modal-overlay {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 9999;
        }
        .modal-overlay.active {
            display: flex;
        }
        .modal {
            background: #fff;
            padding: 20px;
            border-radius: 8px;
            width: 100%;
            max-width: 500px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.2);
        }
        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid #eee;
            padding-bottom: 10px;
            margin-bottom: 15px;
        }
        .modal-close {
            background: none; border: none; font-size: 24px; cursor: pointer;
        }
        .modal-footer {
            margin-top: 20px; text-align: right;
        }
        .badge-success { background-color: #28a745; color: white; padding: 4px 8px; border-radius: 4px; }
        .badge-danger { background-color: #dc3545; color: white; padding: 4px 8px; border-radius: 4px; }
    </style>
</head>
<body>

<?php include "../../../../../layouts/admin/header.php"; ?>
<?php include "../../../../../layouts/admin/avancement/nav-second-level.php"; ?>

<main class="main-content">
<div class="container">


    <div class="search-section">
        <form id="searchForm" class="search-form" onsubmit="event.preventDefault();">
            <div class="form-group">
                <label for="searchCode">Code</label>
                <input type="text" id="searchCode" placeholder="Code...">
            </div>
            <div class="form-group">
                <label for="searchLibelle">Libellé</label>
                <input type="text" id="searchLibelle" placeholder="Libellé...">
            </div>
            <div class="form-group">
                <label for="searchStatus">Statut</label>
                <select id="searchStatus">
                    <option value="">Tous</option>
                    <option value="active">Actif</option>
                    <option value="inactive">Inactif</option>
                </select>
            </div>
            <div class="search-actions">
                <button type="button" class="btn btn-primary" onclick="loadTypes()"><i class="fas fa-search"></i> Filtrer</button>
                <button type="button" class="btn btn-secondary" onclick="resetSearch()"><i class="fas fa-undo"></i> Reset</button>
                <button type="button" class="btn btn-success" onclick="openCreateModal()"><i class="fas fa-plus"></i> Ajouter</button>
            </div>
        </form>
    </div>

    <div class="table-container">
        <div class="table-wrapper">
            <table>
                <thead>
                <tr>
                    <th>ID</th>
                    <th>Code</th>
                    <th>Libellé</th>
                    <th>Description</th>
                    <th>Statut</th>
                    <th>Actions</th>
                </tr>
                </thead>
                <tbody id="tableBody">
                    <tr>
                        <td colspan="6" style="text-align: center; padding: 20px;">Chargement des données en cours...</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
</main>

<?php include "../../../../../layouts/admin/footer.php"; ?>
<?php include "../create-edit/modal.php"; ?>
<?php include "../view/modal.php"; ?>

<div class="toast-container" id="toastContainer"></div>
<script src="main.js"></script>
</body>
</html>
