:root {
  --sidebar-bg: #1f2937;
  --brand: #4f46e5;
}

body {
  background-color: #f4f5f7;
}

[data-bs-theme="dark"] body {
  background-color: #15181e;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  min-height: 100vh;
  background-color: var(--sidebar-bg);
  transition: width 0.15s ease;
  overflow-x: hidden;
}

.sidebar .nav-link {
  display: flex;
  align-items: flex-start;
  color: #cbd5e1;
  border-radius: 8px;
}

.sidebar .nav-link i {
  flex-shrink: 0;
}

.sidebar-toggle-btn {
  border: none;
  background: transparent;
  padding: 0.25rem 0.4rem;
  line-height: 1;
}

.sidebar-toggle-btn:hover {
  color: #fff !important;
}

.sidebar.collapsed {
  width: 72px;
}

.sidebar.collapsed .nav-label {
  display: none;
}

.sidebar.collapsed .sidebar-brand {
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar.collapsed .nav-link {
  justify-content: center;
  position: relative;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.sidebar.collapsed .nav-link i {
  margin-right: 0 !important;
}

.sidebar.collapsed .nav-group-toggle::before {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  margin-right: 0;
}

.sidebar .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar .nav-link.active {
  background-color: var(--brand);
  color: #fff;
}

.sidebar .nav-caret {
  transition: transform 0.15s ease;
}

.sidebar .nav-link[aria-expanded="true"] .nav-caret {
  transform: rotate(180deg);
}

.sidebar.collapsed .nav-caret {
  display: none;
}

.sidebar.collapsed .nav-group-toggle::before {
  content: ">";
  font-size: 0.7rem;
  color: #cbd5e1;
  margin-right: 2px;
}

.sidebar .ms-3 .nav-link {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.content {
  min-height: 100vh;
  min-width: 0;
}

.flash-container {
  margin-bottom: 1rem;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.card-kpi {
  border: none;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  min-width: 0;
  overflow: hidden;
  container-type: inline-size;
}

.card-kpi .kpi-value {
  font-size: clamp(1.05rem, 11cqw, 1.8rem);
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.2;
}

.kpi-clickable {
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  cursor: pointer;
}

.kpi-clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.cursor-pointer {
  cursor: pointer;
}

.table-card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4f46e5, #1f2937);
}

.login-card {
  width: 380px;
  border: none;
  border-radius: 16px;
}

.chart-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  padding: 1rem;
}

[data-bs-theme="dark"] .chart-card {
  background: var(--bs-tertiary-bg);
}

[data-bs-theme="dark"] .card-kpi,
[data-bs-theme="dark"] .table-card {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Lignes d'activités en retard (rose) / du jour (jaune) : teintes assombries
   en dark mode pour rester lisibles sur fond sombre plutôt que d'utiliser
   les tons pastel clairs directement. */
.table-rose {
  --bs-table-bg: #fce4ec;
  --bs-table-color: #212529;
}

[data-bs-theme="dark"] .table-rose {
  --bs-table-bg: #4a1930;
  --bs-table-color: #f4c9dc;
}

[data-bs-theme="dark"] .table-warning {
  --bs-table-bg: #4a3b0a;
  --bs-table-color: #ffe69c;
}

/* Lignes de total (Temps par projets) : les variantes table-primary/table-light
   de Bootstrap restent claires en dark mode, d'où des classes dédiées. */
.table-total-general {
  --bs-table-bg: #cfe2ff;
  --bs-table-color: #052c65;
}

.table-total-projet {
  --bs-table-bg: var(--bs-tertiary-bg);
  --bs-table-color: var(--bs-body-color);
}

[data-bs-theme="dark"] .table-total-general {
  --bs-table-bg: #0a2a5c;
  --bs-table-color: #cfe2ff;
}

.badge-statut {
  text-transform: capitalize;
}

/* Empêche la flèche de tri de chevaucher le libellé de la colonne suivante :
   le libellé et l'icône ne se compressent plus l'un dans l'autre. */
.sortable-th {
  white-space: nowrap;
}

.sortable-th > a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* Empêche le champ de recherche client (filtre besoins) de s'étirer même
   si le nom saisi/sélectionné est très long, et positionne sa liste de
   suggestions en dessous. */
.client-filter-wrap {
  position: relative;
}

.client-filter-input {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-filter-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0.75rem;
  z-index: 1050;
  width: 340px;
  max-height: 260px;
  overflow-y: auto;
  margin-top: 0.15rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.client-filter-dropdown.show {
  display: block;
}

.client-filter-dropdown .list-group-item {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

/* Variante utilisée dans les formulaires (ex: nouvelle facture) où le champ
   client doit occuper toute la largeur de sa colonne plutôt que d'être
   limité comme dans les filtres de liste. */
.client-filter-wrap.client-filter-wide .client-filter-input {
  max-width: none;
}

.client-filter-wrap.client-filter-wide .client-filter-dropdown {
  width: 100%;
}

/* Limite la hauteur des listes (tableaux et grilles de cartes) pour qu'elles
   tiennent sur une page, avec défilement interne au-delà. */
.table-scroll {
  max-height: 75vh;
  overflow-y: auto;
}

.table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background-color: #fff;
}

[data-bs-theme="dark"] .table-scroll thead th {
  background-color: var(--bs-tertiary-bg);
  color: #fff;
}

/* Lignes résumé (jour / semaine) du tableau "Mon temps" du dashboard
   collaborateur - couleurs pilotées via les variables Bootstrap pour bien
   s'ajuster au mode sombre. */
.row-total-jour > td {
  background-color: var(--bs-tertiary-bg);
}

.row-total-semaine > td {
  background-color: var(--bs-secondary-bg);
  border-top: 1px solid var(--bs-border-color);
  border-bottom: 1px solid var(--bs-border-color);
}

.row-total-jour,
.row-total-semaine {
  cursor: pointer;
}

.row-total-jour .toggle-icon,
.row-total-semaine .toggle-icon {
  display: inline-block;
  width: 1em;
}

.card-scroll {
  max-height: 75vh;
  overflow-y: auto;
}

/* Fond jaune pâle pour les boutons outline-warning (ex: actions "Saisie
   exceptionnelle" / "Modification par lot") plutôt que le blanc par défaut
   de Bootstrap, pour mieux les distinguer des boutons neutres. */
.btn-outline-warning {
  background-color: #fff8e1;
  color: #664d03;
}

.btn-outline-warning:hover {
  background-color: #ffc107;
  color: #000;
}

[data-bs-theme="dark"] .btn-outline-warning {
  background-color: #4a3b0a;
  color: #ffe69c;
}

[data-bs-theme="dark"] .btn-outline-warning:hover {
  background-color: #ffc107;
  color: #000;
}
