<!-- Modal Create/Edit Document -->
<div class="modal-overlay">
    <div class="modal-content" style="max-width: 700px;">
        <div class="modal-header">
            <h2 id="modalTitle">Nouveau Document</h2>
            <button type="button" class="modal-close" onclick="closeModal()">&times;</button>
        </div>
        <div class="modal-body">
            <form id="documentForm">
                <input type="hidden" id="documentId" value="">

                <div class="form-group">
                    <label for="libelle">Libellé <span class="required">*</span></label>
                    <input type="text" id="libelle" name="libelle"
                           placeholder="Ex: Contrat de travail" required>
                </div>

                <div class="form-group">
                    <label for="code">Code <span class="required">*</span></label>
                    <input type="text" id="code" name="code"
                           placeholder="Ex: CONTRAT_2024" required>
                    <small class="form-text">Code unique identifiant le document (majuscules, underscores autorisés)</small>
                </div>

                <div class="form-group">
                    <label for="type_document_id">Type de Document <span class="required">*</span></label>
                    <select id="type_document_id" name="type_document_id" required>
                        <option value="">Sélectionner un type</option>
                    </select>
                </div>

                <div class="form-group">
                    <label for="etat_document_id">État <span class="required">*</span></label>
                    <select id="etat_document_id" name="etat_document_id" required>
                        <option value="">Sélectionner un état</option>
                    </select>
                </div>

                <div class="form-group">
                    <label for="document_date">Date du document <span class="required">*</span></label>
                    <input type="date" id="document_date" name="document_date" required>
                </div>

                <div class="form-group">
                    <label for="description">Description</label>
                    <textarea id="description" name="description" rows="4"
                              placeholder="Description détaillée du document..."></textarea>
                </div>

                <div class="form-group">
                    <label for="documentFiles">Fichiers</label>
                    <input type="file" id="documentFiles" name="documentFiles[]"
                           multiple accept=".pdf,.doc,.docx,.jpg,.jpeg,.png">
                    <small class="form-text">Formats acceptés: PDF, DOC, DOCX, JPG, PNG (Max 10MB)</small>
                </div>

                <div id="existingFiles" style="margin-top: 10px; display: none;">
                    <label>Fichiers existants :</label>
                    <ul id="fileList" class="file-list"></ul>
                </div>

                <div class="form-actions">
                    <button type="button" class="btn btn-secondary" onclick="closeModal()">
                        <i class="fas fa-times"></i> Annuler
                    </button>
                    <button type="button" class="btn btn-primary" onclick="saveDocument()">
                        <i class="fas fa-save"></i> Enregistrer
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>