/* -----------------------------------------
----                                    ----
----  EN MODE DE FONCTIONNEMENT COMMUN  ----
----                                    ----
--------------------------------------------
*/
* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f6f8;
    margin: 0;
}

/* Conteneur Principal */
.tableau {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 95%;
    max-width: 1200px;
    margin: 20px auto;
}

/* En-tête du listing */
.headerListing {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.headerListing h1 {
    color: #2c3e50;
    font-size: 1.5rem;
    margin: 0;
    border-bottom: 2px solid #478ac9;
    padding-bottom: 5px;
}

/* Bouton Créer */
.btnCreerUtilisateur {
    background-color: #478ac9;
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    transition: background-color 0.3s;
}

.btnCreerUtilisateur:hover {
    background-color: #2d6ca8;
}

/* Table Styles */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 10px;
}

th,
td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

th {
    background-color: #f8f9fa;
    color: #333;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

tr:last-child td {
    border-bottom: none;
}

/* Lignes cliquables */
tbody tr {
    cursor: pointer;
    transition: background-color 0.2s;
}

tbody tr:hover {
    background-color: #f1f5f9;
}

/* Style pour les administrateurs */
.admin-row {
    color: #d35400; /* Orange foncé */
    font-weight: bold;
}

/* Boutons de tri */
.az {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 5px;
    vertical-align: middle;
}

.az img {
    width: 16px;
    height: 16px;
}

/* --- MODALE --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 30px;
    border: 1px solid #888;
    width: 90%;
    max-width: 800px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.modal-header h2 {
    margin: 0;
    color: #2c3e50;
}

.close-modal {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close-modal:hover {
    color: #e74c3c;
}

/* Formulaire Modale */
.modal-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.full-width {
    grid-column: 1 / -1;
}

.modal-form-grid input[type="text"],
.modal-form-grid input[type="email"],
.modal-form-grid input[type="tel"],
.modal-form-grid input[type="password"],
.modal-form-grid select {
    width: 100%;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background-color: #f9fafb;
}

/* --- STYLES ACCORDÉON (Fieldset) --- */
fieldset {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px;
    background: #fafafa;
    margin-bottom: 0px;
    scroll-margin-top: 10px; /* Marge pour le scroll auto dans la modale */
}

/* Style pour les labels à l'intérieur des fieldsets */
fieldset label {
    display: block;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 8px;
}

legend {
    font-weight: 600;
    color: #4b5563;
    padding: 0 10px;
}

.mobile-toggle-checkbox {
    display: none !important;
}

.mobile-toggle-label {
    display: block;
    background-color: #e9ecef;
    color: #478ac9;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 10px;
    transition: background-color 0.3s;
    font-size: 0.9rem;
}

.mobile-toggle-label:hover {
    background-color: #dee2e6;
}

.mobile-toggle-label::after {
    content: ' ▼';
    font-size: 0.8em;
}

/* Checkboxes Container */
.checkbox-container {
    /* On retire les bordures car le fieldset les gère maintenant */
    border: none;
    padding: 0;
    max-height: none; /* On laisse le contenu s'étendre */
    overflow-y: visible;
    background: transparent;
}

.checkbox-container label {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    cursor: pointer;
    font-weight: normal;
    color: #333; /* Force la couleur du texte pour qu'il soit visible */
}

.checkbox-container input[type="checkbox"] {
    margin-right: 10px;
}

/* --- STYLE PERSONNALISÉ DES CHECKBOXES --- */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    background-color: #fff;
    margin: 0;
    margin-right: 10px;
    font: inherit;
    color: currentColor;
    width: 1.2em;
    height: 1.2em;
    border: 2px solid #478ac9;
    /* Bordure bleue */
    border-radius: 4px;
    display: grid;
    place-content: center;
    cursor: pointer;
}

input[type="checkbox"]::before {
    content: "";
    width: 0.65em;
    height: 0.65em;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    box-shadow: inset 1em 1em white;
    /* Le V blanc */
    transform-origin: center;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

input[type="checkbox"]:checked {
    background-color: #478ac9;
    /* Fond bleu quand coché */
}

input[type="checkbox"]:checked::before {
    transform: scale(1);
}

/* Style pour "Tout sélectionner" */
.label-select-all {
    color: #478ac9;
    font-weight: bold;
    margin-bottom: 10px;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

/* Conteneur des actions du bas de modale */
.modal-footer-actions {
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    margin-top: 20px;
    gap: 20px; /* Espace entre les boutons */
}

/* Bouton Sauvegarder */
.btn-save {
    background-color: #478ac9;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0; /* La marge est gérée par le conteneur */
    justify-content: center;
}

.btn-save:hover {
    background-color: #2d6ca8;
}

/* Bouton Supprimer (Poubelle) */
.btn-delete {
    background-color: #fafafa; /* Fond blanc */
    padding: 10px; /* Padding ajusté pour un bouton carré */
    border-radius: 10px; /* Coins arrondis */
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); /* Ombre */
    transition: transform 0.3s, box-shadow 0.3s;
}

.btn-delete:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-delete-icon {
    width: 30px; 
    height: 35px;
    
}

/* --------------------------------------------
----                                       ----
----  EN MODE DE FONCTIONNEMENT TELEPHONE  ----
----                                       ----
-----------------------------------------------
*/

@media screen and (max-width: 767.98px) {
    .collapsible-content {
        display: none; /* Caché par défaut sur mobile */
    }

    /* Quand on clique (checkbox cochée), on affiche le contenu */
    .mobile-toggle-checkbox:checked ~ .collapsible-content {
        display: block;
        animation: fadeIn 0.3s ease-in-out;
    }

    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(-5px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .cacher-mobile {
        display: none;
    }

    .modal-form-grid {
        grid-template-columns: 1fr;
    }

    .headerListing {
        flex-direction: column;
        text-align: center;
    }

   
}

/* -----------------------------------------
----                                    ----
----  EN MODE DE FONCTIONNEMENT PC      ----
----                                    ----
--------------------------------------------
*/

@media screen and (min-width: 768px) {
    .headerListing {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
    }

    .headerListing h1 {
        grid-column: 2;
        grid-row: 1;
    }

    .btnCreerUtilisateur {
        grid-column: 3;
        grid-row: 1;
        justify-self: end;
    }

    /* --- SPÉCIFIQUE PC : Affichage complet et 2 colonnes --- */
    .mobile-toggle-label { display: none; }
    .collapsible-content { display: block !important; }
    
    .checkbox-container {
        display: grid;
        grid-template-columns: 1fr 1fr; /* 2 colonnes */
        gap: 10px 20px;
    }
}
