@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;900&display=swap');

:root {
  --anth: #2A2D31;
  --bg: #F5F7FA;
  --blue: #0B63E5;
  --glass-bg: rgba(20, 22, 26, .55);
  --glass-brd: rgba(255, 255, 255, .08);
}

/* ===== RESET ===== */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
}
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #0e0f12;
  font-family: "Inter", system-ui, sans-serif;
  color: #111;
  touch-action: manipulation;
}

/* ========= CONTAINER ========= */
.screen {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--bg);
  border: 3px solid var(--blue);
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ========= BARRE DU HAUT ========= */
.top {
  flex: 0 0 60px;
  flex: 0 0 120px; /* Doublé */
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px; /* Doublé */
  background: var(--glass-bg);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--glass-brd);
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
  color: #fff;
  z-index: 5;
  position: relative;
}

.logo {
  font-weight: 900;
  font-size: 2rem; /* Doublé */
  letter-spacing: 2px;
  flex: 0 0 auto;
}

.limit-top {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 900;
  font-size: 1.5rem; /* Doublé */
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  color: #fff;
  white-space: nowrap;
  /* Ajustement pour le centrage vertical si nécessaire avec la nouvelle hauteur de barre */
  line-height: 1; /* Assure que la hauteur de ligne ne perturbe pas le centrage */
}

.help-btn {
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-weight: 700;
  font-size: 1.4rem; /* Doublé */
  padding: 10px 20px; /* Doublé */
  border-radius: 16px; /* Doublé */
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}
.help-btn:hover {
  background: rgba(255,255,255,0.3);
  transform: scale(1.05);
}

/* ========= ZONE PRODUITS (scrollable) ========= */
.main {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  scrollbar-width: none;
}
.main::-webkit-scrollbar { display: none; }

/* ========= GRILLE PRODUITS ========= */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(22%, 1fr)); /* 4 produits */
  gap: 8px;
  align-items: stretch;
  justify-content: center;
}

/* ========= CARTES ========= */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 3px 10px rgba(0,0,0,.12);
  padding: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform .2s, box-shadow .2s;
}
.card:hover { box-shadow: 0 6px 18px rgba(0,0,0,.15); transform: scale(1.02); }
.card:active { transform: scale(0.98); }

.imgwrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  border-radius: 8px;
  overflow: hidden;
}
.card .img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border: 1px solid rgba(0,0,0,.06);
}
.flag-dot {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  background: #fff;
  border-radius: 50%; /* Rond parfait */
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
  width: 64px; /* Taille du cercle (doublée) */
  height: 64px; /* Taille du cercle (doublée) */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden; /* Assure que l'image ne dépasse pas si elle est rectangulaire */
}
.flag-dot img {
  width: 48px; /* Taille de l'image (doublée) */
  height: auto;
}
.title {
  margin-top: 6px;
  text-align: center;
  font-weight: 700;
  font-size: 24px; /* Doublé */
  line-height: 1.2;
  height: calc(1.2em * 2);
  overflow: hidden;
}
.price {
  margin-top: 4px;
  width: 100%;
  text-align: center;
  font-weight: 800;
  font-size: 28px; /* Doublé */
  color: var(--blue);
}

/* ========= BARRE DU BAS ========= */
.bottom {
  flex: 0 0 80px;
  flex: 0 0 160px; /* Doublé */
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 48px; /* Doublé */
  background: var(--glass-bg);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--glass-brd);
  color: #fff;
  z-index: 5;
}
.bottom-left {
  position: relative; /* Contexte pour le positionnement de Pikachu */
  display: flex;
  align-items: center;
}
#pika-anim {
  /* On le sort du flux pour le superposer */
  position: absolute; 
  /* On le positionne par rapport au bas de la barre */
  bottom: 55px; 
  left: 20px;
  height: 180px; /* Hauteur de l'animation */
  width: auto;
  /* Empêche l'utilisateur de cliquer sur le GIF */
  pointer-events: none; 
}
.cart-strip {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  height: 100%;
  padding: 0 20px;
  overflow: hidden;
}
.mini {
  position: relative;
  flex-shrink: 0;
  width: 100px;
  height: 133px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  border: 2px solid rgba(255,255,255,0.2);
}
.mini img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.mini .badge {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 36px;
  height: 36px;
  background: var(--blue);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 800;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.cart-qty {
  font-weight: 900;
  font-size: 2.6rem; /* Doublé */
  /* On positionne le compteur sous Pikachu */
  position: absolute;
  left: 60px;
  z-index: 1; /* Pour s'assurer qu'il est visible */
}
.bottom-right {
  display: flex;
  align-items: center;
  gap: 24px; /* Doublé */
}
.cart-total {
  font-weight: 900;
  font-size: 2.8rem; /* Doublé */
  color: #fff; /* Couleur changée en blanc */
  text-shadow: 0 2px 8px rgba(0,0,0,0.7); /* Ombre portée pour la lisibilité */
}
.pay-btn {
  background: linear-gradient(180deg, #0b63e5, #004bcf);
  color: #fff;
  font-weight: 800;
  font-size: 2rem; /* Doublé */
  border: none;
  border-radius: 20px; /* Doublé */
  padding: 16px 36px; /* Doublé */
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}
.pay-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 15px rgba(0,0,0,0.45);
}

/* ========= MINI FOOTER ========= */
.bottom-mini {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  transform: translateY(100%);
  height: 6vh;
  background: var(--glass-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--glass-brd);
}
.bottom-mini .mini-sep {
  height: 1px;
  background: rgba(0,0,0,.75);
  width: 100%;
}
.bottom-mini .mini-pay {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.pay-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  backdrop-filter: blur(6px);
}

/* ========= MODAL ========= */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.modal {
  position: relative;
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  width: 90%;
  max-width: 640px;
  max-height: 90vh;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-close {
  position: absolute;
  top: 10px;
  left: 10px; /* Déplacé à gauche */
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: #f2f3f7;
  font-size: 20px;
  font-weight: 800;
}
.modal-img-wrap {
  position: relative; /* Contexte pour le positionnement du drapeau */
  width: 100%;
}
.modal img {
  width: 100%;
  max-height: 55vh;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.06);
}
/* Positionnement du drapeau dans la modale */
.modal .flag-dot {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
}

/* --- MODAL (SIMPLE & FAST) --- */
/* Titre du produit : centré, gras, noir */
.modal-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: #000;
  text-align: center;
  margin: 10px 0 5px 0;
}
/* Prix du produit : centré */
.modal-price {
  font-size: 2rem;
  font-weight: 700;
  color: var(--blue);
  text-align: center;
}

/* Contrôles de quantité : simple et aligné */
.qty-ctrl {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 20px 0;
}
.qty-view {
  font-size: 2.5rem;
  font-weight: 700;
  color: #000;
}
.qty-btn {
  width: 70px;
  height: 70px;
  border-radius: 16px;
  border: none;
  background: #e9edf2;
  color: #111;
  font-size: 3rem;
}

/* Actions de la modale : simple et centré */
.modal-actions {
  display: flex;
  justify-content: center;
  gap: 15px;
}
/* Style pour le bouton Annuler, visible sur fond blanc */
.btn-secondary {
  background: #e9edf2;
  color: #555;
  font-weight: 700;
  font-size: 1.5rem;
  border: none;
  border-radius: 20px;
  padding: 16px 36px;
  cursor: pointer;
}

/* ========= MODALE PAIEMENT ========= */
.payment-modal {
  gap: 10px;
}
.payment-modal h2 {
  text-align: center;
  margin: 0;
  font-size: 1.8rem;
  color: #333;
}
.payment-choice-title {
  margin: 30px 0 15px 0 !important; /* Espace augmenté avant */
}
.payment-cart-list {
  width: 100%;
  max-height: 35vh;
  overflow-y: auto;
  border-top: 1px solid #eee;
  border-bottom: 1px solid #eee;
  padding: 10px 0;
}
.payment-cart-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 8px;
}
.payment-cart-item img {
  width: 60px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
}
.payment-cart-item .details {
  flex: 1;
  font-size: 1.2rem;
  font-weight: 600;
}
.payment-cart-item .qty {
  font-size: 1.5rem;
  font-weight: 700;
}
.payment-total-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 2rem;
  font-weight: 800;
  padding: 10px 5px;
}
.payment-methods {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 100%;
}
.payment-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 20px;
  /* On enlève le style de bouton */
  border: none;
  background: none;
  cursor: pointer;
  color: #333;
}
#paypal-button-container {
  width: 100%;
  min-height: 55px; /* Hauteur minimale pour être visible */
  padding: 10px 0;
}
.payment-icon-wrapper, .payment-text-wrapper, .payment-spacer {
  display: flex;
  align-items: center;
}
.payment-icon-wrapper {
  flex: 1; /* Prend 1/5 de l'espace */
  justify-content: center;
}
.payment-text-wrapper {
  flex: 3; /* Prend 3/5 de l'espace */
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 800;
}
.payment-spacer {
  flex: 1; /* Prend 1/5 de l'espace */
}
.payment-icon-cb {
  height: 30px; /* Ajusté */
  width: auto;
}
.payment-icon-paypal {
  height: 60px; /* Doublé */
  width: auto;
}

/* ========= MODALE QR CODE ========= */
.qr-modal {
  max-width: 480px;
  gap: 15px;
}
.qr-modal h2 {
  text-align: center;
  color: #333;
}
.qr-code-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.qr-instructions {
  text-align: center;
  font-weight: 600;
}
.payment-success-icon {
  font-size: 120px;
  line-height: 1;
}

/* ========= ADMIN & SCREENSAVER ========= */
.admin, .screensaver {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
}
.admin { background: rgba(0,0,0,.6); }
.screensaver {
  background: #000;
  width: 100vw; /* Forcer la largeur du viewport */
  height: 100vh; /* Forcer la hauteur du viewport */
  color: #fff;
  font-size: 36px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.screensaver.active {
  display: flex;
  opacity: 1;
  pointer-events: all;
}

/* ========= ADMIN PANEL STYLES ========= */
.admin {
  backdrop-filter: blur(10px);
}

.admin-modal {
  display: flex;
  flex-direction: column;
  width: 90%;
  max-width: 850px; /* Augmenté à nouveau */
  background: #2A2D31;
  color: #fff;
  border: 1px solid var(--glass-brd);
  padding: 24px;
}
.admin-pin, .admin-stock {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.admin-modal h2 {
  margin: 0 0 20px 0;
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center; /* Centrer le titre */
}

.pin-dots {
  display: flex;
  gap: 15px;
  margin-bottom: 25px;
  justify-content: center; /* Centrer les points */
}
.pin-dots div {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.2);
  transition: background-color 0.2s;
}
.pin-dots div.on {
  background: var(--blue);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  width: 100%;
  max-width: 320px;
  margin: 0 auto; /* Centrer le clavier */
}
.keypad button:active {
  background: rgba(255,255,255,0.2);
}
.keypad button {
  aspect-ratio: 1.3 / 1;
  border-radius: 16px;
  border: none;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s;
}

/* STYLES DE LA LISTE DES STOCKS (ceux qui manquaient) */
.adm-list-header {
  display: grid;
  grid-template-columns: 50px 1fr 80px 300px; /* Colonne de droite agrandie */
  gap: 10px;
  padding: 0 8px 8px 8px;
  font-style: italic;
  font-size: 0.9rem;
  color: #aaa;
  border-bottom: 2px solid var(--glass-brd);
}
.adm-list {
  width: 100%;
  max-height: 50vh;
  overflow-y: auto;
  border-top: 1px solid var(--glass-brd);
  border-bottom: 1px solid var(--glass-brd);
  margin-bottom: 20px;
}
.adm-list .row {
  display: grid;
  grid-template-columns: 50px 1fr 80px 300px; /* Colonne de droite agrandie */
  gap: 10px;
  align-items: center;
  padding: 12px 8px;
  border-bottom: 1px solid var(--glass-brd);
}
.adm-list .stk {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.btn-test-motor {
  background: #f0ad4e; /* Orange */
  color: white;
  border: none;
  padding: 0 15px;
  cursor: pointer;
  font-weight: 700;
  width: 80px !important;
}
.adm-list .stk button {
  width: 45px; /* Agrandis */
  height: 45px; /* Agrandis */
  border-radius: 8px;
  font-size: 1.5rem; /* Police plus grande pour - et + */
  font-weight: 600;
}
.adm-list .stk input {
  width: 60px;
  height: 40px;
  text-align: center;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid #555;
  background: #333;
  color: #fff;
}

.admin-actions {
  display: flex;
  gap: 15px;
  justify-content: flex-end;
  width: 100%;
}

/* Déplacer la croix de fermeture à droite UNIQUEMENT pour le panneau admin */
.admin .modal-close {
  left: auto;
  right: 10px;
}

/* ========= TOAST NOTIFICATION ========= */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 150%);
  background: var(--anth);
  color: #fff;
  padding: 16px 32px;
  border-radius: 12px;
  border: 1px solid var(--glass-brd);
  box-shadow: 0 5px 20px rgba(0,0,0,0.4);
  z-index: 100;
  opacity: 0;
  transition: transform 0.4s ease, opacity 0.4s ease;
  pointer-events: none;
  text-align: center;
}
.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}
.toast p {
  margin: 0;
  font-weight: 600;
  font-size: 1.2rem;
}

/*
================================================
OPTIMISATIONS POUR CHROMIUM SUR RASPBERRY PI
================================================
Ceci désactive les effets de flou (backdrop-filter) qui sont
très gourmands en ressources et peuvent causer des bugs/ralentissements
sur les appareils moins puissants.
*/
.chromium .top,
.chromium .bottom,
.chromium .bottom-mini,
.chromium .overlay,
.chromium .admin {
  backdrop-filter: none;
}

.chromium .overlay, .chromium .admin {
  background: rgba(0,0,0,.75); /* Fond plus opaque pour compenser l'absence de flou */
}
