/* Feuille de style de l'application, calquée sur l'admin Shopify (Polaris).
   Écrite à la main plutôt que compilée avec Tailwind : le projet n'a alors
   aucune chaîne Node à installer sur le VPS, et le fichier reste léger.

   Les valeurs (couleurs, rayons, ombres, 13 px de base) reprennent celles de
   l'admin pour qu'on passe de Shopify à cet outil sans changer de repères.
   Mobile d'abord : la navigation est une barre basse, comme l'application
   Shopify ; au-delà de 900 px elle devient la colonne latérale de l'admin. */

:root {
  --fond: #f1f1f1;
  --carte: #ffffff;
  --texte: #303030;
  --texte-fort: #1a1a1a;
  --doux: #616161;
  --bord: #e3e3e3;
  --bord-doux: #ebebeb;
  --survol: #f7f7f7;

  /* Dans l'admin, le bleu ne sert qu'aux liens : les boutons sont noirs. */
  --lien: #005bd3;
  --accent: #303030;
  --accent-survol: #1a1a1a;
  --accent-doux: #f1f1f1;

  --rouge: #8e1f0b;
  --rouge-fond: #fed3d1;
  --vert: #0c5132;
  --vert-fond: #cdfee1;
  --orange: #5e4200;
  --orange-fond: #ffd6a4;
  --info: #00404d;
  --info-fond: #d8f3f8;

  --barre-haute: 48px;
  --barre-basse: 58px;
  --sure-bas: env(safe-area-inset-bottom, 0px);

  --ombre-carte: 0 0 0 1px var(--bord-doux), 0 1px 0 0 rgba(26, 26, 26, .07);
  --ombre-bouton: 0 -1px 0 0 #b5b5b5 inset, 0 0 0 1px rgba(26, 26, 26, .12),
                  0 1px 0 0 rgba(26, 26, 26, .08);
  --ombre-primaire: 0 -1px 0 0 rgba(0, 0, 0, .5) inset,
                    0 0 0 1px rgba(26, 26, 26, .9), 0 1px 0 0 rgba(26, 26, 26, .1);
  --rayon-carte: 12px;
  --rayon: 8px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #1a1a1a;
    --carte: #262626;
    --texte: #e3e3e3;
    --texte-fort: #f1f1f1;
    --doux: #a3a3a3;
    --bord: #404040;
    --bord-doux: #3a3a3a;
    --survol: #303030;
    --lien: #6cb0ff;
    --accent: #e3e3e3;
    --accent-survol: #ffffff;
    --accent-doux: #333333;
    --rouge: #ff8f85;
    --rouge-fond: #4a1512;
    --vert: #8fe3b4;
    --vert-fond: #0f3d26;
    --orange: #ffc266;
    --orange-fond: #4a3300;
    --info: #9fe0ee;
    --info-fond: #10353d;
    --ombre-carte: 0 0 0 1px var(--bord-doux);
    --ombre-bouton: 0 0 0 1px var(--bord);
    --ombre-primaire: 0 0 0 1px rgba(255, 255, 255, .15);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  /* 13 px : la taille de l'admin Shopify. */
  font: 13px/1.4615 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(var(--barre-basse) + var(--sure-bas));
  overscroll-behavior-y: contain;
}

/* La barre supérieure étant fixée, le contenu doit démarrer dessous — mais
   seulement sur les pages qui en ont une (pas la connexion). */
body:has(.barre-appli) {
  padding-top: calc(var(--barre-haute) + env(safe-area-inset-top, 0px));
}

a { color: var(--lien); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--lien); outline-offset: 1px; }

/* ---------- Barre supérieure sombre, comme l'admin ---------- */

/* Fixée et pleine largeur : dans l'admin, elle passe AU-DESSUS de la colonne
   latérale, qui commence dessous. */
.barre-appli {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  background: #1a1a1a;
  height: calc(var(--barre-haute) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 12px 0;
  display: flex; align-items: center; gap: 10px;
}
.barre-appli .logo {
  width: 24px; height: 24px; border-radius: 6px; flex: none;
  background: #ffffff; color: #1a1a1a;
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.barre-appli .nom { color: #e3e3e3; font-weight: 600; font-size: 13px; }
.barre-appli .boutique {
  color: #b5b5b5; font-size: 12px; margin-left: auto;
  padding: 4px 8px; border-radius: 8px; background: #303030;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 48vw;
}

/* ---------- En-tête de page ---------- */

.entete {
  padding: 16px 16px 4px;
  display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap;
  max-width: 1180px; margin: 0 auto;
}
.entete h1 {
  margin: 0; font-size: 20px; font-weight: 650; line-height: 1.3;
  letter-spacing: -.01em; color: var(--texte-fort); flex: 1; min-width: 180px;
}
.entete .sous {
  color: var(--doux); font-size: 13px; font-weight: 400; display: block;
  margin-top: 2px; letter-spacing: 0;
}
.entete .actions { display: flex; gap: 8px; align-items: center; }

/* ---------- Navigation ---------- */

.nav-basse {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: var(--carte);
  border-top: 1px solid var(--bord);
  padding-bottom: var(--sure-bas);
}
.nav-basse a {
  flex: 1; text-align: center; padding: 8px 2px 6px;
  color: var(--doux); font-size: 10.5px; font-weight: 500; text-decoration: none;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.nav-basse a[aria-current="page"] { color: var(--texte-fort); font-weight: 600; }
.nav-basse svg { width: 21px; height: 21px; stroke-width: 1.8; }
/* La marque n'a sa place que dans la colonne latérale : en bas d'écran,
   elle volerait la place d'un onglet. */
.nav-basse .marque { display: none; }
.nav-basse .pastille {
  position: absolute; transform: translate(14px, -4px);
  background: var(--rouge-fond); color: var(--rouge); border-radius: 8px;
  font-size: 9.5px; font-weight: 600; padding: 1px 5px; line-height: 1.4;
}

/* ---------- Contenu ---------- */

main { padding: 8px 16px 24px; max-width: 1180px; margin: 0 auto; }

.grille { display: grid; gap: 8px; grid-template-columns: repeat(2, 1fr); }
.carte {
  background: var(--carte); border: none;
  border-radius: var(--rayon-carte); padding: 12px 14px;
  box-shadow: var(--ombre-carte);
}
a.carte:hover { box-shadow: 0 0 0 1px var(--bord), 0 2px 4px rgba(26, 26, 26, .08); }
.carte .valeur {
  font-size: 24px; font-weight: 650; letter-spacing: -.02em;
  color: var(--texte-fort); line-height: 1.2;
}
.carte .libelle { color: var(--doux); font-size: 12px; margin-top: 2px; }
.carte.accent { background: var(--info-fond); box-shadow: none; color: var(--info); }

.titre-section {
  font-size: 13px; font-weight: 650; letter-spacing: 0;
  text-transform: none; color: var(--texte-fort); margin: 20px 0 8px;
}

/* Le bandeau d'information de l'admin : fond bleu pâle, pas de barre latérale. */
.rappel {
  background: var(--info-fond); color: var(--info);
  border-radius: var(--rayon-carte); border: none;
  padding: 12px 14px; font-size: 13px; margin-bottom: 12px;
}
.rappel strong { font-weight: 650; }

/* ---------- Listes de produits (mobile) ---------- */

.liste { display: flex; flex-direction: column; gap: 6px; }
.ligne {
  background: var(--carte); border: none;
  border-radius: var(--rayon-carte); padding: 12px 14px;
  box-shadow: var(--ombre-carte);
  display: block; color: inherit; text-decoration: none;
}
.ligne:hover {
  text-decoration: none;
  box-shadow: 0 0 0 1px var(--bord), 0 2px 4px rgba(26, 26, 26, .08);
}
.ligne .haut { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.ligne .nom { font-weight: 600; font-size: 13px; line-height: 1.4; color: var(--texte-fort); }
.ligne .meta { color: var(--doux); font-size: 12px; margin-top: 2px; }
.ligne .prix { text-align: right; white-space: nowrap; }
.ligne .prix .final { font-weight: 650; font-size: 14px; color: var(--texte-fort); }
.ligne .prix .affiche { color: var(--doux); font-size: 12px; text-decoration: line-through; }
.ligne .bas {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--bord-doux);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 12px;
}
.ligne .raison { color: var(--doux); font-size: 12px; margin-top: 6px; line-height: 1.45; }

.ecart-positif { color: var(--rouge); font-weight: 600; }
.ecart-negatif { color: var(--vert); font-weight: 600; }

/* ---------- Badges, à l'identique de l'admin ---------- */

.puce {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: var(--rayon); font-size: 12px; font-weight: 500;
  white-space: nowrap; line-height: 1.3333;
}
.puce.align, .puce.promo_gap { background: var(--rouge-fond); color: var(--rouge); }
.puce.cannot_match, .puce.no_cost { background: var(--orange-fond); color: var(--orange); }
.puce.competitive, .puce.opportunity_up { background: var(--vert-fond); color: var(--vert); }
.puce.to_review, .puce.config_missing, .puce.locked { background: var(--accent-doux); color: var(--doux); }

/* ---------- Formulaires ---------- */

.champ { margin-bottom: 12px; }
.champ label { display: block; font-size: 13px; font-weight: 450; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=search],
input[type=number], select, textarea {
  width: 100%; padding: 7px 12px; font: inherit; font-size: 16px; /* 16px : évite le zoom iOS */
  background: var(--carte); color: var(--texte);
  border: 1px solid var(--bord); border-radius: var(--rayon);
  box-shadow: 0 1px 0 0 rgba(26, 26, 26, .05) inset;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--lien); outline-offset: -1px; border-color: var(--lien);
}

.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--rayon); border: none;
  background: var(--accent); color: var(--carte);
  box-shadow: var(--ombre-primaire);
  font: inherit; font-weight: 600; font-size: 13px; line-height: 1.5385;
  cursor: pointer; width: 100%; text-decoration: none; min-height: 32px;
}
.bouton:hover { text-decoration: none; background: var(--accent-survol); }
.bouton.secondaire {
  background: var(--carte); color: var(--texte); box-shadow: var(--ombre-bouton);
}
.bouton.secondaire:hover { background: var(--survol); }
.bouton.petit { width: auto; padding: 5px 10px; font-size: 12px; min-height: 28px; }
.bouton:disabled { opacity: .55; cursor: not-allowed; }

.alerte {
  padding: 12px 14px; border-radius: var(--rayon-carte); font-size: 13px;
  margin-bottom: 12px;
}
.alerte.erreur { background: var(--rouge-fond); color: var(--rouge); }
.alerte.succes { background: var(--vert-fond); color: var(--vert); }

/* ---------- Connexion ---------- */

.page-connexion {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.page-connexion .boite { width: 100%; max-width: 380px; }
.page-connexion h1 { font-size: 20px; font-weight: 650; margin: 0 0 4px; color: var(--texte-fort); }
.page-connexion .sous { color: var(--doux); font-size: 13px; margin-bottom: 20px; }

/* ---------- Filtres et recherche ---------- */

.barre-filtres {
  display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap;
  background: var(--carte); padding: 10px;
  border-radius: var(--rayon-carte); box-shadow: var(--ombre-carte);
}
.barre-filtres input, .barre-filtres select {
  font-size: 14px; padding: 6px 10px; width: auto; flex: 1; min-width: 130px;
}

.vide { text-align: center; color: var(--doux); padding: 40px 16px; font-size: 13px; }

.pagination { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 14px; }
.pagination span { color: var(--doux); font-size: 12px; }

/* ---------- Flux d'actualité ---------- */

.evenement { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--bord-doux); }
.evenement:last-child { border-bottom: none; }
.evenement .quand { color: var(--doux); font-size: 12px; min-width: 58px; padding-top: 1px; }
.evenement .quoi { flex: 1; font-size: 13px; }
.evenement .impact { font-size: 12px; color: var(--doux); margin-top: 2px; }
.evenement .impact.fort { color: var(--rouge); font-weight: 600; }

/* ---------- Tableaux (ordinateur) ---------- */

.tableau-enveloppe { display: none; }

/* ---------- Ordinateur ---------- */

@media (min-width: 900px) {
  :root { --barre-haute: 56px; }

  body { padding-bottom: 0; padding-left: 232px; }

  .barre-appli { padding-left: 16px; padding-right: 16px; }
  .barre-appli .boutique { max-width: none; }

  /* La colonne latérale de l'admin : posée sur le gris, l'onglet actif est
     une pastille blanche. */
  .nav-basse {
    top: calc(var(--barre-haute) + env(safe-area-inset-top, 0px));
    bottom: 0; right: auto; width: 232px;
    flex-direction: column; background: transparent;
    border-top: none; border-right: 1px solid var(--bord);
    padding: 8px; gap: 2px;
  }
  .nav-basse a {
    flex: none; flex-direction: row; justify-content: flex-start;
    gap: 8px; font-size: 13px; font-weight: 500;
    padding: 6px 8px; border-radius: var(--rayon); color: var(--texte);
  }
  .nav-basse a:hover { background: rgba(26, 26, 26, .05); }
  .nav-basse a[aria-current="page"] {
    background: var(--carte); font-weight: 600;
    box-shadow: 0 0 0 1px rgba(26, 26, 26, .07), 0 1px 0 0 rgba(26, 26, 26, .05);
  }
  .nav-basse .pastille {
    position: static; transform: none; margin-left: auto;
    background: var(--accent-doux); color: var(--doux);
  }
  .nav-basse a[aria-current="page"] .pastille { background: var(--fond); }
  .nav-basse .marque { display: none; }

  .grille { grid-template-columns: repeat(4, 1fr); }
  main { padding: 8px 24px 40px; }
  .entete { padding: 20px 24px 6px; }

  /* Sur grand écran, un tableau est plus lisible qu'une liste de cartes. */
  .liste { display: none; }
  .tableau-enveloppe {
    display: block; overflow-x: auto; background: var(--carte);
    border: none; border-radius: var(--rayon-carte); box-shadow: var(--ombre-carte);
  }
  table { border-collapse: collapse; width: 100%; font-size: 13px; }
  th, td {
    padding: 8px 12px; text-align: left;
    border-bottom: 1px solid var(--bord-doux); white-space: nowrap;
  }
  tbody tr:last-child td { border-bottom: none; }
  th {
    background: var(--survol); font-weight: 600; font-size: 12px;
    color: var(--doux);
  }
  td.titre-cellule {
    white-space: normal; min-width: 230px; max-width: 340px;
    font-weight: 500; color: var(--texte-fort);
  }
  td.raison-cellule { white-space: normal; min-width: 240px; color: var(--doux); font-size: 12px; }
  tbody tr:hover { background: var(--survol); }
  .num { text-align: right; }
}

/* ---------- Installation de l'application ---------- */

.invite-installer {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(var(--barre-basse) + var(--sure-bas) + 10px);
  background: var(--carte); border: none; border-radius: var(--rayon-carte);
  padding: 12px 14px; box-shadow: 0 4px 12px rgba(26, 26, 26, .16),
                                 0 0 0 1px var(--bord);
  display: none; align-items: center; gap: 12px; z-index: 50; font-size: 13px;
}
.invite-installer.visible { display: flex; }
@media (min-width: 900px) {
  .invite-installer { left: auto; right: 20px; bottom: 20px; max-width: 340px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
