Ver Fonte

update demande d avenant V2

OneHealth sur scw-3 há 6 meses atrás
pai
commit
136542be88
1 ficheiros alterados com 868 adições e 235 exclusões
  1. 868 235
      demande-avenant2.php

+ 868 - 235
demande-avenant2.php

@@ -1,262 +1,895 @@
 <!DOCTYPE html>
 <html lang="fr">
 <head>
-    <meta charset="UTF-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>Demande d'Avenant - SIPA Automobiles</title>
-    
-    <!-- Tailwind CSS CDN -->
-    <script src="https://cdn.tailwindcss.com"></script>
-    
-    <!-- Flatpickr CSS -->
-    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
-    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/preline/dist/preline.css" />
-
-    <style>
-      /* Styles pour les champs readonly */
-      .readonly-field {
-        background-color: rgb(243, 244, 246);
-        color: rgb(107, 114, 128);
-        cursor: not-allowed;
+  <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <title>Demande d'Avenant - SIPA Automobiles</title>
+  <script src="https://cdn.tailwindcss.com"></script>
+  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
+  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/preline/dist/preline.css" />
+  <style>
+    .readonly-field { background-color: rgb(243, 244, 246); color: rgb(107, 114, 128); cursor: not-allowed; }
+    @media (prefers-color-scheme: dark) {
+      .readonly-field { background-color: rgb(38, 38, 38); color: rgb(163, 163, 163); }
+    }
+    .panel-pre-avenant { background-color: rgb(254 242 242); border-color: rgb(254 202 202); }
+    .panel-post-avenant { background-color: rgb(240 253 244); border-color: rgb(187 247 208); }
+    @media (prefers-color-scheme: dark) {
+      .panel-pre-avenant { background-color: rgb(69 10 10 / 0.35); border-color: rgb(127 29 29); }
+      .panel-post-avenant { background-color: rgb(6 78 59 / 0.35); border-color: rgb(20 83 45); }
+    }
+    /* Encarts blancs à l’intérieur des panneaux pré/post (fond rouge/vert visible autour) */
+    .avenant-panel-section {
+      border-radius: 0.5rem;
+      border: 1px solid rgb(229 231 235);
+      background-color: rgb(255 255 255);
+      padding: 1rem;
+      box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
+    }
+    @media (prefers-color-scheme: dark) {
+      .avenant-panel-section {
+        border-color: rgb(82 82 82);
+        background-color: rgb(10 10 10);
       }
-      
-      @media (prefers-color-scheme: dark) {
-        .readonly-field {
-          background-color: rgb(38, 38, 38);
-          color: rgb(163, 163, 163);
-        }
-      }
-      
-      /* Animation fade-in pour les cards */
-      @keyframes fadeInUp {
-        from {
-          opacity: 0;
-          transform: translateY(20px);
-        }
-        to {
-          opacity: 1;
-          transform: translateY(0);
-        }
-      }
-      
-      .animate-fade-in-up {
-        animation: fadeInUp 0.5s ease-out;
-      }
-    </style>
+    }
+    .conditional-field { display: none; }
+    .conditional-field.is-active { display: block; }
+    .conditional-field.is-active.grid { display: grid; }
+    .conditional-field.is-active.flex { display: flex; }
+    @keyframes fadeInUp {
+      from { opacity: 0; transform: translateY(12px); }
+      to { opacity: 1; transform: translateY(0); }
+    }
+    .animate-fade-in-up { animation: fadeInUp 0.4s ease-out; }
+    input[type="radio"], input[type="checkbox"] { accent-color: #21B6BA; }
+    .person-badge {
+      display: inline-flex; align-items: center; gap: 0.5rem;
+      padding: 0.375rem 0.75rem; background-color: #21B6BA; color: white;
+      border-radius: 0.5rem; font-size: 0.875rem;
+    }
+    .person-badge button { background: transparent; border: none; color: white; cursor: pointer; padding: 0; }
+  </style>
 </head>
 <body class="bg-gray-50 dark:bg-neutral-900">
-    
-    <?php 
-    $skip_default_content = true;
-    include 'menu.php'; 
-    ?>
-    
-    <!-- Content -->
-    <div class="pt-12 lg:pt-16 lg:ps-64">
-      <div class="min-h-screen p-4 md:p-8">
-        <!-- Header -->
-        <div class="mb-6 flex justify-between items-start">
-          <div>
-            <h1 class="text-2xl font-semibold text-[#21B6BA] dark:text-[#21B6BA]">Demande d'Avenant</h1>
-            <p class="mt-1 text-sm text-gray-600 dark:text-neutral-400">Deux formulaires d'avenant côte à côte</p>
+<?php $skip_default_content = true; include 'menu.php'; ?>
+
+<div class="pt-12 lg:pt-16 lg:ps-64">
+  <div class="min-h-screen p-4 md:p-8">
+    <div class="mb-6">
+      <h1 class="text-2xl font-semibold text-[#21B6BA]">Demande d'Avenant</h1>
+      <p class="mt-1 text-sm text-gray-600 dark:text-neutral-400">
+        Saisie pré-avenant (fond rouge clair) et post-avenant (fond vert clair). Vous pouvez ne renseigner qu’une partie du formulaire (ex. rémunération uniquement) ; en revanche, pour chaque champ, si la valeur pré ou post est renseignée, la valeur correspondante de l’autre côté doit l’être aussi.
+      </p>
+    </div>
+
+    <form id="form-avenant" class="space-y-6">
+      <input type="hidden" name="demande_id" id="demande_id" value="">
+
+      <!-- 1. Informations de suivi -->
+      <div class="bg-white border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-800 dark:border-neutral-700">
+        <div class="p-6">
+          <h2 class="text-lg font-semibold text-gray-800 dark:text-white mb-4">Informations de suivi</h2>
+          <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
+            <div>
+              <label class="block text-sm font-medium mb-2 text-gray-700 dark:text-neutral-300">Créé par</label>
+              <input type="text" readonly class="readonly-field py-3 px-4 w-full border border-gray-200 rounded-lg text-sm dark:border-neutral-700" value="Sophie Bernard (RH)">
+            </div>
+            <div>
+              <label class="block text-sm font-medium mb-2 text-gray-700 dark:text-neutral-300">Date de création</label>
+              <input type="text" readonly class="readonly-field py-3 px-4 w-full border border-gray-200 rounded-lg text-sm dark:border-neutral-700" value="07 mai 2026 10:00">
+            </div>
+            <div>
+              <label for="statut_global" class="block text-sm font-medium mb-2 text-gray-700 dark:text-neutral-300">Statut de la demande</label>
+              <select id="statut_global" name="statut_global" disabled class="py-3 px-4 w-full border border-gray-200 rounded-lg text-sm bg-gray-50 dark:bg-neutral-900 dark:border-neutral-700 opacity-70">
+                <option value="nouveau" selected>Nouveau</option>
+                <option value="en_cours">En cours</option>
+                <option value="valide">Validé</option>
+              </select>
+            </div>
+            <div class="md:col-span-3">
+              <label class="block text-sm font-medium mb-2 text-gray-700 dark:text-neutral-300">Site</label>
+              <input type="text" readonly class="readonly-field py-3 px-4 w-full border border-gray-200 rounded-lg text-sm dark:border-neutral-700" value="Auto 33" aria-readonly="true">
+              <input type="hidden" name="site_selectionne" id="site_selectionne" value="auto33">
+            </div>
+          </div>
+        </div>
+      </div>
+
+      <!-- 2. Informations personnelles -->
+      <div class="bg-white border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-800 dark:border-neutral-700 animate-fade-in-up">
+        <div class="p-6">
+          <h2 class="text-lg font-semibold text-gray-800 dark:text-white mb-4">Informations personnelles</h2>
+          <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
+            <div>
+              <label class="block text-sm font-medium mb-2 text-gray-700 dark:text-neutral-300">Prénom</label>
+              <input type="text" id="prenom_collab" name="prenom_collab" readonly class="readonly-field py-3 px-4 w-full border rounded-lg text-sm dark:border-neutral-700" value="Jean">
+            </div>
+            <div>
+              <label class="block text-sm font-medium mb-2 text-gray-700 dark:text-neutral-300">Nom</label>
+              <input type="text" id="nom_collab" name="nom_collab" readonly class="readonly-field py-3 px-4 w-full border rounded-lg text-sm dark:border-neutral-700" value="DUPONT">
+            </div>
+            <div>
+              <label for="date_effet_avenant" class="block text-sm font-medium mb-2 text-gray-700 dark:text-neutral-300">Date d’effet de l’avenant <span class="text-red-500">*</span></label>
+              <input type="text" id="date_effet_avenant" name="date_effet_avenant" required placeholder="jj/mm/aaaa"
+                class="py-3 px-4 w-full border border-gray-200 rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
+            </div>
+            <div>
+              <label for="email_pro_collab" class="block text-sm font-medium mb-2 text-gray-700 dark:text-neutral-300">Email professionnel</label>
+              <input type="email" id="email_pro_collab" name="email_pro_collab" readonly class="readonly-field py-3 px-4 w-full border rounded-lg text-sm dark:border-neutral-700" value="jean.dupont@sipa-automobiles.fr">
+            </div>
+          </div>
+        </div>
+      </div>
+
+      <!-- 3. Type de contrat -->
+      <div class="bg-white border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-800 dark:border-neutral-700">
+        <div class="p-6">
+          <h2 class="text-lg font-semibold text-gray-800 dark:text-white mb-4">Informations sur le collaborateur concerné</h2>
+          <p class="text-sm text-gray-600 dark:text-neutral-400 mb-4">Type de contrat pris en compte pour l’avenant</p>
+          <div class="flex flex-wrap gap-6">
+            <div class="flex items-center gap-2">
+              <input type="radio" name="type_contrat_avenant" id="type_cdi" value="CDI" class="shrink-0 border-gray-200 rounded-full" checked>
+              <label for="type_cdi" class="text-sm text-gray-700 dark:text-neutral-300">CDI</label>
+            </div>
+            <div class="flex items-center gap-2">
+              <input type="radio" name="type_contrat_avenant" id="type_cdd" value="CDD" class="shrink-0 border-gray-200 rounded-full">
+              <label for="type_cdd" class="text-sm text-gray-700 dark:text-neutral-300">CDD</label>
+            </div>
           </div>
         </div>
+      </div>
+
+      <!-- 4a. Section CDI pré/post -->
+      <div id="bloc-section-cdi" class="space-y-4">
+        <h2 class="text-lg font-semibold text-gray-800 dark:text-white px-1">Section CDI</h2>
+        <div class="grid grid-cols-1 xl:grid-cols-2 gap-4">
+          <?php
+          foreach ([['pre','Pré-avenant','panel-pre-avenant'],['post','Post-avenant','panel-post-avenant']] as $t) {
+            $s = $t[0]; $label = $t[1]; $panel = $t[2];
+          ?>
+          <div class="rounded-xl border-2 p-4 md:p-6 space-y-6 <?php echo $panel; ?>">
+            <p class="text-sm font-bold text-gray-800 dark:text-white border-b border-gray-300/50 dark:border-neutral-600 pb-2"><?php echo htmlspecialchars($label); ?></p>
+
+            <div class="avenant-panel-section">
+              <h3 class="text-sm font-semibold text-gray-700 dark:text-neutral-300 mb-3">Planning</h3>
+              <label class="inline-flex items-center gap-2">
+                <input type="checkbox" name="samedi_cdi_<?php echo $s; ?>" id="samedi_cdi_<?php echo $s; ?>" value="1" class="rounded border-gray-200">
+                <span class="text-sm text-gray-700 dark:text-neutral-300">Samedi travaillé ?</span>
+              </label>
+            </div>
+
+            <div class="avenant-panel-section">
+              <h3 class="text-sm font-semibold text-gray-700 dark:text-neutral-300 mb-3">Manager</h3>
+              <div class="space-y-3">
+                <div>
+                  <label class="block text-xs font-medium mb-1 text-gray-600 dark:text-neutral-400">Qui sera son manager ?</label>
+                  <input type="text" name="manager_recherche_<?php echo $s; ?>" placeholder="Prénom ou nom du manager"
+                    class="py-2.5 px-3 w-full border border-gray-200 rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
+                </div>
+                <div>
+                  <span class="block text-xs font-medium mb-2 text-gray-600 dark:text-neutral-400">Sera-t-il lui-même manager ?</span>
+                  <div class="flex gap-4">
+                    <label class="inline-flex items-center gap-2"><input type="radio" name="est_manager_cdi_<?php echo $s; ?>" value="oui" class="est-manager-cdi" data-side="<?php echo $s; ?>"> <span class="text-sm">Oui</span></label>
+                    <label class="inline-flex items-center gap-2"><input type="radio" name="est_manager_cdi_<?php echo $s; ?>" value="non" checked class="est-manager-cdi" data-side="<?php echo $s; ?>"> <span class="text-sm">Non</span></label>
+                  </div>
+                </div>
+                <div id="wrap-supervisees-cdi-<?php echo $s; ?>" class="conditional-field">
+                  <label class="block text-xs font-medium mb-1">Ajouter les personnes supervisées</label>
+                  <div class="flex gap-2">
+                    <input type="text" id="input-supervisee-cdi-<?php echo $s; ?>" placeholder="Prénom NOM" class="flex-1 py-2 px-3 border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
+                    <button type="button" class="btn-add-supervisee px-3 py-2 bg-[#21B6BA] text-white rounded-lg text-sm" data-target="cdi-<?php echo $s; ?>">Ajouter</button>
+                  </div>
+                  <div id="badges-cdi-<?php echo $s; ?>" class="flex flex-wrap gap-2 mt-2 min-h-[36px]"></div>
+                  <input type="hidden" name="personnes_supervisees_cdi_<?php echo $s; ?>" id="hidden-supervisees-cdi-<?php echo $s; ?>" value="">
+                </div>
+              </div>
+            </div>
+
+            <div class="avenant-panel-section">
+              <h3 class="text-sm font-semibold text-gray-700 dark:text-neutral-300 mb-3">Contrat</h3>
+              <div class="grid grid-cols-1 gap-3">
+                <div>
+                  <label class="block text-xs mb-1">Service</label>
+                  <select name="service_<?php echo $s; ?>" class="py-2.5 px-3 w-full border rounded-lg text-sm bg-white dark:bg-neutral-900 dark:border-neutral-700">
+                    <option value="">Sélectionner</option>
+                    <option value="vente_pra">Vente P.R.A.</option>
+                    <option value="apres_vente">Après-Vente</option>
+                    <option value="administration">Administration</option>
+                  </select>
+                </div>
+                <div>
+                  <label class="block text-xs mb-1">Intitulé de poste</label>
+                  <select name="intitule_poste_<?php echo $s; ?>" class="py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
+                    <option value="">Sélectionner</option>
+                    <option value="conseiller">Conseiller commercial</option>
+                    <option value="chef">Chef des ventes</option>
+                  </select>
+                </div>
+                <div>
+                  <label class="block text-xs mb-1">Statut</label>
+                  <select name="statut_<?php echo $s; ?>" class="py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
+                    <option value="">Sélectionner</option>
+                    <option value="ouvrier">Ouvrier</option>
+                    <option value="employe">Employé</option>
+                    <option value="am">Agent de maîtrise</option>
+                    <option value="cadre">Cadre</option>
+                  </select>
+                </div>
+                <div>
+                  <label class="block text-xs mb-1">Échelon</label>
+                  <select name="echelon_<?php echo $s; ?>" class="echelon-select py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" data-side="<?php echo $s; ?>" data-context="cdi">
+                    <option value="">Sélectionner</option>
+                    <option value="III_A">III A</option>
+                    <option value="III_B">III B</option>
+                    <option value="III_C">III C</option>
+                  </select>
+                </div>
+                <div class="table-minima-wrap rounded-lg border border-gray-200 dark:border-neutral-600 overflow-hidden text-xs" id="minima-cdi-<?php echo $s; ?>">
+                  <table class="w-full">
+                    <thead class="bg-gray-100 dark:bg-neutral-800"><tr>
+                      <th class="text-left p-2">Échelon</th><th class="p-2">35h</th><th class="p-2">37h</th><th class="p-2">39h</th>
+                    </tr></thead>
+                    <tbody class="bg-white dark:bg-neutral-900"><tr>
+                      <td class="p-2 font-medium">—</td><td class="p-2">—</td><td class="p-2">—</td><td class="p-2">—</td>
+                    </tr></tbody>
+                  </table>
+                </div>
+              </div>
+            </div>
 
-        <!-- Conteneur pour les deux formulaires côte à côte -->
-        <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
-          
-          <!-- Formulaire de gauche -->
-          <form id="avenant-form-left" class="space-y-6">
-            <div class="bg-white border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-800 dark:border-neutral-700 animate-fade-in-up">
-              <div class="p-10">
-                <h2 class="text-lg font-semibold text-gray-800 dark:text-white mb-6">Informations personnelles</h2>
-                
-                <!-- Grille de 2 colonnes - 2 inputs par ligne -->
-                <div class="space-y-6">
-                  <!-- Première ligne -->
-                  <div class="grid grid-cols-2 gap-6">
-                    <!-- Date de naissance -->
-                    <div>
-                      <label for="date_naissance_left" class="block text-sm font-medium mb-2 text-gray-700 dark:text-neutral-300">
-                        Date de naissance <span class="text-red-500">*</span>
-                      </label>
-                      <div class="relative">
-                        <input type="text" id="date_naissance_left" name="date_naissance_left" required value="01/01/2000"
-                          class="py-3 px-4 pe-11 block w-full border border-gray-200 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600"
-                          placeholder="Sélectionner une date">
-                        <div class="absolute inset-y-0 end-0 flex items-center pointer-events-none pe-4">
-                          <svg class="shrink-0 size-4 text-gray-500 dark:text-neutral-400" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
-                            <rect width="18" height="18" x="3" y="4" rx="2" ry="2"></rect>
-                            <line x1="16" x2="16" y1="2" y2="6"></line>
-                            <line x1="8" x2="8" y1="2" y2="6"></line>
-                            <line x1="3" x2="21" y1="10" y2="10"></line>
-                          </svg>
-                        </div>
-                      </div>
-                    </div>
-                    
-                    <!-- Email professionnel -->
-                    <div>
-                      <label for="email_pro_left" class="block text-sm font-medium mb-2 dark:text-white">
-                        Adresse mail professionnelle (Office 365) <span class="text-red-500">*</span>
-                      </label>
-                      <input type="email" id="email_pro_left" name="email_pro_left" required value="jean.dupont@sipa.fr"
-                        class="py-2.5 sm:py-3 px-4 block w-full border border-gray-200 rounded-lg sm:text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600"
-                        placeholder="jean.dupont@sipa.fr">
-                      <p class="text-xs text-gray-500 mt-1 dark:text-neutral-500">Email généré automatiquement</p>
-                    </div>
+            <div class="avenant-panel-section">
+              <h3 class="text-sm font-semibold text-gray-700 dark:text-neutral-300 mb-3">Rémunération</h3>
+              <div class="space-y-3">
+                <div>
+                  <span class="block text-xs mb-2">Temps partiel ?</span>
+                  <div class="flex gap-4">
+                    <label class="inline-flex items-center gap-2"><input type="radio" name="temps_partiel_cdi_<?php echo $s; ?>" value="non" checked class="tp-cdi" data-side="<?php echo $s; ?>"> Non</label>
+                    <label class="inline-flex items-center gap-2"><input type="radio" name="temps_partiel_cdi_<?php echo $s; ?>" value="oui" class="tp-cdi" data-side="<?php echo $s; ?>"> Oui</label>
                   </div>
-                  
-                  <!-- Deuxième ligne -->
-                  <div class="grid grid-cols-2 gap-6">
-                    <!-- Email personnel -->
-                    <div>
-                      <label for="email_perso_left" class="block text-sm font-medium mb-2 dark:text-white">
-                        Email personnel
-                      </label>
-                      <input type="email" id="email_perso_left" name="email_perso_left" value="jean.dupont@gmail.com"
-                        class="py-2.5 sm:py-3 px-4 block w-full border border-gray-200 rounded-lg sm:text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600"
-                        placeholder="jean.dupont@gmail.com">
-                    </div>
-                    
-                    <!-- Numéro de téléphone -->
-                    <div>
-                      <label for="telephone_left" class="block text-sm font-medium mb-2 dark:text-white">
-                        Numéro de téléphone
-                      </label>
-                      <input type="tel" id="telephone_left" name="telephone_left" value="06 12 34 56 78"
-                        class="py-2.5 sm:py-3 px-4 block w-full border border-gray-200 rounded-lg sm:text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600"
-                        placeholder="06 12 34 56 78">
-                    </div>
+                </div>
+                <div id="tp-oui-cdi-<?php echo $s; ?>" class="conditional-field space-y-2">
+                  <label class="block text-xs">Salaire temps partiel brut mensuel (€)</label>
+                  <input type="text" name="salaire_tp_cdi_<?php echo $s; ?>" class="py-2 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" placeholder="0.00">
+                  <label class="block text-xs">Base horaire (h / semaine)</label>
+                  <input type="text" name="base_horaire_tp_cdi_<?php echo $s; ?>" placeholder="ex. 27" class="py-2 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
+                </div>
+                <div id="tp-non-cdi-<?php echo $s; ?>" class="space-y-2">
+                  <label class="block text-xs">Base horaire</label>
+                  <select name="base_horaire_cdi_<?php echo $s; ?>" class="base-horaire-cdi py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" data-side="<?php echo $s; ?>">
+                    <option value="">Sélectionner</option>
+                    <option value="35">35h</option>
+                    <option value="37">37h</option>
+                    <option value="39">39h (forfait)</option>
+                  </select>
+                  <label class="block text-xs">Salaire mensuel brut</label>
+                  <input type="text" name="salaire_cdi_<?php echo $s; ?>" class="salaire-cdi py-2 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" data-side="<?php echo $s; ?>" placeholder="0.00">
+                  <label class="block text-xs">Équivalent 35h (calculé)</label>
+                  <input type="text" readonly name="salaire_35h_cdi_<?php echo $s; ?>" class="readonly-field salaire-35h-cdi py-2 px-3 w-full border rounded-lg text-sm dark:border-neutral-700" data-side="<?php echo $s; ?>">
+                </div>
+                <div>
+                  <span class="block text-xs mb-2">Rémunération variable ?</span>
+                  <div class="flex gap-4">
+                    <label class="inline-flex items-center gap-2"><input type="radio" name="rem_var_cdi_<?php echo $s; ?>" value="non" checked class="rem-var-cdi" data-side="<?php echo $s; ?>"> Non</label>
+                    <label class="inline-flex items-center gap-2"><input type="radio" name="rem_var_cdi_<?php echo $s; ?>" value="oui" class="rem-var-cdi" data-side="<?php echo $s; ?>"> Oui</label>
+                  </div>
+                </div>
+                <div>
+                  <span class="block text-xs mb-2">Garantie de salaire ?</span>
+                  <div class="flex gap-4">
+                    <label class="inline-flex items-center gap-2"><input type="radio" name="garantie_cdi_<?php echo $s; ?>" value="non" checked class="gar-cdi" data-side="<?php echo $s; ?>"> Non</label>
+                    <label class="inline-flex items-center gap-2"><input type="radio" name="garantie_cdi_<?php echo $s; ?>" value="oui" class="gar-cdi" data-side="<?php echo $s; ?>"> Oui</label>
                   </div>
                 </div>
+                <div id="gar-detail-cdi-<?php echo $s; ?>" class="conditional-field grid grid-cols-1 gap-2">
+                  <label class="text-xs">Montant brut (€ / mois)</label>
+                  <input type="text" name="garantie_montant_cdi_<?php echo $s; ?>" class="py-2 px-3 border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
+                  <label class="text-xs">Durée de la garantie</label>
+                  <select name="garantie_duree_cdi_<?php echo $s; ?>" class="py-2 px-3 border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
+                    <option value="">Sélectionner</option>
+                    <option value="3m">3 mois</option>
+                    <option value="6m">6 mois</option>
+                    <option value="12m">12 mois</option>
+                  </select>
+                </div>
+                <div>
+                  <span class="block text-xs mb-2">Véhicule de fonction ?</span>
+                  <div class="flex gap-4">
+                    <label class="inline-flex items-center gap-2"><input type="radio" name="vehicule_cdi_<?php echo $s; ?>" value="non" checked class="veh-cdi" data-side="<?php echo $s; ?>"> Non</label>
+                    <label class="inline-flex items-center gap-2"><input type="radio" name="vehicule_cdi_<?php echo $s; ?>" value="oui" class="veh-cdi" data-side="<?php echo $s; ?>"> Oui</label>
+                  </div>
+                </div>
+                <div id="veh-detail-cdi-<?php echo $s; ?>" class="conditional-field">
+                  <label class="text-xs">Avantages en nature (€ / mois)</label>
+                  <input type="text" name="avantages_nature_cdi_<?php echo $s; ?>" class="py-2 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" placeholder="0.00">
+                </div>
               </div>
             </div>
-            
-            <!-- Boutons d'action pour le formulaire de gauche -->
-            <div class="flex justify-end gap-3">
-              <button type="button" class="py-3 px-4 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-gray-200 bg-white text-gray-800 shadow-sm hover:bg-gray-50 focus:outline-hidden focus:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-800 dark:border-neutral-700 dark:text-white dark:hover:bg-neutral-700 dark:focus:bg-neutral-700">
-                Annuler
-              </button>
-              <button type="submit" class="py-3 px-4 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-[#21B6BA] text-white hover:bg-[#1AA5A9] focus:outline-hidden focus:bg-[#1AA5A9] disabled:opacity-50 disabled:pointer-events-none">
-                Soumettre
-              </button>
+          </div>
+          <?php } ?>
+        </div>
+      </div>
+
+      <!-- 4b. Section CDD pré/post -->
+      <div id="bloc-section-cdd" class="space-y-4 hidden">
+        <h2 class="text-lg font-semibold text-gray-800 dark:text-white px-1">Section CDD</h2>
+        <div class="grid grid-cols-1 xl:grid-cols-2 gap-4">
+          <?php
+          foreach ([['pre','Pré-avenant','panel-pre-avenant'],['post','Post-avenant','panel-post-avenant']] as $t) {
+            $s = $t[0]; $label = $t[1]; $panel = $t[2];
+          ?>
+          <div class="rounded-xl border-2 p-4 md:p-6 space-y-6 <?php echo $panel; ?>">
+            <p class="text-sm font-bold text-gray-800 dark:text-white border-b border-gray-300/50 dark:border-neutral-600 pb-2"><?php echo htmlspecialchars($label); ?></p>
+
+            <div class="avenant-panel-section">
+              <h3 class="text-sm font-semibold mb-3 text-gray-700 dark:text-neutral-300">Planning</h3>
+              <label class="inline-flex items-center gap-2">
+                <input type="checkbox" name="samedi_cdd_<?php echo $s; ?>" value="1" class="rounded border-gray-200">
+                <span class="text-sm text-gray-700 dark:text-neutral-300">Samedi travaillé ?</span>
+              </label>
+            </div>
+
+            <div class="avenant-panel-section">
+              <h3 class="text-sm font-semibold mb-3 text-gray-700 dark:text-neutral-300">Dates du contrat</h3>
+              <div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
+                <div>
+                  <label class="block text-xs">Date début contrat</label>
+                  <input type="text" name="date_debut_cdd_<?php echo $s; ?>" class="fp-date py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" placeholder="jj/mm/aaaa">
+                </div>
+                <div>
+                  <label class="block text-xs">Date de sortie</label>
+                  <input type="text" name="date_sortie_cdd_<?php echo $s; ?>" class="fp-date py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" placeholder="jj/mm/aaaa">
+                </div>
+              </div>
             </div>
-          </form>
-
-          <!-- Formulaire de droite -->
-          <form id="avenant-form-right" class="space-y-6">
-            <div class="bg-white border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-800 dark:border-neutral-700 animate-fade-in-up">
-              <div class="p-10">
-                <h2 class="text-lg font-semibold text-gray-800 dark:text-white mb-6">Informations personnelles</h2>
-                
-                <!-- Grille de 2 colonnes - 2 inputs par ligne -->
-                <div class="space-y-6">
-                  <!-- Première ligne -->
-                  <div class="grid grid-cols-2 gap-6">
-                    <!-- Date de naissance -->
-                    <div>
-                      <label for="date_naissance_right" class="block text-sm font-medium mb-2 text-gray-700 dark:text-neutral-300">
-                        Date de naissance <span class="text-red-500">*</span>
-                      </label>
-                      <div class="relative">
-                        <input type="text" id="date_naissance_right" name="date_naissance_right" required value="01/01/2000"
-                          class="py-3 px-4 pe-11 block w-full border border-gray-200 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600"
-                          placeholder="Sélectionner une date">
-                        <div class="absolute inset-y-0 end-0 flex items-center pointer-events-none pe-4">
-                          <svg class="shrink-0 size-4 text-gray-500 dark:text-neutral-400" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
-                            <rect width="18" height="18" x="3" y="4" rx="2" ry="2"></rect>
-                            <line x1="16" x2="16" y1="2" y2="6"></line>
-                            <line x1="8" x2="8" y1="2" y2="6"></line>
-                            <line x1="3" x2="21" y1="10" y2="10"></line>
-                          </svg>
-                        </div>
-                      </div>
-                    </div>
-                    
-                    <!-- Email professionnel -->
-                    <div>
-                      <label for="email_pro_right" class="block text-sm font-medium mb-2 dark:text-white">
-                        Adresse mail professionnelle (Office 365) <span class="text-red-500">*</span>
-                      </label>
-                      <input type="email" id="email_pro_right" name="email_pro_right" required value="jean.dupont@sipa.fr"
-                        class="py-2.5 sm:py-3 px-4 block w-full border border-gray-200 rounded-lg sm:text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600"
-                        placeholder="jean.dupont@sipa.fr">
-                      <p class="text-xs text-gray-500 mt-1 dark:text-neutral-500">Email généré automatiquement</p>
-                    </div>
+
+            <div class="avenant-panel-section">
+              <h3 class="text-sm font-semibold mb-3 text-gray-700 dark:text-neutral-300">Manager</h3>
+              <div class="space-y-3">
+                <input type="text" name="manager_cdd_<?php echo $s; ?>" placeholder="Manager" class="py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
+                <div>
+                  <span class="block text-xs mb-2">Sera-t-il lui-même manager ?</span>
+                  <div class="flex gap-4">
+                    <label class="inline-flex items-center gap-2"><input type="radio" name="est_manager_cdd_<?php echo $s; ?>" value="oui" class="est-cdd" data-side="<?php echo $s; ?>"> Oui</label>
+                    <label class="inline-flex items-center gap-2"><input type="radio" name="est_manager_cdd_<?php echo $s; ?>" value="non" checked class="est-cdd" data-side="<?php echo $s; ?>"> Non</label>
                   </div>
-                  
-                  <!-- Deuxième ligne -->
-                  <div class="grid grid-cols-2 gap-6">
-                    <!-- Email personnel -->
-                    <div>
-                      <label for="email_perso_right" class="block text-sm font-medium mb-2 dark:text-white">
-                        Email personnel
-                      </label>
-                      <input type="email" id="email_perso_right" name="email_perso_right" value="jean.dupont@gmail.com"
-                        class="py-2.5 sm:py-3 px-4 block w-full border border-gray-200 rounded-lg sm:text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600"
-                        placeholder="jean.dupont@gmail.com">
-                    </div>
-                    
-                    <!-- Numéro de téléphone -->
-                    <div>
-                      <label for="telephone_right" class="block text-sm font-medium mb-2 dark:text-white">
-                        Numéro de téléphone
-                      </label>
-                      <input type="tel" id="telephone_right" name="telephone_right" value="06 12 34 56 78"
-                        class="py-2.5 sm:py-3 px-4 block w-full border border-gray-200 rounded-lg sm:text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600"
-                        placeholder="06 12 34 56 78">
-                    </div>
+                </div>
+                <div id="wrap-supervisees-cdd-<?php echo $s; ?>" class="conditional-field">
+                  <div class="flex gap-2">
+                    <input type="text" id="input-supervisee-cdd-<?php echo $s; ?>" placeholder="Prénom NOM" class="flex-1 py-2 px-3 border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
+                    <button type="button" class="btn-add-supervisee px-3 py-2 bg-[#21B6BA] text-white rounded-lg text-sm" data-target="cdd-<?php echo $s; ?>">Ajouter</button>
                   </div>
+                  <div id="badges-cdd-<?php echo $s; ?>" class="flex flex-wrap gap-2 mt-2 min-h-[36px]"></div>
+                  <input type="hidden" name="personnes_supervisees_cdd_<?php echo $s; ?>" id="hidden-supervisees-cdd-<?php echo $s; ?>" value="">
                 </div>
               </div>
             </div>
-            
-            <!-- Boutons d'action pour le formulaire de droite -->
-            <div class="flex justify-end gap-3">
-              <button type="button" class="py-3 px-4 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-gray-200 bg-white text-gray-800 shadow-sm hover:bg-gray-50 focus:outline-hidden focus:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-800 dark:border-neutral-700 dark:text-white dark:hover:bg-neutral-700 dark:focus:bg-neutral-700">
-                Annuler
-              </button>
-              <button type="submit" class="py-3 px-4 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-[#21B6BA] text-white hover:bg-[#1AA5A9] focus:outline-hidden focus:bg-[#1AA5A9] disabled:opacity-50 disabled:pointer-events-none">
-                Soumettre
-              </button>
+
+            <div class="avenant-panel-section">
+              <h3 class="text-sm font-semibold mb-3 text-gray-700 dark:text-neutral-300">Contrat</h3>
+              <div class="grid grid-cols-1 gap-3">
+                <select name="service_cdd_<?php echo $s; ?>" class="py-2.5 px-3 w-full border rounded-lg text-sm bg-white dark:bg-neutral-900 dark:border-neutral-700">
+                  <option value="">Service</option>
+                  <option value="vente_pra">Vente P.R.A.</option>
+                  <option value="pieces">Pièces</option>
+                </select>
+                <select name="intitule_cdd_<?php echo $s; ?>" class="py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
+                  <option value="">Intitulé de poste</option>
+                  <option value="conseiller">Conseiller commercial</option>
+                </select>
+                <select name="statut_cdd_<?php echo $s; ?>" class="py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
+                  <option value="">Statut</option>
+                  <option value="employe">Employé</option>
+                  <option value="cadre">Cadre</option>
+                </select>
+                <select name="echelon_cdd_<?php echo $s; ?>" class="echelon-select py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" data-side="<?php echo $s; ?>" data-context="cdd">
+                  <option value="">Échelon</option>
+                  <option value="III_A">III A</option>
+                  <option value="III_B">III B</option>
+                </select>
+                <div class="rounded-lg border overflow-hidden text-xs" id="minima-cdd-<?php echo $s; ?>">
+                  <table class="w-full"><thead class="bg-gray-100 dark:bg-neutral-800"><tr>
+                    <th class="p-2 text-left">Échelon</th><th class="p-2">35h</th><th class="p-2">37h</th><th class="p-2">39h</th>
+                  </tr></thead><tbody class="dark:bg-neutral-900"><tr><td class="p-2">—</td><td class="p-2">—</td><td class="p-2">—</td><td class="p-2">—</td></tr></tbody></table>
+                </div>
+              </div>
             </div>
-          </form>
-          
+
+            <div class="avenant-panel-section">
+              <h3 class="text-sm font-semibold mb-3 text-gray-700 dark:text-neutral-300">Rémunération</h3>
+              <div class="space-y-3">
+                <div class="flex gap-4 text-sm">
+                  <label class="inline-flex items-center gap-2"><input type="radio" name="temps_partiel_cdd_<?php echo $s; ?>" value="non" checked class="tp-cdd" data-side="<?php echo $s; ?>"> Temps plein</label>
+                  <label class="inline-flex items-center gap-2"><input type="radio" name="temps_partiel_cdd_<?php echo $s; ?>" value="oui" class="tp-cdd" data-side="<?php echo $s; ?>"> Temps partiel</label>
+                </div>
+                <div id="tp-oui-cdd-<?php echo $s; ?>" class="conditional-field space-y-2">
+                  <label class="block text-xs">Salaire temps partiel brut mensuel (€)</label>
+                  <input type="text" name="salaire_tp_cdd_<?php echo $s; ?>" class="py-2 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" placeholder="0.00">
+                  <label class="block text-xs">Base horaire (h / semaine)</label>
+                  <input type="text" name="base_tp_cdd_<?php echo $s; ?>" placeholder="ex. 27" class="py-2 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
+                </div>
+                <div id="tp-non-cdd-<?php echo $s; ?>" class="space-y-2">
+                  <label class="block text-xs">Base horaire</label>
+                  <select name="base_horaire_cdd_<?php echo $s; ?>" class="base-horaire-cdd py-2.5 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" data-side="<?php echo $s; ?>">
+                    <option value="">Sélectionner</option>
+                    <option value="35">35h</option>
+                    <option value="37">37h</option>
+                    <option value="39">39h (forfait)</option>
+                  </select>
+                  <label class="block text-xs">Salaire mensuel brut</label>
+                  <input type="text" name="salaire_cdd_val_<?php echo $s; ?>" class="salaire-cdd py-2 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" data-side="<?php echo $s; ?>" placeholder="0.00">
+                  <label class="block text-xs">Équivalent 35h (calculé)</label>
+                  <input type="text" readonly class="readonly-field salaire-35h-cdd py-2 px-3 w-full border rounded-lg text-sm dark:border-neutral-700" name="salaire_35h_cdd_<?php echo $s; ?>" data-side="<?php echo $s; ?>">
+                </div>
+                <div class="flex gap-4 text-sm">
+                  <label class="inline-flex items-center gap-2"><input type="radio" name="rem_var_cdd_<?php echo $s; ?>" value="non" checked class="rem-cdd" data-side="<?php echo $s; ?>"> Rém. variable Non</label>
+                  <label class="inline-flex items-center gap-2"><input type="radio" name="rem_var_cdd_<?php echo $s; ?>" value="oui" class="rem-cdd" data-side="<?php echo $s; ?>"> Oui</label>
+                </div>
+                <div class="flex gap-4 text-sm">
+                  <label class="inline-flex items-center gap-2"><input type="radio" name="garantie_cdd_<?php echo $s; ?>" value="non" checked class="gar-cdd" data-side="<?php echo $s; ?>"> Garantie Non</label>
+                  <label class="inline-flex items-center gap-2"><input type="radio" name="garantie_cdd_<?php echo $s; ?>" value="oui" class="gar-cdd" data-side="<?php echo $s; ?>"> Oui</label>
+                </div>
+                <div id="gar-detail-cdd-<?php echo $s; ?>" class="conditional-field grid gap-2">
+                  <input type="text" name="garantie_montant_cdd_<?php echo $s; ?>" placeholder="Montant €/mois" class="py-2 px-3 border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
+                  <select name="garantie_duree_cdd_<?php echo $s; ?>" class="py-2 px-3 border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
+                    <option value="">Durée garantie</option>
+                    <option value="3m">3 mois</option>
+                    <option value="6m">6 mois</option>
+                  </select>
+                </div>
+                <div class="flex gap-4 text-sm">
+                  <label class="inline-flex items-center gap-2"><input type="radio" name="vehicule_cdd_<?php echo $s; ?>" value="non" checked class="veh-cdd" data-side="<?php echo $s; ?>"> Véhicule Non</label>
+                  <label class="inline-flex items-center gap-2"><input type="radio" name="vehicule_cdd_<?php echo $s; ?>" value="oui" class="veh-cdd" data-side="<?php echo $s; ?>"> Oui</label>
+                </div>
+                <div id="veh-detail-cdd-<?php echo $s; ?>" class="conditional-field">
+                  <input type="text" name="avantages_nature_cdd_<?php echo $s; ?>" placeholder="Avantages en nature €/mois" class="py-2 px-3 w-full border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
+                </div>
+              </div>
+            </div>
+          </div>
+          <?php } ?>
         </div>
       </div>
-    </div>
 
-    <!-- Flatpickr JS -->
-    <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
-    <script src="https://cdn.jsdelivr.net/npm/flatpickr/dist/l10n/fr.js"></script>
-    
-    <!-- Preline JS -->
-    <script src="https://cdn.jsdelivr.net/npm/preline/dist/preline.js"></script>
-    
-    <!-- Script pour initialiser les datepickers -->
-    <script>
-      document.addEventListener('DOMContentLoaded', function() {
-        // Initialiser Flatpickr pour les champs de date
-        if (document.getElementById('date_naissance_left')) {
-          flatpickr('#date_naissance_left', {
-            locale: 'fr',
-            dateFormat: 'd/m/Y',
-            allowInput: true,
-            defaultDate: '01/01/2000'
-          });
-        }
-        
-        if (document.getElementById('date_naissance_right')) {
-          flatpickr('#date_naissance_right', {
-            locale: 'fr',
-            dateFormat: 'd/m/Y',
-            allowInput: true,
-            defaultDate: '01/01/2000'
-          });
-        }
+      <!-- Justification RH -->
+      <div class="bg-white border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-800 dark:border-neutral-700">
+        <div class="p-6">
+          <h2 class="text-lg font-semibold text-[#21B6BA] mb-3">Justification à destination des RH</h2>
+          <textarea name="commentaires_rh" id="justification_rh" rows="4" class="py-3 px-4 w-full border border-gray-200 rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" placeholder="Contexte et motifs de la demande pour les ressources humaines"></textarea>
+        </div>
+      </div>
+      <div class="bg-white border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-800 dark:border-neutral-700">
+        <div class="p-6 space-y-8">
+          <h2 class="text-lg font-semibold text-gray-800 dark:text-white">Informatique</h2>
+
+          <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
+            <div>
+              <label class="block text-xs mb-1">Compte Windows</label>
+              <div class="flex gap-2">
+                <input type="text" id="compte_windows" readonly class="readonly-field flex-1 py-2 px-3 border rounded-lg text-sm dark:border-neutral-700" value="jean.dupont">
+                <button type="button" onclick="copier('compte_windows', event)" class="px-3 py-2 bg-[#21B6BA] text-white rounded-lg text-sm shrink-0">Copier</button>
+              </div>
+            </div>
+            <div>
+              <label class="block text-xs mb-1">Office 365</label>
+              <div class="flex gap-2">
+                <input type="text" id="compte_o365" readonly class="readonly-field flex-1 py-2 px-3 border rounded-lg text-sm dark:border-neutral-700" value="jean.dupont@sipa-automobiles.fr">
+                <button type="button" onclick="copier('compte_o365', event)" class="px-3 py-2 bg-[#21B6BA] text-white rounded-lg text-sm shrink-0">Copier</button>
+              </div>
+            </div>
+            <div>
+              <label class="block text-xs mb-1">Mot de passe temporaire</label>
+              <div class="flex gap-2">
+                <input type="text" id="mdp_temp" readonly class="readonly-field flex-1 py-2 px-3 border rounded-lg text-sm dark:border-neutral-700" value="(renseigné par l’IT)">
+                <button type="button" onclick="copier('mdp_temp', event)" class="px-3 py-2 bg-[#21B6BA] text-white rounded-lg text-sm shrink-0">Copier</button>
+              </div>
+            </div>
+          </div>
+
+          <?php
+          if (!function_exists('it_toggle_block')) {
+            function it_toggle_block($id, $title) {
+              echo '<div class="border-t border-gray-200 dark:border-neutral-700 pt-6">';
+              echo '<div class="flex items-center gap-3 mb-3"><h3 class="text-base font-semibold text-gray-800 dark:text-white">' . htmlspecialchars($title) . '</h3>';
+              echo '<label class="relative inline-flex items-center cursor-pointer"><input type="checkbox" class="sr-only peer it-toggle" data-target="' . htmlspecialchars($id) . '">';
+              echo '<div class="relative w-11 h-6 bg-gray-200 rounded-full peer dark:bg-neutral-600 peer-checked:after:translate-x-full peer-checked:bg-[#21B6BA] peer-focus:ring-4 peer-focus:ring-[#21B6BA]/30 after:content-[\'\'] after:absolute after:top-[2px] after:start-[2px] after:h-5 after:w-5 after:bg-white after:border after:rounded-full after:transition-all"></div></label></div>';
+              echo '<div id="' . htmlspecialchars($id) . '" class="it-panel space-y-4 border border-dashed border-gray-200 dark:border-neutral-600 rounded-lg p-4 hidden">';
+            }
+          }
+          it_toggle_block('panel-mobile', 'Téléphone mobile');
+          ?>
+            <div>
+              <span class="text-sm block mb-2">Récupère-t-il le mobile d’un collaborateur ?</span>
+              <div class="flex gap-4 mb-2">
+                <label class="inline-flex items-center gap-2"><input type="radio" name="recup_mobile" value="oui"> Oui</label>
+                <label class="inline-flex items-center gap-2"><input type="radio" name="recup_mobile" value="non" checked> Non</label>
+              </div>
+              <input type="text" name="ancien_collab_mobile" placeholder="Nom de l’ancien collaborateur" class="py-2 px-3 w-full max-w-md border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
+              <p class="text-xs text-gray-500 mt-2">Si Non :</p>
+              <div class="flex gap-4 mt-1">
+                <label class="inline-flex items-center gap-2"><input type="radio" name="type_mobile" value="iphone"> iPhone</label>
+                <label class="inline-flex items-center gap-2"><input type="radio" name="type_mobile" value="android"> Android</label>
+              </div>
+            </div>
+          </div>
+          </div>
+
+          <?php it_toggle_block('panel-fixe', 'Téléphone fixe'); ?>
+            <div>
+              <div class="flex gap-4 mb-2">
+                <label class="inline-flex items-center gap-2"><input type="radio" name="recup_fixe" value="oui"> Récupère le fixe d’un collab.</label>
+                <label class="inline-flex items-center gap-2"><input type="radio" name="recup_fixe" value="non" checked> Non</label>
+              </div>
+              <input type="text" name="ancien_collab_fixe" placeholder="Recherche AD" class="py-2 px-3 w-full max-w-md border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700 mb-2">
+              <div class="flex gap-4">
+                <label class="inline-flex items-center gap-2"><input type="radio" name="type_fixe" value="classique"> Poste classique</label>
+                <label class="inline-flex items-center gap-2"><input type="radio" name="type_fixe" value="sansfil"> Poste sans fil</label>
+              </div>
+            </div>
+          </div>
+          </div>
+
+          <?php it_toggle_block('panel-pc', 'Ordinateur'); ?>
+            <div class="space-y-3">
+              <div class="flex gap-4">
+                <label class="inline-flex items-center gap-2"><input type="radio" name="recup_pc" value="oui"> Récupère le PC d’un collab.</label>
+                <label class="inline-flex items-center gap-2"><input type="radio" name="recup_pc" value="non" checked> Non</label>
+              </div>
+              <input type="text" name="ancien_collab_pc" placeholder="Nom ancien collaborateur (AD)" class="py-2 px-3 w-full max-w-md border rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700">
+              <div class="flex gap-4">
+                <label class="inline-flex items-center gap-2"><input type="radio" name="type_pc" value="fixe"> PC fixe</label>
+                <label class="inline-flex items-center gap-2"><input type="radio" name="type_pc" value="portable"> PC portable</label>
+              </div>
+              <div>
+                <span class="text-sm">Écran supplémentaire ?</span>
+                <div class="flex gap-4 mt-1">
+                  <label class="inline-flex items-center gap-2"><input type="radio" name="ecran_supp" value="oui"> Oui</label>
+                  <label class="inline-flex items-center gap-2"><input type="radio" name="ecran_supp" value="non" checked> Non</label>
+                </div>
+              </div>
+            </div>
+          </div>
+          </div>
+
+          <div>
+            <h3 class="text-sm font-semibold mb-3">Accès logiciels (par catégorie)</h3>
+            <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 text-sm">
+              <?php foreach (['dms'=>'DMS','commerce'=>'Commerce','compta'=>'Comptabilité','atelier'=>'Atelier','dsi'=>'DSI','crc'=>'CRC'] as $k=>$lab): ?>
+              <div>
+                <label class="block text-xs mb-1"><?php echo htmlspecialchars($lab); ?></label>
+                <select name="logiciel_<?php echo $k; ?>" class="py-2 px-2 w-full border rounded-lg dark:bg-neutral-900 dark:border-neutral-700">
+                  <option value="">Niveau d’accès</option>
+                  <option value="aucun">Aucun</option>
+                  <option value="lecture">Lecture</option>
+                  <option value="ecriture">Écriture</option>
+                  <option value="admin">Admin</option>
+                </select>
+              </div>
+              <?php endforeach; ?>
+            </div>
+          </div>
+
+          <?php it_toggle_block('panel-messagerie', 'Messagerie'); ?>
+            <div class="space-y-3">
+              <div>
+                <label class="block text-xs mb-1">Liste de diffusion groupe SIPA</label>
+                <select name="ld_sipa" class="py-2 px-3 w-full max-w-lg border rounded-lg dark:bg-neutral-900 dark:border-neutral-700">
+                  <option value="">(optionnel)</option>
+                  <option value="ld_mds">LD_MDS</option>
+                  <option value="ld_directeurs">LD_DIRECTEURS</option>
+                </select>
+              </div>
+              <div>
+                <label class="block text-xs mb-1">Liste de diffusion du site</label>
+                <select name="ld_site" class="py-2 px-3 w-full max-w-lg border rounded-lg dark:bg-neutral-900 dark:border-neutral-700">
+                  <option value="">(optionnel)</option>
+                  <option value="ld_magasin">LD_MAGASIN_AUTO_33</option>
+                  <option value="ld_sav">LD_SAV_AUTO_33</option>
+                </select>
+              </div>
+              <div>
+                <span class="text-sm">Redirection boîte mail d’un autre collaborateur ?</span>
+                <div class="flex gap-4 mt-1">
+                  <label class="inline-flex items-center gap-2"><input type="radio" name="redirect_mail" value="oui"> Oui</label>
+                  <label class="inline-flex items-center gap-2"><input type="radio" name="redirect_mail" value="non" checked> Non</label>
+                </div>
+              </div>
+              <div>
+                <label class="block text-xs mb-1">Intitulé pour la signature</label>
+                <input type="text" name="intitule_signature_it" class="py-2 px-3 w-full max-w-lg border rounded-lg dark:bg-neutral-900 dark:border-neutral-700" placeholder="Ex. Responsable commercial">
+              </div>
+            </div>
+          </div>
+          </div>
+
+        </div>
+      </div>
+
+      <!-- Commentaires IT -->
+      <div class="bg-white border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-800 dark:border-neutral-700">
+        <div class="p-6">
+          <h2 class="text-lg font-semibold text-gray-800 dark:text-white mb-3">Commentaires IT</h2>
+          <textarea name="commentaires_it" rows="3" class="py-3 px-4 w-full border border-gray-200 rounded-lg text-sm dark:bg-neutral-900 dark:border-neutral-700" placeholder="Réservé à l’IT"></textarea>
+        </div>
+      </div>
+
+      <div class="flex flex-wrap justify-end gap-3 pb-12">
+        <button type="button" class="py-3 px-4 text-sm font-medium rounded-lg border border-gray-200 bg-white dark:bg-neutral-800 dark:border-neutral-700">Annuler</button>
+        <button type="submit" class="py-3 px-4 text-sm font-medium rounded-lg bg-[#21B6BA] text-white hover:bg-[#1AA5A9]">Soumettre la demande</button>
+      </div>
+    </form>
+  </div>
+</div>
+
+<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
+<script src="https://cdn.jsdelivr.net/npm/flatpickr/dist/l10n/fr.js"></script>
+<script src="https://cdn.jsdelivr.net/npm/preline/dist/preline.js"></script>
+<script>
+(function() {
+  const MINIMA = {
+    III_A: ['3804', '4075,61', '4347,21'],
+    III_B: ['4093', '4385,24', '4677,48'],
+    III_C: ['4383', '4695,95', '5008,89']
+  };
+
+  function majTableauMinima(sel) {
+    const side = sel.dataset.side;
+    const ctx = sel.dataset.context;
+    const id = ctx === 'cdi' ? 'minima-cdi-' + side : 'minima-cdd-' + side;
+    const wrap = document.getElementById(id);
+    if (!wrap) return;
+    const v = sel.value;
+    const row = MINIMA[v];
+    const tb = wrap.querySelector('tbody');
+    if (row && tb) {
+      tb.innerHTML = '<tr><td class="p-2 font-medium">' + v.replace('_',' ') + '</td><td class="p-2">' + row[0] + '</td><td class="p-2">' + row[1] + '</td><td class="p-2">' + row[2] + '</td></tr>';
+    } else if (tb) {
+      tb.innerHTML = '<tr><td class="p-2">—</td><td class="p-2">—</td><td class="p-2">—</td><td class="p-2">—</td></tr>';
+    }
+  }
+
+  function calc35(salaireEl, baseEl, outEl) {
+    const salaire = parseFloat(String(salaireEl.value).replace(',', '.'));
+    const opt = baseEl.options[baseEl.selectedIndex];
+    if (!salaire || !opt || !opt.value) { outEl.value = ''; return; }
+    let h = parseFloat(opt.value);
+    if (opt.value === '39') h = 37.5;
+    if (h === 35) outEl.value = salaire.toFixed(2);
+    else outEl.value = (salaire / h * 35).toFixed(2);
+  }
+
+  function bindGestionnaireCDI() {
+    document.querySelectorAll('.est-manager-cdi').forEach(r => {
+      r.addEventListener('change', () => {
+        const side = r.dataset.side;
+        const wrap = document.getElementById('wrap-supervisees-cdi-' + side);
+        const oui = document.querySelector('input[name="est_manager_cdi_' + side + '"]:checked')?.value === 'oui';
+        if (oui) { wrap.classList.add('is-active'); wrap.style.display = 'block'; }
+        else { wrap.classList.remove('is-active'); wrap.style.display = 'none'; }
+      });
+    });
+    document.querySelectorAll('.tp-cdi').forEach(r => {
+      r.addEventListener('change', () => {
+        const side = r.dataset.side;
+        const oui = document.querySelector('input[name="temps_partiel_cdi_' + side + '"]:checked')?.value === 'oui';
+        document.getElementById('tp-oui-cdi-' + side).classList.toggle('is-active', oui);
+        document.getElementById('tp-oui-cdi-' + side).style.display = oui ? 'block' : 'none';
+        document.getElementById('tp-non-cdi-' + side).style.display = oui ? 'none' : 'block';
+      });
+    });
+    ['rem-var-cdi','gar-cdi','veh-cdi'].forEach(cls => {
+      document.querySelectorAll('.' + cls).forEach(r => {
+        r.addEventListener('change', () => {
+          const side = r.dataset.side;
+          if (cls === 'rem-var-cdi') { /* optionnel champs */ }
+          if (cls === 'gar-cdi') {
+            const on = document.querySelector('input[name="garantie_cdi_' + side + '"]:checked')?.value === 'oui';
+            const el = document.getElementById('gar-detail-cdi-' + side);
+            el.classList.toggle('is-active', on); el.style.display = on ? 'grid' : 'none';
+          }
+          if (cls === 'veh-cdi') {
+            const on = document.querySelector('input[name="vehicule_cdi_' + side + '"]:checked')?.value === 'oui';
+            const el = document.getElementById('veh-detail-cdi-' + side);
+            el.classList.toggle('is-active', on); el.style.display = on ? 'block' : 'none';
+          }
+        });
+      });
+    });
+    document.querySelectorAll('.base-horaire-cdi').forEach(b => {
+      b.addEventListener('change', () => {
+        const side = b.dataset.side;
+        calc35(document.querySelector('.salaire-cdi[data-side="' + side + '"]'), b, document.querySelector('.salaire-35h-cdi[data-side="' + side + '"]'));
+      });
+    });
+    document.querySelectorAll('.salaire-cdi').forEach(s => {
+      s.addEventListener('input', () => {
+        const side = s.dataset.side;
+        calc35(s, document.querySelector('.base-horaire-cdi[data-side="' + side + '"]'), document.querySelector('.salaire-35h-cdi[data-side="' + side + '"]'));
+      });
+    });
+  }
+
+  function bindCDD() {
+    document.querySelectorAll('.est-cdd').forEach(r => {
+      r.addEventListener('change', () => {
+        const side = r.dataset.side;
+        const on = document.querySelector('input[name="est_manager_cdd_' + side + '"]:checked')?.value === 'oui';
+        const w = document.getElementById('wrap-supervisees-cdd-' + side);
+        w.classList.toggle('is-active', on); w.style.display = on ? 'block' : 'none';
+      });
+    });
+    document.querySelectorAll('.tp-cdd').forEach(r => {
+      r.addEventListener('change', () => {
+        const side = r.dataset.side;
+        const oui = document.querySelector('input[name="temps_partiel_cdd_' + side + '"]:checked')?.value === 'oui';
+        document.getElementById('tp-oui-cdd-' + side).classList.toggle('is-active', oui);
+        document.getElementById('tp-oui-cdd-' + side).style.display = oui ? 'block' : 'none';
+        document.getElementById('tp-non-cdd-' + side).style.display = oui ? 'none' : 'block';
+      });
+    });
+    document.querySelectorAll('.gar-cdd').forEach(r => {
+      r.addEventListener('change', () => {
+        const side = r.dataset.side;
+        const on = document.querySelector('input[name="garantie_cdd_' + side + '"]:checked')?.value === 'oui';
+        const el = document.getElementById('gar-detail-cdd-' + side);
+        el.classList.toggle('is-active', on); el.style.display = on ? 'grid' : 'none';
+      });
+    });
+    document.querySelectorAll('.veh-cdd').forEach(r => {
+      r.addEventListener('change', () => {
+        const side = r.dataset.side;
+        const on = document.querySelector('input[name="vehicule_cdd_' + side + '"]:checked')?.value === 'oui';
+        const el = document.getElementById('veh-detail-cdd-' + side);
+        if (el) { el.classList.toggle('is-active', on); el.style.display = on ? 'block' : 'none'; }
+      });
+    });
+    document.querySelectorAll('.base-horaire-cdd').forEach(b => {
+      b.addEventListener('change', () => {
+        const side = b.dataset.side;
+        calc35(
+          document.querySelector('.salaire-cdd[data-side="' + side + '"]'),
+          b,
+          document.querySelector('.salaire-35h-cdd[data-side="' + side + '"]')
+        );
+      });
+    });
+    document.querySelectorAll('.salaire-cdd').forEach(s => {
+      s.addEventListener('input', () => {
+        const side = s.dataset.side;
+        calc35(s, document.querySelector('.base-horaire-cdd[data-side="' + side + '"]'), document.querySelector('.salaire-35h-cdd[data-side="' + side + '"]'));
+      });
+    });
+  }
+
+  function toggleContratType() {
+    const cdiChecked = document.getElementById('type_cdi')?.checked;
+    const elCdi = document.getElementById('bloc-section-cdi');
+    const elCdd = document.getElementById('bloc-section-cdd');
+    if (elCdi) elCdi.classList.toggle('hidden', !cdiChecked);
+    if (elCdd) elCdd.classList.toggle('hidden', !!cdiChecked);
+    if (elCdi) elCdi.querySelectorAll('input,select,textarea,button').forEach(e => { e.disabled = !cdiChecked; });
+    if (elCdd) elCdd.querySelectorAll('input,select,textarea,button').forEach(e => { e.disabled = !!cdiChecked; });
+  }
+
+  document.querySelectorAll('input[name="type_contrat_avenant"]').forEach(r => r.addEventListener('change', toggleContratType));
+
+  document.querySelectorAll('.echelon-select').forEach(s => {
+    s.addEventListener('change', () => majTableauMinima(s));
+  });
+
+  document.querySelectorAll('.btn-add-supervisee').forEach(btn => {
+    btn.addEventListener('click', () => {
+      const t = btn.dataset.target.split('-');
+      const ctx = t[0];
+      const side = t[1];
+      const inp = document.getElementById('input-supervisee-' + ctx + '-' + side);
+      const name = (inp && inp.value || '').trim();
+      if (!name) return;
+      const box = document.getElementById('badges-' + ctx + '-' + side);
+      const hid = document.getElementById('hidden-supervisees-' + ctx + '-' + side);
+      const b = document.createElement('span');
+      b.className = 'person-badge';
+      b.innerHTML = '<span class="nom-badge"></span><button type="button" class="remove" aria-label="Retirer">&times;</button>';
+      b.querySelector('.nom-badge').textContent = name;
+      b.querySelector('.remove').addEventListener('click', () => {
+        b.remove();
+        syncHid(box, hid);
       });
-    </script>
+      box.appendChild(b);
+      inp.value = '';
+      syncHid(box, hid);
+    });
+  });
+
+  function syncHid(box, hid) {
+    if (!hid) return;
+    const names = [...box.querySelectorAll('.nom-badge')].map(el => el.textContent.trim()).filter(Boolean);
+    hid.value = names.join(', ');
+  }
+
+  document.querySelectorAll('.it-toggle').forEach(t => {
+    t.addEventListener('change', () => {
+      const p = document.getElementById(t.dataset.target);
+      if (p) p.classList.toggle('hidden', !t.checked);
+    });
+  });
+
+  window.copier = function(id, evt) {
+    const el = document.getElementById(id);
+    if (!el) return;
+    navigator.clipboard.writeText(el.value).catch(() => {});
+  };
+
+  /** Si un champ *_pre ou *_post est renseigné, l’autre côté doit l’être aussi (section CDI ou CDD active uniquement). */
+  function validatePrePostMirror() {
+    const errs = [];
+    const cdiOn = document.getElementById('type_cdi')?.checked;
+    const rootId = cdiOn ? 'bloc-section-cdi' : 'bloc-section-cdd';
+    const root = document.getElementById(rootId);
+    if (!root || root.classList.contains('hidden')) return errs;
+
+    function val(el) {
+      if (!el || el.disabled) return null;
+      if (el.type === 'checkbox') return el.checked ? '1' : '';
+      return String(el.value != null ? el.value : '').trim();
+    }
+
+    const seen = new Set();
+    root.querySelectorAll('[name$="_pre"]').forEach(preEl => {
+      if (preEl.disabled || preEl.readOnly || preEl.type === 'radio' || preEl.type === 'button' || preEl.type === 'submit') return;
+      const n = preEl.name;
+      if (!n.endsWith('_pre')) return;
+      const base = n.slice(0, -4);
+      const postName = base + '_post';
+      if (seen.has(base)) return;
+      seen.add(base);
+      const postEl = Array.from(root.querySelectorAll('[name]')).find(el => el.name === postName);
+      if (!postEl || postEl.type === 'radio' || postEl.readOnly) return;
+      const pv = val(preEl);
+      const qv = val(postEl);
+      if (pv === null || qv === null) return;
+      const preEmpty = pv === '';
+      const postEmpty = qv === '';
+      if (!preEmpty && postEmpty) {
+        errs.push('« ' + base + ' » : le pré-avenant est renseigné, complétez la même information côté post-avenant.');
+      }
+      if (preEmpty && !postEmpty) {
+        errs.push('« ' + base + ' » : le post-avenant est renseigné, complétez la même information côté pré-avenant.');
+      }
+    });
+    return errs;
+  }
+
+  document.addEventListener('DOMContentLoaded', () => {
+    toggleContratType();
+    bindGestionnaireCDI();
+    bindCDD();
+
+    flatpickr('#date_effet_avenant', { locale: 'fr', dateFormat: 'd/m/Y', allowInput: true });
+    document.querySelectorAll('.fp-date').forEach(inp => flatpickr(inp, { locale: 'fr', dateFormat: 'd/m/Y', allowInput: true }));
+
+    document.querySelectorAll('.est-manager-cdi').forEach(r => r.dispatchEvent(new Event('change')));
+    document.querySelectorAll('.tp-cdi').forEach(r => r.dispatchEvent(new Event('change')));
+    document.querySelectorAll('.gar-cdi').forEach(r => r.dispatchEvent(new Event('change')));
+    document.querySelectorAll('.veh-cdi').forEach(r => r.dispatchEvent(new Event('change')));
+    document.querySelectorAll('.tp-cdd').forEach(r => r.dispatchEvent(new Event('change')));
+    document.querySelectorAll('.gar-cdd').forEach(r => r.dispatchEvent(new Event('change')));
+    document.querySelectorAll('.veh-cdd').forEach(r => r.dispatchEvent(new Event('change')));
+  });
+
+  document.getElementById('form-avenant').addEventListener('submit', e => {
+    e.preventDefault();
+    const mirrorErrs = validatePrePostMirror();
+    if (mirrorErrs.length) {
+      alert(mirrorErrs.join('\n'));
+      return;
+    }
+    if (!document.getElementById('form-avenant').checkValidity()) {
+      document.getElementById('form-avenant').reportValidity();
+      return;
+    }
+    alert('Maquette : aucun envoi réel. Brancher le traitement serveur ici.');
+  });
+})();
+</script>
 </body>
 </html>
-