/* Style commun a toutes les pages (refonte du 29/10/2026).
 *
 * Pense d'abord pour le telephone : un en-tete simple en haut (retour, titre,
 * actualiser), une barre de navigation fixe en bas (Accueil, Ruptures, Ventes,
 * Fournisseurs, Panier). Fond sombre, rouge Carmin du logo pour ce qui compte.
 *
 * Une page l'utilise avec <body class="v2"> et ce fichier ; commun.js pose
 * alors l'en-tete et la barre du bas a sa place.
 */

:root {
  color-scheme: dark;
  /* Couleurs */
  --fond: #141211;
  --carte: #1f1c1a;
  --carte-haute: #29251f;    /* ce qui est pose par-dessus (barres, menus) */
  --trait: #36312b;
  --texte: #f1ece6;
  --doux: #a0978b;
  --accent: #e0352b;         /* rouge Carmin, celui du logo */
  --accent-fonce: #b8261e;
  --sur-accent: #ffffff;
  --accent-clair: #3a1a17;   /* fond rouge tres sombre (etiquettes) */
  --ok: #5fbf7f;
  --ok-clair: #1c3325;
  --whatsapp: #25a35a;
  --creux: #2a2622;          /* fond d'une image qui charge */
  /* Mesures */
  --r-petit: 8px;
  --r: 12px;
  --r-grand: 16px;
  --haut-entete: 56px;
  --haut-nav: 74px;          /* hauteur de la barre du bas (hors marge iPhone) */
  --toucher: 44px;
  --police: -apple-system, "Segoe UI", Roboto, sans-serif;           /* taille minimale d'un bouton au doigt */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.v2 {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 15px/1.45 var(--police);
  /* Exactement la hauteur de la barre du bas : rien ne passe dessous. */
  padding-bottom: calc(var(--haut-nav) + env(safe-area-inset-bottom) + 24px);
}
body.v2 a { color: inherit; }
body.v2 svg.ic {
  width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* --- En-tete : retour, titre, actualiser -------------------------------- */
.entete {
  position: sticky; top: 0; z-index: 40;
  height: var(--haut-entete); padding: 0 6px;
  display: flex; align-items: center; gap: 4px;
  background: rgba(20,18,17,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--trait);
}
.entete .titre-page {
  flex: 1; min-width: 0; text-align: center; line-height: 1.15;
}
.entete .titre-page b {
  display: block; font-size: 17px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.entete .titre-page small {
  display: block; font-size: 12px; color: var(--doux);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bouton-rond {
  width: var(--toucher); height: var(--toucher); flex: none; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%; background: transparent; color: var(--texte);
  cursor: pointer; text-decoration: none;
}
.bouton-rond:active { background: var(--carte-haute); }
.bouton-rond svg { width: 24px; height: 24px; }

/* --- Barre de navigation du bas ---------------------------------------- */
/* Barre flottante aux bords arrondis, posee au-dessus du bas de l'ecran
   (et de la marge de l'iPhone) ; l'onglet actif est dans une pilule claire. */
.nav-bas {
  position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 45;
  height: var(--haut-nav); padding: 7px; gap: 2px; box-sizing: border-box;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: rgba(31,28,26,.96); backdrop-filter: blur(14px);
  border: 1px solid var(--trait); border-radius: 40px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.nav-bas a {
  position: relative; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; text-decoration: none;
  font-size: 10px; font-weight: 600; color: var(--texte);
  border-radius: 30px; min-width: 0;
}
.nav-bas a svg { width: 24px; height: 24px; }
.nav-bas a.actif { color: var(--accent); }
.nav-bas a { z-index: 1; transition: color .25s; }
/* Le curseur sous l'onglet choisi : une pilule dans la barre, qui glisse
   d'un onglet a l'autre. */
.nav-bas .curseur-nav {
  position: absolute; top: 7px; height: calc(var(--haut-nav) - 16px); left: 0; width: 0; z-index: 0;
  border-radius: 32px; background: #3a342e; border: 1px solid rgba(255,255,255,.14);
  pointer-events: none; opacity: 0;
  /* Part vite, finit lentement (courbe « ease-out » marquee). */
  transition: transform .34s cubic-bezier(.16,1,.3,1), width .34s cubic-bezier(.16,1,.3,1), opacity .12s;
}
.nav-bas .curseur-nav.sans-anim { transition: none; }
/* Le panier : un rond rouge dans la barre, toujours visible. */
.nav-bas a.onglet-panier { color: #fff; }
.nav-bas a.onglet-panier::before {
  content: ""; position: absolute; z-index: -1; left: 50%; top: 50%;
  width: 58px; height: 58px; border-radius: 50%; transform: translate(-50%, -50%);
  background: var(--accent);
}
.nav-bas a.onglet-panier.actif { color: #fff; }
.nav-bas a.onglet-panier .pastille-nombre { top: -2px; background: #fff; color: var(--accent); }
.nav-bas .pastille-nombre:empty { display: none; }
.menu-tinder {
  position: fixed; z-index: 46; right: 12px;
  bottom: calc(var(--haut-nav) + env(safe-area-inset-bottom) + 18px);
  display: grid; background: var(--carte-haute); border: 1px solid var(--trait);
  border-radius: 12px; overflow: hidden;
}
.menu-tinder[hidden] { display: none; }
.menu-tinder a {
  padding: 14px 18px; color: inherit; text-decoration: none; font-size: 15px;
}
.menu-tinder a + a { border-top: 1px solid var(--trait); }
@media (min-width: 900px) {
  /* Sur ordinateur, la barre occupe toute la largeur, ses onglets restent
     groupes au milieu. */
  .nav-bas { left: 50%; right: auto; width: 600px; transform: translateX(-50%); }
}

/* --- Mise en page ------------------------------------------------------- */
body.v2 main { padding: 12px 16px; max-width: 1100px; margin: 0 auto; }
.section { margin: 22px 0 10px; }
.section:first-child { margin-top: 4px; }
.titre-section {
  display: flex; align-items: center; gap: 8px; min-height: var(--toucher);
  margin: 0 0 8px; font-size: 17px; font-weight: 700;
}
.titre-section .nombre {
  font-size: 13px; font-weight: 700; color: var(--doux);
  background: var(--carte-haute); border-radius: 999px; padding: 2px 9px;
}
.titre-section .actions { margin-left: auto; display: flex; gap: 6px; }

/* Rangee qui defile du doigt (pastilles de fournisseurs, de types) */
.defile {
  position: relative; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; padding: 2px 0 6px; margin: 0 -16px; padding-inline: 16px;
}
.defile::-webkit-scrollbar { display: none; }
.defile > * { flex: none; }

/* --- Boutons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 0 14px; border-radius: var(--r-petit);
  font: 600 14px/1 var(--police); white-space: nowrap; cursor: pointer;
  border: 1px solid var(--trait); background: var(--carte-haute); color: var(--texte);
  text-decoration: none;
}
.btn:active { filter: brightness(1.15); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.principal { background: var(--accent); border-color: var(--accent); color: var(--sur-accent); }
.btn.discret { background: transparent; border-color: transparent; color: var(--doux); }
.btn.danger { background: transparent; border-color: transparent; color: #ff8a80; }
.btn.large { width: 100%; min-height: 48px; font-size: 15px; }
.btn.icone-seule { width: 40px; padding: 0; }
.btn svg { width: 18px; height: 18px; }

/* Pastille de choix (filtre) */
.pastille {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--trait); background: var(--carte);
  color: var(--texte); font: 600 13px/1 var(--police); cursor: pointer; white-space: nowrap;
}
.pastille .n { color: var(--doux); font-weight: 600; font-size: 12px; }
.pastille.actif { background: var(--accent); border-color: var(--accent); color: var(--sur-accent); }
.pastille.actif .n { color: rgba(255,255,255,.75); }
/* Pastille de type : l'icone, son nom en petit dessous */
.pastille.avec-icone { flex-direction: column; justify-content: center; height: auto; min-height: 48px;
                       padding: 5px 10px; gap: 3px; border-radius: var(--r); }

/* Selecteur a deux ou trois choix (Liste / Carte) */
.segments {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px;
  background: var(--carte); border: 1px solid var(--trait); border-radius: var(--r);
}
.segments button {
  height: 36px; border: none; border-radius: var(--r-petit); cursor: pointer;
  font: 600 14px/1 var(--police); background: transparent; color: var(--doux);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.segments { position: relative; }
.segments button { position: relative; z-index: 1; transition: color .16s; }
.segments button.actif { color: var(--texte); }
/* Le fond du choix actif glisse d'un choix a l'autre (Commun.animerSegments). */
.segments .curseur-seg {
  position: absolute; top: 4px; bottom: 4px; left: 0; width: 0; z-index: 0; opacity: 0;
  border-radius: var(--r-petit); background: var(--carte-haute); box-shadow: 0 1px 3px rgba(0,0,0,.4);
  pointer-events: none; transition: transform .34s cubic-bezier(.16,1,.3,1), width .34s cubic-bezier(.16,1,.3,1);
}
.segments .curseur-seg.sans-anim { transition: none; }
/* Les choix d'un selecteur peuvent etre des liens (pages « Trier », « Bijoux »). */
.segments a {
  position: relative; z-index: 1; height: 36px; border-radius: var(--r-petit);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 14px/1 var(--police); color: var(--doux); text-decoration: none; transition: color .16s;
}
.segments a.actif { color: var(--texte); }
/* Sous l'en-tete : le choix entre les deux pages du groupe. */
.sous-nav-zone { padding: 10px 16px 0; max-width: 1100px; margin: 0 auto; }

/* --- Cartes et listes --------------------------------------------------- */
.carte-bloc {
  background: var(--carte); border: 1px solid var(--trait); border-radius: var(--r-grand);
  padding: 14px;
}
.liste { display: flex; flex-direction: column; background: var(--carte);
         border: 1px solid var(--trait); border-radius: var(--r-grand); overflow: hidden; }
.ligne {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 8px 10px 16px;
  border: none; border-bottom: 1px solid var(--trait); background: transparent;
  color: inherit; font: inherit; text-align: left; cursor: pointer; width: 100%; text-decoration: none;
}
.ligne:last-child { border-bottom: none; }
.ligne:active { background: var(--carte-haute); }
.ligne .corps { flex: 1; min-width: 0; }
.ligne .corps b { display: block; font-size: 16px; }
.ligne .corps small { display: block; color: var(--doux); font-size: 13px; margin-top: 2px; }
.ligne .chevron { color: var(--doux); }
.compteur-rouge { color: var(--accent); font-weight: 700; }

.etiquette {
  display: inline-block; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 2px 7px;
  background: var(--ok-clair); color: var(--ok);
}
.etiquette.rouge { background: var(--accent-clair); color: #ff8a80; }

.vide {
  text-align: center; color: var(--doux); padding: 28px 18px; line-height: 1.6;
  background: var(--carte); border: 1px dashed var(--trait); border-radius: var(--r-grand);
}

/* Petit dessin (une boite vide) au-dessus des messages de liste vide. */
.vide::before, body.v2 .vide-message::before {
  content: ""; display: block; width: 44px; height: 44px; margin: 0 auto 10px;
  background: var(--doux); opacity: .55;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8l2-4h14l2 4M3 8v11h18V8M3 8h18M9 12h6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8l2-4h14l2 4M3 8v11h18V8M3 8h18M9 12h6'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Grille de photos de bijoux */
.grille-bijoux {
  display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 560px) { .grille-bijoux { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 860px) { .grille-bijoux { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); } }
.bijou { position: relative; border-radius: var(--r); overflow: hidden; background: var(--creux); }
.bijou img, .bijou .absente {
  display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--creux); cursor: pointer;
}
.bijou .absente { display: flex; align-items: center; justify-content: center; color: var(--doux); font-size: 26px; }
.bijou.fait { opacity: .45; }

/* Champs de saisie */
.champ { display: flex; flex-direction: column; gap: 5px; }
.champ span { font-size: 12px; font-weight: 600; color: var(--doux); }
.champ-ligne { display: flex; gap: 8px; align-items: center; }
body.v2 input[type=text], body.v2 input[type=tel], body.v2 input[type=email],
body.v2 input[type=url], body.v2 input[type=search] {
  width: 100%; min-width: 0; height: 44px; padding: 0 12px; border-radius: var(--r-petit);
  border: 1px solid var(--trait); background: var(--fond); color: var(--texte);
  font: 16px var(--police);   /* 16px : le telephone ne zoome pas */
}
body.v2 input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

/* --- Barre d'outils d'une page (recherche, filtres, tri), sous l'en-tete --- */
body.v2 .outils {
  position: static !important; padding: 10px 16px 4px !important;
  background: transparent; border: none; max-width: 1100px; margin: 0 auto;
}
body.v2 .outils:empty { display: none; }
body.v2 .outils #resume, body.v2 .outils .sous-titre:not(#restants):not(#avancement) { display: none; }  /* repris sous le titre */
body.v2 .outils .barre, body.v2 .outils .titre-ligne {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 8px;
}
body.v2 .outils .boutons-filtre, body.v2 .boutons-filtre {
  display: flex; gap: 8px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px;
}
body.v2 .boutons-filtre::-webkit-scrollbar { display: none; }
body.v2 .boutons-filtre > * { flex: none; }
body.v2 .etiquette-filtre { color: var(--doux); font-size: 12px; font-weight: 600; }

/* --- Anciennes classes des pages, au meme style que les nouvelles ------- */
body.v2 .action, body.v2 .lien-retour, body.v2 .bouton-filtres {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: var(--r-petit);
  font: 600 14px/1 var(--police); white-space: nowrap; cursor: pointer; text-decoration: none;
  border: 1px solid var(--trait); background: var(--carte-haute); color: var(--texte);
}
body.v2 .action.plein, body.v2 .lien-retour.plein, body.v2 .bouton-filtres.actif {
  background: var(--accent); border-color: var(--accent); color: var(--sur-accent);
}
body.v2 .action.discret { background: transparent; border-color: transparent; color: var(--doux); }
body.v2 .action:disabled, body.v2 .lien-retour:disabled { opacity: .45; cursor: default; }
body.v2 .action .icone, body.v2 .icone {
  width: 18px; height: 18px; margin: 0; vertical-align: middle; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
body.v2 button.choix {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--trait); background: var(--carte);
  color: var(--texte); font: 600 13px/1 var(--police); cursor: pointer; white-space: nowrap;
}
body.v2 button.choix.actif { background: var(--accent); border-color: var(--accent); color: var(--sur-accent); }
body.v2 button.choix .compte-choix { color: inherit; opacity: .7; font-size: 12px; margin: 0; }
body.v2 button.choix.avec-icone { flex-direction: column; justify-content: center; min-height: 48px;
                                  padding: 5px 10px; gap: 3px; border-radius: var(--r); }
body.v2 select {
  height: 40px; padding: 0 10px; border-radius: var(--r-petit); border: 1px solid var(--trait);
  background: var(--carte); color: var(--texte); font: 15px var(--police);
}
body.v2 main h2 { font-size: 17px; font-weight: 700; color: var(--texte); }
body.v2 .vide-message {
  text-align: center; color: var(--doux); padding: 28px 18px; line-height: 1.6;
  background: var(--carte); border: 1px dashed var(--trait); border-radius: var(--r-grand);
}

/* --- Ce que commun.js pose par-dessus la page ---------------------------- */
/* La barre du bas remplace les boutons ronds Panier / Retour / Accueil. */
body.v2 .panier-flottant, body.v2 .retour-flottant, body.v2 .accueil-flottant { display: none !important; }
body.v2 .barre-selection { bottom: calc(var(--haut-nav) + env(safe-area-inset-bottom) + 22px); }

/* Fenetres (ajout de photos...) */
body.v2 dialog {
  border: 1px solid var(--trait); border-radius: var(--r-grand); padding: 0;
  max-width: min(480px, 94vw); background: var(--carte); color: var(--texte);
}
body.v2 dialog::backdrop { background: rgba(0,0,0,.75); }

/* Selection : seulement par appui long sur une photo (plus de bouton). */
body.v2 [data-bascule-selection] { display: none !important; }

/* Un element cache (attribut hidden) reste cache, quel que soit son style. */
body.v2 [hidden] { display: none !important; }
