/* ============================================================
   HRmaps Design System — BRIDGE OVERRIDES (hand-written)
   ------------------------------------------------------------
   Additive. Loaded AFTER ds-bridge.css (so it wins for fields).
   Never modifies existing stylesheets. Holds rules that can't be
   auto-generated: form fields (dark-mode repaint), status labels,
   focus ring, and a dark-theme root safety-net.
   Light mode stays visually identical (tokens == legacy values);
   the dark-only block below is inert unless data-theme="dark".
   ============================================================ */

/* ---- BRAND KNOB FED BY THE PORTAL SETTING -------------------------------
   `--primary` is the design system's single brand knob: every tint, state,
   focus ring — and, through the remap right below, the whole legacy
   `--primary-*` family — derives from it. Left at its stylesheet default it
   pinned the entire UI to HRmaps red.

   The portal has its own brand knob: "Couleur principale" in the global
   settings, which can be set for all entities or per entity. Which one applies
   to the current user is resolved SERVER-side (ApplyGlobalSettings →
   GetParsedSetting), lands in `UserSettings.primaryColor`, and mainCtrl
   injects the chosen palette entry on <html> as `--light-primary-bg` /
   `--dark-primary-bg` (+ `-fg`). Feeding that into `--primary` is what makes
   the picked colour actually re-theme the app, instantly and everywhere.

   Read from the LEGACY vars rather than written from JS on purpose: the theme
   is per-container, not per-document — under `dark-sidebar` only the nav is
   dark, and a single inline `--primary` could not say two things at once.

   The `bg` variant (not `color`) is the solid brand fill, which is what
   `--primary` means here; the dark block of tokens/colors.css already derives
   the lightened text/tint variants from it. The fallback keeps HRmaps red when
   no colour is injected — login screen, or no global setting for this user —
   and must stay in sync with the default in tokens/colors.css.

   Consequence for the "one line per client" theming note in tokens/colors.css:
   a `:root { --primary }` override in a client stylesheet no longer has the
   last word, since this file loads after it. The in-product setting wins, on
   purpose — an admin changing the colour must see the colour change. */
:root {
  --primary:    var(--light-primary-bg, #ED4337);
  --on-primary: var(--light-primary-fg, #ffffff);
}

[data-theme="dark"],
[data-theme="dark-sidebar"] .nav-v2-container {
  --primary:    var(--dark-primary-bg, #ED4337);
  --on-primary: var(--dark-primary-fg, #ffffff);
}

/* ---- APP TOKEN REMAP (modern v2 UI) -------------------------------------
   The modern app has its OWN token system (predefinedClass.css) with a
   built-in light/dark theme via [data-theme=dark]. Its brand knob is
   --primary-color (=injected tenant indigo). We re-point the whole primary
   family onto the DS --primary so every modern screen follows the design
   system + the one-line tenant override, in BOTH light and dark.          */
:root,
[data-theme="dark"],
[data-theme="dark-sidebar"] .nav-v2-container {
  --primary-color: var(--primary) !important;
  --primary-bg: var(--primary) !important;
  --primary-fg: var(--on-primary) !important;
  --primaryLight-bg: var(--primary-soft) !important;
  --primaryLight-fg: var(--primary-700) !important;

  /* ---- FAMILLE DES CHAMPS -----------------------------------------------
     `sitecss.css` habille tous les champs natifs avec ces variables, et sous
     un selecteur enorme :
       select:not(.form-control):not(.cs-select):not(...)  ->  (0,12,1)
     Aucune recette du design system ne peut le battre sans repeter des
     classes a l infini. Mais elle n a pas a le battre : il suffit de brancher
     les VARIABLES qu il lit sur les tokens. C est la methode que prescrit le
     CLAUDE.md du design system — on branche l ancien CSS sur les tokens plutot
     que de le reecrire.

     Effet : tout champ natif de l application suit le theme et la couleur du
     client, y compris sur les ecrans non encore migres. Sans ce remappage, un
     <select> reste blanc a fond #272727 en mode sombre (les valeurs claires en
     dur de predefinedClass.css). */
  --input-bg: var(--field-bg) !important;
  --input-color: var(--text-primary) !important;
  --input-border: var(--field-border) !important;
  --input-focus-border: var(--primary) !important;
  --input-disabled-bg: var(--surface-sunken) !important;
  --label-color: var(--text-muted) !important;
}

/* ---- NAMED-COLOR FAMILY REMAP (modern v2 utility classes) ---------------
   The app's utility color classes (.redColor, .greenBg, .orangeColor, …) all
   point to its OWN named-color tokens (--red-color, --green-bg, …), defined
   light+dark in predefinedClass.css. We re-point only the families that map
   ONE-TO-ONE onto a DS semantic WITHOUT merging two distinct app categories:
     red→danger, green→success, orange→warning, blue→info, grey/lightgray→neutral.
   Deliberately NOT remapped (would collapse co-occurring categories — handled
   per-screen later): orangeRed, yellow, yellowgreen, azure, purple,
   mediumpurple, hotpink, skyblue.
   var(--danger) etc. are theme-stable in the DS, so light & dark both follow. */
:root,
[data-theme="dark"],
[data-theme="dark-sidebar"] .nav-v2-container {
  /* red → danger */
  --red-color: var(--danger) !important;
  --red-bg: var(--danger) !important;
  --red-fg: var(--danger-fg) !important;
  --redLight-bg: var(--danger-soft) !important;
  --redLight-fg: var(--text-primary) !important;
  /* green → success */
  --green-color: var(--success) !important;
  --green-bg: var(--success) !important;
  --green-fg: var(--success-fg) !important;
  --greenLight-bg: var(--success-soft) !important;
  --greenLight-fg: var(--text-primary) !important;
  /* orange → warning */
  --orange-color: var(--warning) !important;
  --orange-bg: var(--warning) !important;
  --orange-fg: var(--warning-fg) !important;
  --orangeLight-bg: var(--warning-soft) !important;
  --orangeLight-fg: var(--text-primary) !important;
  /* blue → info */
  --blue-color: var(--info) !important;
  --blue-bg: var(--info) !important;
  --blue-fg: var(--info-fg) !important;
  --blueLight-bg: var(--info-soft) !important;
  --blueLight-fg: var(--text-primary) !important;
  /* grey / lightgray → neutral text (bg/fg left as-is: neutral, no clean DS target) */
  --grey-color: var(--text-muted) !important;
  --lightgray-color: var(--text-muted) !important;
}

/* ---- DARK BACKGROUNDS: THE TWO BLACKS, EVERYWHERE -----------------------
   Dark mode ran two palettes at once. The design system paints exactly two
   blacks — the deep page black `--bg-app` (#14161B) and the raised surface
   black `--surface` (#1C1F26), which is what the v3 screens show. Every screen
   painted from the app's own token family got a different set: `--content-bg`
   #2D2C2C, `--surface-bg` / `--modal-bg` / `--main-bg` #2A2A2A, `--wrapper-bg`
   #232523, `--contrast-bg` / `--pills-bg` #121212 — five blacks belonging to
   no palette. And ds-bridge.css reads those legacy vars FIRST
   (`var(--surface-bg, var(--surface))`), so even the selectors it covers kept
   them. Re-pointing the vars themselves fixes both paths at once.

   Dark only: in light the app's values already sit within a hair of the DS
   light tokens (#f7f7f7 vs #F4F5F8, white vs white), so there is nothing to
   gain there and a whole theme to risk.

   WHICH of the two each var gets is read off its LIGHT value — the original
   intent — so contrast RELATIONSHIPS survive the collapse: white meant raised
   (card, modal, menu) → `--surface`; a page gray meant recessed (the canvas a
   card sits on) → `--bg-app`. The date-range picker, whose panel is
   `--wrapper-bg` with `--surface-bg` cells, thus stays a two-level object
   instead of flattening into one slab. */
[data-theme="dark"],
[data-theme="dark-sidebar"] .nav-v2-container {
  /* raised — cards, modals, menus, pills, wizard (light value: white) */
  --surface-bg:  var(--surface) !important;
  --content-bg:  var(--surface) !important;
  --contrast-bg: var(--surface) !important;
  --modal-bg:    var(--surface) !important;
  --pills-bg:    var(--surface) !important;
  --wizard-bg:   var(--surface) !important;

  /* recessed — the page under the cards (light value: a gray) */
  --main-bg:     var(--bg-app) !important;
  --wrapper-bg:  var(--bg-app) !important;

  /* hovers stay inside the same system instead of the old #363636 / #4E4E4E */
  --main-hover-bg:    var(--surface-hover) !important;
  --content-hover-bg: var(--surface-hover) !important;
  --modal-hover-bg:   var(--surface-hover) !important;
  --nav-hover-bg:     var(--surface-hover) !important;

  /* fields are already painted `--field-bg` by the rule below; this keeps the
     var in step for the widgets that read it themselves rather than being
     matched by that selector */
  --input-bg:    var(--field-bg) !important;
}

/* ---- HOME STACK GAPS: SUPPRIMÉ ------------------------------------------
   Il y avait ici un bloc « ONE STACK GAP PER COLUMN » : la colonne publiait une
   variable `--widgets-stack-gap` dont héritaient À LA FOIS ses propres enfants
   et `.widgets-wrapper` plusieurs niveaux plus bas, en `row-gap: … !important`.
   Les deux écarts ne POUVAIENT donc pas différer.

   C'était contraire à la maquette, qui les tient distincts à dessein : 32px
   séparent deux SECTIONS (« À traiter » → dashboard), 14 ou 20px deux CARTES
   d'une même section. Mesuré dans `Accueil HRmaps.dc.html` : conteneur de la
   colonne principale à `gap:32px`, cartes à `gap:14px` (collaborateur, l.208)
   ou `gap:20px` (manager l.329, admin l.461, recruteur l.585).

   Les deux écarts sont posés séparément par le tableau de bord du DS
   (`board`, `board-group.is-dense`, ds-components.css), sans `!important`.
   Ne pas rétablir : ce serait re-fusionner deux écarts que le design sépare. */

/* ---- THEME PREVIEW CARDS (settings modal) -------------------------------
   The three cards that advertise the themes still painted the pre-DS blacks
   (#121212 page / #2A2A2A surface). They are a PREVIEW: they must show the dark
   theme while the app itself is light, so the tokens cannot be used here —
   `var(--bg-app)` would resolve to the light value. Literal, and to be kept in
   sync with the dark block of tokens/colors.css. */
.theme-card-radio-container .theme-card-radio.dark-theme-card-radio {
  background: #14161B;                     /* --bg-app, dark */
}

.theme-card-radio-container .theme-card-radio.dark-theme-card-radio .left-side,
.theme-card-radio-container .theme-card-radio.dark-theme-card-radio .right-side,
/* dark-sidebar: light page, dark menu — only the menu half is repainted */
.theme-card-radio-container .theme-card-radio.dark-sidebar-theme-card-radio .left-side {
  background: #1C1F26;                     /* --surface, dark */
}

/* ---- FORM FIELDS ---------------------------------------------------------
   Tokenized bg/text/border so native fields repaint on theme switch.
   appearance:none only on text inputs & textarea (NOT select — keeps its
   native chevron); select relies on color-scheme for dark repaint.        */
.form-control,
input:where(:not([class^="ds-"], [class*=" ds-"])):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="submit"]):not([type="button"]),
textarea:where(:not([class^="ds-"], [class*=" ds-"])),
select:where(:not([class^="ds-"], [class*=" ds-"])) {
  background-color: var(--field-bg) !important;
  color: var(--text-primary) !important;
  border-color: var(--field-border) !important;
}

input:where(:not([class^="ds-"], [class*=" ds-"])):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="submit"]):not([type="button"]),
textarea:where(:not([class^="ds-"], [class*=" ds-"])),
.form-control:not(select) {
  -webkit-appearance: none;
  appearance: none;
}

.form-control::placeholder,
input:where(:not([class^="ds-"], [class*=" ds-"]))::placeholder,
textarea:where(:not([class^="ds-"], [class*=" ds-"]))::placeholder { color: var(--field-placeholder) !important; opacity: 1; }

.form-control:focus,
input:where(:not([class^="ds-"], [class*=" ds-"])):focus,
textarea:where(:not([class^="ds-"], [class*=" ds-"])):focus,
select:focus {
  border-color: var(--primary) !important;
  box-shadow: var(--ring) !important;
  outline: none !important;
}

/* checkbox / radio accent follows the brand */
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }

/* ---- STATUS LABELS (semantic, tokenized) --------------------------------
   Only the clearly-semantic Bootstrap labels are retouched; kept solid so
   appearance stays close to today's, but consistent + dark-legible.        */
.label-success { background-color: var(--success) !important; color: #fff !important; }
.label-danger  { background-color: var(--danger)  !important; color: #fff !important; }
.label-warning { background-color: var(--warning) !important; color: #fff !important; }
.label-info    { background-color: var(--info)    !important; color: #fff !important; }

/* ---- DARK THEME ROOT SAFETY-NET -----------------------------------------
   Inert in light mode. Catches the document root + any element that never
   set an explicit color, so text stays legible on the dark canvas.         */
[data-theme="dark"] html,
[data-theme="dark"] body {
  background-color: var(--bg-app) !important;
  color: var(--text-primary);
}

/* ---- LIGNE SECONDAIRE D UNE FICHE (`title-collab`) -----------------------
   `sitecss.css` pose `.title-collab { color: #a2a9b2 }`, un gris EN DUR : il
   ne bougeait donc ni en theme sombre, ni sous une couleur client. Mesure sur
   la modale Details d un collaborateur : rgb(162,169,178) a l identique dans
   les deux themes, alors que tout ce qui l entoure suit ses jetons.

   `--text-muted` est la correspondance deja retenue par le projet pour cette
   teinte : `ds-utilities.css` ecrit noir sur blanc que `.ds-text-muted`
   remplace les `#a2a9b2` inline. On applique la meme decision a la classe.

   Non scope a `.ds`, comme les repeints voisins de ce pont : il repointe les
   couleurs cuites de l application entiere, pas les seuls ecrans migres. */
.title-collab { color: var(--text-muted) !important; }

/* ---- FICHE COLLABORATEUR : les deux dernieres couleurs cuites ------------
   Vues rendues a l ecran, la seconde en forcant son `ng-repeat`.

   `.vacation-title` — le bandeau « absent du … au … » — etait `#d53e3a`, un
   rouge en dur. Il passe a `--danger` (#DC2626) : meme intention, meme lecture,
   mais il suit desormais le theme. Mesure avant : rgb(213,62,58) identique en
   clair et en sombre.

   `.event-user` — l icone de gateau d anniversaire — est un corail `#ff6c35`.
   La TEINTE EST CONSERVEE telle quelle : `--warning` est l orange « en cours » des statuts,
   et peindre un gateau en couleur d avertissement lui donnerait un sens qu il
   n a pas. Meme parti que `.ds-text-gap` dans `ds-utilities.css` : on centralise
   la valeur ici pour pouvoir la re-tokeniser d un seul endroit le jour ou
   l equipe tranche. Sa marge passe en revanche au jeton, elle remplace un
   `style="margin-left: 5px"`.

   `.img-collab` — le cadre de l avatar — remplace un
   `style="margin: 15px auto !important"`. Le `!important` est conserve : il
   battait une regle legacy, et le retirer reposerait la question. 15px devient
   `--space-4`, soit 16px : un pixel, sur un bloc centre. */
.vacation-title { color: var(--danger) !important; }
.ds-field .event-user { color: #ff6c35; margin-left: var(--space-1); }
.img-collab { margin: var(--space-4) auto !important; }

/* ---- LE LIEN NU, EN COULEUR DE TEXTE ET NON DE REMPLISSAGE ---------------
   `ds-bridge.css` peint `a { color: var(--primary) !important }`. C est juste
   en clair, et faux en sombre : `--primary` est la teinte de REMPLISSAGE de la
   marque — celle du bouton plein, ou elle porte du blanc — pas une teinte de
   texte. Posee sur une surface sombre elle tombe a 2,40:1, sous le minimum de
   4,5:1. Mesure faite sur un banc hors ecran, thème sombre, fond `--surface`.

   `--text-link` existe depuis le debut pour ca, et il n a PAS besoin d un
   selecteur de theme : en clair il vaut `var(--primary)`, donc rien ne bouge ;
   en sombre il vaut `color-mix(--primary 45%, #fff)`. Une seule regle, les
   deux themes, et la couleur du client toujours respectee.

   DEUX PRECAUTIONS, chacune verifiee au banc :

   `:not(.btn)` est INDISPENSABLE. Les recettes de bouton posent leur couleur
   en `!important` avec une specificite de (0,2,0) ; sans l exclusion, ce
   selecteur a (0,2,1) et repeindrait le libelle d un `<a class="btn
   btn-primary">` — mesure : blanc sur indigo a 6,87:1 aujourd hui, dans les
   deux themes. Il n y a rien a corriger la.

   LA PORTEE S ARRETE AU CORPS ET AU PIED DE FENETRE, et c est une correction
   apres mesure : j avais d abord ecrit `.ds a:not(.btn)`, en croyant `.ds`
   propre aux modales. Il est sur la COQUE DE L APPLICATION — les 19 liens
   visibles de l accueil sont dessous. Le menu principal passait donc du gris
   neutre (182, 189, 201, 8,73:1) a l indigo clair : un contraste toujours bon,
   mais un menu repeint que personne n avait demande. `.modal-body` et
   `.modal-foot` ne visent que ce qui a ete mesure.

   Les liens hors fenetre de saisie gardent donc celui du pont — dette connue,
   pas un oubli. */
.ds .modal-body a:not(.btn),
.ds .modal-foot a:not(.btn) { color: var(--text-link) !important; }
.ds .modal-body a:not(.btn):hover,
.ds .modal-body a:not(.btn):focus,
.ds .modal-foot a:not(.btn):hover,
.ds .modal-foot a:not(.btn):focus { color: var(--text-link-hover) !important; }

/* Questions Classement / Association : simple.css peint les items en blanc en dur. */
.simpleDemo ul[dnd-list] li {
  background-color: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}
.simpleDemo ul[dnd-list] li.selected {
  background-color: var(--success-soft) !important;
  color: var(--success-fg) !important;
}
.simpleDemo ul[dnd-list] .dndPlaceholder { background-color: var(--surface-hover) !important; }
