/*
 * ============================================================
 *  CSS DE COMPATIBILITE — Safari iOS 9.3.5 (iPad 2)
 *  Nom du fichier : safari9_styles.css
 *
 *  COMMENT UTILISER :
 *  Dans chaque fichier PHP, dans le <head>, ajoutez :
 *
 *      <link rel="stylesheet" href="safari9_styles.css">
 *
 *  APRES votre balise <style> existante (pour surcharger).
 *  OU collez le contenu directement en fin de votre <style>.
 * ============================================================
 *
 *  CORRECTIONS :
 *  1. CSS Grid → remplacé par float
 *  2. Flexbox → préfixes -webkit- ajoutés
 *  3. gap → margin de remplacement
 *  4. linear-gradient → préfixe -webkit-
 *  5. calc(), border-radius → déjà supportés sur iOS 9
 * ============================================================
 */

/* ---- FLEXBOX : ajout des préfixes -webkit- ---- */

/* Tous les éléments utilisant display:flex */
#screen-setup,
#screen-login,
.pin-display,
.modal-box,
.modal-actions,
.btn-row,
.form-row,
.nav-item,
.bnav-item,
.sidebar-item,
.stat-box,
.cart-item-row,
.pay-method-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
}

/* align-items:center */
#screen-setup,
#screen-login,
.pin-display,
.modal-box,
.stat-box {
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
}

/* justify-content:center */
#screen-setup,
#screen-login,
.pin-display {
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
}

/* flex-direction:column */
#screen-setup > div,
#screen-login > div,
.modal-content {
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  flex-direction: column;
}

/* flex:1 */
.flex-1 {
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  flex: 1;
}

/* ---- GRADIENTS : préfixes -webkit- ---- */

#screen-setup,
#screen-login {
  background: -webkit-linear-gradient(160deg, #1C1C1E 0%, #0A84FF 100%);
  background: linear-gradient(160deg, #1C1C1E 0%, #0A84FF 100%);
}

/* ---- CSS GRID → FLOAT FALLBACK ---- */

/*
 * #bottom-nav et #header utilisaient display:table qui
 * n'est pas fiable avec position:fixed sur Safari iOS 9.
 * Remplacé par float:left sur les items.
 */
#bottom-nav {
  display: block !important;
  overflow: hidden !important;
  height: 54px !important;
}
#bottom-nav:after {
  content: "";
  display: table;
  clear: both;
}
.bnav-item {
  display: block !important;
  float: left !important;
  width: 20% !important;
  height: 54px !important;
  vertical-align: top !important;
  -webkit-box-sizing: border-box !important;
  box-sizing: border-box !important;
}

#header {
  display: block !important;
  overflow: hidden !important;
}
#header:after {
  content: "";
  display: table;
  clear: both;
}
#hdr-logo  { display: block !important; float: left !important; }
#hdr-info  { display: block !important; float: left !important; }
#hdr-right { display: block !important; float: right !important; }

/*
 * .pin-grid (display:grid avec 3 colonnes)
 * Remplacé par float:left + width:33.33%
 */
.pin-grid {
  display: block !important;
  overflow: hidden;
}

.pin-grid:after {
  content: "";
  display: table;
  clear: both;
}

/* Chaque bouton PIN prend 1/3 de la largeur */
.pin-btn {
  float: left;
  width: 30%;
  margin: 1.5%;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  /* transition : supporté iOS 9 avec -webkit- */
  -webkit-transition: background 0.1s;
  transition: background 0.1s;
  /* border-radius : supporté */
  border-radius: 14px;
  padding: 16px;
  font-size: 20px;
  font-weight: 600;
  color: #1C1C1E;
  background: #F2F2F7;
  border: none;
  cursor: pointer;
  text-align: center;
}

/* Bouton "0" + bouton effacer : 2 colonnes */
.pin-btn:last-child,
.pin-btn.pin-wide {
  width: 63%;
}

/* .pin-display : flex → centrage manuel */
.pin-display {
  text-align: center;
  line-height: 58px;
}

/* ---- TRANSFORM -webkit- ---- */

.product-card {
  -webkit-transition: -webkit-transform 0.1s, border-color 0.1s;
  transition: transform 0.1s, border-color 0.1s;
}

.product-card:active {
  -webkit-transform: scale(0.96);
  transform: scale(0.96);
  border-color: #0A84FF;
}

/* Toast centré avec -webkit-transform */
#toast {
  position: fixed;
  bottom: 70px;
  left: 50%;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  background: #1C1C1E;
  color: #fff;
  padding: 11px 22px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  z-index: 999;
  display: none;
  max-width: 90%;
  text-align: center;
  -webkit-box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

/* ---- box-shadow : -webkit- pour iOS 9 ---- */

.card,
.modal-box,
.sidebar,
.bottom-nav,
#header {
  -webkit-box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}

/* ---- border-radius : déjà OK sur iOS 9 ---- */

/* ---- Scroll -webkit-overflow-scrolling ---- */

.main-content,
#main,
.modal-body,
.tbl-wrap {
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
}

/* ---- Suppression du tap highlight iOS ---- */

button,
.btn,
.nav-item,
.bnav-item,
.product-card,
.sidebar-item {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ---- Input / select : apparence iOS ---- */

input,
select,
textarea {
  -webkit-appearance: none;
  appearance: none;
  border-radius: 8px;
}

select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M6 8L0 0h12z' fill='%238E8E93'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

/* ---- Modal overlay ---- */
/* backdrop-filter non supporté sur Safari iOS 9 — on le supprime */

#modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

#modal-overlay.active {
  display: block !important;
}

/* ---- Forcer TOUS les modals cachés par défaut (fix Safari iOS 9) ---- */
/*
 * Sur Safari iOS 9, position:fixed + overflow-y:scroll peut ignorer display:none.
 * On force visibility:hidden en plus de display:none pour être sûr.
 */
.modal-box {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.modal-box.active {
  display: block !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

/* Sécurité supplémentaire sur le modal PDV */
#modal-choix-pdv:not(.active) {
  display: none !important;
  visibility: hidden !important;
}

/* ---- Responsive iPad 2 (1024x768) ---- */

@media screen and (max-width: 1024px) {
  .grid2-left,
  .grid2-right {
    float: none;
    width: 100%;
  }

  #cart-panel {
    width: 100%;
  }
}

@media screen and (max-width: 600px) {
  .stat-grid > div {
    float: left;
    width: 48%;
    margin: 1%;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }
}

/* ============================================================
   NOTE SUR LE GAP CSS
   gap / column-gap / row-gap ne sont PAS supportés sur Safari
   iOS 9. Utiliser margin à la place (déjà fait ci-dessus
   via margin:1.5% sur .pin-btn).
   ============================================================ */
