/* ==================================================================
   ADAPTATION TÉLÉPHONE
   Chargée après style.css. Objectifs concrets :
   - toutes les zones cliquables atteignent 44 px (recommandation Apple),
     sinon on rate le bouton avec le pouce
   - les champs passent à 16 px : en dessous, iOS zoome tout seul à la
     saisie et l'écran part de travers
   - les tableaux larges deviennent lisibles au lieu de déborder
   - le menu passe en barre du bas, atteignable au pouce
   ================================================================== */

@media (max-width: 760px) {

  /* ---------- confort général ---------- */
  body {
    -webkit-text-size-adjust: 100%;     /* pas de recadrage sauvage */
    overscroll-behavior-y: contain;     /* pas de rebond parasite */
  }

  /* ---------- zones tactiles ---------- */
  .btn {
    min-height: 44px;
    padding: 11px 16px;
    font-size: 14.5px;
  }
  .btn.mini {
    min-height: 38px;
    padding: 8px 12px;
    font-size: 13.5px;
  }
  .puce {
    min-height: 40px;
    padding: 9px 15px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
  }
  .ligne-panier .qte button {
    width: 38px;
    height: 38px;
    font-size: 19px;
  }
  .check input[type=checkbox] {
    width: 20px;
    height: 20px;
    margin-top: 1px;
  }

  /* ---------- champs : 16 px minimum, sinon iOS zoome ---------- */
  input[type=text], input[type=password], input[type=number], input[type=search],
  input[type=tel], input[type=date], select, textarea {
    font-size: 16px;
    min-height: 46px;
    padding: 11px 12px;
  }
  textarea { min-height: 80px; }
  .ligne-champs { flex-direction: column; gap: 0; }

  /* ---------- menu en barre du bas ---------- */
  .appli { padding-bottom: 62px; }

  .rail {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    top: auto;
    width: 100%;
    height: auto;
    z-index: 50;
    flex-direction: column-reverse;
    border-top: 1px solid #32363d;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .rail .marque { display: none; }
  .rail nav {
    display: flex;
    overflow-x: auto;
    padding: 0;
    scrollbar-width: none;
  }
  .rail nav::-webkit-scrollbar { display: none; }
  .rail a {
    flex: 0 0 auto;
    flex-direction: column;
    gap: 2px;
    padding: 9px 15px;
    font-size: 12px;
    min-height: 54px;
    justify-content: center;
    border-bottom: 0;
    border-top: 3px solid transparent;
  }
  .rail a.actif { border-top-color: var(--accent); border-bottom: 0; }
  .rail .pied {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 14px;
    border-top: 0;
    border-bottom: 1px solid #32363d;
  }
  .rail .pied .role { display: none; }
  .rail .pied button { width: auto; margin-top: 0; min-height: 36px; }

  /* ---------- en-tête compacte ---------- */
  .entete {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 9px;
  }
  .entete .titre { font-size: 16px; }
  .barre-actions { width: 100%; }
  .barre-actions .btn { flex: 1; }
  .contenu { padding: 13px 12px 24px; }

  /* ---------- indicateurs sur deux colonnes ---------- */
  .grille.g4, .grille.g3, .grille.g2 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .indic { padding: 11px 12px; }
  .indic .val { font-size: 20px; }
  .indic .lib { font-size: 10.5px; }

  /* ---------- tableaux : on masque le secondaire ----------
     Plutôt qu'un défilement horizontal pénible, on garde les colonnes
     utiles au doigt et on cache le reste, disponible sur grand écran. */
  table.tab th, table.tab td { padding: 11px 9px; }
  table.tab td.actions { padding: 8px 6px; }
  table.tab td.actions .btn { margin: 2px; }

  /* stock : réf., seuil, valeur et date de maj passent à la trappe */
  #lignesStock th:nth-child(1), #lignesStock td:nth-child(1),
  #lignesStock th:nth-child(4), #lignesStock td:nth-child(4),
  #lignesStock th:nth-child(6), #lignesStock td:nth-child(6),
  #lignesStock th:nth-child(7), #lignesStock td:nth-child(7) { display: none; }

  /* clients : e-mail, créé par */
  #lignesClients th:nth-child(3), #lignesClients td:nth-child(3),
  #lignesClients th:nth-child(7), #lignesClients td:nth-child(7) { display: none; }

  /* équipe : matricule, activité */
  #lignesEquipe th:nth-child(4), #lignesEquipe td:nth-child(4),
  #lignesEquipe th:nth-child(6), #lignesEquipe td:nth-child(6) { display: none; }

  /* journal : cible et détail sur la même ligne suffisent */
  #lignesJournal th:nth-child(4), #lignesJournal td:nth-child(4) { display: none; }

  /* commandes : origine et client */
  #lignesCmd th:nth-child(4), #lignesCmd td:nth-child(4) { display: none; }

  .filtres { padding: 10px 12px; gap: 8px; }
  .filtres input[type=search], .filtres input[type=text] { width: 100%; }
  .filtres select { width: 100%; }

  /* ---------- fenêtres : en feuille depuis le bas ---------- */
  .voile {
    padding: 0;
    align-items: flex-end;
  }
  .modale, .modale.large {
    max-width: 100%;
    width: 100%;
    border-radius: 14px 14px 0 0;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    animation: monteFeuille .18s ease-out;
  }
  @keyframes monteFeuille { from { transform: translateY(100%); } }

  .modale .tete { padding: 15px 16px; flex: 0 0 auto; }
  .modale .tete h2 { font-size: 16px; }
  .modale .tete .fermer { font-size: 30px; padding: 0 10px; min-height: 44px; }
  .modale .corps { padding: 16px; overflow-y: auto; flex: 1 1 auto; }
  .modale .pied {
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
    flex: 0 0 auto;
    flex-wrap: wrap;
  }
  .modale .pied .btn { flex: 1; min-width: 130px; }

  /* ---------- écran cuisine : une colonne, billets plus gros ---------- */
  .colonnes-file { grid-template-columns: 1fr; gap: 11px; }
  .colonne-file > h2 { font-size: 14px; }
  .billet { padding: 14px 15px; }
  .billet .num { font-size: 22px; }
  .billet ul { font-size: 15px; }
  .billet ul li { padding: 4px 0; }
  .billet .pied { flex-direction: column; gap: 8px; }
  .billet .pied .btn { width: 100%; min-height: 46px; font-size: 15px; }

  /* ---------- caisse : produits confortables ---------- */
  .grille-produits { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tuile { min-height: 92px; padding: 12px 10px; }
  .tuile .n { font-size: 14px; }
  .ticket-panier { position: static; }

  /* ---------- bulles au-dessus de la barre du bas ---------- */
  #bulles {
    bottom: calc(70px + env(safe-area-inset-bottom, 0));
    left: 12px;
    right: 12px;
  }
  .bulle { max-width: 100%; font-size: 14px; padding: 12px 15px; }

  /* ---------- photos de réassort ---------- */
  .depot { padding: 26px 14px; }
  .vignette { width: 54px; height: 54px; }
  .apercu img, .apercu video { max-height: 260px; }
}

/* ==================================================================
   CÔTÉ CLIENT (page publique et espace client)
   ================================================================== */

@media (max-width: 760px) {
  .contenu-accueil, .contenu-client { padding: 14px 12px 30px; }

  .cartes-produits { grid-template-columns: 1fr; gap: 9px; }
  .carte-produit { padding: 14px; }
  .carte-produit .nom { font-size: 15.5px; }
  .carte-produit .prix { font-size: 18px; }
  .carte-produit .bas { margin-top: 10px; }
  .carte-produit .btn { min-height: 42px; padding: 10px 18px; }

  .rayon > h2 { font-size: 16px; }

  /* le panier reste accessible : il descend sous la carte */
  .commander { grid-template-columns: 1fr; }
  .panier-client { position: static; margin-top: 6px; }

  .bandeau-accueil .dedans,
  .bandeau-client .dedans { padding: 10px 12px; gap: 9px; }
  .btn-connexion { min-height: 42px; padding: 10px 15px; }
  .marque-accueil .slogan, .marque-client .slogan { display: none; }
  .onglets-client button { min-height: 42px; padding: 10px 14px; font-size: 14px; }

  .suivi .etape { font-size: 10.5px; }
  .carte-commande .numero { font-size: 21px; }
  .total-panier { font-size: 21px; }
}

/* Très petits écrans : on repasse tout en une colonne */
@media (max-width: 400px) {
  .grille.g4, .grille.g3, .grille.g2 { grid-template-columns: 1fr; }
  .grille-produits { grid-template-columns: 1fr; }
  .rail a { padding: 9px 12px; font-size: 11.5px; }
}

/* Écran tactile, quelle que soit la largeur : pas d'effet de survol
   fantôme qui reste collé après un appui. */
@media (hover: none) {
  .btn:hover { background: var(--blanc); }
  .btn.primaire:hover { background: var(--accent); }
  .btn.valide:hover { filter: none; }
  .tuile:hover { border-color: var(--trait); box-shadow: none; }
  table.tab tbody tr:hover { background: transparent; }
  .btn:active { opacity: .7; }
  .tuile:active { border-color: var(--accent); }
}
