/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  --navy:       #1B2F6E;
  --gold:       #E8A020;
  --cream:      #F8F6F2;
  --beige:      #F5ECD7;
  --white:      #FFFFFF;
  --text:       #2C2C2C;
  --text-light: #6B6B6B;
  --border:     #E2D9C8;
  --success:    #2E7D32;
  --error:      #C62828;
  --danger:     #C62828;
  --muted:      #6B6B6B;
  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 2px 12px rgba(27,47,110,0.10);
  --shadow-lg:  0 8px 32px rgba(27,47,110,0.15);
  --font-title: 'Cormorant Garamond', Georgia, serif;
  --font-body:  'Inter', system-ui, sans-serif;
  /* legacy aliases */
  --r:    12px;
  --r-sm: 8px;
  --sh:   0 2px 12px rgba(27,47,110,0.10);
  --sh-lg:0 8px 32px rgba(27,47,110,0.15);
  --ff-title: 'Cormorant Garamond', Georgia, serif;
  --ff-body:  'Inter', system-ui, sans-serif;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
body {
  font-family: var(--font-body); background: var(--cream); color: var(--text);
  font-size: 16px; line-height: 1.5; min-height: 100vh; overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 16px; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* ── Typography ──────────────────────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--font-title); color: var(--navy); line-height: 1.2; }
h1 { font-size: clamp(1.8rem, 5vw, 2.2rem); }
h2 { font-size: clamp(1.4rem, 4vw, 1.6rem); }
h3 { font-size: 1.2rem; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.page { max-width: 960px; margin: 0 auto; padding: 0 1rem 5rem; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.header {
  background: var(--navy); color: var(--white);
  padding: 0 1rem; height: 56px;
  display: flex; align-items: center; gap: .75rem;
  position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow);
}
.header__logo {
  font-family: var(--font-title); font-size: 1.3rem;
  color: var(--gold); flex: 1; letter-spacing: .02em;
}
.header__user { font-size: .85rem; opacity: .85; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 48px; padding: .6rem 1.25rem; border-radius: var(--radius-sm);
  font-size: 1rem; font-weight: 500; transition: filter .15s, opacity .15s, transform .1s;
  -webkit-user-select: none; user-select: none; cursor: pointer;
  border: none;
}
.btn:active { filter: brightness(.9); transform: scale(.98); }
.btn:disabled { opacity: .45; pointer-events: none; }

.btn-primary, .btn-navy { background: var(--navy); color: var(--white); }
.btn-gold               { background: var(--gold); color: var(--white); font-weight: 700; }
.btn-outline            { background: transparent; color: var(--navy); border: 2px solid var(--navy); }
.btn-ghost              { background: transparent; color: var(--text-light); }
.btn-danger             { background: var(--error); color: var(--white); }
.btn-full               { width: 100%; }
.btn-lg                 { min-height: 56px; font-size: 1.05rem; padding: .8rem 1.5rem; }
.btn-sm                 { min-height: 36px; padding: .3rem .75rem; font-size: .85rem; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.card-beige { background: var(--beige); box-shadow: none; }

/* ── Form inputs ─────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group label { font-size: .875rem; color: var(--text-light); font-weight: 500; }

.input {
  width: 100%; height: 48px; padding: 0 .875rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 16px; background: var(--white); color: var(--text);
  transition: border-color .15s; outline: none;
  -webkit-appearance: none; appearance: none;
}
.input:focus { border-color: var(--navy); }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6B6B' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .75rem center;
  padding-right: 2.5rem;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(140%);
  padding: .75rem 1.5rem; border-radius: 24px; color: var(--white);
  font-weight: 500; font-size: .9rem; z-index: 200;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
  white-space: nowrap; box-shadow: var(--shadow-lg); pointer-events: none;
}
.toast--show    { transform: translateX(-50%) translateY(0); }
.toast--success { background: var(--success); }
.toast--error   { background: var(--error); }
.toast--info    { background: var(--navy); }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-hero {
  background: var(--navy); min-height: 30vh;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 2.5rem 1rem 3rem;
}
.login-logo-icon {
  width: 64px; height: 64px; background: rgba(255,255,255,.12);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  margin-bottom: 1rem; color: var(--gold);
}
.login-title {
  font-family: var(--font-title); font-size: 2.2rem; color: var(--white);
  letter-spacing: .03em; text-align: center; line-height: 1.1;
}
.login-sub { font-size: .85rem; color: rgba(255,255,255,.65); margin-top: .35rem; text-align: center; }
.login-body { padding: 1.5rem 1rem 5rem; max-width: 480px; margin: 0 auto; width: 100%; }
.login-who { font-family: var(--font-title); font-size: 1.1rem; color: var(--text-light);
             text-align: center; margin-bottom: 1.25rem; }

/* ── Operator grid ───────────────────────────────────────────────────────── */
.op-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: .875rem;
}
.op-card {
  background: var(--white); border-radius: 16px; padding: 1.5rem 1rem 1.25rem;
  text-align: center; cursor: pointer; box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s, border-color .15s;
  border: 2px solid transparent;
}
.op-card:active { transform: scale(.96); border-color: var(--gold); }
.op-card__initials {
  font-family: var(--font-title); font-size: 2.4rem; font-weight: 600;
  color: var(--navy); line-height: 1; margin-bottom: .5rem;
}
.op-card__name { font-size: 1rem; font-weight: 600; color: var(--text); }
.op-card__role { font-size: .75rem; color: var(--text-light); margin-top: .2rem; }
/* keep legacy .op-card__icon for backward compat */
.op-card__icon { font-size: 2rem; line-height: 1; }

/* ── PIN overlay ─────────────────────────────────────────────────────────── */
.pin-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100; padding: 0;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.pin-box {
  background: var(--white); border-radius: 24px 24px 0 0;
  padding: 1.75rem 1.5rem 2rem; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .3s cubic-bezier(.34,1.4,.64,1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.pin-title {
  font-family: var(--font-title); font-size: 1.5rem; text-align: center;
  color: var(--navy); margin-bottom: 1.5rem;
}
.pin-dots {
  display: flex; justify-content: center; gap: 1rem; margin-bottom: 1.5rem;
}
.pin-dot {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border); transition: background .15s, border-color .15s, transform .1s;
}
.pin-dot--filled {
  background: var(--gold); border-color: var(--gold); transform: scale(1.1);
}
.pin-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-bottom: .5rem;
}
.pin-key {
  height: 72px; border-radius: 50%; font-size: 1.5rem; font-weight: 600;
  background: var(--cream); color: var(--navy); transition: background .1s, transform .1s;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(27,47,110,.08);
}
.pin-key:active { background: var(--beige); transform: scale(.93); }
.pin-key--back  { background: var(--beige); color: var(--text-light); font-size: 1rem; }
.pin-key--clear { background: #FDECEA; color: var(--error); }
.pin-key--ok    { background: var(--navy); color: var(--white); }
.pin-error {
  color: var(--error); text-align: center; font-size: .875rem;
  margin-top: .75rem; min-height: 1.2em;
}

/* ── Index dashboard ─────────────────────────────────────────────────────── */
.ca-card {
  background: linear-gradient(135deg, var(--navy) 0%, #2a4494 100%);
  color: var(--white); border-radius: var(--radius); padding: 1.5rem;
  box-shadow: var(--shadow-lg); margin-bottom: 1.25rem;
}
.ca-card__label { font-size: .85rem; opacity: .75; margin-bottom: .4rem; }
.ca-card__amount {
  font-family: var(--font-title); font-size: 3rem; font-weight: 700; line-height: 1;
}
.ca-card__sub { font-size: .82rem; opacity: .7; margin-top: .4rem; }
.ca-card__badge {
  display: inline-block; background: var(--gold); color: var(--white);
  border-radius: 20px; padding: .2rem .7rem; font-size: .78rem;
  font-weight: 700; margin-top: .6rem;
}

.nav-list { display: flex; flex-direction: column; gap: .625rem; margin-top: 1.25rem; }
.nav-btn {
  background: var(--white); border-radius: var(--radius); padding: 0 1.25rem;
  height: 64px; box-shadow: var(--shadow); cursor: pointer;
  transition: box-shadow .15s, transform .1s;
  display: flex; align-items: center; gap: 1rem;
  color: var(--navy); font-weight: 600; font-size: 1rem; border: none;
  width: 100%; position: relative;
}
.nav-btn:active { transform: scale(.99); box-shadow: none; }
.nav-btn__icon { color: var(--gold); flex-shrink: 0; }
.nav-btn__label { flex: 1; text-align: left; }
.nav-btn__chevron { color: var(--border); flex-shrink: 0; }
.nav-btn__badge {
  position: absolute; top: 12px; left: 38px;
  width: 10px; height: 10px; background: var(--error);
  border-radius: 50%; border: 2px solid var(--white);
  display: none;
}

.footer-logout {
  text-align: center; padding: 2rem 0 1rem;
  color: var(--text-light); font-size: .9rem; cursor: pointer; background: none; border: none;
  width: 100%;
}

/* ── Caisse ──────────────────────────────────────────────────────────────── */
.caisse-header-total {
  font-family: var(--font-title); font-size: 1.2rem; color: var(--gold); font-weight: 700;
}
.tab-switcher {
  display: flex; background: var(--beige); border-radius: 10px; padding: 3px; margin: 1rem 0 .75rem;
}
.tab-sw-btn {
  flex: 1; height: 40px; border-radius: 8px; font-size: .9rem; font-weight: 600;
  color: var(--text-light); transition: background .15s, color .15s, box-shadow .15s;
  border: none; background: none; cursor: pointer;
}
.tab-sw-btn.active { background: var(--white); color: var(--navy); box-shadow: var(--shadow); }
.tab-panel-caisse { display: none; }
.tab-panel-caisse.active { display: block; }

/* ── Filter chips ────────────────────────────────────────────────────────── */
.filter-tabs {
  display: flex; gap: .5rem; overflow-x: auto; padding: 0 0 .5rem;
  scrollbar-width: none; -ms-overflow-style: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
  flex-shrink: 0; padding: .45rem 1.1rem; border-radius: 999px; font-size: .875rem;
  font-weight: 500; border: 1.5px solid var(--border); background: var(--white);
  color: var(--text-light); cursor: pointer; transition: all .15s; white-space: nowrap;
}
.filter-tab--active { background: var(--navy); border-color: var(--navy); color: var(--white); }

/* ── Catalogue prestations ───────────────────────────────────────────────── */
.cat-title {
  font-family: var(--font-title); font-size: 1.05rem; color: var(--navy);
  padding: .75rem 0 .4rem; border-bottom: 2px solid var(--beige); margin-bottom: .5rem;
}
.presta-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: .625rem;
  margin-bottom: .75rem;
}
.presta-card {
  background: var(--white); border-radius: var(--radius-sm); padding: .875rem;
  box-shadow: var(--shadow); cursor: pointer; transition: transform .1s, box-shadow .1s;
  border: 2px solid transparent; -webkit-tap-highlight-color: transparent;
}
.presta-card:active { transform: scale(.96); border-color: var(--gold); box-shadow: none; }
.presta-card__name  { font-weight: 600; font-size: .875rem; color: var(--navy); line-height: 1.3; }
.presta-card__type  { font-size: .72rem; color: var(--text-light); margin: .2rem 0 .4rem; }
.presta-card__price { font-family: var(--font-title); font-size: 1.15rem; color: var(--gold); font-weight: 700; }

/* ── Panier ──────────────────────────────────────────────────────────────── */
.cart-empty { text-align: center; color: var(--text-light); padding: 2rem 1rem; font-size: .9rem; }
.cart-item {
  display: flex; align-items: center; gap: .625rem;
  padding: .75rem 0; border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: none; }
.cart-item__name  { flex: 1; font-weight: 500; font-size: .875rem; color: var(--text); }
.cart-item__price { font-family: var(--font-title); font-size: 1.05rem; color: var(--navy); white-space: nowrap; }
.cart-item__select {
  font-size: .8rem; padding: .3rem .5rem; min-height: 32px;
  border: 1.5px solid var(--border); border-radius: 6px;
  background: var(--cream); width: 100%; margin-top: .25rem;
}
.cart-total {
  display: flex; justify-content: space-between; align-items: center;
  padding: .875rem 0 .5rem; font-weight: 700;
}
.cart-total__amount { font-family: var(--font-title); font-size: 1.6rem; color: var(--navy); }

/* ── Payment mode buttons ────────────────────────────────────────────────── */
.pay-mode-group { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.pay-mode-btn {
  flex: 1; min-width: 80px; min-height: 44px; border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 600; border: 2px solid var(--border);
  background: var(--white); color: var(--text-light); cursor: pointer;
  transition: all .15s;
}
.pay-mode-btn.active { border-color: var(--navy); background: var(--navy); color: var(--white); }

/* ── Sticky validate button ──────────────────────────────────────────────── */
.cart-sticky {
  position: sticky; bottom: 0; background: var(--cream);
  padding: .75rem 0 1rem; z-index: 10;
}

/* ── Stock cards ─────────────────────────────────────────────────────────── */
.stock-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: .75rem;
}
.stock-card {
  background: var(--white); border-radius: var(--radius); padding: 1rem;
  box-shadow: var(--shadow); position: relative;
}
.stock-card__marque { font-size: .72rem; color: var(--text-light); text-transform: uppercase;
                      letter-spacing: .05em; margin-bottom: .1rem; }
.stock-card__nom    { font-weight: 600; font-size: .9rem; color: var(--navy); margin-bottom: .5rem; }
.stock-card__qty    { font-family: var(--font-title); font-size: 2.2rem; font-weight: 700;
                      color: var(--navy); line-height: 1; }
.stock-card__seuil  { font-size: .72rem; color: var(--text-light); margin-top: .1rem; }
.stock-card--alerte .stock-card__qty  { color: var(--error); }
.stock-card__alert-dot {
  position: absolute; top: 10px; right: 10px;
  width: 10px; height: 10px; background: var(--error); border-radius: 50%;
}
.stock-card__actions { margin-top: .75rem; display: flex; gap: .4rem; flex-wrap: wrap; }

/* ── Bottom sheet modal ──────────────────────────────────────────────────── */
.bottom-sheet-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
}
.bottom-sheet-overlay.hidden { display: none; }
.bottom-sheet {
  background: var(--white); border-radius: 24px 24px 0 0;
  padding: 1.5rem 1.5rem 2.5rem; width: 100%; max-width: 480px;
  animation: slideUp .28s cubic-bezier(.34,1.4,.64,1);
}
.bottom-sheet__handle {
  width: 40px; height: 4px; background: var(--border); border-radius: 2px;
  margin: 0 auto 1.25rem;
}
.bottom-sheet h3 { margin-bottom: 1rem; }

/* ── Client list ─────────────────────────────────────────────────────────── */
.cl-row {
  display: flex; align-items: center; gap: .75rem; padding: 1rem .75rem;
  border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s;
}
.cl-row:last-child { border-bottom: none; }
.cl-row:active { background: var(--beige); }
.cl-avatar {
  width: 42px; height: 42px; border-radius: 50%; background: var(--beige);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-title); font-size: 1.2rem; color: var(--navy); flex-shrink: 0;
}
.cl-carte { font-size: .72rem; color: var(--gold); font-weight: 600; letter-spacing: .02em; }
.cl-stats { margin-left: auto; text-align: right; flex-shrink: 0; }
.cl-montant { font-family: var(--font-title); font-size: 1.05rem; color: var(--navy); }
.cl-visites { font-size: .72rem; color: var(--text-light); }

/* ── FAB ─────────────────────────────────────────────────────────────────── */
.fab {
  position: fixed; bottom: 24px; right: 20px; z-index: 40;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--navy); color: var(--white); box-shadow: var(--shadow-lg);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, box-shadow .15s;
}
.fab:active { transform: scale(.93); }

/* ── Fiche cliente ───────────────────────────────────────────────────────── */
.fiche-carte {
  background: linear-gradient(135deg, var(--navy), #2a4494);
  color: var(--white); border-radius: var(--radius);
  padding: 1.25rem 1.5rem; display: flex; align-items: center;
  gap: 1rem; margin-bottom: 1rem; cursor: pointer;
}
.fiche-carte__code {
  font-family: monospace; font-size: 1.2rem; color: var(--gold);
  font-weight: 700; letter-spacing: .04em;
}
.fiche-carte__copy { color: rgba(255,255,255,.5); font-size: .75rem; margin-top: .2rem; }
.stats-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .75rem; margin-bottom: 1rem; }
@media (max-width: 400px) { .stats-row { grid-template-columns: 1fr 1fr; } }
.stat-card {
  background: var(--beige); border-radius: var(--radius); padding: 1rem;
}
.stat-card__label { font-size: .78rem; color: var(--text-light); font-weight: 500; }
.stat-card__value { font-family: var(--font-title); font-size: 1.5rem; color: var(--navy); line-height: 1.1; }
.stat-card__sub   { font-size: .75rem; color: var(--text-light); margin-top: .25rem; }
.vente-row { padding: .875rem 0; border-bottom: 1px solid var(--border); }
.vente-row:last-child { border-bottom: none; }
.vente-prestations { font-size: .8rem; color: var(--text-light); margin-top: .2rem; }

/* ── Legacy aliases (used by generated HTML in JS) ───────────────────────── */
.badge-alerte {
  display: inline-block; background: #FDECEA; color: var(--error);
  font-size: .75rem; font-weight: 700; border-radius: 6px; padding: .2rem .5rem;
}
.badge-ok {
  display: inline-block; background: #EDF7ED; color: var(--success);
  font-size: .75rem; font-weight: 700; border-radius: 6px; padding: .2rem .5rem;
}
.stock-table { width: 100%; border-collapse: collapse; }
.stock-table th { text-align: left; font-size: .8rem; color: var(--text-light); font-weight: 600;
                  padding: .5rem .75rem; background: var(--navy); color: var(--white); }
.stock-table td { padding: .75rem; border-bottom: 1px solid var(--border); font-size: .9rem; vertical-align: middle; }
.stock-table tr:last-child td { border-bottom: none; }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ── Section title ───────────────────────────────────────────────────────── */
.section-title { font-family: var(--font-title); font-size: 1.1rem; color: var(--text-light);
                 text-align: center; margin-bottom: .5rem; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (min-width: 480px) {
  .op-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 640px) {
  .presta-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .stock-grid  { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
@media (min-width: 768px) {
  .caisse-layout { display: flex; flex-direction: row; align-items: start; gap: 1.5rem; }
  .caisse-layout > div:first-child { flex: 1; min-width: 0; }
  .caisse-layout > div:last-child { width: 380px; flex-shrink: 0; }
  .tab-switcher { display: none; }
  .tab-panel-caisse { display: block !important; }
  .cart-sticky { position: relative; padding: 0; }
}
