/*  
STYLES CSS - Interface administrateur

Ce fichier définit les styles de l'interface administrateur.
*/

/* Styles généraux */
.admin * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Segoe UI", Tahoma, Helvetica, Arial, sans-serif;
}

.fas {
  font-family: "Font Awesome 6 Free";
}

/* === CONTENEUR PRINCIPAL === */
.admin-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

body:not(:has(.custom-tabs)) .admin-container {
    margin-top: 60px;
}

/* === CARTES === */
.card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(16, 45, 105, 0.08);
    border: 1px solid #e2e8f0;
    width: 80%;
    transition: transform 0.2s ease;
}

/* Pour ajuster la taille de la carte */
.card:first-child {
    min-height: 150px;
    max-height: calc(100vh - 270px);
}

/* Titre des cartes */
.card-title {
    margin-bottom: 20px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #102D69;
    letter-spacing: -0.01em;
}

/* En-tête des cartes */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;  
    padding: 0;
    background: transparent;
    border: none !important;
}


/* === TABS === */
/* Conteneur des onglets */
.custom-tabs {
    background-color: transparent; 
    padding-left: 25px;
    margin-bottom: 25px;
    box-shadow: none;
    border-bottom: 1px solid #edf2f7; 
    width: 100%;
    display: flex;
    justify-content: center;
}

/* Barre de navigation */
.custom-tabs .nav-tabs {
    border: none;
    gap: 30px; 
}

/* Liens des onglets */
.custom-tabs .nav-tabs .nav-link {
    color: #94a3b8; 
    background: transparent !important;
    border: none !important;
    padding: 10px 0; 
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent !important; 
}

/* Onglet actif */
.custom-tabs .nav-tabs .nav-link.active {
    color: #102D69 !important; 
    font-weight: 600;
    border-bottom: 1px solid #102D69 !important; 
}

/* Survol des onglets */
.custom-tabs .nav-tabs .nav-link.active:hover {
    color: #0A1E45 !important;
}


/* === FORMULAIRE (INPUTS et DROPDOWNS) === */
/* Conteneur global du formulaire */
.add-container {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    flex-wrap: wrap;
    width: 100%;
}

/* Label des champs */
.form-label{
    display: block;
    font-weight: 500;
    font-size: 0.88rem;
    color: #102D69;
    margin-bottom: 6px;
    margin-left: 2px;
}

/* Regroupement label + champ + champ requis + bouton ajouter */
.add-form-group, .add-form-group-button {
    display: flex;
    flex-direction: column;
    position: relative; 
    padding-bottom: 20px; 
    justify-content: flex-start;
}

.add-form-group {
    flex-grow: 1;
    width: 200px;
}

/* Champ requis */
.add-form-group .text-danger {
    position: absolute;
    bottom: 0;                
    left: 0;
    white-space: nowrap;
    line-height: 1;
    margin: 0;
}

/* --- Base commune --- */
/* Base Commune : Input et Dropdown */
.add-form-input,
.add-form-dropdown {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    color: #475569 !important;
    font-size: 14px;
    padding: 8px 12px;
    transition: all 0.2s ease-in-out;
}

/* Base Commune : Etat au survol */
.add-form-input:hover, 
.add-form-dropdown:hover {
    border-color: #102D69;
    background: #f8fafc !important;
}

/* Base Commune : Rempli - Quand l'input ou le dropdown contient du texte (sauf le custom) */
.add-form-input:not(#user-name):not(:placeholder-shown),
.add-form-dropdown:not(.is-focused):has(.Select-value) {
    background-color: #f8fafc !important;
    border: 1px solid #102D69 !important;
    border-radius: 6px;
}

/* Base Commune : Etat au focus (quand on clique pour ouvrir) */
.add-form-input:focus, 
.add-form-dropdown.is-focused {
    border: 1px solid #102D69 !important;
    box-shadow: 0 0 0 3px rgba(16, 45, 105, 0.12) !important;
    border-radius: 6px !important;
    background-color: white !important;
}

/* Base Commune : Etat Désactivé */
.add-form-input:disabled, 
.add-form-dropdown.is-disabled {
    background: #f1f5f9 !important;
    opacity: 0.7;
    cursor: not-allowed !important;
    color: #94a3b8 !important;
}

/* Base Commune : Etat invalide pour l'input classique */
/* Si le span d'erreur contient du texte, on colore l'input précédent */
.add-form-group:has(.text-danger:not(:empty)) .add-form-input,
.add-form-group:has(.text-danger:not(:empty)) .add-form-dropdown {
    border-color: #e11d48 !important;
    background-color: #fff1f2 !important;
    box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.12) !important;
}

/* --- Input standard --- */
.add-form-input {
    padding: 8px 12px;
    caret-color: #102D69;
}

/* Correction Autocomplétion navigateur */
.add-form-input:-webkit-autofill,
.add-form-input:-webkit-autofill:hover, 
.add-form-input:-webkit-autofill:focus {
    -webkit-text-fill-color: #475569 !important; 
    -webkit-box-shadow: 0 0 0px 1000px #f8fafc inset !important; 
    transition: background-color 5000s ease-in-out 0s;
}

/* --- Dropdown standard --- */
.add-form-dropdown {
    padding: 1px 0px;
}

/* Conteneur principal */
.add-form-dropdown .Select-control {
    border-radius: 6px !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Texte sélectionné (Simple et multi) */
.add-form-dropdown .Select-value,
.add-form-dropdown .Select-value-label {
    color: #475569 !important;
}

/* Placeholder et saisie de recherche */
.add-form-dropdown .Select-placeholder {
    color: #94a3b8 !important;
    line-height: 34px;
}

/* Couleur du texte pendant la saisie/recherche dans le Dropdown */
.add-form-dropdown .Select-input > input {
    color: #475569 !important;
    font-family: inherit;
}

/* Menu déroulant (liste) */
.add-form-dropdown .Select-menu-outer {
    margin-top: 4px;
    border-radius: 6px !important;
    border: 1px solid #102D69 !important;
    box-shadow: 0 4px 12px rgba(16, 45, 105, 0.15) !important;
    background: white !important;
    overflow: hidden;
}

/* Style des options dans la liste */
.add-form-dropdown .Select-menu .VirtualizedSelectOption {
    padding: 10px 12px !important;
    color: #334155 !important;
    border-radius: 6px !important;
    transition: all 0.2s ease;
}

/* Survol des options */
.add-form-dropdown .Select-menu .VirtualizedSelectOption:hover {
    background-color: #f1f5f9 !important;
    color: #102D69 !important;
    padding-left: 16px !important;
}

/* Option focalisée (clavier ou première de liste) */
.add-form-dropdown .Select-menu-outer .VirtualizedSelectFocusedOption {
    border-radius: 6px !important;
    background: #f1f5f9 !important;
    color: #102D69 !important;
    font-weight: 600 !important;
}

/* Gestion du désactivé spécifique Select-control */
.add-form-dropdown.is-disabled .Select-control {
    pointer-events: none;
    opacity: 0.5;
}

/* --- Multi-Dropdown (Tags/Badges) --- */
/* Le badge sélectionné */
.add-form-dropdown.Select--multi .Select-value {
    background-color: #f1f5f9 !important; 
    border: 1px solid rgba(16, 45, 105, 0.2) !important;
    border-radius: 4px !important;
    display: inline-flex !important;
    align-items: center;
    margin-top: 6px;
}

/* Le texte à l'intérieur du badge */
.add-form-dropdown.Select--multi .Select-value-label {
    font-weight: 600 !important;
    padding: 2px 8px !important;
}

/* L'icône "X" pour supprimer un badge */
.add-form-dropdown .Select-value-icon {
    padding: 2px 8px !important;
    border: none !important;
    border-right: 1px solid rgba(16, 45, 105, 0.1) !important; 
    color: #475569 !important; 
    background: transparent !important;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* Au survol de la croix de suppression */
.add-form-dropdown .Select-value-icon:hover {
    background-color: #fee2e2 !important;
    color: #dc3545 !important;
    border-radius: 4px 0 0 4px !important;
}

/* --- Custom Dropdown (Input manuel) --- */
/* Déclencheur et curseur */
#trigger-click-user-name,
#trigger-click-user-name .add-form-input {
    cursor: default !important;
}

/* Devient un curseur de saisie (barre) uniquement quand on clique dedans */
#trigger-click-user-name .add-form-input:focus {
    cursor: text !important;
}

/* Quand une option a été choisie (via le user-id caché) */
.add-form-group:has(#user-id[value]:not([value=""])) #user-name {
    background-color: #f8fafc !important;
    border-color: #102D69 !important;
}

/* Menu flottant custom */
#user-name-options-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    width: 100%; 
    margin-top: 4px;
    z-index: 2000;
    box-sizing: border-box;
    background-color: white;
    border: 1px solid #102D69;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(16, 45, 105, 0.15);
    max-height: 250px;
    overflow-y: auto;
    display: none; 
}

/* Item de la liste custom */
.custom-dropdown-item {
    padding: 10px 12px;
    cursor: pointer;
    color: #334155;
    font-size: 14px;
    border-radius: 6px;
    transition: all 0.2s;
}

/* Survol et option focalisée (clavier ou première de liste)  */
.custom-dropdown-item:hover,
#user-name-options-menu .custom-dropdown-item:first-child:not(:hover),
.custom-dropdown-item.selected {
    background: #f1f5f9;
    color: #102D69;
    font-weight: 600;
}

/* --- Flèche Dropdown --- */
.custom-select-arrow {
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #999;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

/* Rotation au clic/focus */
#trigger-click-user-name:focus-within .custom-select-arrow {
    transform: translateY(-50%) rotate(180deg);
}

/* --- Croix --- */
#clear-user-name {
    position: absolute;
    right: 28px;
    top: 50%;
    transform: translateY(-60%);
    display: none;
    color: #999;
    cursor: pointer;
    font-size: 18px;
    font-weight: 400;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.15s ease;
    user-select: none;
    z-index: 5;
}

/* Survol de la croix */
#clear-user-name:hover {
    color: red;
}

/* === MESSAGES DE CONFIRMATION === */
.confirmation-message {
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    margin-top: 15px;
    width: 100%;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    display: none;
    border: none; 
}

/* Etat : Succès (Vert doux) */
.confirmation-message {
    background-color: #f0fdf4; 
    color: #166534;
}

/* Etat : Erreur / Invalide (Rouge doux) */
.confirmation-message.invalid {
    background-color: #fef2f2 !important;
    color: #991b1b !important; 
}

/* Etat : Warning (Ambre doux) */
.confirmation-message.warning {
    background-color: #fffbeb;
    color: #92400e;
}

/* Animation d'entrée quand on ajoute la classe .show */
.confirmation-message.show {
    display: block;
    animation: slideUpFade 0.4s ease-out;
}

/* === BOUTON AJOUTER === */
.btn-add {
    padding: 9px 24px;
    background-color: rgba(16, 45, 105, 0.05); 
    color: #102D69;                            
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

/* Effet au survol : On joue sur l'opacité du fond */
.btn-add:hover:not(:disabled) {
    background-color: rgba(16, 45, 105, 0.1); 
    color: #0A1E45; 
    transform: scale(1.02);
}

/* Le petit trait décoratif en dessous qui n'apparaît qu'au survol */
.btn-add::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background-color: #102D69;
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.btn-add:hover::after {
    width: 40%; 
}

/* Effet au clic */
.btn-add:active:not(:disabled) {
    background-color: rgba(16, 45, 105, 0.15);
    transform: scale(0.98);
}

/* Etat désactivé : On le rend presque invisible */
.btn-add:disabled {
    background-color: transparent;
    color: #cbd5e1;
    cursor: not-allowed;
}

/* === Bouton Refresh === */
.btn-refresh {
    margin-bottom: 15px;
    color: #6c757d;
    background-color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.btn-refresh:hover {
    color: #5a6268;
}


/* === TABLEAU === */
/* Conteneur principal */
.table-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    align-items: flex-start;
    overflow-x: auto;
    max-width: 100%;
}

/* Base du tableau Dash */
#users-table, #groupes-table {
    border-collapse: collapse !important; 
    width: 100%;
    table-layout: fixed;
    height: 100%;
}


/* Style commun aux cellules (Header et Data) */
#users-table th, #users-table td, 
#groupes-table th, #groupes-table td {
    border: 1px solid #f1f5f9 !important;
    padding: 6px 10px;
    cursor: default;
    text-align: center !important;
    overflow: hidden;
    box-sizing: border-box !important;
    word-wrap: break-word;
    white-space: normal !important; /* Pour le retour à la ligne */
}

/* Spécificités de l'En-tête */
#users-table th, #groupes-table th {
    background-color: #f8fafc !important;
    color: #102D69 !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    text-transform: uppercase;

    padding-top: 10px !important;
    padding-bottom: 10px !important;
}

/* Spécificités du corps de tableau */
#users-table td, #groupes-table td {
    color: #475569;
    font-size: 13.5px;
    background-color: white !important;
}

/* --- Spécificité colonnes user-table--- */
/* Colonne 1 (Plus large) */
#users-table th:nth-child(1), #users-table td:nth-child(1) {
    width: 150px !important; 
    min-width: 150px !important;
    max-width: 150px !important;
}

/* Colonne 2 à 5 */
#users-table th:nth-child(n+2):nth-child(-n+5), 
#users-table td:nth-child(n+2):nth-child(-n+5) {
    width: 120px !important;
    min-width: 120px !important;
    max-width: 120px !important;
}

/* Colonnes 6 et 7 (Moins larges) */
#users-table th:nth-child(6), #users-table td:nth-child(6),
#users-table th:nth-child(7), #users-table td:nth-child(7){
    width: 85px !important;
    min-width: 85px !important;
    max-width: 85px !important;
}

/* --- Spécificité colonnes user-table--- */
/* Colonnes 1 et 2 */
#groupes-table th:nth-child(1), #groupes-table td:nth-child(1),
#groupes-table th:nth-child(2), #groupes-table td:nth-child(2) {
    width: 120px !important; 
    min-width: 120px !important;
    max-width: 120px !important;
}

/* Colonne 3 (Plus large) */
#groupes-table th:nth-child(3), #groupes-table td:nth-child(3) {
    width: 200px !important; 
    min-width: 200px !important;
    max-width: 200px !important;
}

/* Colonnes 4 et 5 (moins larges) */
#groupes-table th:nth-child(4), #groupes-table td:nth-child(4),
#groupes-table th:nth-child(5), #groupes-table td:nth-child(5){
    width: 85px !important;
    min-width: 85px !important;
    max-width: 85px !important;
}

/* --- Création des bordures --- */
/* Bordure sur la première ligne du header et du bloc de données*/
#users-table tr:first-child th, #groupes-table tr:first-child th {
    border-top: 1px solid #e2e8f0 !important;
}

#users-table tbody tr:first-child td, #groupes-table tbody tr:first-child td{
    border-top: none !important;
}

/* Bordure sur la dernière ligne du header et du bloc de données */
#users-table tr:last-child th, #groupes-table tr:last-child th,
#users-table tr:last-child td, #groupes-table tr:last-child td  {
    border-bottom: 1px solid #e2e8f0 !important;
}

/* Bordure à gauche pour le header et pour le bloc de données */
#users-table th:first-child, #groupes-table th:first-child,
#users-table tr td:first-child, #groupes-table tr td:first-child{
    border-left: 1px solid #e2e8f0 !important;
}
/* Bordure à droite pour le header et pour le bloc de données */
#users-table th:last-child, #groupes-table th:last-child,
#users-table tr td:last-child, #groupes-table tr td:last-child {
    border-right: 1px solid #e2e8f0 !important;
}

/* Survol */
#users-table tr:hover td, 
#groupes-table tr:hover td {
    background-color: #f1f5f9 !important; 
    color: #102D69 !important; 
    cursor: default;
}

/* Focus : Supprime le contour de sélection lors du clic sur une cellule */
.dash-spreadsheet-container .dash-spreadsheet-inner td.focused {
    outline: none !important;
}

/* Supprime aussi l'éventuel trait rose/bleu de sélection de cellule de Dash */
.dash-spreadsheet-container .dash-spreadsheet-inner td.selected {
    background-color: transparent !important;
}

/* Filtres */
#users-table .dash-filter, #groupes-table .dash-filter {
    background-color: white !important;
    border-top: none !important;
}

/* Style du texte à l'intérieur des filtres */
#users-table .dash-filter input, 
#groupes-table .dash-filter input {
    text-align: left !important;    
    font-weight: normal !important;
    color: #64748b !important; 
    outline: none !important;
    padding-left: 10px !important;
}

/* Style du texte quand on tape dedans */
#users-table .dash-filter input:focus, 
#groupes-table .dash-filter input:focus {
    color: #475569 !important;
    outline: none !important;
}

/* Masquer le bouton de casse (Case Sensitive) pour épurer */
#users-table input.dash-filter--case, #groupes-table input.dash-filter--case {
    display: none !important;
}

/* Tri */
.column-header--sort {
    color: #94a3b8 !important; 
    transition: color 0.2s;
    margin-left: 10px;
}

/* Réduire la marge de l'icône de tri seulement pour les colonnes 6 et 7 */
#users-table th:nth-child(6) .column-header--sort,
#users-table th:nth-child(7) .column-header--sort {
    padding: 0px;
    margin-left: 3px !important; 
    margin-right: 3px !important; 
}

th:hover .column-header--sort {
    color: #102D69 !important;
}

/* Centrage Markdown */
.cell-markdown > p {
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Masque le bouton Show/Hide  */
#users-table .show-hide, #groupes-table .show-hide {
    display: none !important;
}

/* --- Spécificité pour les boutons modifier et supprimer --- */
/* Curseur pointer pour les deux colonnes d'action */
[data-dash-column="MODIFIER"], 
[data-dash-column="SUPPRIMER"] {
    cursor: pointer !important;
}

/* Style spécifique pour SUPPRIMER */
[data-dash-column="SUPPRIMER"] {
    color: red !important;
    font-weight: bold !important;
}

/* Force le rouge même quand la ligne est survolée */
#users-table tr:hover td[data-dash-column="SUPPRIMER"], 
#groupes-table tr:hover td[data-dash-column="SUPPRIMER"] {
    color: red !important;
}

/* Style spécifique pour MODIFIER */
[data-dash-column="MODIFIER"] {
    color: #102D69 !important;
    font-weight: bold !important;
}

/* Style spécifique pour le bouton du modal */
.modal-header-admin .btn-close {
  --bs-btn-close-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000000'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414'/%3e%3c/svg%3e");
  
  /* You can now customize color & hover with Bootstrap variables */
  --bs-btn-close-opacity: 1;
}
