/* ===== VARIABLES ===== */
:root {
  --bg: #edeaf0;
  --bg2: #e8e4ee;
  --surface: #ffffff;
  --surface2: #f5f3f8;
  --navy: #1a2268;
  --navy2: #252d82;
  --blue-mid: #3d4dbf;
  --blue-soft: #eef0fb;
  --red: #c0392b;
  --green: #2a8a4a;
  --green-soft: #eaf6ef;
  --orange: #e08a1e;
  --orange-soft: #fdf3e3;
  --text: #2c2c2c;
  --text2: #555566;
  --text3: #9090a8;
  --border: #d8d4e4;
  --border2: #c8c4d8;
  --radius: 8px;
  --radius-lg: 14px;
  --shadow: 0 4px 24px rgba(26,34,104,0.08);
  --shadow-sm: 0 2px 10px rgba(26,34,104,0.06);
}

/* ===== BASE ===== */
body {
  font-family: 'Open Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1,h2,h3,h4,h5,h6,.fw-bold,.fw-semibold { font-family: 'Raleway', sans-serif; }

/* ===== HEADER ===== */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 1000;
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 18px; }
.app-logo { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.logo-img { height: 38px; width: auto; object-fit: contain; }
.logo-fallback { display: flex; align-items: center; gap: 10px; }
.logo-square {
  width: 38px; height: 38px;
  background: var(--navy);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-text {
  font-family: 'Raleway', sans-serif;
  font-size: 16px; font-weight: 800;
  color: var(--navy);
  letter-spacing: 0.04em;
}
.header-divider { width: 1px; height: 28px; background: var(--border); }
.header-app-name {
  font-family: 'Raleway', sans-serif;
  font-size: 11.5px; font-weight: 700;
  color: var(--text2);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.header-right { display: flex; align-items: center; gap: 12px; }

/* Bandeau : société de travail + recherche universelle */
.header-outils { flex: 1; display: flex; align-items: center; justify-content: center; gap: 12px; min-width: 0; padding: 0 18px; }
.societe-travail { display: flex; align-items: center; gap: 7px; margin: 0; padding: 3px 4px 3px 11px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface2); }
.societe-travail > .bi { color: var(--text3); }
.societe-travail .form-select { border: 0; background-color: transparent; font-weight: 700; color: var(--navy); min-width: 170px; max-width: 260px; box-shadow: none; }
.societe-travail.active { border-color: var(--navy); background: var(--blue-soft); }
/* Avec la recherche dans les listes (public/js/listes-recherche.js) */
.societe-travail .lr-champ { border: 0; background-color: transparent; font-weight: 700; color: var(--navy); box-shadow: none; min-width: 170px; }
.societe-travail.active > .bi { color: var(--navy); }
.recherche-globale { position: relative; flex: 0 1 360px; margin: 0; }
.recherche-globale > .bi { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text3); pointer-events: none; }
.recherche-globale .form-control { padding-left: 34px; border-radius: 999px; background: var(--surface2); }
.recherche-globale .form-control:focus { background: var(--surface); }
.recherche-suggestions {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; min-width: 320px; z-index: 1090;
  background: var(--surface); border: 1.5px solid var(--border2); border-radius: var(--radius);
  box-shadow: var(--shadow); max-height: 70vh; overflow-y: auto; padding: 4px 0;
}
.rs-groupe { padding: 8px 14px 3px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; color: var(--text3); }
.rs-ligne { display: block; padding: 7px 14px; text-decoration: none; color: var(--text); }
.rs-ligne:hover, .rs-ligne.actif, .rs-tout.actif { background: var(--blue-soft); }
.rs-titre { display: block; font-weight: 600; font-size: 13px; }
.rs-detail { display: block; font-size: 11.5px; color: var(--text3); }
.rs-tout { display: block; padding: 9px 14px; border-top: 1px solid var(--border); font-size: 12px; font-weight: 700; color: var(--blue-mid); text-decoration: none; }
.recherche-tel { color: var(--navy); font-size: 18px; padding: 6px; }
@media (max-width: 1250px) { .header-app-name, .header-divider { display: none; } }
.user-chip {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 4px 14px 4px 5px;
}
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--navy);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Raleway', sans-serif;
  font-weight: 800; font-size: 11px;
  flex-shrink: 0;
}
.user-chip-name { font-size: 12.5px; font-weight: 600; color: var(--text2); }
.logout-btn {
  background: none; border: none;
  padding: 2px 4px; color: var(--text3); cursor: pointer;
  display: flex; align-items: center;
  border-radius: 4px; transition: color 0.15s;
}
.logout-btn:hover { color: var(--red); }

/* ===== LAYOUT ===== */
.app-layout { display: flex; flex: 1; }

/* ===== SIDEBAR ===== */
.app-sidebar {
  width: 232px; min-width: 232px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 62px;
  height: calc(100vh - 62px);
  overflow-y: auto;
}
.nav-section-label {
  font-family: 'Raleway', sans-serif;
  font-size: 9px; font-weight: 800;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 12px 10px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
  color: var(--text2);
  text-decoration: none;
  transition: all 0.15s;
}
.nav-item:hover { background: var(--surface2); color: var(--navy); }
.nav-item.active { background: var(--blue-soft); color: var(--navy); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--text3); }
.nav-item.active svg, .nav-item:hover svg { color: var(--blue-mid); }

/* ===== MAIN CONTENT ===== */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.main-content main { flex: 1; }

/* ===== PAGE HEADER ===== */
.page-title {
  font-family: 'Raleway', sans-serif;
  font-size: 20px; font-weight: 800;
  color: var(--navy);
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 2px;
}
.page-title::before {
  content: '';
  width: 4px; height: 20px;
  background: var(--red);
  border-radius: 2px;
  flex-shrink: 0;
}
.page-sub { font-size: 12.5px; color: var(--text3); padding-left: 14px; }

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-sm) !important;
}
.card-header {
  background: var(--surface) !important;
  border-bottom: 1px solid var(--border) !important;
  font-family: 'Raleway', sans-serif;
  font-size: 11px; font-weight: 800;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ===== TABLES ===== */
.table thead tr { background: var(--navy); }
/* Fond posé sur les cellules : Bootstrap 5.3 peint chaque cellule en blanc
   (--bs-table-bg), ce qui masquait le fond de la ligne et le texte blanc. */
.table thead th {
  background-color: var(--navy);
  font-family: 'Raleway', sans-serif;
  font-size: 10px; font-weight: 700;
  color: rgba(255,255,255,0.92);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 11px 14px;
  border: none; white-space: nowrap;
}
.table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text);
  vertical-align: middle; border-top: none;
}
.table tfoot td { padding: 11px 14px; border-top: none; }
.table tbody tr:nth-child(even) td { background: var(--surface2); }
.table tbody tr:hover td { background: #eeebf8; }
.table-rounded { border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }

/* ===== BUTTONS ===== */
.btn {
  font-family: 'Raleway', sans-serif;
  font-weight: 700; letter-spacing: 0.04em;
  border-radius: var(--radius);
}
.btn-primary { background: var(--navy); border-color: var(--navy); }
.btn-primary:hover, .btn-primary:focus { background: var(--navy2); border-color: var(--navy2); }
.btn-outline-secondary { border-color: var(--border2); color: var(--text2); }
.btn-outline-secondary:hover { background: var(--surface2); border-color: var(--navy); color: var(--navy); }

/* ===== FORMS ===== */
.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Open Sans', sans-serif;
  font-size: 13px; color: var(--text);
}
.form-control:focus, .form-select:focus {
  border-color: var(--blue-mid);
  box-shadow: 0 0 0 3px rgba(61,77,191,0.1);
}
.form-label { font-size: 11.5px; font-weight: 700; color: var(--text2); }

/* ===== ALERTS ===== */
.alert-success { background: var(--green-soft); border-color: #a8d8b8; color: #1a5c2c; }
.alert-danger   { background: #fdf0f0; border-color: #f5c0c0; color: #8b1a1a; }
.alert-warning  { background: var(--orange-soft); border-color: #f0d9a8; color: #7a5500; }
.alert-info     { background: #f0f0fc; border-color: #b0b4e8; color: var(--navy); }

/* ===== FLASH ===== */
.flash-bar { padding: 10px 20px; font-size: 13px; display: flex; align-items: center; gap: 9px; }

/* ===== FOOTER ===== */
.app-footer {
  background: var(--navy);
  padding: 12px 28px;
  font-size: 11.5px;
  color: rgba(255,255,255,0.5);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.footer-right { display: flex; align-items: center; gap: 7px; color: rgba(255,255,255,0.35); }
.footer-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--red); }

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border-top: 4px solid var(--navy);
  position: relative;
}
.stat-card.blue   { border-top-color: var(--blue-mid); }
.stat-card.green  { border-top-color: var(--green); }
.stat-card.orange { border-top-color: var(--orange); }
.stat-card.red    { border-top-color: var(--red); }
.stat-lbl {
  font-size: 10.5px; color: var(--text3);
  font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 9px;
}
.stat-val {
  font-family: 'Raleway', sans-serif;
  font-size: 30px; font-weight: 800;
  color: var(--navy); line-height: 1;
}
.stat-val small { font-size: 15px; font-weight: 600; color: var(--text3); }
.stat-note { font-size: 11px; color: var(--text3); margin-top: 6px; display: flex; align-items: center; gap: 5px; }

/* ===== CARD TITLE BAR ===== */
.card-title-bar {
  font-family: 'Raleway', sans-serif;
  font-size: 12px; font-weight: 800;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 9px;
}
.spacer-line {
  flex: 1; height: 1.5px;
  background: var(--red);
  opacity: 0.35; border-radius: 1px;
}

/* ===== BAR CHARTS ===== */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.bar-label { width: 120px; font-size: 12px; color: var(--text2); flex-shrink: 0; text-align: right; }
.bar-track { flex: 1; height: 22px; background: var(--bg2); border-radius: 5px; overflow: hidden; }
.bar-fill {
  height: 100%; border-radius: 5px;
  display: flex; align-items: center; padding-left: 9px;
  font-size: 11px; font-weight: 700; color: white;
  font-family: 'Raleway', sans-serif;
  min-width: 5px; transition: width 0.6s ease;
}
.bar-value { width: 50px; font-size: 12px; font-weight: 800; color: var(--navy); font-family: 'Raleway', sans-serif; text-align: right; flex-shrink: 0; }

/* ===== STATUS BADGES ===== */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700;
  font-family: 'Raleway', sans-serif;
  padding: 4px 11px; border-radius: 12px;
  letter-spacing: 0.03em; white-space: nowrap;
}
.st-done     { background: var(--green-soft);  color: var(--green); }
.st-pending  { background: var(--orange-soft); color: var(--orange); }
.st-relance  { background: var(--blue-soft);   color: var(--blue-mid); }
.st-late     { background: #fdf0f0;            color: var(--red); }
.st-inactive { background: var(--bg2);         color: var(--text3); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* ===== LAYOUT UTILS ===== */
.grid-2       { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.flex-gap     { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.mb-14 { margin-bottom: 14px; }
.mb-18 { margin-bottom: 18px; }
.mt-14 { margin-top: 14px; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* ===== MODAL ===== */
.modal-content { border-radius: var(--radius-lg); border: 1px solid var(--border); }
.modal-header { border-bottom: 1px solid var(--border); font-family: 'Raleway', sans-serif; }
.modal-footer { border-top: 1px solid var(--border); }

/* ===== RECHERCHE DANS LES LISTES DÉROULANTES (public/js/listes-recherche.js) ===== */
.lr { position: relative; }
.lr.lr-inline { display: inline-block; vertical-align: middle; }
.lr.lr-auto { width: max-content; max-width: 100%; }
.lr-natif {
  position: absolute !important; left: 0; bottom: 0; width: 100% !important; height: 1px !important;
  opacity: 0; pointer-events: none; padding: 0 !important; border: 0 !important;
}
.lr-champ { cursor: text; background-color: var(--surface); }
.lr-champ::placeholder { color: var(--text3); opacity: 1; }
.lr-champ:disabled { background-color: var(--surface2); cursor: not-allowed; }
.lr.lr-invalide .lr-champ { border-color: var(--red); }
.lr-liste {
  position: absolute; left: 0; top: calc(100% + 3px); z-index: 1080;
  min-width: 100%; width: max-content; max-width: min(560px, 92vw);
  max-height: 300px; overflow-y: auto;
  background: var(--surface); border: 1.5px solid var(--border2); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 4px 0; font-size: 13px;
}
.lr-option { padding: 7px 12px; cursor: pointer; color: var(--text); white-space: normal; }
.lr-option-vide { color: var(--text3); font-style: italic; }
.lr-option.lr-choisie { font-weight: 700; color: var(--navy); }
.lr-option.lr-actif { background: var(--blue-soft); }
.lr-groupe { padding: 6px 12px 2px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; color: var(--text3); }
.lr-aucun { padding: 8px 12px; color: var(--text3); font-style: italic; }
