/* Variables CSS pour faciliter les changements de thème */
:root {
    /*--primary-color: #007bff; /* Bleu typique pour les actions principales */
	--primary-color: #007aba;
    --secondary-color: #6c757d; /* Gris pour les actions secondaires */
    --success-color: #28a745; /* Vert pour succès */
    --error-color: #dc3545; /* Rouge pour erreur */
    --text-color: #333;
    --bg-color: #f8f9fa; /* Arrière-plan léger */
    --card-bg: #ffffff;
    --border-color: #dee2e6;
    --header-bg: #343a40; /* Sombre pour l'entête */
    --header-text: #fbfbfb;
    --font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --input-bg: #ffffff;
    --input-text: #202a32;
    --input-border: #2e5277;
    --input-placeholder: #8a96a3;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --primary-color: #287097;
    --secondary-color: #585f66; /* Gris pour les actions secondaires */
    --success-color: #28a745; /* Vert pour succès */
    --error-color: #dc3545; /* Rouge pour erreur */
    --bg-color: #12181b; /* Arrière-plan léger */
    --card-bg: #1b242b;
    --border-color: #2e5277;
    --header-bg: #14202d; /* Sombre pour l'entête */
    --header-text: #cbd1d9;
    --text-color: #e2e8f0;
    --font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --input-bg: #202a32;
    --input-text: #e2e8f0;
    --input-border: #2e5277;
    --input-placeholder: #8a96a3;
    --shadow-color: rgba(0, 0, 0, 0.4);
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* --- En-tête de l'application --- */
.app-header {
    background-color: var(--header-bg);
    color: var(--header-text);
    padding: 15px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-title {
    margin: 0;
    font-size: 1.8em;
    float: left; /* Aligne le titre à gauche */
}

.main-nav {
    float: right; /* Aligne la navigation à droite */
}

.main-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.main-nav ul li {
    display: inline-block;
    margin-left: 20px;
}

.main-nav ul li a {
    color: var(--header-text);
    text-decoration: none;
    font-weight: bold;
    padding: 5px 0;
    transition: color 0.3s ease;
}

.main-nav ul li a:hover {
    color: var(--primary-color);
}

/* Nettoie le flottement après l'entête */
.app-header .container::after {
    content: "";
    display: table;
    clear: both;
	/*position: relative;*/
}

/* --- Section principale (Contenu) --- */
.app-main {
    padding: 20px 0;
}

.app-logo {
	background-image: url("../img/new_logo.png");
	background-size: contain;
	background-repeat: no-repeat;
	background-position: left;
	height: 100px; /* Ajustez la taille du logo sur la page de login */
}

.section-title {
    font-size: 2em;
    color: var(--primary-color);
    margin-bottom: 25px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.content-block {
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    margin-bottom: 30px;
}

/* --- Messages d'alerte --- */


.alert {
    position: fixed;
    top: 30px;                 /* ou 50% pour centré */
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;

    padding: 12px 20px;
    border-radius: 4px;
    min-width: 300px;
    max-width: 80%;
    text-align: center;
    font-weight: bold;
    display: none;
}

.alert.success {
    background-color: #d4edda;
    color: var(--success-color);
    border: 2px solid #c3e6cb;
}

.alert.error {
    background-color: #f8d7da;
    color: var(--error-color);
    border: 2px solid #f5c6cb;
}

.alert.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 2px solid #bee5eb;
}

.alert.warning {
    background-color: #fff3cd;
    color: #856404;
    border: 2px solid #ffeeba;
}

/* --- Boutons --- */
.button {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    cursor: pointer;
    border: none;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.button.primary {
    background-color: var(--primary-color);
    color: var(--header-text);
}

.button.primary:hover {
    background-color: #0056b3;
    /*transform: translateY(-1px);*/
}

.button.warning {
    background-color: var(--error-color);
    color: var(--header-text);
}

.button.secondary {
    background-color: var(--secondary-color);
    color: var(--header-text);
}

.button.secondary:hover {
    background-color: #5a6268;
    /*transform: translateY(-1px);*/
}

.button.small {
    background-color: var(--primary-color);
    color: var(--header-text);
    height: fit-content;
    padding: 2px 20px;
    margin: 0 5px 0 30px;
    font-size: 0.6em;
}

/* --- Formulaires --- */
.data-form .form-group {
    margin-bottom: 20px;
}

.data-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--text-color);
}

.data-form input[type="text"],
.data-form input[type="date"],
.data-form select,
.data-form textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    color: var(--input-text);
    border-radius: 4px;
    font-size: 1em;
    box-sizing: border-box; /* Inclut le padding dans la largeur totale */
    transition: border-color 0.3s ease;
}

.data-form input[type="text"]:focus,
.data-form input[type="date"]:focus,
.data-form select:focus,
.data-form textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

.data-form input:disabled {
    background-color: var(--bg-color);
    cursor: not-allowed;
}

.data-form select[multiple] {
    min-height: 120px; /* Hauteur minimale pour les select multiples */
}

.data-form small {
    display: block;
    color: var(--secondary-color);
    font-size: 0.85em;
    margin-top: 5px;
}

.data-form--compact input[type="text"],
.data-form--compact input[type="date"],
.data-form--compact select,
.data-form--compact textarea {
    width: 80%;
    padding: 2px;
    font-size: 0.85em;
    border-radius: 2px;
}


/* --- Switch ON-OFF --- */
label:has([role="switch"]) {
	display: inline-flex;
	align-items: center;
	gap: 0.25em;
}

[role="switch"] {
	--height: 1.1875em;
	--width: 0.8;
    vertical-align: middle; /* <-- Ajout pour éviter le décalage de qqs pixels vers le bas */
	appearance: none;
	background-color: var(--input-bg);
	height: var(--height);
	width: calc(var(--height) * calc(1 + var(--width)));
	border: 0;
	border-radius: 99em;
	display: inline-block;
  transition: background-color 100ms ease-in-out;
}

/* The toggle */
[role="switch"]::after {
  content: "";
  display: block;
  aspect-ratio: 1;
  background-color: var(--input-bg);
  border: max(2px, 0.125em) solid #808080;
  height: 100%;
  border-radius: 50%;
  transition: transform 100ms ease-in-out, border-color 100ms ease-in-out;
  box-sizing: border-box;
  transform: translate(0, 0); /* position initiale */
}

/* on/off state */
[role="switch"]:checked {
	background-color: #0088cc;
}

[role="switch"]:checked::after {
  border-color: #0088cc;
  transform: translateX(calc(var(--height) * var(--width))); /* décalage horizontal */
}

input[type="checkbox"] {
  accent-color: var(--primary-color);
}

/* --- Element dashboard ---*/
.dashboard-container {
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    margin-bottom: 30px;
    display: grid;
    /* Crée 3 colonnes de largeur égale */
    grid-template-columns: repeat(3, 1fr); 
    /* Ajoute un espace entre les éléments */
    gap: 20px;
}
.element-dashboard {
    flex: 0 0 calc((100% / 3) - (25px * 2 / 3)); /* largeur = 1/3 du conteneur - la part du gap */
    background-color: var(--card-bg);
    box-shadow: 0px 0px 9px 0px var(--shadow-color);
    border-radius: 3px;
    padding: 25px 30px;
    color: var(--text-color);
    height: fit-content;
    text-align: center;
    min-height: 90px;
}

.card-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 10px;
    text-align: left;
}

.card-value {
    font-size: 36px; /* plus grand */
    font-weight: bold;
    align-self: center; /* centre la valeur horizontalement */
    display: flex;
    justify-content: center;
}
.small-loader {
  width: 41px;
  height: 41px;
  background: url("/assets/gif/loading-small.svg") no-repeat center;
  background-size: contain;
}

/* --- Tableaux Responsives --- */
.responsive-table {
    list-style: none;
    padding: 0;
    margin: 0;
}

.responsive-table li {
    border-radius: 3px;
    /*padding: 25px 30px;*/
	padding: 10px 30px;
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    align-items: center; /* Aligne verticalement les éléments */
}

.responsive-table .table-header {
    background-color: var(--primary-color);
    color: var(--header-text);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: bold;
}

.responsive-table .table-row {
    background-color: var(--card-bg);
    box-shadow: 0px 0px 9px 0px var(--shadow-color);
}

.responsive-table .col {
    flex-basis: 25%; /* Par défaut, 4 colonnes */
    padding: 10px 0;
    text-align: left;
}

.responsive-table .col-1 { flex-basis: 35%; }
.responsive-table .col-2 { flex-basis: 30%; }
.responsive-table .col-3 { flex-basis: 15%; }
.responsive-table .col-4 { flex-basis: 5%; } 

.title-container {
	display: flex;
	align-items: center;
	width: 100%;
}
.half-title {
	flex: 1;
}

/* Liens dans les actions de tableau */
.action-link {
    display: inline-block;
    color: var(--primary-color);
    text-decoration: none;
    margin-right: 15px; /* Espacement entre les liens */
    transition: color 0.2s ease;
	cursor: pointer;
}

.action-link:hover {
    color: #0056b3;
}

.action-link i {
    margin-right: 5px; /* Espace entre icône et texte */
}

/* Images d'action (comme delete.png) */
.action-link img {
    height: 20px; /* Ajustez la taille selon vos images */
    vertical-align: middle;
    margin-right: 5px;
}

/* --- Pied de page --- */
.app-footer {
    text-align: center;
    padding: 20px 0;
    margin-top: 30px;
    color: var(--secondary-color);
    font-size: 0.9em;
    border-top: 1px solid var(--border-color);
}

/* --- Thème Switcher (Bouton bascule thème clair/sombre) --- */

.theme-switch {
  --sw-width: 65px; /* Un peu plus large pour les icônes */
  --sw-height: 32px;
  position: relative;
  display: inline-block;
  width: var(--sw-width);
  height: var(--sw-height);
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #333; /* Fond sombre par défaut */
  transition: .4s;
  border-radius: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px; /* Espacement pour les icônes */
}

/* Le bouton coulissant */
.slider:before {
  position: absolute;
  content: "";
  height: 24px;
  width: 24px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  z-index: 2; /* Pour passer par dessus les icônes */
}

/* Style des icônes */
.slider i {
  font-size: 14px;
  z-index: 1;
}

.icon-sun { color: #f1c40f; }
.icon-moon { color: #f5f3ce; }

/* Logique de mouvement et changement de couleur de fond */
input:checked + .slider {
  background-color: #2c3e50;
}

input:checked + .slider:before {
  transform: translateX(33px);
}

/* Optionnel : cacher l'icône sous le bouton blanc */
input:not(:checked) + .slider .icon-sun {
  opacity: 0; /* Le soleil est caché par le bouton blanc au départ */
}

input:checked + .slider .icon-moon {
  opacity: 0; /* La lune est cachée quand on bascule */
}

/* --- Media Queries pour le Responsive Design (Mobile-first) --- */
@media all and (max-width: 767px) {
    .app-header .container {
        text-align: center;
    }
    .app-title {
        float: none;
        margin-bottom: 10px;
    }
    .main-nav {
        float: none;
    }
    .main-nav ul li {
        display: block;
        margin: 5px 0;
    }

    .responsive-table .table-header {
        display: none; /* Cache l'en-tête du tableau sur mobile */
    }

    .responsive-table li {
        display: block; /* Empile les lignes sur mobile */
        margin-bottom: 20px;
        box-shadow: 0px 0px 9px 0px rgba(0,0,0,0.1);
    }

    .responsive-table .col {
        flex-basis: 100%; /* Chaque colonne prend toute la largeur */
        text-align: right;
        padding-left: 50%; /* Espace pour le label */
        position: relative;
    }

    .responsive-table .col::before {
        content: attr(data-label); /* Utilise l'attribut data-label pour afficher le titre de colonne */
        position: absolute;
        left: 10px;
        width: 45%; /* Place le label à gauche */
        text-align: left;
        font-weight: bold;
        color: var(--primary-color);
    }

    .action-link {
        display: block;
        margin-right: 0;
        margin-bottom: 10px;
        text-align: left;
        padding-left: 50%; /* Aligne avec les valeurs */
    }
}