/* LU STUDIO Ventes — même style que « Commandes LU STUDIO » et l'outil Support
   (IBM Plex, en-tête sombre, bleu, cartes arrondies, pastilles de couleur).
   Différence : pensé d'abord pour le téléphone en foire (zones tactiles ≥ 44 px). */

:root {
  --ground: #EEF0F3; --panel: #FFFFFF; --lane: #E3E6EB; --ink: #16181D; --muted: #4A505C; --soft: #5B6270;
  --line: #D5DAE1; --line2: #E3E6EB; --field: #C9CFD8;
  --accent: #1F4FD8; --accent-ink: #163A9F; --accent-bg: #F5F8FF; --accent-line: #C7D5FB;
  --warn-bg: #FFF1DC; --warn: #D97706; --warn-ink: #B45309;
  --crit-bg: #FDE8E8; --crit: #DC2626; --crit-ink: #B91C1C;
  --ok: #16A34A; --ok-bg: #ECFDF3; --ok-line: #A7E3BF;
  --head: #16181D; --head2: #2A2D35; --head-muted: #B8BEC9;
  --police: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ground); color: var(--ink); font-family: var(--police); font-size: 15px; line-height: 1.45;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
[hidden] { display: none !important; }

/* --- En-tête --------------------------------------------------------------- */
.entete {
  background: var(--head); color: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 10px 20px;
  padding: calc(env(safe-area-inset-top) + 10px) 20px 10px; position: sticky; top: 0; z-index: 20;
}
.entete .marque { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entete .qui { display: flex; align-items: center; gap: 10px; font-size: 13px; margin-left: auto; }
.avatar {
  width: 30px; height: 30px; border-radius: 15px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.entete button.secondaire { background: transparent; color: #fff; border-color: #4A505C; }
.entete button.secondaire:hover { background: var(--head2); }

/* --- Contenu ------------------------------------------------------------------ */
main { padding: 18px 20px calc(env(safe-area-inset-bottom) + 28px); max-width: 760px; margin: 0 auto; }
h1 { margin: 0; font-size: 21px; font-weight: 600; }
.chargement { text-align: center; color: var(--soft); padding-top: 30vh; }

.barre { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 12px; }
.barre h1 { margin-right: auto; }
.infos { color: var(--muted); font-size: 13px; margin: 6px 0 12px; }

/* --- Boutons et champs ------------------------------------------------------- */
button {
  font: inherit; font-size: 14px; font-weight: 600;
  height: 44px; padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  touch-action: manipulation; transition: background-color .12s, transform .08s, filter .12s;
}
button:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
button:active { transform: scale(.97); filter: brightness(.9); }
button.secondaire { background: #fff; color: var(--ink); border-color: var(--field); font-weight: 400; }
button.secondaire:hover { background: #fff; border-color: #9AA2AF; }
button:disabled { opacity: .55; cursor: not-allowed; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--soft); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="search"], input[type="email"], input[type="tel"] {
  width: 100%; font: inherit; font-size: 16px; height: 44px; padding: 0 12px;
  border: 1px solid var(--field); border-radius: 8px; background: #fff; color: var(--ink);
}
.champ { margin-bottom: 16px; }

/* --- Connexion ---------------------------------------------------------------- */
.carte-connexion {
  max-width: 400px; margin: 10vh auto 0; padding: 28px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.carte-connexion h1 { margin-bottom: 4px; }
.carte-connexion .sous-titre { margin: 0 0 22px; color: var(--muted); }
.carte-connexion button { width: 100%; height: 48px; font-size: 15px; }
.carte-connexion .lien-bas { margin: 14px 0 0; text-align: center; }
.carte-connexion .lien-bas button.lien { width: auto; height: 36px; }

.message { padding: 10px 14px; margin-bottom: 14px; border-radius: 8px; font-size: 14px; font-weight: 500; border: 1px solid var(--accent-line); background: var(--accent-bg); color: var(--accent-ink); }
.message.erreur { background: var(--crit-bg); border-color: #F3B4B4; color: var(--crit-ink); }
.message.info { background: var(--warn-bg); border-color: #F3D19B; color: var(--warn-ink); }

/* --- Choix de la période (puces, comme Commandes / Support) ------------------- */
.filtres { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--field); background: #fff; color: var(--ink); font-size: 13px; font-weight: 400; }
.chip:hover { background: #fff; border-color: #9AA2AF; }
.chip[aria-pressed="true"], .chip[aria-pressed="true"]:hover { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.recherche { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }

/* --- Liste des ventes : cartes --------------------------------------------- */
.liste-ventes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.vente { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.vente-haut { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.vente-numero { font-size: 22px; font-weight: 700; letter-spacing: .3px; }
.vente-heure { font-size: 13px; color: var(--soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
.vente-montant { font-size: 18px; font-weight: 600; margin: 2px 0 8px; font-variant-numeric: tabular-nums; }
.vente-articles { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.vente-articles li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.vente-articles .titre { font-weight: 500; }
.vente-articles .qte { font-weight: 700; color: var(--muted); }
.option { background: var(--accent-bg); border: 1px solid var(--accent-line); border-radius: 8px; padding: 0 8px; font-size: 13px; color: var(--accent-ink); white-space: nowrap; }
.vide { padding: 40px 0; text-align: center; color: var(--soft); }

/* Pastilles (repères) */
.reperes { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.reperes:empty { display: none; }
.repere { display: inline-block; font-size: 12px; font-weight: 500; line-height: 1.5; padding: 1px 8px; border-radius: 10px; white-space: nowrap; background: #EEF0F3; color: var(--muted); }
.repere.inscrite { background: var(--ok-bg); color: #14532D; box-shadow: inset 0 0 0 1px var(--ok-line); font-weight: 600; }
.repere.envoye { background: var(--accent-bg); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent-line); }
.repere.echec { background: var(--crit-bg); color: var(--crit-ink); font-weight: 600; }

.repere.affiche { background: var(--accent-bg); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent-line); }
.repere.transmis { background: var(--accent-bg); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent-line); }
.repere.refuse { background: var(--crit-bg); color: var(--crit-ink); font-weight: 600; }

.vente.cliquable { cursor: pointer; }
.vente.cliquable:hover { border-color: #9AA2AF; }
.vente.cliquable:active { background: #F6F8FB; }

/* Foire choisie (lieu d'achat transmis à la page d'enregistrement) */
.choix-lieu {
  width: 100%; height: auto; min-height: 48px; margin-bottom: 14px; padding: 8px 14px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  display: flex; align-items: center; justify-content: flex-start; gap: 10px; font-weight: 600; text-align: left;
}
.choix-lieu:hover { background: var(--panel); border-color: #9AA2AF; }
.choix-lieu .petit { font-size: 12px; font-weight: 600; color: var(--soft); text-transform: uppercase; letter-spacing: .5px; }
.choix-lieu #lieu-actuel { flex: 1; font-size: 16px; overflow: hidden; text-overflow: ellipsis; }
.choix-lieu .changer { color: var(--accent); font-weight: 500; font-size: 13px; }
.choix-lieu.a-choisir { border-color: var(--warn); background: var(--warn-bg); }
.choix-lieu.a-choisir #lieu-actuel { color: var(--warn-ink); }

.dialogue { border: 0; border-radius: 14px; padding: 18px; width: min(92vw, 420px); max-height: 86vh; }
.dialogue::backdrop { background: rgba(22, 24, 29, .6); }
.dialogue h2 { margin: 0 0 4px; font-size: 18px; }
.dialogue .petit { margin: 0 0 12px; }
.dialogue > button { width: 100%; margin-top: 12px; }
.liste-lieux { display: flex; flex-direction: column; gap: 6px; }
.liste-lieux button { width: 100%; justify-content: flex-start; background: #fff; color: var(--ink); border-color: var(--field); font-weight: 500; }
.liste-lieux button:hover { background: var(--accent-bg); border-color: var(--accent); }
.liste-lieux button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.petit { font-size: 13px; color: var(--soft); }

/* Détail d'une vente */
.retour { margin: 0 0 10px; }
button.lien { background: none; border: 0; padding: 0; height: 36px; color: var(--accent); font-weight: 500; }
button.lien:hover { background: none; color: var(--accent-ink); }
.vente.detail { margin-bottom: 12px; }
.bloc { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.bloc h2 { font-size: 12px; font-weight: 600; color: var(--soft); text-transform: uppercase; letter-spacing: .5px; margin: 0 0 10px; }
button.gros { width: 100%; height: 56px; font-size: 17px; }
.autres-canaux { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.autres-canaux button.gros { height: 48px; font-size: 15px; }
.envoyer .petit { margin: 8px 0 0; }
.historique { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }

/* QR code plein écran : fond blanc, contraste maximal pour le scan */
.qr-plein-ecran {
  position: fixed; inset: 0; z-index: 50; background: #fff; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px); text-align: center;
}
.qr-texte { margin: 0; font-size: 22px; font-weight: 700; line-height: 1.25; max-width: 420px; }
.qr-image { width: min(88vw, 60vh, 440px); aspect-ratio: 1; }
.qr-image svg { width: 100%; height: 100%; display: block; shape-rendering: crispEdges; }
.qr-numero { margin: 0; font-family: var(--mono); font-size: 18px; color: var(--muted); }
.qr-conseil { margin: 0; font-size: 13px; color: var(--soft); }
.qr-plein-ecran button.gros { max-width: 420px; }

/* Ruban de chargement (même que Commandes / Support) */
#ruban-chargement { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100; pointer-events: none; opacity: 0; transition: opacity .15s; background: linear-gradient(90deg, transparent 0, #EC4D8B 30%, var(--accent) 60%, transparent 100%); background-size: 50% 100%; background-repeat: no-repeat; }
#ruban-chargement.actif { opacity: 1; animation: ruban 1s linear infinite; }
@keyframes ruban { from { background-position: -50% 0; } to { background-position: 150% 0; } }
@media (prefers-reduced-motion: reduce) { #ruban-chargement.actif { animation-duration: 2.5s; } }

/* --- Téléphone ------------------------------------------------------------- */
@media (max-width: 760px) {
  .entete { padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; gap: 8px; }
  .entete .marque { font-size: 15px; }
  .entete .qui { gap: 6px; }
  .entete .qui > #nom-compte { display: none; }
  .entete .avatar { width: 26px; height: 26px; font-size: 10px; }
  .entete .qui button { height: 32px; padding: 0 10px; font-size: 12px; }
  main { padding: 12px 12px calc(env(safe-area-inset-bottom) + 24px); }
  .carte-connexion { margin-top: 24px; padding: 20px; }
  .barre h1 { font-size: 19px; }
  .filtres { width: 100%; }
  .chip { flex: 1 1 0; padding: 0 6px; }
  .vente-numero { font-size: 26px; }
}
