/* ============================================================
   FIDÉLITÉ PREMIUM — CSS Global
   Mobile-first, optimisé Raspberry Pi (pas de framework lourd)
   ============================================================ */

/* ── Variables ──────────────────────────────────────────────────── */
:root {
  --rose:       #C98AA0;
  --rose-soft:  #E7C4D1;
  --rose-deep:  #A96880;
  --rose-pale:  #F3E8EE;
  --bg:         #F8F5F6;
  --text:       #2D2D2D;
  --text-muted: #8A7A80;
  --white:      #FFFFFF;
  --gold:       #C9A96A;
  --gold-soft:  #F0E6CC;
  --border:     #EAD9E2;
  --success:    #2E9E5B;
  --error:      #E03E3E;
  --radius-sm:  10px;
  --radius-md:  16px;
  --radius-lg:  22px;
  --shadow-sm:  0 2px 12px rgba(201,138,160,.10);
  --shadow-md:  0 4px 24px rgba(201,138,160,.15);
  --shadow-lg:  0 8px 40px rgba(45,20,30,.18);
  --nav-h:      72px;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────────── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html  { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body  { font-family: var(--font-body); background: var(--bg); color: var(--text);
        min-height: 100vh; -webkit-tap-highlight-color: transparent; }
img   { max-width: 100%; display: block; }
a     { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
::-webkit-scrollbar { display: none; }

/* ── Typography ─────────────────────────────────────────────────── */
h1 { font-family: var(--font-display); font-size: 1.6rem; font-weight: 900; line-height: 1.2; }
h2 { font-family: var(--font-display); font-size: 1.25rem; font-weight: 800; }
h3 { font-size: 1rem; font-weight: 800; }

/* ── Layout ─────────────────────────────────────────────────────── */
.app-shell { max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative; }
.page      { padding-bottom: calc(var(--nav-h) + 16px); }

/* ── Page header (hero) ─────────────────────────────────────────── */
.page-hero {
  background: linear-gradient(135deg, var(--rose) 0%, var(--rose-deep) 100%);
  padding: 52px 22px 28px;
  position: relative; overflow: hidden;
}
.page-hero::before {
  content: ''; position: absolute; top: -40px; right: -40px;
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255,255,255,.07);
}
.page-hero--dark {
  background: linear-gradient(135deg, #2D2D2D 0%, #4A3040 100%);
}
.page-hero h1 { color: #fff; }
.page-hero p  { color: rgba(255,255,255,.75); font-size: .875rem; margin-top: 4px; }

/* ── Card ───────────────────────────────────────────────────────── */
.card {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 20px;
}
.card--flush { padding: 0; overflow: hidden; }
.card-row {
  display: flex; align-items: center; padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-row:last-child { border-bottom: none; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--radius-md); padding: 12px 22px;
  font-size: .875rem; font-weight: 700; cursor: pointer;
  transition: opacity .15s, transform .1s; white-space: nowrap;
  letter-spacing: .03em;
}
.btn:active     { transform: scale(.97); }
.btn:disabled   { opacity: .5; cursor: not-allowed; }
.btn--primary   { background: var(--rose); color: #fff; }
.btn--secondary { background: var(--rose-pale); color: var(--rose); }
.btn--ghost     { background: transparent; color: var(--rose); border: 1.5px solid var(--border); }
.btn--gold      { background: var(--gold); color: #fff; }
.btn--full      { width: 100%; }
.btn--danger    { background: var(--error); color: #fff; }

/* ── Form ───────────────────────────────────────────────────────── */
.form-group    { margin-bottom: 16px; }
.form-label    { display: block; font-size: .8rem; font-weight: 700; color: var(--text-muted);
                 text-transform: uppercase; letter-spacing: .07em; margin-bottom: 6px; }
.form-input    { width: 100%; padding: 13px 16px; border: 1.5px solid var(--border);
                 border-radius: var(--radius-md); font-size: .9375rem; background: var(--white);
                 color: var(--text); outline: none; transition: border-color .2s; }
.form-input:focus   { border-color: var(--rose); }
.form-input::placeholder { color: var(--text-muted); }

/* ── Badge ───────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; border-radius: 20px;
         padding: 3px 10px; font-size: .6875rem; font-weight: 700; letter-spacing: .04em; }
.badge--rose     { background: var(--rose-pale); color: var(--rose-deep); }
.badge--gold     { background: var(--gold-soft); color: var(--gold); }
.badge--success  { background: #E8F5E9; color: var(--success); }
.badge--muted    { background: #F0EDED; color: var(--text-muted); }
.badge--platinum { background: #E8F0F5; color: #4A7FA5; }
.badge--silver   { background: #E8E8F0; color: #6B6B9A; }
.badge--bronze   { background: #F5EDE0; color: #C9813A; }

/* ── Progress bar ───────────────────────────────────────────────── */
.progress { background: var(--rose-pale); border-radius: 99px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 99px;
                background: linear-gradient(90deg, var(--rose), var(--rose-deep));
                transition: width .6s cubic-bezier(.4,0,.2,1); }

/* ── Bottom nav ──────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: var(--white); border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; align-items: center;
  padding: 8px 0 max(16px, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 24px rgba(201,138,160,.10); z-index: 200;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--text-muted); font-size: .625rem; font-weight: 500;
  padding: 4px 12px; position: relative; border: none; background: none; cursor: pointer;
  transition: color .2s;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--rose); }
.nav-item.active::after {
  content: ''; position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  width: 30px; height: 3px; background: var(--rose); border-radius: 0 0 4px 4px;
}
.nav-badge {
  position: absolute; top: 0; right: 6px;
  background: #FF4B6A; color: #fff; border-radius: 50%;
  width: 16px; height: 16px; font-size: .5625rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.bottom-nav--admin .nav-item--scan svg { width: 26px; height: 26px; }
.bottom-nav--admin .nav-item--scan.active { color: var(--gold); }
.bottom-nav--admin .nav-item--scan.active::after { background: var(--gold); }

/* ── Flash message ───────────────────────────────────────────────── */
.flash {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; border-radius: var(--radius-md);
  padding: 12px 22px; font-size: .875rem; font-weight: 600; z-index: 999;
  box-shadow: var(--shadow-lg); white-space: nowrap; max-width: calc(100vw - 32px);
  animation: flashIn .35s ease;
}
.flash--error   { background: var(--error); }
.flash--success { background: var(--success); }
@keyframes flashIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Auth pages ──────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh; display: flex; flex-direction: column;
  background: linear-gradient(160deg, var(--rose-pale) 0%, var(--bg) 60%);
}
.auth-logo {
  text-align: center; padding: 56px 24px 32px;
  font-family: var(--font-display); font-size: 1.75rem; color: var(--rose);
}
.auth-card { margin: 0 20px 40px; padding: 28px; }

/* ── Dashboard header card ───────────────────────────────────────── */
.dash-hero {
  background: linear-gradient(135deg, var(--rose) 0%, var(--rose-deep) 100%);
  padding: 52px 22px 80px; position: relative; overflow: hidden;
}
.dash-hero::before, .dash-hero::after {
  content: ''; position: absolute; border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.dash-hero::before { top: -50px; right: -50px; width: 200px; height: 200px; }
.dash-hero::after  { top: 30px;  right: 50px;  width: 90px;  height: 90px; }

.dash-avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255,255,255,.25); display: flex; align-items: center;
  justify-content: center; font-weight: 800; font-size: 1rem; color: #fff;
}
.points-card { margin: -48px 20px 0; }
.points-value {
  font-family: var(--font-display); font-size: 2.5rem; font-weight: 900;
  color: var(--rose); line-height: 1;
}

/* ── Loyalty card (QR page) ──────────────────────────────────────── */
.loyalty-card {
  background: linear-gradient(135deg, #2D2D2D 0%, #4A3040 100%);
  border-radius: 22px; padding: 26px; color: #fff; position: relative;
  overflow: hidden; box-shadow: var(--shadow-lg);
}
.loyalty-card::before {
  content: ''; position: absolute; top: -40px; right: -40px;
  width: 160px; height: 160px; border-radius: 50%; background: rgba(255,255,255,.05);
}
.loyalty-card::after {
  content: ''; position: absolute; bottom: -25px; left: -25px;
  width: 110px; height: 110px; border-radius: 50%; background: rgba(201,138,160,.08);
}
.qr-wrap {
  background: #fff; border-radius: var(--radius-md); padding: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; position: relative; z-index: 1;
}
.qr-wrap img { width: 100%; max-width: 180px; height: auto; }
.qr-fullscreen {
  position: fixed; inset: 0; background: #fff; z-index: 999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px;
}
.qr-fullscreen img { width: min(80vw, 300px); height: auto; }

/* ── Reward grid ─────────────────────────────────────────────────── */
.reward-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.reward-card {
  background: var(--white); border-radius: var(--radius-lg); padding: 18px 14px;
  box-shadow: var(--shadow-sm); cursor: pointer; transition: transform .15s;
  border: 1.5px solid var(--border);
}
.reward-card:active     { transform: scale(.97); }
.reward-card--available { border-color: var(--rose-soft); }
.reward-emoji           { font-size: 2.25rem; text-align: center; margin-bottom: 10px; }
.reward-name            { font-weight: 800; font-size: .875rem; line-height: 1.3; margin-bottom: 4px; }
.reward-pts             { font-weight: 800; font-size: .8125rem; color: var(--rose); }

/* ── Modal (bottom sheet) ────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(45,25,35,.55);
  display: flex; align-items: flex-end; justify-content: center; z-index: 800;
  animation: fadeOverlay .25s ease;
}
.modal-sheet {
  background: var(--white); border-radius: 24px 24px 0 0; padding: 28px;
  width: 100%; max-width: 480px; animation: slideUp .3s cubic-bezier(.4,0,.2,1);
}
@keyframes fadeOverlay { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ── History list ────────────────────────────────────────────────── */
.txn-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.125rem; font-weight: 900; flex-shrink: 0;
}
.txn-icon--gain       { background: #E8F5E9; color: var(--success); }
.txn-icon--spend      { background: var(--rose-pale); color: var(--rose); }
.txn-icon--bonus      { background: var(--gold-soft); color: var(--gold); }
.txn-icon--adjustment { background: #EEF0F8; color: #6B6B9A; }
.txn-amount--pos { color: var(--success); font-weight: 800; }
.txn-amount--neg { color: var(--rose);    font-weight: 800; }

/* ── Admin scanner ────────────────────────────────────────────────── */
.scan-page { min-height: 100vh; background: #1A1020; color: #fff; }
.scan-viewport {
  position: relative; width: 100%; aspect-ratio: 1/1; max-width: 360px;
  margin: 0 auto; border-radius: var(--radius-lg); overflow: hidden;
  background: #000;
}
.scan-viewport video { width: 100%; height: 100%; object-fit: cover; }
.scan-crosshair {
  position: absolute; inset: 0; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}
.scan-crosshair::before, .scan-crosshair::after {
  content: ''; position: absolute; width: 60px; height: 60px;
  border-color: var(--rose); border-style: solid; border-width: 0;
}
.scan-crosshair::before {
  top: 20px; left: 20px;
  border-top-width: 3px; border-left-width: 3px;
  border-top-left-radius: 8px;
}
.scan-crosshair::after {
  bottom: 20px; right: 20px;
  border-bottom-width: 3px; border-right-width: 3px;
  border-bottom-right-radius: 8px;
}
.scan-line {
  position: absolute; left: 20px; right: 20px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--rose), transparent);
  animation: scanLine 2s ease-in-out infinite;
}
@keyframes scanLine {
  0%   { top: 20px;  opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { top: calc(100% - 20px); opacity: 0; }
}
.scan-result {
  margin: 16px 20px; border-radius: var(--radius-lg); padding: 20px;
  animation: fadeIn .4s ease;
}
.scan-result--valid   { background: rgba(46,158,91,.15); border: 1.5px solid rgba(46,158,91,.4); }
.scan-result--invalid { background: rgba(224,62,62,.15); border: 1.5px solid rgba(224,62,62,.4); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Category tabs ───────────────────────────────────────────────── */
.cat-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.cat-tab {
  flex-shrink: 0; border: none; border-radius: 20px; padding: 8px 16px;
  font-size: .8125rem; font-weight: 700; cursor: pointer; transition: all .2s;
  font-family: inherit;
}
.cat-tab--active   { background: var(--rose); color: #fff; }
.cat-tab--inactive { background: var(--rose-pale); color: var(--rose); }

/* ── Section title ───────────────────────────────────────────────── */
.section-title {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.section-title h2 { font-size: 1.0625rem; font-weight: 800; }
.section-link { background: none; border: none; color: var(--rose); font-size: .8125rem;
                font-weight: 700; cursor: pointer; font-family: inherit; }

/* ── Search bar ──────────────────────────────────────────────────── */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--white); border-radius: var(--radius-md);
  padding: 10px 16px; border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm); margin-bottom: 14px;
}
.search-bar svg   { flex-shrink: 0; }
.search-bar input {
  border: none; outline: none; flex: 1; font-size: .9375rem;
  font-family: inherit; background: transparent; color: var(--text);
}

/* ── Stat cards (admin) ──────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--white); border-radius: var(--radius-lg);
             box-shadow: var(--shadow-sm); padding: 18px 16px; }
.stat-icon  { font-size: 1.75rem; margin-bottom: 8px; }
.stat-value { font-size: 1.5rem; font-weight: 900; line-height: 1; }
.stat-label { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }

/* ── System health ───────────────────────────────────────────────── */
.health-row { margin-bottom: 14px; }
.health-row:last-child { margin-bottom: 0; }

/* ── Pagination ──────────────────────────────────────────────────── */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 20px; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 700;
}
.pagination a { background: var(--white); color: var(--text); box-shadow: var(--shadow-sm); }
.pagination .current { background: var(--rose); color: #fff; }

/* ── Utility ─────────────────────────────────────────────────────── */
.px-5  { padding-left: 20px; padding-right: 20px; }
.mt-4  { margin-top: 16px; }
.mt-5  { margin-top: 20px; }
.mb-4  { margin-bottom: 16px; }
.text-muted   { color: var(--text-muted); font-size: .875rem; }
.text-rose    { color: var(--rose); }
.text-success { color: var(--success); }
.text-center  { text-align: center; }
.fw-800 { font-weight: 800; }
.d-flex { display: flex; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }

/* ── Responsive desktop (tablette+) ─────────────────────────────── */
@media (min-width: 480px) {
  .app-shell { box-shadow: 0 0 60px rgba(0,0,0,.08); }
}
