/* ═══════════════════════════════════════════
   FEY — Mobile CSS  (max 430px, centré)
═══════════════════════════════════════════ */

/* ── Tokens ──────────────────────────────── */
:root {
  --c  : #D85A30;   /* terracotta */
  --cl : #FAECE7;
  --cd : #712B13;
  --b  : #1B75BB;   /* wave blue */
  --bl : #EAF3FC;
  --g  : #1D9E75;   /* vert succès */
  --gl : #E1F5EE;
  --bg : #F4F1EB;   /* fond chaud */
  --bd : #E2DDD4;   /* bordure */
  --t  : #1A1714;   /* texte */
  --t2 : #6B6560;   /* texte secondaire */
}

/* ── Reset ───────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box; margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
}
html { height: 100%; }
body {
  font-family: 'DM Sans', sans-serif;
  color: var(--t);
  background: var(--bg);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; border: none; outline: none; background: none; }
a { color: inherit; text-decoration: none; }

/* ── Conteneur racine ────────────────────── */
#fey-root {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  background: #fff;
  overflow-x: hidden;
  position: relative;
}

/* Desktop : apparaît comme une app mobile centrée */
@media (min-width: 500px) {
  body { background: #e8e4dc; }
  #fey-root {
    margin: 24px auto;
    border-radius: 28px;
    box-shadow: 0 12px 60px rgba(0,0,0,.18);
    min-height: calc(100vh - 48px);
    overflow: hidden;
  }
}

/* ── App shell ───────────────────────────── */
.fey-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Screens : une seule visible à la fois */
.fey-screen        { display: none; flex-direction: column; min-height: 100vh; }
.fey-screen.active { display: flex; }

/* ── Barre du haut ───────────────────────── */
.fey-bar {
  padding: 16px 20px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--bd);
}
.fey-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 24px;
  color: var(--t);
  line-height: 1;
}
.fey-dot {
  display: inline-block;
  width: 7px; height: 7px;
  background: var(--c);
  border-radius: 50%;
  margin-left: 2px;
  vertical-align: middle;
  margin-bottom: 4px;
}
.fey-bar-title {
  font-size: 16px;
  font-weight: 700;
  flex: 1;
}
.fey-clock {
  font-size: 13px;
  color: var(--t2);
  margin-left: auto;
}
.fey-back {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg);
  cursor: pointer;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--t);
}
.fey-tbl-badge {
  background: var(--cl);
  color: var(--cd);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  margin-left: auto;
}

/* ══════════════════════════════════════════
   ÉCRAN SCAN
══════════════════════════════════════════ */
.fey-scan-zone {
  margin: 16px;
  background: var(--bg);
  border-radius: 20px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.fey-hint { font-size: 14px; color: var(--t2); text-align: center; }

/* Boîte caméra */
.fey-cam-box {
  position: relative;
  width: 100%; max-width: 230px;
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  background: #111;
  flex-shrink: 0;
}
#feyCamFeed { width: 100%; height: 100%; object-fit: cover; display: none; }

/* États caméra */
.fey-cam-state {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; padding: 16px; text-align: center;
}
.fey-cam-init    { background: #1a1714; }
.fey-cam-loading { background: rgba(0,0,0,.75); }
.fey-cam-err     { background: #1a0a0a; }
.fey-cam-ico  { font-size: 30px; opacity: .5; }
.fey-cam-txt  { font-size: 12px; color: #888; line-height: 1.4; }
.fey-cam-btn {
  background: var(--c); color: #fff;
  border-radius: 10px; padding: 9px 18px;
  font-size: 13px; font-weight: 700; cursor: pointer; margin-top: 4px;
}
.fey-spinner {
  width: 28px; height: 28px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: fey-spin .8s linear infinite;
}
@keyframes fey-spin { to { transform: rotate(360deg); } }
.fey-cam-errmsg {
  font-size: 11px; color: #FF9090;
  line-height: 1.5; white-space: pre-line;
}
.fey-cam-retry {
  background: rgba(255,255,255,.12); color: #fff;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px; padding: 7px 14px;
  font-size: 12px; font-weight: 600; cursor: pointer; margin-top: 4px;
}

/* Overlay coins */
.fey-cam-ov { position: absolute; inset: 0; pointer-events: none; }
.fey-corner {
  position: absolute; width: 22px; height: 22px;
  border-color: var(--c); border-style: solid;
}
.fey-corner.tl { top:10px; left:10px;   border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.fey-corner.tr { top:10px; right:10px;  border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; }
.fey-corner.bl { bottom:10px; left:10px;  border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; }
.fey-corner.br { bottom:10px; right:10px; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }
.fey-scan-line {
  position: absolute; left: 10px; right: 10px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--c), transparent);
  animation: fey-scan 2s ease-in-out infinite;
}
@keyframes fey-scan {
  0%   { top: 10px; opacity: 1; }
  90%  { top: calc(100% - 10px); opacity: 1; }
  100% { top: 10px; opacity: 0; }
}

/* Alerte HTTPS */
.fey-https-warn {
  width: 100%;
  background: #FFF8E6; border: 1.5px solid #F5C842;
  border-radius: 12px; padding: 12px 14px;
  font-size: 12px; color: #7A5A00; line-height: 1.5; text-align: center;
}

/* Barre détection */
.fey-det-bar {
  width: 100%;
  background: var(--bl); border-radius: 12px;
  padding: 10px 14px;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: #0C447C; font-weight: 500;
}
.fey-det-dot {
  width: 7px; height: 7px;
  background: var(--b); border-radius: 50%; flex-shrink: 0;
  animation: fey-pulse 1.5s infinite;
}
@keyframes fey-pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* Tag table */
.fey-tbl-tag {
  background: var(--cl); color: var(--cd);
  border-radius: 20px; padding: 7px 18px;
  font-size: 13px; font-weight: 600;
}

/* Saisie manuelle */
.fey-manual { width: 100%; border-top: 1px solid var(--bd); padding-top: 14px; }
.fey-manual-label { font-size: 12px; color: var(--t2); text-align: center; margin-bottom: 8px; }
.fey-manual-row { display: flex; gap: 8px; }
.fey-manual-inp {
  flex: 1; padding: 12px 14px;
  border-radius: 11px; border: 1.5px solid var(--bd);
  font-size: 14px; font-weight: 600; letter-spacing: 1px;
  background: #fff; color: var(--t);
  transition: border-color .15s;
}
.fey-manual-inp:focus { border-color: var(--c); }
.fey-manual-btn {
  width: 48px; border-radius: 11px;
  background: var(--c); color: #fff;
  font-size: 18px; font-weight: 700; cursor: pointer;
}

/* ══════════════════════════════════════════
   ÉCRAN ADDITION
══════════════════════════════════════════ */
.fey-bill-hd {
  margin: 14px 16px 10px;
  padding: 14px 16px;
  background: var(--bg); border-radius: 14px;
}
.fey-bill-name { font-size: 16px; font-weight: 700; }
.fey-bill-sub  { font-size: 12px; color: var(--t2); margin-top: 3px; }

/* Résumé */
.fey-summary {
  margin: 0 16px 12px;
  border-radius: 14px; overflow: hidden;
  border: 1.5px solid var(--bd);
}
.fey-sr {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--bd);
  font-size: 14px;
}
.fey-sr:last-child   { border-bottom: none; }
.fey-sr.sr-total     { background: #f8f7f4; color: var(--t2); font-size: 13px; }
.fey-sr.sr-my        {
  background: var(--cl); color: var(--cd);
  font-weight: 700; font-size: 15px;
  border-left: 4px solid var(--c);
}
.fey-sr.sr-rest      {
  background: var(--bl); color: #0C447C;
  font-weight: 600;
  border-left: 4px solid var(--b);
}
.fey-sr-val { font-weight: 700; white-space: nowrap; }

/* Liste articles */
.fey-items { flex: 1; padding: 0 16px; overflow-y: auto; }
.fey-item {
  display: flex; align-items: center;
  padding: 12px 0; gap: 12px;
  border-bottom: 1px solid #f0ede6;
  cursor: pointer; user-select: none;
}
.fey-item:last-child { border-bottom: none; }
.fey-chk {
  width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid var(--bd);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 12px;
  transition: all .15s;
}
.fey-chk.on { background: var(--c); border-color: var(--c); color: #fff; }
.fey-item-info { flex: 1; min-width: 0; }
.fey-item-name { font-size: 14px; font-weight: 500; }
.fey-item-cat  { font-size: 11px; color: var(--t2); margin-top: 2px; }
.fey-item.other .fey-item-name,
.fey-item.other .fey-item-cat  { color: #c0bcb8; }
.fey-item-price { font-size: 14px; font-weight: 700; white-space: nowrap; }
.fey-item.other .fey-item-price { color: #d0ccc8; }

.fey-bill-foot {
  padding: 14px 16px 20px;
  border-top: 1.5px solid var(--bd);
  background: #fff; flex-shrink: 0;
}
.fey-foot-hint { font-size: 12px; color: var(--t2); text-align: center; margin-bottom: 12px; font-style: italic; }

/* ══════════════════════════════════════════
   ÉCRAN PAIEMENT
══════════════════════════════════════════ */

/* Tableau récap */
.fey-split {
  margin: 14px 16px 12px;
  border-radius: 14px; overflow: hidden;
  border: 1.5px solid var(--bd);
}
.fey-sp {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 16px;
  border-bottom: 1px solid var(--bd);
  font-size: 14px;
}
.fey-sp:last-child     { border-bottom: none; border-radius: 0 0 12px 12px; }
.fey-sp.sp-muted       { color: var(--t2); font-size: 13px; }
.fey-sp.sp-my          { background: var(--cl); color: var(--cd); font-weight: 700; font-size: 15px; }
.fey-sp.sp-rest        { background: var(--bl); color: #0C447C; font-weight: 600; }
.fey-sp.sp-total       { background: var(--t); color: #fff; font-weight: 700; font-size: 16px; }

/* Héros montant */
.fey-amt-hero {
  margin: 0 16px 14px;
  padding: 22px; background: var(--t);
  border-radius: 18px; text-align: center; color: #fff;
}
.fey-amt-lbl { font-size: 13px; color: rgba(255,255,255,.5); margin-bottom: 6px; }
.fey-amt-val {
  font-family: 'DM Serif Display', serif;
  font-size: 48px; line-height: 1; letter-spacing: -1px;
}
.fey-amt-cur { font-size: 13px; color: rgba(255,255,255,.4); margin-top: 4px; }

/* Pourboire */
.fey-tip-wrap  { margin: 0 16px 14px; }
.fey-tip-lbl   { font-size: 13px; color: var(--t2); font-weight: 500; margin-bottom: 8px; }
.fey-tip-row   { display: flex; gap: 8px; }
.fey-tip-opt {
  flex: 1; padding: 10px 4px;
  border-radius: 11px; border: 1.5px solid var(--bd);
  background: #fff; font-size: 13px; color: var(--t2);
  cursor: pointer; text-align: center; transition: all .1s;
}
.fey-tip-opt.active {
  background: var(--cl); border-color: var(--c);
  color: var(--cd); font-weight: 700;
}

/* Bouton Wave */
.fey-wave-btn {
  display: block; margin: 0 16px 12px;
  padding: 18px 20px; border-radius: 16px;
  background: var(--b); color: #fff; text-align: center;
  position: relative; overflow: hidden;
}
.fey-wave-btn::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.12) 0%, transparent 60%);
}
.fey-wave-main { font-size: 16px; font-weight: 700; }
.fey-wave-sub  { font-size: 12px; opacity: .7; margin-top: 3px; }

/* Instructions manuelles */
.fey-wave-manual {
  margin: 0 16px 20px; padding: 16px;
  border-radius: 14px; background: var(--bl);
  border: 1.5px solid #C5DDF5;
}
.fey-wm-title  { font-size: 14px; font-weight: 700; color: #0C447C; margin-bottom: 10px; }
.fey-wm-steps  { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.fey-wm-step   { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #185FA5; }
.fey-wm-n {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--b); color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.fey-wm-phone {
  padding: 12px; background: #fff; border-radius: 11px;
  border: 1px solid #C5DDF5;
  font-size: 18px; font-weight: 700; color: #0C447C;
  text-align: center; letter-spacing: 2px;
  cursor: pointer; user-select: all;
}
.fey-wm-copy { font-size: 11px; color: #185FA5; text-align: center; margin-top: 5px; }

/* ══════════════════════════════════════════
   ÉCRAN SUCCÈS
══════════════════════════════════════════ */
.fey-ok-body {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 20px; text-align: center;
}
.fey-ok-ring {
  width: 88px; height: 88px; border-radius: 50%;
  background: var(--gl);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 24px;
  animation: fey-pop .45s cubic-bezier(.34,1.56,.64,1);
}
@keyframes fey-pop { from{transform:scale(0);opacity:0} to{transform:scale(1);opacity:1} }
.fey-ok-title {
  font-family: 'DM Serif Display', serif;
  font-size: 30px; color: var(--t); margin-bottom: 8px;
}
.fey-ok-sub  { font-size: 14px; color: var(--t2); line-height: 1.7; margin-bottom: 18px; }
.fey-ok-amt  { font-family: 'DM Serif Display', serif; font-size: 46px; color: var(--b); letter-spacing: -1px; }
.fey-ok-cur  { font-size: 13px; color: var(--t2); margin: 5px 0 16px; }
.fey-ok-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--gl); color: #085041;
  border-radius: 20px; padding: 6px 16px;
  font-size: 13px; font-weight: 600; margin-bottom: 20px;
}
.fey-ok-dot {
  width: 7px; height: 7px; background: var(--g);
  border-radius: 50%; display: inline-block;
}
.fey-receipt {
  width: 100%; padding: 16px;
  background: var(--bg); border-radius: 14px;
  text-align: left; margin-bottom: 20px;
}
.fey-rc {
  display: flex; justify-content: space-between;
  font-size: 13px; padding: 5px 0;
  border-bottom: 1px solid var(--bd);
}
.fey-rc:last-child { border-bottom: none; }
.fey-rc-l { color: var(--t2); }
.fey-rc-v  { font-weight: 600; }

/* ══════════════════════════════════════════
   BOUTONS GLOBAUX
══════════════════════════════════════════ */
.fey-btn {
  display: block;
  width: calc(100% - 32px); margin: 0 16px;
  padding: 16px; border-radius: 14px;
  font-size: 15px; font-weight: 700;
  cursor: pointer; text-align: center;
  transition: opacity .1s; border: none;
}
.fey-btn:active         { opacity: .85; }
.fey-btn-primary        { background: var(--c); color: #fff; }
.fey-btn-confirm        { background: var(--g); color: #fff; }
.fey-btn-close {
  padding: 12px 36px; border-radius: 12px;
  border: 1.5px solid var(--bd); background: transparent;
  font-size: 14px; color: var(--t2); cursor: pointer;
}

/* Utilitaires */
.fey-gap    { height: 24px; flex-shrink: 0; }
.hidden     { display: none !important; }

/* ── Page WP standard ────────────────────── */
.fey-page {
  padding: 24px 20px 40px; min-height: 100vh;
}
.fey-page-title {
  font-family: 'DM Serif Display', serif;
  font-size: 24px; color: var(--t);
  margin-bottom: 16px; line-height: 1.2;
}
.fey-page-content {
  font-size: 15px; color: var(--t2); line-height: 1.7;
}
.fey-page-content p  { margin-bottom: 12px; }
.fey-page-content h2 { font-size: 18px; color: var(--t); margin: 20px 0 8px; }
