:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-card-hover: #273549;
  --border-color: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-carrefour: #0055b8;
  --accent-carrefour-light: #2563eb;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  padding: 16px 16px 80px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #0055b8, #0088ff);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  color: white;
  box-shadow: 0 4px 12px rgba(0, 85, 184, 0.4);
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-success);
}

.status-dot.offline {
  background-color: var(--accent-warning);
}

/* Balance Hero Card */
.hero-balance {
  background: linear-gradient(135deg, #1e3a8a, #0f172a);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  box-shadow: var(--shadow-lg);
}

.hero-balance-info .label {
  font-size: 0.85rem;
  color: #93c5fd;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 4px;
}

.hero-balance-info .amount {
  font-size: 2.2rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -1px;
}

.hero-balance-meta {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

.badge-cards-count {
  background: rgba(59, 130, 246, 0.25);
  color: #bfdbfe;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.btn-sync {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ffffff;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-sync:active {
  transform: scale(0.96);
  background: rgba(255, 255, 255, 0.2);
}

.btn-sync.syncing {
  opacity: 0.7;
  pointer-events: none;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spin-icon {
  animation: spin 0.8s linear infinite;
}

/* Lock Screen */
.lock-screen-overlay {
  position: fixed;
  inset: 0;
  background: #090d16;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lock-screen-card {
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
}

/* Devices List */
.device-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.device-item.revoked {
  opacity: 0.55;
  background: rgba(239, 68, 68, 0.05);
  border-color: rgba(239, 68, 68, 0.2);
}

.device-item-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: white;
  display: flex;
  align-items: center;
  gap: 6px;
}

.device-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.35;
}

.btn-revoke {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-revoke:hover {
  background: rgba(239, 68, 68, 0.35);
}

.btn-unrevoke {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* Toast Notification */
.toast-container {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 90%;
  max-width: 420px;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  color: #ffffff;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-success {
  border-color: rgba(34, 197, 94, 0.5);
  color: #86efac;
}

.toast-info {
  border-color: rgba(59, 130, 246, 0.5);
  color: #93c5fd;
}

.toast-warning {
  border-color: rgba(245, 158, 11, 0.5);
  color: #fde68a;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-15px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Sections */
.section-title {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Loyalty Card (Pass Carrefour) */
.loyalty-card {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border-radius: var(--radius-lg);
  padding: 18px;
  color: white;
  box-shadow: 0 8px 20px rgba(2, 132, 199, 0.35);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s;
}

.loyalty-card:active {
  transform: scale(0.98);
}

.loyalty-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.loyalty-tag {
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}

.barcode-preview-box {
  background: white;
  border-radius: 12px;
  padding: 12px 10px 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.06);
}

.barcode-preview-box svg {
  width: 100%;
  max-height: 75px;
}

.barcode-number-text {
  font-family: monospace;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: #0f172a;
  margin-top: 6px;
}

.tap-zoom-hint {
  font-size: 0.7rem;
  color: #e0f2fe;
  text-align: center;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* Gift Cards List */
.cards-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.gift-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.gift-card.non-alimentaire {
  border-left: 5px solid var(--accent-warning);
}

.gift-card.standard {
  border-left: 5px solid var(--accent-carrefour-light);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.card-title-group h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.badge-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-tag.tag-warning {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
}

.badge-tag.tag-info {
  background: rgba(37, 99, 235, 0.18);
  color: #60a5fa;
}

.card-balance-display {
  text-align: right;
}

.card-balance-display .cur-bal {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-success);
}

.card-balance-display .cur-bal.low {
  color: var(--accent-warning);
}

.card-balance-display .init-bal {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Balance Progress bar */
.progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-success);
  border-radius: 4px;
  transition: width 0.3s;
}

.progress-fill.low {
  background: var(--accent-warning);
}

/* Card Barcode Area */
.card-barcode-container {
  background: white;
  border-radius: 12px;
  padding: 12px 10px 8px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.15s;
}

.card-barcode-container:active {
  transform: scale(0.99);
}

.card-barcode-container svg {
  width: 100%;
  max-height: 80px;
}

/* Card details (PAN & PIN) */
.card-codes-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.6);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
}

.pan-code {
  font-family: monospace;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-copy {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.pin-badge {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-family: monospace;
}

/* Bouton pleine largeur : Présenter en caisse */
.btn-present-caisse {
  width: 100%;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
  transition: all 0.2s;
  letter-spacing: 0.3px;
}

.btn-present-caisse:hover {
  background: linear-gradient(135deg, #0369a1, #075985);
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.5);
}

.btn-present-caisse:active {
  transform: scale(0.98);
}

/* Card Actions */
/* User Profile Pill */
.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  padding: 4px 10px 4px 6px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s;
}

.user-pill:active {
  transform: scale(0.96);
  background: rgba(255, 255, 255, 0.15);
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-carrefour-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: white;
}

/* Admin Zone Card */
.admin-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
  border: 1px dashed rgba(96, 165, 250, 0.4);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-buy-card {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
  transition: all 0.2s;
}

.btn-buy-card:active {
  transform: scale(0.98);
}

.secure-badge-info {
  font-size: 0.75rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.25);
  padding: 8px 10px;
  border-radius: 8px;
}

/* Profile Selection Grid */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 8px;
}

.profile-card-choice {
  background: #0f172a;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.profile-card-choice.active {
  border-color: var(--accent-carrefour-light);
  background: rgba(37, 99, 235, 0.15);
}

.profile-avatar-large {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 800;
  color: white;
}

.card-actions-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 2px;
}

.btn-action-history {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-action-history:active {
  background: rgba(255, 255, 255, 0.15);
}

/* Modals / Overlays */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.btn-close-modal {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-primary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
}

/* Fullscreen Scanner Modal - Haute Luminosité & Contraste Caisse */
#modal-scanner.modal-overlay {
  background: #ffffff !important;
  backdrop-filter: none !important;
  padding: 0 !important;
  z-index: 99999 !important;
}

#modal-scanner .modal-content {
  background: #ffffff !important;
  color: #0f172a !important;
  width: 100vw !important;
  max-width: 100vw !important;
  min-height: 100vh !important;
  height: 100% !important;
  border-radius: 0 !important;
  border: none !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  padding: env(safe-area-inset-top, 20px) 20px env(safe-area-inset-bottom, 24px) 20px !important;
  box-shadow: none !important;
  overflow-y: auto !important;
}

#modal-scanner .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 14px;
  margin-bottom: 15px;
}

#modal-scanner .modal-title {
  color: #0f172a !important;
  font-size: 1.25rem !important;
  font-weight: 800 !important;
}

#modal-scanner .btn-close-modal {
  background: #f1f5f9 !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  font-weight: bold;
}

.scanner-card-box {
  background: #ffffff !important;
  border: 2px dashed #94a3b8;
  border-radius: 16px;
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: auto 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.scanner-card-box svg {
  width: 100%;
  max-height: 140px;
}

.scanner-number-text {
  font-family: 'SF Mono', 'Courier New', monospace;
  font-size: 1.4rem;
  font-weight: 900;
  color: #000000;
  letter-spacing: 3px;
  margin-top: 16px;
  text-align: center;
}

.scanner-pin-banner {
  background: #fef3c7;
  border: 2px solid #f59e0b;
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 15px 0;
  color: #92400e;
}

.scanner-pin-banner span {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.scanner-pin-banner strong {
  font-family: monospace;
  font-size: 1.5rem;
  font-weight: 900;
  color: #b45309;
  letter-spacing: 2px;
}

.scanner-lum-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.8rem;
  color: #64748b;
  line-height: 1.35;
  margin-bottom: 16px;
}

.scanner-lum-hint svg {
  flex-shrink: 0;
  color: #f59e0b;
}

/* Debit Form Keypad & Input */
.debit-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.debit-input-group label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.debit-amount-input {
  background: #0f172a;
  border: 2px solid var(--accent-carrefour-light);
  border-radius: 12px;
  padding: 14px;
  font-size: 1.8rem;
  font-weight: 800;
  color: white;
  text-align: center;
  outline: none;
}

.quick-amounts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.btn-quick-amt {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 0;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-quick-amt:active {
  background: var(--accent-carrefour-light);
}

.btn-confirm-debit {
  background: linear-gradient(135deg, var(--accent-success), #059669);
  border: none;
  color: white;
  padding: 14px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

/* History Modal list */
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.history-item:last-child {
  border-bottom: none;
}

.history-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.history-amt {
  font-weight: 700;
}

.history-amt.neg {
  color: var(--accent-danger);
}

.history-amt.pos {
  color: var(--accent-success);
}

/* Bannière d'installation PWA Flottante */
.pwa-install-banner {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 440px;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(59, 130, 246, 0.45);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 16px 35px rgba(0, 0, 0, 0.7);
  z-index: 99999;
  animation: slideUpBanner 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpBanner {
  from { transform: translate(-50%, 80px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.btn-install-pwa {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
  transition: transform 0.15s;
}

.btn-install-pwa:active {
  transform: scale(0.96);
}

.btn-dismiss-pwa {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
}
