/* =========================================================
   CRM Pistaches — styles (design « Pistache Pop »)
   Mobile-first : tout est pensé pour un téléphone, puis élargi.
   ========================================================= */

/* ---------- Couleurs : thème clair (par défaut) ---------- */
:root {
  --fond: #FBF7EC;        /* crème */
  --carte: #FFFFFF;
  --trait: #E6DFCB;
  --encre: #1F2A1A;       /* texte principal */
  --gris: #5C6652;        /* texte secondaire */
  --doux: #DDEBC5;        /* vert très clair */
  --pistache: #93C572;    /* LA couleur */
  --pistache-fonce: #3F6B1F;
  --rose: #B83A60;
  --rose-doux: #F7D9E1;
  --rose-encre: #6E1F38;
  --or: #F2C14E;
  --plein: #1F2A1A;       /* blocs « pleins » (boutons, pied de page) */
  --sur-plein: #FBF7EC;
  --sur-plein-gris: #C9D6B4;
  --ombre: 0 6px 16px rgba(31, 42, 26, .25);
  --rayon: 22px;
  --titre: 'Bricolage Grotesque', system-ui, sans-serif;
  color-scheme: light;
}

/* ---------- Thème sombre ---------- */
[data-theme="sombre"] {
  --fond: #141A11;
  --carte: #1E261A;
  --trait: #313C2A;
  --encre: #EEF3E4;
  --gris: #A6B199;
  --doux: #2C3B22;
  --pistache-fonce: #B7D98B;
  --rose: #F08AAA;
  --rose-doux: #4A2230;
  --rose-encre: #F7D9E1;
  --plein: #DDEBC5;
  --sur-plein: #1F2A1A;
  --sur-plein-gris: #3D4734;
  --ombre: 0 6px 16px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font-family: Inter, system-ui, sans-serif;
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--pistache-fonce); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; }
.titre { font-family: var(--titre); font-weight: 800; letter-spacing: -.5px; }
.gris { color: var(--gris); }
.petit { font-size: 12px; }
.label {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--gris);
}

/* Conteneur principal : colonne étroite sur mobile, centrée sur grand écran */
.page {
  max-width: 560px; margin: 0 auto;
  padding: 20px 20px 120px;
  display: flex; flex-direction: column; gap: 16px;
}
.page.large { max-width: 1200px; }

/* ---------- En-têtes ---------- */
.entete { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.entete h1 { font-size: 30px; }
.entete-simple { display: flex; align-items: center; gap: 12px; }
.entete-simple h1 { font-size: 26px; flex: 1; }
.outils { display: flex; gap: 8px; }

/* Boutons ronds (retour, recherche, thème…) */
.rond {
  width: 44px; height: 44px; flex: none; border-radius: 22px;
  background: var(--carte); border: 1.5px solid var(--trait);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--encre);
}
.rond svg { width: 20px; height: 20px; }

/* ---------- Cartes ---------- */
.carte {
  background: var(--carte); border: 1.5px solid var(--trait);
  border-radius: var(--rayon); padding: 14px;
}
.grille-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grille-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 20px; }
.stat .valeur { font-family: var(--titre); font-weight: 800; font-size: 24px; }
.stat .nom { font-size: 12px; color: var(--gris); font-weight: 500; }
.stat.centre { text-align: center; padding: 10px 4px; }
.stat.centre .valeur { font-size: 21px; }

/* ---------- Pastille client (emoji dans un rond coloré) ---------- */
.pastille {
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; line-height: 1;
}
.pastille.grande { width: 72px; height: 72px; font-size: 38px; }

/* ---------- Boutons ---------- */
.btn {
  height: 52px; padding: 0 22px; border-radius: 26px; border: none;
  font-weight: 800; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-pistache { background: var(--pistache); color: #1F2A1A; }
.btn-plein { background: var(--plein); color: var(--sur-plein); }
.btn-contour { background: transparent; border: 2px solid var(--encre); color: var(--encre); }
.btn-large { width: 100%; height: 56px; border-radius: 28px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-mini {
  height: 40px; padding: 0 14px; border-radius: 20px; border: none;
  background: var(--plein); color: var(--sur-plein);
  font-weight: 700; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn-mini.clair { background: var(--doux); color: var(--encre); }
.btn-mini.rose { background: var(--rose-doux); color: var(--rose-encre); }
.btn-lien { background: none; border: none; color: var(--rose); font-weight: 700; padding: 8px; }

/* ---------- Le bocal (accueil) ---------- */
.bocal {
  background: var(--doux); border-radius: 28px; padding: 18px;
  display: flex; gap: 14px; align-items: center;
}
.bocal svg { flex: none; animation: wobble 4s ease-in-out infinite; transform-origin: 60px 140px; }
.bocal .remplissage { transition: transform 1s cubic-bezier(.3, 1.4, .5, 1); }
.bocal .chiffre { font-family: var(--titre); font-weight: 800; font-size: 44px; line-height: 1; letter-spacing: -1px; }
.bocal .chiffre small { font-size: 22px; }
.bocal .surtitre { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--pistache-fonce); }
.puce {
  align-self: flex-start; background: var(--plein); color: var(--sur-plein);
  font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 999px;
}
@keyframes wobble { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-3deg); } }

/* Défilement horizontal (relances, choix du client) */
.defile {
  display: flex; gap: 10px; overflow-x: auto;
  margin: 0 -20px; padding: 4px 20px;
  scrollbar-width: none;
}
.defile::-webkit-scrollbar { display: none; }
.relance {
  flex: none; width: 150px; display: flex; flex-direction: column; gap: 8px;
}
.relance .nom { font-weight: 700; font-size: 14px; }
.relance .actions { display: flex; gap: 6px; }

.client-du-mois {
  background: var(--plein); color: var(--sur-plein); border-radius: var(--rayon);
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
  border: none; width: 100%; text-align: left;
}
.client-du-mois .couronne { font-size: 34px; animation: wobble 2.5s ease-in-out infinite; }
.client-du-mois .gris { color: var(--sur-plein-gris); }

.alerte {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: var(--rose-doux); color: var(--rose-encre);
  border: none; border-radius: 16px; padding: 10px 14px; font-size: 13px; text-align: left;
}

.ligne {
  display: flex; align-items: center; gap: 12px;
}
.ligne .infos { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ligne .infos b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section { display: flex; flex-direction: column; gap: 10px; }
.section-titre { display: flex; justify-content: space-between; align-items: baseline; }
.section-titre h2 { font-family: var(--titre); font-weight: 800; font-size: 19px; }
.vide {
  border: 2px dashed var(--trait); border-radius: var(--rayon);
  padding: 22px; text-align: center; color: var(--gris); font-size: 14px;
}

/* ---------- Vendre ---------- */
.choix-client {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px; border-radius: 20px; border: none; background: transparent; min-width: 72px;
}
.choix-client .pastille { width: 52px; height: 52px; font-size: 26px; }
.choix-client span:last-child { font-size: 12px; font-weight: 600; max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.choix-client[aria-pressed="true"] { background: var(--plein); color: var(--sur-plein); }
.choix-client.nouveau .pastille { border: 2px dashed var(--gris); background: transparent; color: var(--gris); }

.produit-vente {
  display: flex; flex-direction: column; gap: 6px; padding: 12px;
  border-radius: var(--rayon); background: var(--carte); border: 1.5px solid var(--trait);
  transition: background .2s, border-color .2s;
}
.produit-vente.actif { background: var(--doux); border-color: var(--pistache); }
.produit-vente .haut { display: flex; justify-content: space-between; align-items: flex-start; font-size: 30px; }
.produit-vente .nom { font-weight: 700; font-size: 14px; line-height: 1.25; }
.qte {
  min-width: 28px; height: 28px; border-radius: 14px; padding: 0 8px;
  background: var(--plein); color: var(--sur-plein); font-weight: 800; font-size: 14px;
  display: flex; align-items: center; justify-content: center; animation: pop .25s ease-out;
}
.plus-moins { display: flex; gap: 8px; }
.plus-moins button {
  flex: 1; height: 44px; border-radius: 14px; font-size: 22px; font-weight: 700;
}
.plus-moins .moins { border: 1.5px solid var(--encre); background: transparent; color: var(--encre); }
.plus-moins .plus { border: none; background: var(--plein); color: var(--sur-plein); }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }

.caisse {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
}
.caisse > div {
  max-width: 536px; margin: 0 auto;
  background: var(--plein); color: var(--sur-plein); border-radius: 28px;
  padding: 14px 14px 14px 20px; display: flex; align-items: center; gap: 12px;
  box-shadow: var(--ombre);
}
.caisse .total { font-family: var(--titre); font-weight: 800; font-size: 30px; }
.caisse .resume { font-size: 12px; color: var(--sur-plein-gris); }
.caisse .btn:disabled { opacity: 1; background: var(--sur-plein-gris); color: var(--gris); }

/* Écran de victoire après une vente */
.victoire {
  position: fixed; inset: 0; z-index: 50; background: var(--pistache); color: #1F2A1A;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 32px; text-align: center; animation: pop .35s ease-out;
}
.victoire .gros { font-size: 90px; animation: wobble 1s ease-in-out infinite; }
.victoire h2 { font-family: var(--titre); font-weight: 800; font-size: 34px; line-height: 1.05; }
.victoire .btn-contour { border-color: #1F2A1A; color: #1F2A1A; }
.victoire .btn-plein { background: #1F2A1A; color: #FBF7EC; }

/* ---------- Pipeline (La Récolte) ---------- */
.onglets { display: flex; gap: 6px; }
.onglet {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px; border-radius: 18px; border: none; background: transparent;
}
.onglet .e { font-size: 24px; }
.onglet .n { font-size: 11px; font-weight: 700; }
.onglet .c { font-size: 11px; font-weight: 600; color: var(--gris); }
.onglet[aria-selected="true"] { background: var(--plein); color: var(--sur-plein); }
.onglet[aria-selected="true"] .c { color: var(--sur-plein-gris); }
.progression { height: 8px; border-radius: 4px; background: var(--trait); overflow: hidden; }
.progression div { height: 100%; background: var(--pistache); border-radius: 4px; transition: width .3s; }

.kanban-astuce { display: none; }
.kanban { display: flex; flex-direction: column; gap: 12px; }
.colonne { display: none; flex-direction: column; gap: 12px; border-radius: 24px; transition: background .15s; }
.colonne.actif { display: flex; }
.colonne .tete { display: flex; justify-content: space-between; align-items: baseline; }
.colonne .tete h2 { font-family: var(--titre); font-weight: 800; font-size: 22px; }
.colonne.survol { background: var(--doux); outline: 2px dashed var(--pistache); }
.fiche-pipe { display: flex; align-items: center; gap: 10px; animation: glisse .25s ease-out; }
.fiche-pipe[draggable="true"] { cursor: grab; }
.fiche-pipe .infos { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; color: var(--encre); background: none; border: none; text-align: left; padding: 0; }
.fiche-pipe .infos b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-fidele { height: 32px; padding: 0 12px; border-radius: 16px; background: var(--rose-doux); color: var(--rose-encre); font-weight: 700; font-size: 12px; display: flex; align-items: center; }
@keyframes glisse { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Grand écran : 5 colonnes côte à côte avec glisser-déposer */
@media (min-width: 900px) {
  .onglets, .progression { display: none; }
  .kanban-astuce { display: inline; }
  .kanban { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: start; }
  .colonne { display: flex; padding: 10px; background: color-mix(in srgb, var(--trait) 35%, transparent); min-height: 300px; }
  .colonne .tete h2 { font-size: 17px; }
  .fiche-pipe { flex-wrap: wrap; }
}

/* ---------- Fiche client ---------- */
.bandeau {
  margin: -20px -20px 0; padding: 20px 20px 22px; border-radius: 0 0 36px 36px;
  display: flex; flex-direction: column; gap: 14px; color: #1F2A1A;
}
.bandeau .rond { background: #FBF7EC; border-color: transparent; color: #1F2A1A; }
.bandeau h1 { font-size: 28px; line-height: 1.1; }
.bandeau .sous { font-size: 13px; color: #3D3416; }
.bandeau .pastille { background: #FBF7EC; }
.action {
  height: 60px; border-radius: 18px; background: #1F2A1A; color: #FBF7EC;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 12px; font-weight: 700;
}
.action span:first-child { font-size: 20px; line-height: 1; }
.action.inactif { opacity: .35; pointer-events: none; }
.etapes { display: flex; gap: 6px; flex-wrap: wrap; }
.etape {
  border: 1.5px solid var(--trait); background: var(--carte); border-radius: 999px;
  padding: 7px 11px; font-size: 13px; font-weight: 600;
}
.etape[aria-pressed="true"] { background: var(--plein); color: var(--sur-plein); border-color: var(--plein); }
.chouchou { padding: 8px 12px; border-radius: 999px; background: var(--doux); font-size: 13px; font-weight: 600; }
.chrono { border-left: 3px solid var(--pistache); margin-left: 7px; padding-left: 16px; display: flex; flex-direction: column; gap: 14px; }
.chrono .point { position: relative; display: flex; flex-direction: column; gap: 6px; }
.chrono .point::before {
  content: ''; position: absolute; left: -24px; top: 3px; width: 13px; height: 13px;
  border-radius: 7px; background: var(--pistache); border: 2px solid var(--fond);
}
.chrono .bas { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.statut-cmd { border: none; border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 700; }
.statut-cmd.a_preparer { background: var(--rose-doux); color: var(--rose-encre); }
.statut-cmd.livree { background: var(--doux); color: var(--encre); }
.statut-cmd.payee { background: var(--pistache); color: #1F2A1A; }
.notes {
  width: 100%; min-height: 80px; resize: vertical;
  background: var(--carte); border: 1.5px dashed var(--trait); border-radius: 18px;
  padding: 12px 14px; font-size: 14px; line-height: 1.4;
}

/* ---------- Produits ---------- */
.produit { display: flex; flex-direction: column; gap: 10px; }
.produit .ligne input[type="text"] { font-weight: 700; }
.champs-produit { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 8px; align-items: end; }
.stock-btns { display: flex; align-items: center; gap: 4px; }
.stock-btns button { width: 36px; height: 44px; border-radius: 12px; border: 1.5px solid var(--trait); background: var(--fond); font-weight: 800; font-size: 18px; flex: none; }
.stock-btns input { text-align: center; min-width: 0; }
.stock-bas input { color: var(--rose); font-weight: 800; }

/* ---------- Formulaires ---------- */
.champ { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--gris); }
.champ input, .champ select, .champ textarea, .recherche input {
  height: 44px; padding: 0 12px; border-radius: 14px;
  border: 1.5px solid var(--trait); background: var(--fond); color: var(--encre);
  font-size: 16px; font-weight: 500; width: 100%; /* 16px : évite le zoom auto sur iPhone */
}
.champ textarea { height: auto; min-height: 70px; padding: 10px 12px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--pistache); outline-offset: 1px;
}
.puces { display: flex; gap: 6px; flex-wrap: wrap; }
.puce-choix {
  border: 1.5px solid var(--trait); background: var(--fond); border-radius: 999px;
  padding: 8px 12px; font-size: 14px; font-weight: 600; color: var(--encre);
}
.puce-choix[aria-pressed="true"] { background: var(--plein); color: var(--sur-plein); border-color: var(--plein); }
.emojis { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.emojis button { height: 40px; border-radius: 12px; border: 1.5px solid transparent; background: var(--fond); font-size: 22px; padding: 0; }
.emojis button[aria-pressed="true"] { border-color: var(--pistache); background: var(--doux); }

/* Panneau qui monte du bas (formulaires) */
.voile { position: fixed; inset: 0; z-index: 40; background: rgba(20, 26, 17, .55); display: flex; align-items: flex-end; justify-content: center; }
.panneau {
  background: var(--carte); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 28px 28px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px; animation: monte .25s ease-out;
}
@keyframes monte { from { transform: translateY(40%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Recherche globale ---------- */
.recherche-fond { position: fixed; inset: 0; z-index: 45; background: var(--fond); overflow-y: auto; }
.recherche { display: flex; gap: 10px; align-items: center; }
.recherche input { height: 52px; border-radius: 26px; padding: 0 20px; font-size: 17px; background: var(--carte); }
.resultat { width: 100%; text-align: left; color: var(--encre); }

/* ---------- Barre de navigation ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--carte); border-top: 1.5px solid var(--trait);
  padding: 0 8px env(safe-area-inset-bottom);
}
.nav > div { max-width: 560px; margin: 0 auto; height: 74px; display: flex; align-items: center; justify-content: space-around; }
.nav a {
  display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 56px; padding-top: 6px;
  font-size: 11px; font-weight: 600; color: var(--gris);
}
.nav a[aria-current="page"] { color: var(--encre); font-weight: 800; }
.nav a svg { width: 24px; height: 24px; }
.nav .vendre {
  width: 64px; height: 64px; margin-top: -30px; border-radius: 32px; padding: 0;
  background: var(--pistache); border: 4px solid var(--fond); box-shadow: var(--ombre);
  justify-content: center; color: #1F2A1A;
}
.nav .vendre svg { width: 30px; height: 30px; }

/* ---------- Petits messages et confettis ---------- */
.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); z-index: 60;
  transform: translateX(-50%); max-width: 92vw;
  background: var(--plein); color: var(--sur-plein); box-shadow: var(--ombre);
  padding: 12px 18px; border-radius: 999px; font-weight: 700; font-size: 14px;
  animation: pop .25s ease-out;
}
.toast.erreur { background: var(--rose); color: #fff; }
.confettis { position: fixed; inset: 0; z-index: 70; pointer-events: none; overflow: hidden; }
.confettis span { position: absolute; top: -60px; animation: tombe linear forwards; }
@keyframes tombe { to { transform: translateY(110vh) rotate(720deg); } }

/* Respect du réglage « réduire les animations » du téléphone */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
