/* =====================================================
   SANKSI — Design "Candy" 🍬
   Violet / Rose pastel premium + effets de clic
   ===================================================== */

:root {
  --bg: #F8FAFC;
  --bg-elevated: #FFFFFF;
  --bg-deep: #F1F5F9;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;
  --text: #111827;
  --text-muted: #6B7280;
  --text-dim: #9CA3AF;

  --primary: #0EA5E9; /* Bleu ciel de l'affiche */
  --primary-hover: #0284C7;
  --primary-soft: #E0F2FE; /* Bleu très clair pour les fonds */
  --primary-glow: rgba(14, 165, 233, 0.35);

  --secondary: #1E3A8A; /* Bleu marine foncé */
  --secondary-soft: #DBEAFE;
  --secondary-glow: rgba(30, 58, 138, 0.35);

  --success: #10B981;
  --success-soft: #D1FAE5;
  --success-glow: rgba(16, 185, 129, 0.30);

  --danger: #EF4444;
  --danger-soft: #FEE2E2;
  --warning: #F59E0B;
  --warning-soft: #FEF3C7;

  --orange: #FF7900;
  --moov: #0066CC;
  --wave: #1DC3F3;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-sm: 0 1px 3px rgba(30, 16, 51, 0.05);
  --shadow: 0 4px 16px rgba(30, 16, 51, 0.06);
  --shadow-lg: 0 12px 32px rgba(124, 58, 237, 0.18), 0 4px 12px rgba(30, 16, 51, 0.05);

  --grad: var(--primary);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: opacity 0.2s; }
a:hover { opacity: 0.8; }

button { font-family: inherit; cursor: pointer; border: none; }

.app-container {
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow-x: hidden;
}
.page { padding: 20px; flex: 1; display: flex; flex-direction: column; }

.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  transform: scale(0);
  animation: rippleAnim 0.6s ease-out;
  pointer-events: none;
}
.key .ripple, .shortcut-btn .ripple, .header-link .ripple {
  background: var(--primary);
  opacity: 0.25;
}
@keyframes rippleAnim { to { transform: scale(2.5); opacity: 0; } }

.confetti {
  position: fixed;
  top: -12px;
  width: 8px;
  height: 14px;
  border-radius: 3px;
  pointer-events: none;
  animation: confettiFall linear forwards;
  z-index: 9999;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(var(--rot)); opacity: 0; }
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo {
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: 1.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-mark {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 900;
  font-size: 16px;
  box-shadow: 0 4px 14px var(--primary-glow);
}
.header-link {
  font-size: 12px;
  color: var(--primary);
  font-weight: 700;
  background: var(--primary-soft);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: transform 0.12s ease, background 0.15s;
}
.header-link:active { transform: scale(0.94); background: var(--primary); color: white; }

.bm-card {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 20px 20px 12px 20px;
  box-shadow: var(--shadow-sm);
}
.bm-logo {
  width: 50px; height: 50px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900;
  color: white;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 6px 16px var(--primary-glow);
}
.bm-name { font-weight: 800; font-size: 16px; }
.bm-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.operators {
  display: flex;
  gap: 10px;
  padding: 0 20px;
  margin-bottom: 18px;
}
.op-btn {
  flex: 1;
  padding: 14px 8px;
  border-radius: var(--radius);
  font-weight: 800;
  font-size: 12px;
  text-align: center;
  opacity: 0.35;
  filter: grayscale(0.5);
  border: 2px solid transparent;
  line-height: 1.3;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.2s, filter 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.op-btn:active { transform: scale(0.94); }
.op-btn.active {
  opacity: 1;
  filter: none;
  border-color: #FFFFFF;
  transform: scale(1.05);
  animation: opPop 0.4s ease;
}
@keyframes opPop {
  0% { transform: scale(0.95); }
  55% { transform: scale(1.09); }
  100% { transform: scale(1.05); }
}
.op-orange { background: var(--orange); color: white; }
.op-orange.active { box-shadow: 0 8px 22px rgba(255, 121, 0, 0.45); }
.op-moov { background: var(--moov); color: white; }
.op-moov.active { box-shadow: 0 8px 22px rgba(0, 102, 204, 0.45); }
.op-wave { background: var(--wave); color: var(--text); }
.op-wave.active { box-shadow: 0 8px 22px rgba(29, 195, 243, 0.45); }

.tabs {
  position: relative;
  display: flex;
  background: var(--bg-deep);
  border-radius: var(--radius);
  padding: 4px;
  margin: 0 20px;
  border: none;
}
.tabs-indicator {
  position: absolute;
  top: 4px; left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  background: var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 16px var(--primary-glow);
  transition: transform 0.35s cubic-bezier(0.4, 0.0, 0.2, 1);
  z-index: 0;
}
.tabs.retrait .tabs-indicator { transform: translateX(100%); }
.tab {
  flex: 1;
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 12px;
  font-weight: 700;
  font-size: 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: transparent;
  transition: color 0.25s;
}
.tab.active { color: white; }

.amount-display {
  font-weight: 900;
  text-align: center;
  margin: 22px 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
}
.amount-display .currency {
  color: var(--primary);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1.5px;
}
.amount-display .value {
  font-size: 52px;
  letter-spacing: -1.5px;
  background: var(--primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  transition: transform 0.15s;
}
.amount-display .value.bump { animation: bump 0.28s ease; }
@keyframes bump {
  0% { transform: scale(1); }
  45% { transform: scale(1.10); }
  100% { transform: scale(1); }
}
.amount-big {
  font-size: 36px;
  font-weight: 900;
  background: var(--primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
  margin: 8px 0;
}

.shortcuts {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 0 20px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.shortcut-btn {
  background: white;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  padding: 10px 18px;
  border-radius: 22px;
  font-weight: 800;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
              background 0.15s, color 0.15s, box-shadow 0.15s;
}
.shortcut-btn:active {
  background: var(--primary);
  color: white;
  transform: scale(0.90);
  box-shadow: 0 4px 14px var(--primary-glow);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 20px;
  flex: 1;
  align-content: end;
  margin-bottom: 16px;
}
.key {
  background: white;
  color: var(--text);
  font-size: 26px;
  font-weight: 700;
  border-radius: var(--radius);
  padding: 22px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
              background 0.1s, color 0.1s, box-shadow 0.1s;
  user-select: none;
}
.key:active {
  background: white;
  color: var(--primary);
  transform: scale(0.90);
  box-shadow: 0 1px 2px rgba(30, 16, 51, 0.10);
}
.key.action { color: var(--primary); font-weight: 800; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  font-weight: 800;
  font-size: 16px;
  padding: 16px 20px;
  border-radius: var(--radius);
  min-height: 52px;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s, background 0.2s;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 8px 22px var(--primary-glow); }
.btn-success { background: var(--success); color: white; box-shadow: 0 6px 16px var(--success-glow); }
.btn-secondary { background: white; color: var(--text); border: 1.5px solid var(--border); }
.btn-block { width: 100%; }

.btn-main {
  position: relative;
  overflow: hidden;
  background: var(--primary);
  color: white;
  font-weight: 900;
  font-size: 17px;
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 0 20px 20px 20px;
  box-shadow: var(--shadow-lg);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}
.btn-main::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  pointer-events: none;
}
.btn-main:active {
  transform: scale(0.97) translateY(1px);
  box-shadow: 0 6px 14px var(--primary-glow);
}
.btn-main:active::after { animation: shine 0.7s ease; }
@keyframes shine {
  from { left: -100%; }
  to { left: 100%; }
}
.btn-main.retrait-mode {
  background: linear-gradient(135deg, #10B981 0%, #34D399 100%);
  box-shadow: 0 12px 32px var(--success-glow), 0 4px 12px rgba(30, 16, 51, 0.05);
}

.card, .step-card {
  background: white;
  border: none;
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.step-title {
  font-weight: 800;
  font-size: 16px;
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 900;
  flex-shrink: 0;
  box-shadow: 0 4px 10px var(--primary-glow);
}

.input-field {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--bg-deep);
  border: 1.5px solid transparent;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  outline: none;
}
.input-field::placeholder { color: var(--text-dim); }
.input-field:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15);
}
.label { display: block; font-weight: 800; font-size: 14px; margin-bottom: 8px; }
.hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

.merchant-number {
  font-size: 20px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: 1px;
  text-align: center;
  background: var(--bg-deep);
  padding: 14px;
  border-radius: var(--radius);
  border: 1.5px dashed var(--primary);
  margin: 12px 0;
}
.merchant-number.reference { color: var(--warning); border-color: var(--warning); background: var(--warning-soft); }

.timer-wrap { text-align: center; }
.timer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 800;
  color: var(--danger);
  background: var(--danger-soft);
  padding: 8px 16px;
  border-radius: 20px;
  margin: 12px auto 0;
}

.page-title {
  font-size: 20px;
  font-weight: 900;
  text-align: center;
  margin: 0 0 20px 0;
  background: var(--primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin: 0 0 12px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-success { background: var(--success-soft); color: #047857; }
.badge-warning { background: var(--warning-soft); color: #B45309; }
.badge-danger  { background: var(--danger-soft); color: #B91C1C; }
.badge-info    { background: var(--primary-soft); color: var(--primary); }

.alert {
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid transparent;
}
.alert-success { background: var(--success-soft); border-color: #A7F3D0; color: #047857; }
.alert-warning { background: var(--warning-soft); border-color: #FDE68A; color: #B45309; }
.alert-danger  { background: var(--danger-soft); border-color: #FECACA; color: #B91C1C; }
.alert-info    { background: var(--primary-soft); border-color: #DDD6FE; color: var(--primary); }

#toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 40px);
  max-width: 440px;
}
.toast {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  background: white;
  color: var(--text);
  border: 1.5px solid var(--border);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-info { border-color: var(--primary); color: var(--primary); }
.toast-success { border-color: var(--success); color: #047857; }
.toast-error { border-color: var(--danger); color: #B91C1C; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 16px;
  transition: color 0.2s, transform 0.12s;
  align-self: flex-start;
}
.back-link:active { color: var(--primary); transform: scale(0.96); }

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease; }

/* Animation succès (checkmark) */
@keyframes successBounce {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}
.success-bounce {
  animation: successBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  display: inline-block;
}

/* Logo image - forcé */
.logo {
    display: flex;
    align-items: center;
}
.logo-img {
    height: 40px !important;
    width: auto !important;
    max-height: 40px !important;
    max-width: 120px !important;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--primary-glow);
    display: block;
}

/* Bouton WhatsApp flottant */
.whatsapp-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    background-color: #25D366;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(37, 211, 102, 0.4);
    z-index: 9999;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s;
}
.whatsapp-fab:active {
    transform: scale(0.88);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}
@media (max-width: 480px) {
    .whatsapp-fab {
        bottom: 20px;
        right: 20px;
        width: 54px;
        height: 54px;
    }
}

/* Splash Screen */
#splash-screen {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #FAF7FF;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}
#splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
}
#splash-screen img {
    height: 100px;
    border-radius: 20px;
    box-shadow: 0 10px 30px var(--primary-glow);
    animation: pulseLogo 1.5s infinite alternate;
}
@keyframes pulseLogo {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

/* Barre de navigation en bas */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 10px 0 15px 0; /* Padding plus grand en bas pour les écrans avec encoche */
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    transition: color 0.2s, transform 0.15s;
}

.nav-item:active {
    transform: scale(0.9);
}

.nav-item.active {
    color: var(--primary);
}

.nav-item svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    fill: currentColor;
}

/* Ajouter un espace en bas des pages pour ne pas cacher le contenu sous la barre */
.app-container {
    padding-bottom: 80px;
}

/* Bannière d'installation PWA */
#pwa-banner {
    position: fixed;
    bottom: 70px; /* Au-dessus de la bottom-nav */
    left: 50%;
    transform: translateX(-50%) translateY(150%);
    width: calc(100% - 40px);
    max-width: 440px;
    background: white;
    border: 1.5px solid var(--primary);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.2);
    z-index: 2000;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#pwa-banner.show {
    transform: translateX(-50%) translateY(0);
}
#pwa-banner img { width: 40px; height: 40px; border-radius: 8px; }

/* ============ MODE SOMBRE ============ */
[data-theme="dark"] {
    --bg: #0F0A1E;
    --bg-elevated: #1A1130;
    --bg-deep: #150D28;
    --border: #2D1F4C;
    --border-strong: #3F2C69;
    --text: #F8FAFC;
    --text-muted: #A78BFA;
    --text-dim: #7C6E9E;
    --primary-soft: #2D1F4C;
}
[data-theme="dark"] .card, 
[data-theme="dark"] .step-card, 
[data-theme="dark"] .app-header,
[data-theme="dark"] .key,
[data-theme="dark"] .shortcut-btn,
[data-theme="dark"] .bottom-nav {
    background: var(--bg-elevated);
    color: var(--text);
}
[data-theme="dark"] .input-field {
    background: var(--bg-deep);
    color: var(--text);
}

/* ===== Corrections : bannière d'installation + mode sombre ===== */
#pwa-banner {
    bottom: 80px;
    transform: translateX(-50%) translateY(300%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s, visibility 0s 0.4s;
}
#pwa-banner.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s, visibility 0s;
}

[data-theme="dark"] .bm-card,
[data-theme="dark"] .btn-secondary,
[data-theme="dark"] .toast,
[data-theme="dark"] #pwa-banner {
    background: var(--bg-elevated);
    color: var(--text);
}
[data-theme="dark"] .bm-name { color: var(--text); }
[data-theme="dark"] .btn-secondary { border-color: var(--border-strong); }
