/* =====================================================================
   ALLIANCES COSMETIQUE — identité visuelle de l'application
   Palette dérivée du logo : or rose sur fond ivoire, accents cuivre.
   ===================================================================== */

:root {
  /* Or rose du logo */
  --rose:        #B5887A;
  --rose-fonce:  #9A6E60;
  --rose-clair:  #D4B3A6;
  --rose-pale:   #F2E3DB;
  --rose-voile:  #FBF5F1;

  /* Neutres chauds */
  --encre:       #2E2724;
  --encre-2:     #413732;
  --texte:       #332C28;
  --discret:     #857771;
  --bordure:     #EADFD9;
  --bordure-2:   #F3EAE5;
  --fond:        #F8F4F1;
  --blanc:       #ffffff;

  /* Sémantique */
  --vert:        #3F7D63;
  --vert-pale:   #E8F2EC;
  --rouge:       #B5453C;
  --rouge-pale:  #FBEAE8;
  --ambre:       #B07C2A;
  --ambre-pale:  #FBF0DC;

  --rayon:       12px;
  --rayon-s:     8px;
  --ombre:       0 1px 2px rgba(60,40,32,.04), 0 8px 24px rgba(60,40,32,.06);
  --ombre-forte: 0 2px 6px rgba(60,40,32,.08), 0 16px 40px rgba(60,40,32,.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Barre haute ---------------------------------------------- */
.barre-haute {
  background: linear-gradient(100deg, var(--encre) 0%, #39302C 60%, #463A34 100%);
  padding: .22rem 0;
  border-bottom: 1px solid rgba(181,136,122,.3);
}
.barre-haute .container-fluid { min-height: 2.35rem; }
.barre-haute .navbar-brand {
  color: #fff; font-weight: 600; letter-spacing: .015em;
  display: flex; align-items: center; gap: .6rem; font-size: .98rem;
}
.barre-haute .navbar-brand:hover { text-decoration: none; }
.barre-haute .navbar-brand small {
  color: var(--rose-clair); font-weight: 500; font-size: .66rem;
  text-transform: uppercase; letter-spacing: .18em; padding-left: .6rem;
  border-left: 1px solid rgba(212,179,166,.35);
}
.logo-barre { height: 24px; width: auto; display: block; }
.texte-discret { color: #C4B6B0; }
.btn-menu { color: #fff; border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.04); }
.btn-menu:hover { color: #fff; background: rgba(255,255,255,.12); }

/* ---------- Structure ------------------------------------------------- */
.enveloppe { display: flex; align-items: flex-start; min-height: calc(100vh - 44px); }

.menu { background: var(--blanc); padding: .5rem 0 2rem; }
@media (min-width: 992px) {
  .menu {
    width: 252px; flex: 0 0 252px;
    border-right: 1px solid var(--bordure);
    position: sticky; top: 52px; align-self: flex-start;
  }
}
.menu-groupe {
  font-size: .64rem; text-transform: uppercase; letter-spacing: .16em;
  color: var(--discret); padding: 1.1rem 1.3rem .4rem; font-weight: 700;
}
.menu-lien {
  display: flex; align-items: center; gap: .65rem; padding: .5rem 1.3rem;
  color: var(--texte); text-decoration: none; font-size: .885rem;
  border-left: 3px solid transparent; transition: background .12s, color .12s;
}
.menu-lien i { color: #A9988F; width: 17px; text-align: center; transition: color .12s; }
.menu-lien:hover { background: var(--rose-voile); color: var(--texte); text-decoration: none; }
.menu-lien:hover i { color: var(--rose); }
.menu-lien.actif {
  background: linear-gradient(90deg, var(--rose-pale), var(--rose-voile));
  border-left-color: var(--rose); font-weight: 650;
}
.menu-lien.actif i { color: var(--rose-fonce); }
.menu-lien.alerte { color: var(--rouge); }

.contenu { flex: 1 1 auto; padding: 1.6rem 1.9rem 3rem; min-width: 0; }

.titre-page {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.35rem;
  padding-bottom: .9rem; border-bottom: 1px solid var(--bordure);
}
.titre-page h1 {
  font-size: 1.5rem; font-weight: 650; margin: 0 0 .2rem;
  letter-spacing: -.015em; color: var(--encre);
}
.titre-page .texte-discret, .titre-page p { color: var(--discret); font-size: .875rem; }
.titre-page a { color: var(--rose-fonce); text-decoration: none; }
.titre-page a:hover { text-decoration: underline; }
.actions-page { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }

/* ---------- Cartes ---------------------------------------------------- */
.carte {
  background: var(--blanc); border: 1px solid var(--bordure);
  border-radius: var(--rayon); box-shadow: var(--ombre); padding: 1.25rem;
}
.carte + .carte { margin-top: 1rem; }
.carte-filtres { padding: .95rem 1.25rem; background: linear-gradient(180deg, #fff, var(--rose-voile)); }
.carte-titre {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .14em;
  color: var(--discret); font-weight: 700; margin-bottom: .9rem;
}

/* ---------- Tuiles d'indicateurs -------------------------------------- */
.tuile {
  position: relative; overflow: hidden; height: 100%; padding: 1.1rem 1.25rem;
  transition: box-shadow .15s, transform .15s;
}
.tuile::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: linear-gradient(180deg, var(--rose-clair), var(--rose));
  opacity: .9;
}
.tuile:hover { box-shadow: var(--ombre-forte); transform: translateY(-1px); }
.tuile-icone {
  position: absolute; top: 1rem; right: 1.1rem; font-size: 1.15rem;
  color: var(--rose-clair); opacity: .85;
}
.tuile-libelle {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .13em;
  color: var(--discret); font-weight: 700;
}
.tuile-valeur {
  font-size: 1.55rem; font-weight: 650; margin-top: .35rem;
  letter-spacing: -.025em; color: var(--encre); font-variant-numeric: tabular-nums;
}
.tuile-detail { font-size: .77rem; color: var(--discret); margin-top: .25rem; }
.tuile-detail a { color: var(--rose-fonce); }
.ton-positif .tuile-valeur { color: var(--vert); }
.ton-positif::before { background: linear-gradient(180deg, #7FBDA0, var(--vert)); }
.ton-negatif .tuile-valeur { color: var(--rouge); }
.ton-negatif::before { background: linear-gradient(180deg, #DD8F88, var(--rouge)); }
.ton-alerte .tuile-valeur { color: var(--ambre); }
.ton-alerte::before { background: linear-gradient(180deg, #E0BE7C, var(--ambre)); }

/* ---------- Tableaux --------------------------------------------------- */
.table { font-size: .885rem; }
.table > thead > tr > th {
  background: var(--rose-voile); border-bottom: 1px solid var(--bordure);
  font-size: .67rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--discret); font-weight: 700; white-space: nowrap; padding: .65rem .8rem;
}
.table > tbody > tr > td { padding: .65rem .8rem; border-color: var(--bordure-2); vertical-align: middle; }
.table > tbody > tr { transition: background .1s; }
.table > tbody > tr:hover > td { background: var(--rose-voile); }
.table tr.inactif { opacity: .45; }
.table tr.ligne-total td {
  background: var(--rose-pale); font-weight: 700; color: var(--encre);
  border-top: 2px solid var(--rose-clair);
}
.table tr.ligne-soustotal td { background: var(--rose-voile); font-weight: 650; }
.table tr.ligne-negative td { color: var(--rouge); }
.nombre, .montant { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Formulaires ------------------------------------------------ */
.form-label { font-size: .78rem; font-weight: 650; color: #594E49; margin-bottom: .28rem; letter-spacing: .005em; }
.form-control, .form-select {
  border-color: #E0D3CC; font-size: .89rem; padding: .46rem .72rem;
  border-radius: var(--rayon-s); background-color: #fff;
}
.form-control:focus, .form-select:focus {
  border-color: var(--rose-clair); box-shadow: 0 0 0 .2rem rgba(181,136,122,.14);
}
.form-control::placeholder { color: #B8A9A2; }
.form-text { font-size: .76rem; color: var(--discret); }
.requis { color: var(--rouge); }
.input-group-text {
  background: var(--rose-voile); border-color: #E0D3CC; font-size: .8rem;
  color: var(--discret); border-radius: 0 var(--rayon-s) var(--rayon-s) 0;
}
.input-group > .form-control, .input-group > .form-select { border-radius: var(--rayon-s) 0 0 var(--rayon-s); }
.form-check-input { accent-color: var(--rose); }

.btn { font-size: .865rem; border-radius: var(--rayon-s); padding: .46rem .9rem; font-weight: 550; }
.btn-principal {
  background: linear-gradient(160deg, var(--encre-2), var(--encre));
  border-color: var(--encre); color: #fff; box-shadow: 0 1px 2px rgba(46,39,36,.2);
}
.btn-principal:hover, .btn-principal:focus {
  background: linear-gradient(160deg, #4E423C, #38302C); color: #fff;
}
.btn-or {
  background: linear-gradient(160deg, var(--rose-clair), var(--rose));
  border-color: var(--rose); color: #fff; box-shadow: 0 1px 2px rgba(181,136,122,.3);
}
.btn-or:hover { background: linear-gradient(160deg, var(--rose), var(--rose-fonce)); color: #fff; }
.btn-outline-secondary { color: #5C514C; border-color: #E0D3CC; background: #fff; }
.btn-outline-secondary:hover, .btn-outline-secondary.active {
  background: var(--rose-pale); border-color: var(--rose-clair); color: var(--encre);
}
.btn-outline-danger { color: var(--rouge); border-color: #EBCFCC; }
.btn-outline-danger:hover { background: var(--rouge); border-color: var(--rouge); color: #fff; }
.btn-outline-success { color: var(--vert); border-color: #C6DED2; }
.btn-outline-success:hover { background: var(--vert); border-color: var(--vert); color: #fff; }

.barre-outils { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: space-between; margin-bottom: 1.1rem; }
.champ-recherche { position: relative; max-width: 420px; }
.champ-recherche i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--discret); font-size: .85rem; }
.champ-recherche .form-control { padding-left: 2.1rem; }
.raccourcis .btn { font-size: .77rem; padding: .36rem .62rem; }

/* ---------- Divers ----------------------------------------------------- */
.etat-vide {
  text-align: center; padding: 3.2rem 1rem; color: var(--discret);
  background: var(--blanc); border: 1px dashed var(--bordure);
  border-radius: var(--rayon);
}
.etat-vide i { font-size: 2rem; color: var(--rose-clair); display: block; margin-bottom: .7rem; }
.etat-vide p { margin-bottom: .9rem; }

.badge { font-weight: 650; font-size: .69rem; padding: .34em .62em; letter-spacing: .015em; border-radius: 5px; }
.text-bg-secondary { background: #F0E9E5; color: #5C514C; }
.text-bg-light      { background: var(--rose-pale); color: var(--rose-fonce); }
.text-bg-success    { background: var(--vert-pale); color: #2C5B47; }
.text-bg-danger     { background: var(--rouge-pale); color: #8E322B; }
.text-bg-warning    { background: var(--ambre-pale); color: #7A5518; }
.text-bg-info       { background: var(--rose-pale); color: var(--rose-fonce); }
.text-bg-rose       { background: var(--rose); color: #fff; }
.text-bg-encre      { background: var(--encre); color: #fff; }

.alert {
  border: none; border-left: 3px solid; border-radius: var(--rayon-s);
  font-size: .885rem; padding: .78rem 1.05rem;
}
.alert-success { border-left-color: var(--vert); background: var(--vert-pale); color: #2C5B47; }
.alert-danger  { border-left-color: var(--rouge); background: var(--rouge-pale); color: #8E322B; }
.alert-info    { border-left-color: var(--rose); background: var(--rose-pale); color: #74503F; }
.alert-warning { border-left-color: var(--ambre); background: var(--ambre-pale); color: #7A5518; }

.lien-discret { color: var(--texte); text-decoration: none; }
.lien-discret:hover { color: var(--rose-fonce); text-decoration: underline; }
a { color: var(--rose-fonce); }

.jauge { height: 6px; background: var(--bordure-2); border-radius: 4px; overflow: hidden; }
.jauge > span {
  display: block; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--rose-clair), var(--rose));
}

.marge-positive { color: var(--vert); font-weight: 650; }
.marge-negative { color: var(--rouge); font-weight: 650; }

.list-group-item.active { background: var(--rose-pale); border-left-color: var(--rose); }
.list-group-item-action:hover { background: var(--rose-voile); }
.dropdown-item:hover { background: var(--rose-voile); }
.dropdown-menu { border-color: var(--bordure); border-radius: var(--rayon-s); box-shadow: var(--ombre-forte); }

hr { border-color: var(--bordure); opacity: 1; }
code { background: var(--rose-voile); color: var(--rose-fonce); }

/* ---------- Responsive -------------------------------------------------- */
@media (max-width: 991.98px) {
  .enveloppe { display: block; }
  .contenu { padding: 1rem; }
  .titre-page { align-items: flex-start; flex-direction: column; }
  .titre-page h1 { font-size: 1.25rem; }
  .tuile-valeur { font-size: 1.2rem; }
  .tuile-libelle { font-size: .64rem; }
  .barre-outils { flex-direction: column; align-items: stretch; }
  .champ-recherche { max-width: none; }
  .raccourcis { flex-wrap: wrap; }
  .actions-page { margin-top: .6rem; }
  .logo-barre { height: 21px; }
}

/* --- Grille des droits par profil ------------------------------------- */
.grille-droits th {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--discret); font-weight: 650;
}
.grille-droits td:first-child { font-size: .87rem; }
.grille-droits tbody tr:hover { background: var(--rose-voile); }

/* Sélecteur segmenté : quatre niveaux côte à côte, lisibles au pouce. */
.segments {
  display: inline-flex; border: 1px solid var(--bordure); border-radius: var(--rayon-s);
  overflow: hidden; background: #fff;
}
.segments .seg { margin: 0; cursor: pointer; }
.segments .seg input {
  position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none;
}
.segments .seg span {
  display: block; padding: .32rem .72rem; font-size: .78rem; font-weight: 550;
  color: var(--discret); border-left: 1px solid var(--bordure); white-space: nowrap;
  transition: background-color .12s, color .12s;
}
.segments .seg:first-child span { border-left: none; }
.segments .seg:hover span { background: var(--rose-voile); color: var(--rose-fonce); }
.segments .seg input:checked + span {
  background: linear-gradient(160deg, var(--encre-2), var(--encre)); color: #fff;
}
.segments .seg input:focus-visible + span { outline: 2px solid var(--rose); outline-offset: -2px; }

.font-monospace { font-family: "Consolas", "SF Mono", "Courier New", monospace; font-size: .82em; }

@media (max-width: 767.98px) {
  .table.grille-droits > tbody > tr > td { display: block; padding: .3rem .7rem; }
  .table.grille-droits > tbody > tr > td:first-child { padding-top: .7rem; border-top: 1px solid var(--bordure); }
  .table.grille-droits > tbody > tr > td:last-child { padding-bottom: .7rem; text-align: left; }
  .table.grille-droits > tbody > tr > td { border-top: none; }
  .table.grille-droits > thead { display: none; }
  .segments { width: 100%; }
  .segments .seg { flex: 1; }
  .segments .seg span { padding: .4rem .2rem; text-align: center; font-size: .72rem; }
}

@media print {
  .barre-haute, .menu, .barre-outils, .actions-page, .carte-filtres, .btn { display: none !important; }
  .contenu { padding: 0; }
  .carte { border: none; box-shadow: none; padding: 0; }
  .tuile::before { display: none; }
}


/* ---------- Saisie des lignes de document ----------------------------- *
 * Les champs chiffres doivent rester lisibles, y compris sur telephone :
 * on supprime les fleches du champ nombre, qui volaient la moitie de la
 * largeur, et on elargit la colonne de la remise.                        */
.tableau-lignes input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: .95rem;
  padding-left: .4rem; padding-right: .4rem;
}
.tableau-lignes input[type="number"]::-webkit-outer-spin-button,
.tableau-lignes input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.tableau-lignes .input-group-text {
  padding-left: .4rem; padding-right: .4rem;
  font-size: .8rem; color: var(--discret);
}
.tableau-lignes .f-remise { min-width: 3.6rem; }
.tableau-lignes .f-quantite,
.tableau-lignes .f-prix { min-width: 4rem; }

@media (max-width: 767.98px) {
  /* Sur telephone, les chiffres passent avant tout. La designation se
     remplit toute seule depuis le produit : on la masque pour laisser la
     place a la quantite, au prix et a la remise. Le champ reste dans le
     formulaire et sa valeur est bien enregistree.                        */
  .tableau-lignes input[type="number"] { font-size: 1rem; padding: .4rem .5rem; }
  .tableau-lignes .f-remise { min-width: 4.4rem; }
  .tableau-lignes .f-quantite,
  .tableau-lignes .f-prix { min-width: 5rem; }
  .tableau-lignes th:nth-child(2),
  .tableau-lignes td:nth-child(2) { display: none; }
  .tableau-lignes th:first-child,
  .tableau-lignes td:first-child { min-width: 9rem; }
  .tableau-lignes .form-select { font-size: .88rem; }
  .tableau-lignes th { font-size: .7rem; }
}

/* ---------- Encadres de saisie ---------------------------------------- */
.carte-interne {
  background: var(--rose-voile);
  border: 1px solid rgba(154,110,96,.16);
  border-radius: .6rem;
  padding: .9rem 1rem;
}
.encadre-influenceuse {
  border: 1px solid rgba(154,110,96,.22);
  border-radius: .6rem;
  padding: .7rem .9rem;
  background: rgba(212,179,166,.08);
}
.encadre-influenceuse .form-check-label { cursor: pointer; }

/* ---------- Tableau de fusion des doublons ---------------------------- *
 * base.css positionne les cases a cocher en absolu, ce qui convient a un
 * .form-check mais les rend invisibles dans une cellule de tableau.
 * On les remet dans le flux, agrandies pour etre cliquables au pouce.   */
.table-fusion .form-check-input {
  position: static;
  width: 1.15rem; height: 1.15rem;
  margin: 0 auto;
  display: block;
  cursor: pointer;
}
.table-fusion td, .table-fusion th { vertical-align: middle; }
.table-fusion tr:has(.form-check-input:checked[type="radio"]) { background: rgba(154,110,96,.07); }
.table-fusion .f-conserver { text-align: center; }
