/* =============================================================
   FIDELEATOME — style.css
   ============================================================= */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --blue:         #1976D2;
  --blue-dark:    #1565C0;
  --blue-light:   #E3F2FD;
  --blue-btn:     #1E90FF;
  --green:        #22C55E;
  --green-dark:   #16A34A;
  --green-light:  #D1FAE5;
  --orange:       #F97316;
  --accent:       #F59E0B;
  --danger:       #EF4444;
  --text:         #111827;
  --text-dark:    #0F172A;
  --muted:        #6B7280;
  --bg:           #F1F5F9;
  --white:        #FFFFFF;
  --border:       #E2E8F0;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow:       0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.07);
  --radius:       12px;
  --radius-sm:    8px;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }

/* ── Navbar ─────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  /* height: 56px; */
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.auth-page .navbar {
  background: transparent;
  border-bottom: none;
  box-shadow: none;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  text-decoration: none;
}
.navbar-brand__name {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-dark);
  letter-spacing: .02em;
}
.navbar-brand__3d {
  color: var(--blue);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.navbar-link {
  font-size: .9rem;
  color: var(--muted);
  padding: .35rem .75rem;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}
.navbar-link:hover,
.navbar-link.active { color: var(--blue); background: var(--blue-light); }
.navbar-link--logout { color: var(--text); }
.navbar-link--logout:hover { color: var(--danger); background: #FEF2F2; }

/* ── Hamburger button (masqué sur desktop) ───────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 26px;
  height: 19px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-dark);
  border-radius: 2px;
  transition: transform .3s cubic-bezier(.4,0,.2,1), opacity .25s ease;
}
.hamburger.open span:nth-child(1) { transform: translateY(8.5px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open span:nth-child(3) { transform: translateY(-8.5px) rotate(-45deg); }

.auth-logo-image {
  width: 70px;
  height: auto;
  object-fit: contain;
}
/* ── Main content ───────────────────────────────────────────── */
.main-content {
  margin: 0 auto;
  padding: 2rem 1.5rem;
}


/* ── Business dashboard ─────────────────────────────────────── */

.biz-header { margin-bottom: 1.75rem; }
.biz-header h1 { font-size: 2rem; font-weight: 800; color: var(--text-dark); }
.biz-subtitle  { font-size: .95rem; color: var(--muted); margin-top: .2rem; }

/* Action buttons */
.biz-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.biz-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 1.1rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--white);
  text-decoration: none;
  transition: filter .15s, transform .1s;
}
.biz-btn:hover { filter: brightness(1.08); transform: translateY(-1px); color: var(--white); text-decoration: none; }
.biz-btn:active { transform: translateY(0); }
.biz-btn--blue   { background: #1E90FF; }
.biz-btn--green  { background: #22C55E; }
.biz-btn--purple { background: #7C3AED; }

/* 3 boutons d'action : auto-fit pour s'adapter à tous les écrans */
.biz-actions--three { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* Stat cards */
.biz-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.biz-stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.biz-stat-label {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .5rem;
}

.biz-stat-value {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--blue);
  line-height: 1;
  margin-bottom: .4rem;
}

.biz-stat-sub {
  font-size: .8rem;
  color: var(--muted);
}

/* How it works box */
.biz-howto {
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.biz-howto__title {
  font-weight: 700;
  font-size: .95rem;
  color: #1E40AF;
  margin-bottom: .75rem;
}

.biz-howto__list {
  list-style: decimal;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: .9rem;
}

.biz-howto__list li {
  font-size: .9rem;
  color: #1D4ED8;
}

.biz-rewards-info {
  font-size: .9rem;
  color: #1E40AF;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.biz-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-weight: 700;
  font-size: .9rem;
  color: var(--white);
}
.biz-badge--orange { background: var(--orange); }
.biz-badge--green  { background: var(--green); }

/* Clients page card */
.biz-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.back-link {
  display: inline-block;
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: .75rem;
}
.back-link:hover { color: var(--blue); }

/* ── Generic card ───────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.card-header {
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 1rem; font-weight: 600; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text);
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--white);
}
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-danger  { background: var(--danger); border-color: var(--danger); color: var(--white); }
.btn-full    { width: 100%; }
.btn-sm      { padding: .35rem .8rem; font-size: .85rem; }
.btn-lg      { padding: .75rem 2rem; font-size: 1.05rem; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group {
  position: relative;
  margin-bottom: 1.25rem;
}
.form-control {
  width: 100%;
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  background: #F0F4F8;
  color: var(--text);
  transition: border-color .15s, background .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--blue);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(25,118,210,.12);
}
.form-control::placeholder { color: #9CA3AF; }

.form-label-static {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: .5rem;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ── Role picker ─────────────────────────────────────────────── */
.role-picker { display: flex; gap: 1rem; }
.role-option { flex: 1; cursor: pointer; }
.role-option input[type=radio] { display: none; }
.role-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  transition: border-color .15s, background .15s;
}
.role-icon { font-size: 1.5rem; }
.role-option input:checked + .role-card {
  border-color: var(--blue);
  background: var(--blue-light);
  color: var(--blue-dark);
}

/* ── Auth layout ────────────────────────────────────────────── */
.auth-page .main-content { display: flex; justify-content: center; padding-top: 3rem; }
.auth-container { width: 100%; max-width: 440px; }
.auth-card { background: var(--white); border-radius: var(--radius); padding: 2rem; box-shadow: 0 10px 25px rgba(0,0,0,.1); border: 1px solid var(--border); }
.auth-card--wide { max-width: 560px; }
.auth-logo { text-align: center; margin-bottom: 1.75rem; }
.brand-icon-large { font-size: 2.5rem; color: var(--blue); }
.auth-logo h1 { font-size: 1.75rem; font-weight: 800; margin-top: .25rem; color: var(--text-dark); }
.auth-subtitle { color: var(--muted); font-size: .9rem; margin-top: .25rem; }
.auth-link { text-align: center; margin-top: 1.25rem; font-size: .9rem; color: var(--muted); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-danger  { background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B; }
.alert-success { background: #F0FDF4; border: 1px solid #BBF7D0; color: #166534; }

/* ── Loyalty card (customer) ────────────────────────────────── */
.loyalty-card-wrapper { margin-bottom: 1.5rem; }
.loyalty-card {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 85.6 / 54;
  background: linear-gradient(135deg, #1565C0 0%, #1976D2 50%, #42A5F5 100%);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 20px 40px rgba(25,118,210,.3), 0 8px 16px rgba(0,0,0,.15);
  color: var(--white);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  margin: 0 auto;
}
.loyalty-card::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 180px; height: 180px;
  background: rgba(255,255,255,.07);
  border-radius: 50%;
}
.loyalty-card::after {
  content: '';
  position: absolute;
  bottom: -60px; left: -20px;
  width: 160px; height: 160px;
  background: rgba(255,255,255,.05);
  border-radius: 50%;
}
.loyalty-card__header {
  display: flex;
  justify-content: space-between;
  font-size: .75rem;
  opacity: .85;
  position: relative;
  z-index: 1;
}
.loyalty-card__brand { font-weight: 700; font-size: .9rem; letter-spacing: .05em; }

/* ── QR scanner preview ───────────────────────────────────── */
.qr-container {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 300px;
  background: #111827;
  border-radius: 12px;
  overflow: hidden;         /* empêche l'overlay de déborder */
  display: flex;
  align-items: center;
  justify-content: center;
}
#qr-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  display: none;            /* caché jusqu'au démarrage du scan */
}
/* Neutralise les styles injectés par la lib html5-qrcode */
#qr-reader {
  display: none;            /* caché par défaut */
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border: none !important;
  padding: 0 !important;
  background: transparent !important;
}
#qr-reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border-radius: 0 !important;
}
#qr-reader img, #qr-reader button,
#qr-reader #qr-reader__header_message,
#qr-reader #qr-reader__dashboard_section_swaplink { display: none !important; }

.scan-overlay {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 220px; height: 220px;
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 12px;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.45);  /* assombrit l'extérieur du cadre */
}
/* Coins animés */
.scan-overlay::before,
.scan-overlay::after {
  content: '';
  position: absolute;
  width: 28px; height: 28px;
  border-color: #3B82F6;
  border-style: solid;
}
.scan-overlay::before {
  top: -2px; left: -2px;
  border-width: 3px 0 0 3px;
  border-radius: 4px 0 0 0;
}
.scan-overlay::after {
  bottom: -2px; right: -2px;
  border-width: 0 3px 3px 0;
  border-radius: 0 0 4px 0;
}
/* Laser animé */
.scan-laser {
  position: absolute;
  left: 8px; right: 8px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #3B82F6, transparent);
  border-radius: 1px;
  animation: laserScan 2s ease-in-out infinite;
  top: 0;
}
@keyframes laserScan {
  0%   { top: 8px;   opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { top: calc(100% - 10px); opacity: 0; }
}
/* Placeholder caméra inactive */
.qr-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  color: rgba(255,255,255,.35);
  user-select: none;
  pointer-events: none;
}
.qr-placeholder svg  { width: 48px; height: 48px; opacity: .5; }
.qr-placeholder span { font-size: .85rem; letter-spacing: .04em; }
.scan-status {
  margin-top: .75rem;
  font-size: .9rem;
  color: var(--muted);
  text-align: center;
  font-weight: 500;
  min-height: 1.4rem;
}
.scan-status--scanning { color: var(--blue); }
.scan-status--ok       { color: var(--green); }
.scan-status--error    { color: var(--danger); }
.scan-status--idle     { color: var(--muted); }
.loyalty-card__points {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  position: relative;
  z-index: 1;
}
.loyalty-card__points-value {
  font-family: 'Courier New', monospace;
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
}
.loyalty-card__points-unit { font-size: .85rem; opacity: .8; }
.loyalty-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  position: relative;
  z-index: 1;
}
.loyalty-card__name {
  font-family: 'Courier New', monospace;
  font-size: .8rem;
  letter-spacing: .12em;
  opacity: .9;
}
.loyalty-card__qr {
  background: #ffffff;
  border-radius: 6px;
  padding: 3px;
  line-height: 0;
}
.loyalty-card__qr--btn {
  cursor: pointer;
  transition: opacity .15s, transform .15s;
}
.loyalty-card__qr--btn:hover { opacity: .85; transform: scale(1.06); }
.loyalty-card__qr canvas,
.loyalty-card__qr img { border-radius: 4px; display: block; }

/* ── Customer dashboard ─────────────────────────────────────── */
.dashboard-grid { display: grid; gap: 1.5rem; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  text-align: center;
}
.stat-card__icon {
  font-size: 1.4rem;
  margin-bottom: .5rem;
  width: 2.4rem; height: 2.4rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stat-card__icon--blue  { background: var(--blue-light); }
.stat-card__icon--green { background: var(--green-light); }
.stat-card__icon--gold  { background: #FEF3C7; }
.stat-card__value { font-size: 2rem; font-weight: 800; color: var(--blue); }
.stat-card__value--validated { color: #065F46; }
.stat-card__label { font-size: .8rem; color: var(--muted); margin-top: .2rem; }

/* Progress bar */
.progress-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: .75rem; }
.progress-label { font-size: .9rem; color: var(--muted); margin-bottom: .5rem; }
.progress-bar-track {
  background: var(--border);
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
}
.progress-bar-fill {
  background: linear-gradient(90deg, var(--blue), #42A5F5);
  height: 100%;
  border-radius: 999px;
  min-width: 2%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: .4rem;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.progress-bar-fill span { font-size: .65rem; color: var(--white); font-weight: 700; }

/* Page header (customer pages) */
.page-header { margin-bottom: 1.5rem; }
.page-header h2 { font-size: 1.6rem; font-weight: 700; }
.page-subtitle { color: var(--muted); margin-top: .25rem; }

/* ── Table ──────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }
.table-clients {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.table-clients th {
  background: var(--bg);
  padding: .75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.table-clients td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table-clients tr:last-child td { border-bottom: none; }
.table-clients tbody tr:nth-child(even) { background: #FAFAFA; }
.table-clients tbody tr:hover { background: var(--blue-light); }
.table-clients tr.row-reward { background: #FFFBEB; }

/* Badges */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
}
.badge-blue   { background: var(--blue-light); color: var(--blue-dark); }
.badge-points { background: var(--blue-light); color: var(--blue-dark); }
.badge-reward { background: #FEF3C7; color: #92400E; }
.type-reward   { color: #D97706; font-size: .85rem; }
.type-purchase { color: var(--muted); font-size: .85rem; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px solid var(--border);
}
.pagination-info { font-size: .9rem; color: var(--muted); }

/* ── Scan page ──────────────────────────────────────────────── */
.biz-page { max-width: 1100px; margin: 0 auto; }

.scan-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.scan-card { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.qr-overlay {
  position: relative;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}
#scanVideo { width: 100%; height: 100%; object-fit: cover; display: block; }
.qr-laser {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--blue), transparent);
  animation: laserScan 2s linear infinite;
}
@keyframes laserScan {
  0%   { top: 0; opacity: 1; }
  90%  { top: calc(100% - 2px); opacity: 1; }
  100% { top: 0; opacity: 0; }
}
.scan-actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

/* Customer result card */
.customer-result__header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.customer-result__header .btn-sm { margin-left: auto; }

.customer-avatar-lg {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--blue-light);
  color: var(--blue);
  font-weight: 800;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: .02em;
  border: 2px solid rgba(25,118,210,.15);
}

.customer-result__name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0 0 .15rem;
}
.customer-result__email {
  font-size: .82rem;
  color: var(--muted);
  margin: 0;
}

/* Stats */
.result-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: .75rem; margin: 1rem 0; }
.result-stat { text-align: center; padding: .75rem; background: var(--bg); border-radius: var(--radius-sm); }
.result-stat__label { display: block; font-size: .75rem; color: var(--muted); margin-bottom: .25rem; }
.result-stat__value { display: block; font-size: 1.5rem; font-weight: 800; color: var(--blue); }

/* Progression */
.scan-progress { margin: .75rem 0 1rem; }
.scan-progress__label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: .4rem;
}
.scan-progress__label span:last-child { font-weight: 600; color: var(--text); }

/* Add points */
.add-points-form { margin-top: 1rem; }
.points-input-row { display: flex; gap: .5rem; margin-top: .4rem; align-items: center; }
.points-input { max-width: 100px; text-align: center; }

.points-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
  line-height: 1;
}
.points-btn:hover    { background: var(--bg); border-color: #C0C8D4; }
.points-btn:active   { background: #E8EDF3; }

/* Feedback */
.feedback {
  margin-top: .75rem;
  padding: .6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
}
.feedback.success { background: #D1FAE5; color: #065F46; }
.feedback.error   { background: #FEE2E2; color: #991B1B; }

/* Manual entry */
.manual-entry { margin-top: 1rem; }
.manual-entry h4 { font-size: .95rem; font-weight: 600; margin-bottom: .75rem; }

/* Html5Qrcode internal video */
#qr-reader { width: 100%; }
#qr-reader video {
  width: 100% !important;
  border-radius: 12px;
  max-height: 420px;
  object-fit: cover;
}

/* Empty state */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state__icon { font-size: 3rem; margin-bottom: .75rem; }

/* ── Clients page ───────────────────────────────────────────── */
.clients-search-wrap {
  background: var(--white);
  border-radius: var(--radius);
  padding: .6rem 1rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}
.clients-search-box {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.search-icon { color: var(--muted); flex-shrink: 0; }
.clients-search-input {
  border: none;
  outline: none;
  font-size: .95rem;
  color: var(--text);
  background: transparent;
  width: 100%;
  padding: .35rem 0;
}
.clients-search-input::placeholder { color: #B0BAC9; }

.clients-table-wrap {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.clients-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.clients-table thead tr {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.clients-table th {
  padding: .75rem 1.25rem;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--muted);
}
.clients-table th.th-actions { text-align: right; }

.clients-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.clients-table tbody tr:last-child td { border-bottom: none; }
.clients-table tbody tr:hover { background: #F8FAFF; }

.td-client {
  display: flex;
  align-items: center;
  gap: .85rem;
}
.client-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #DBEAFE;
  color: var(--blue);
  font-weight: 700;
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: .02em;
}
.client-name { font-weight: 500; color: var(--text); }

.pts-badge {
  display: inline-block;
  padding: .25rem .7rem;
  background: #DBEAFE;
  color: var(--blue);
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 600;
}

.td-main { font-weight: 600; font-size: .95rem; color: var(--text); }
.td-sub  { font-size: .78rem; color: var(--muted); margin-top: .1rem; }

.td-date { color: var(--muted); font-size: .88rem; white-space: nowrap; }

.td-actions { text-align: right; white-space: nowrap; }

.action-link {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
  padding: .25rem .5rem;
  border-radius: 4px;
  transition: opacity .15s;
}
.action-link:hover { opacity: .7; }
.action-link--orange { color: #F97316; }
.action-link--blue   { color: var(--blue); }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--muted);
  padding: .2rem .4rem;
  border-radius: 4px;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body   { padding: 1.25rem 1.5rem; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* ── Reward chips (clients table) ───────────────────────────── */
.reward-chip {
  display: inline-block;
  padding: .2rem .65rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
}
.reward-chip--pending   { background: #FEF3C7; color: #92400E; }
.reward-chip--validated { background: #D1FAE5; color: #065F46; }

/* ── Pending rewards section (scan page) ────────────────────── */
.pending-rewards-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1rem 0 .5rem;
  padding: .6rem .75rem;
  background: #FEF3C7;
  border-radius: var(--radius-sm);
  border: 1px solid #FDE68A;
}
.pending-badge-label { font-size: .88rem; font-weight: 600; color: #92400E; }
.pending-count {
  background: #F59E0B;
  color: var(--white);
  font-size: .78rem;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pending-rewards-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .75rem; }

.pending-reward-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: opacity .3s, transform .3s;
}
.pending-reward-item--done { opacity: 0; transform: translateX(20px); }

.pending-reward-info { display: flex; align-items: center; gap: .75rem; }
.pending-reward-icon { font-size: 1.3rem; }
.pending-reward-label { font-size: .9rem; font-weight: 600; color: var(--text); }
.pending-reward-date  { font-size: .78rem; color: var(--muted); margin-top: .1rem; }

.btn-validate {
  background: var(--green);
  border: none;
  color: var(--white);
  padding: .4rem .9rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.btn-validate:hover    { background: var(--green-dark); }
.btn-validate:disabled { opacity: .6; cursor: not-allowed; }

/* ── Coupon modal ───────────────────────────────────────────── */
.coupon-card {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.coupon-card__top {
  background: linear-gradient(135deg, #1565C0, #1976D2);
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.coupon-card__logo  { color: var(--white); font-weight: 800; font-size: .9rem; }
.coupon-card__title { color: rgba(255,255,255,.8); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }

.coupon-card__reward {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-dark);
  padding: 1.25rem 1rem;
  border-bottom: 1px dashed var(--border);
}

.coupon-card__details { padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: .6rem; }
.coupon-detail { display: flex; justify-content: space-between; align-items: center; }
.coupon-detail__label { font-size: .78rem; color: var(--muted); }
.coupon-detail__value { font-size: .88rem; font-weight: 600; color: var(--text); }
.coupon-detail__value--mono { font-family: 'Courier New', monospace; font-size: .78rem; color: var(--blue); }

.coupon-card__footer {
  text-align: center;
  font-size: .72rem;
  color: var(--muted);
  padding: .6rem;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

/* ── Admin history list ──────────────────────────────────────── */
.history-list { display: flex; flex-direction: column; }

.history-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .875rem 0;
  border-bottom: 1px solid var(--border);
}
.history-item:first-child { padding-top: 0; }
.history-item:last-child  { border-bottom: none; padding-bottom: 0; }

.history-item__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #DBEAFE;
  color: var(--blue);
  font-weight: 700;
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: .02em;
}

.history-item__body { flex: 1; min-width: 0; }

.history-item__client {
  font-weight: 700;
  font-size: .95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item__reward {
  font-size: .85rem;
  color: var(--muted);
  margin-top: .1rem;
}

.history-item__meta {
  display: flex;
  align-items: center;
  gap: .625rem;
  margin-top: .35rem;
  font-size: .75rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.history-item__id {
  font-family: 'Courier New', monospace;
  font-size: .68rem;
  color: var(--blue);
  background: var(--blue-light);
  padding: .15rem .45rem;
  border-radius: 4px;
  word-break: break-all;
}

.history-item__btn { flex-shrink: 0; }

.history-item__note {
  font-style: italic;
  color: var(--muted);
}

/* Badge aligné à droite dans un .history-item */
.hist-badge { flex-shrink: 0; }

/* Compteur dans l'en-tête de section */
.hist-count {
  display: inline-block;
  background: var(--blue-light);
  color: var(--blue-dark);
  font-size: .75rem;
  font-weight: 700;
  padding: .15rem .55rem;
  border-radius: 999px;
  margin-left: .5rem;
  vertical-align: middle;
}

/* ── Rewards list (customer history) ────────────────────────── */
.rewards-list { display: flex; flex-direction: column; }

.reward-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.reward-row:first-child { padding-top: 0; }
.reward-row:last-child  { border-bottom: none; padding-bottom: 0; }

.reward-row__icon {
  font-size: 1.75rem;
  flex-shrink: 0;
  width: 2.5rem;
  text-align: center;
  line-height: 1;
}

.reward-row__info { flex: 1; min-width: 0; }

.reward-row__label {
  font-weight: 600;
  font-size: .95rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reward-row__meta {
  font-size: .78rem;
  color: var(--muted);
  margin-top: .2rem;
}

.reward-row__btn { flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — 4 paliers
   1. Tablette large  ≤ 1024px
   2. Tablette standard / grand téléphone  ≤ 768px
   3. Téléphone  ≤ 600px
   4. Clients table → Cartes  ≤ 900px  (couvre tablettes portrait)
   5. Ajustements strict téléphone  ≤ 640px
   ═══════════════════════════════════════════════════════════════ */

/* ── 1. Tablette large (≤ 1024px) ───────────────────────────── */
@media (max-width: 1024px) {
  .main-content { padding: 1.5rem 1.25rem; }
  /* Stat cards du commerçant passent à 2 colonnes */
  .biz-stats    { grid-template-columns: repeat(2, 1fr); }
}

/* ── 2. Tablette standard / grand téléphone (≤ 768px) ───────── */
@media (max-width: 768px) {
  .main-content                    { padding: 1rem; }
  /* Scanner + résultat en colonne dès la tablette portrait */
  .scan-layout                     { grid-template-columns: 1fr; }
  /* Formulaires 2 champs → 1 colonne */
  .form-row                        { grid-template-columns: 1fr; }
  /* Divers */
  .result-stats                    { grid-template-columns: repeat(3, 1fr); }
  .customer-result__header .btn-sm { margin-left: 0; }
  .loyalty-card                    { max-width: 100%; }
  /* Auth */
  .auth-page .main-content         { padding: 1rem; }
  .auth-container                  { max-width: 100%; }
  /* Navbar — burger mobile */
  .navbar {
    padding: 0 1rem;
    position: relative; /* ancre le dropdown et le burger centré */
  }
  .hamburger {
    display: flex;
    transform: translateX(-50%);
  }
  .navbar-right {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border-bottom: 2px solid var(--blue-light);
    box-shadow: 0 8px 24px rgba(0,0,0,.10);
    max-height: 0;
    overflow: hidden;
    transition: max-height .35s cubic-bezier(.4,0,.2,1);
    z-index: 99;
  }
  .navbar-right.open {
    max-height: 400px;
  }
  .navbar-link {
    font-size: 1rem;
    padding: .85rem 1.5rem;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    width: 100%;
    display: block;
  }
  .navbar-link:last-child { border-bottom: none; }
  .navbar-link:hover,
  .navbar-link.active {
    color: var(--blue);
    background: var(--blue-light);
  }
  .navbar-link--logout {
    color: var(--danger);
    margin-top: .25rem;
    border-top: 2px solid var(--border);
  }
  .navbar-link--logout:hover { background: #FEF2F2; }
  .auth-logo-image { width: 65px; height: auto; object-fit: contain; }
}

/* ── 3. Téléphone (≤ 600px) ─────────────────────────────────── */
@media (max-width: 600px) {
  /* Grilles qui n'ont pas besoin de plusieurs colonnes sur petit écran */
  .biz-actions      { grid-template-columns: 1fr; }
  .biz-stats        { grid-template-columns: 1fr; }
  .stats-grid       { grid-template-columns: 1fr; }
  .points-input-row { flex-wrap: wrap; }
  .biz-header h1    { font-size: 1.5rem; }
}

/* ── 4. Clients table → Cartes (≤ 900px — tablettes portrait) ─ */
@media (max-width: 900px) {
  /* Dissoudre le conteneur pour que chaque ligne ait sa propre carte */
  .clients-table-wrap {
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
  }

  .clients-table thead { display: none; }

  .clients-table,
  .clients-table tbody { display: block; }

  .clients-table tr.client-row {
    display: block;
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.1rem;
    margin-bottom: .875rem;
  }
  .clients-table tr.client-row:hover { background: var(--white); }

  .clients-table td {
    display: block;
    width: 100%;
    padding: 0;
    border-bottom: none;
  }

  .clients-table .td-client {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding-bottom: .875rem;
    margin-bottom: .5rem;
    border-bottom: 2px solid var(--border);
  }

  .clients-table td[data-label] {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .42rem 0;
    border-bottom: 1px dashed #EEF2F6;
  }
  .clients-table td[data-label]::before {
    content: attr(data-label);
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    flex-shrink: 0;
  }

  .clients-table td.td-date  { border-bottom: none; padding-bottom: .25rem; }

  .clients-table td.td-actions {
    display: flex;
    gap: .625rem;
    padding-top: .875rem;
    margin-top: .375rem;
    border-top: 1px solid var(--border);
    white-space: normal;
    text-align: left;
  }
  .clients-table td.td-actions .action-link {
    flex: 1;
    text-align: center;
    padding: .75rem .5rem;
    border-radius: var(--radius-sm);
    font-size: .92rem;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
  }
  .clients-table td.td-actions .action-link--orange { background: #FFF7ED; border-color: #FED7AA; }
  .clients-table td.td-actions .action-link--blue   { background: var(--blue-light); border-color: #BFDBFE; }

  .clients-table .td-sub { display: none; }

  .clients-search-wrap { padding: .5rem .875rem; }
}

/* ── 5. Ajustements strict téléphone (≤ 640px) ──────────────── */
@media (max-width: 640px) {
  /* Modale en bottom-sheet */
  .modal-backdrop { padding: .5rem; align-items: flex-end; }
  .modal          { border-radius: var(--radius) var(--radius) 0 0; max-width: 100%; }
  .modal--achats  { max-width: 100%; }

  /* Bouton "Voir le coupon" pleine largeur */
  .reward-row      { flex-wrap: wrap; gap: .5rem .875rem; }
  .reward-row__btn { width: 100%; justify-content: center; min-height: 44px; margin-top: .25rem; }

  /* Bouton "Voir le coupon" admin historique pleine largeur */
  .history-item     { flex-wrap: wrap; gap: .5rem .875rem; }
  .history-item__btn { width: 100%; justify-content: center; min-height: 44px; }
}

/* ── Modal historique achats ────────────────────────────────── */
.modal--achats { max-width: 520px; }

.modal-subtitle {
  font-size: .85rem;
  color: var(--muted);
  margin-top: .15rem;
}

.modal-stats-row {
  display: flex;
  align-items: center;
  padding: 1rem 0 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.modal-stat { flex: 1; text-align: center; }
.modal-stat__label {
  font-size: .72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .3rem;
}
.modal-stat__val { font-size: 1.2rem; font-weight: 700; color: var(--blue); }
.modal-stat__val--plain { color: var(--text); }
.modal-stat-sep { width: 1px; height: 2rem; background: var(--border); flex-shrink: 0; }

.modal-add-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
}
.modal-qty-wrap { display: flex; align-items: center; gap: .4rem; flex: 1; }
.modal-qty-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.modal-qty-btn:hover { background: var(--border); }
.modal-qty-input {
  width: 58px; height: 32px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .9rem;
  padding: 0 .25rem;
}
.modal-qty-label { font-size: .88rem; color: var(--muted); }

.btn-sm { padding: .45rem .9rem; font-size: .85rem; }

.purchase-history-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-height: 240px;
  overflow-y: auto;
}
.purchase-item {
  display: flex;
  align-items: center;
  padding: .7rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
}
.purchase-item__info { flex: 1; }
.purchase-item__date { font-size: .76rem; color: var(--muted); margin-bottom: .15rem; }
.purchase-item__qty  { font-size: .9rem; }
.purchase-item__actions { display: flex; align-items: center; gap: .35rem; }
.purchase-item__edit-input {
  width: 58px; height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
  font-size: .85rem;
  padding: 0 .25rem;
}
.icon-btn {
  background: none; border: none; cursor: pointer;
  padding: .3rem; border-radius: 4px;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  transition: color .15s, background .15s;
}
.icon-btn:hover         { background: var(--bg); }
.icon-btn--edit:hover   { color: var(--orange); }
.icon-btn--del:hover    { color: var(--danger); }
.icon-btn--save:hover   { color: var(--green-dark); }
.icon-btn--cancel:hover { color: var(--text); }

.modal-footer--full { justify-content: stretch; padding: 1rem 1.5rem; }
.btn-dark-close {
  flex: 1;
  background: #374151;
  color: var(--white);
  border: none;
  padding: .75rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  transition: background .15s;
}
.btn-dark-close:hover { background: #1F2937; }
