/* =========================================================================
   Composants réutilisables (boutique + administration)
   Boutons, badges, cartes produits, champs, alertes, toasts, fenêtres,
   squelettes de chargement, états vides, timeline, onglets, sélecteur de quantité.
   ========================================================================= */

/* ---------- Boutons ---------- */
.btn {
  --btn-bg: var(--white); --btn-fg: var(--ink); --btn-bd: var(--line-2);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: var(--r-pill);
  background: var(--btn-bg); color: var(--btn-fg); border: 1.5px solid var(--btn-bd);
  font-weight: 700; font-size: var(--fs-md); letter-spacing: .01em; white-space: nowrap;
  transition: background .2s var(--ease), border-color .2s var(--ease), transform .15s var(--ease), box-shadow .2s var(--ease);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:hover { border-color: var(--ink); }
.btn:active { transform: scale(.98); }
.btn--primary { --btn-bg: var(--brand-500); --btn-fg: var(--deep-900); --btn-bd: var(--brand-500); box-shadow: var(--sh-brand); }
.btn--primary:hover { --btn-bg: var(--brand-600); --btn-bd: var(--brand-600); }
.btn--secondary { --btn-bg: var(--deep-900); --btn-fg: #fff; --btn-bd: var(--deep-900); }
.btn--secondary:hover { --btn-bg: var(--deep-700); --btn-bd: var(--deep-700); }
.btn--outline { --btn-bg: transparent; --btn-fg: var(--ink); --btn-bd: var(--ink); }
.btn--outline:hover { --btn-bg: var(--ink); --btn-fg: #fff; }
.btn--ghost { --btn-bg: transparent; --btn-bd: transparent; padding: 0 12px; }
.btn--ghost:hover { --btn-bg: var(--cream-2); --btn-bd: transparent; }
.btn--whatsapp { --btn-bg: var(--whatsapp); --btn-fg: #fff; --btn-bd: var(--whatsapp); }
.btn--whatsapp:hover { --btn-bg: var(--whatsapp-600); --btn-bd: var(--whatsapp-600); }
.btn--danger { --btn-bg: var(--white); --btn-fg: var(--danger); --btn-bd: #F1B9B4; }
.btn--danger:hover { --btn-bg: var(--danger); --btn-fg: #fff; --btn-bd: var(--danger); }
.btn--light { --btn-bg: #fff; --btn-fg: var(--deep-900); --btn-bd: #fff; }
.btn--sm { min-height: 38px; padding: 0 14px; font-size: var(--fs-sm); }
.btn--sm svg { width: 17px; height: 17px; }
.btn--lg { min-height: 56px; padding: 0 28px; font-size: var(--fs-lg); }
.btn--block { width: 100%; }
.btn--icon { width: 44px; min-height: 44px; padding: 0; }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; box-shadow: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid currentColor; border-color: #fff #fff transparent transparent; animation: spin .7s linear infinite;
}
.btn--outline.is-loading::after, .btn:not(.btn--primary):not(.btn--secondary):not(.btn--whatsapp).is-loading::after { border-color: var(--ink) var(--ink) transparent transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px;
  border-radius: var(--r-pill); color: var(--ink); transition: background .2s;
}
.icon-btn:hover { background: var(--cream-2); }
.icon-btn svg { width: 23px; height: 23px; }
.count-bubble {
  position: absolute; top: 3px; right: 1px; min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: var(--r-pill); background: var(--brand-500); color: var(--deep-900); border: 2px solid var(--white);
  font-size: 11px; font-weight: 800; line-height: 15px; text-align: center;
}
.count-bubble.bump { animation: bump .45s var(--ease); }
@keyframes bump { 40% { transform: scale(1.35); } }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px;
  border-radius: var(--r-pill); font-size: 11.5px; font-weight: 800; letter-spacing: .02em; white-space: nowrap;
  background: var(--cream-2); color: var(--ink-2);
}
.badge svg { width: 13px; height: 13px; }
.badge--promo { background: var(--accent-600); color: #fff; }
.badge--new { background: var(--deep-900); color: #fff; }
.badge--best { background: var(--saffron-100); color: #8A1F5C; }
.badge--stock { background: var(--success-bg); color: var(--success); }
.badge--low { background: var(--warning-bg); color: var(--warning); }
.badge--out { background: var(--danger-bg); color: var(--danger); }
.badge--demo { background: var(--white); color: var(--ink-3); border: 1px dashed var(--line-2); }
.badge--brand { background: var(--brand-50); color: var(--brand-700); }

/* Statuts de commande (texte + pastille, jamais la couleur seule) */
.status { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px; border-radius: var(--r-pill); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status--nouvelle { background: var(--brand-50); color: var(--brand-700); }
.status--confirmee { background: var(--info-bg); color: var(--info); }
.status--preparation { background: var(--saffron-50); color: #8A1F5C; }
.status--livraison { background: #E8F1FB; color: #1D5A9A; }
.status--livree { background: var(--success-bg); color: var(--success); }
.status--annulee { background: var(--danger-bg); color: var(--danger); }

/* ---------- Prix ---------- */
.price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; }
.price__now { font-weight: 800; color: var(--ink); font-size: var(--fs-lg); letter-spacing: -.01em; }
.price__old { color: var(--ink-3); text-decoration: line-through; font-size: var(--fs-sm); }
.price__save { color: var(--accent-600); font-weight: 700; font-size: var(--fs-sm); }

/* ---------- Visuel produit (photo ou illustration de démonstration) ---------- */
.pvisual { position: relative; aspect-ratio: 1 / 1; border-radius: var(--r-md); overflow: hidden; background: var(--tone, var(--cream-2)); }
.pvisual img { width: 100%; height: 100%; object-fit: cover; }
.pvisual svg.art { position: absolute; inset: 14%; width: 72%; height: 72%; transition: transform .5s var(--ease); }
.pvisual::after { /* léger halo pour donner du relief */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 80% at 30% 15%, rgba(255,255,255,.55), transparent 55%);
}

/* ---------- Carte produit ---------- */
.pcard { position: relative; display: flex; flex-direction: column; background: var(--white); border-radius: var(--r-lg); padding: 8px; border: 1px solid var(--line); transition: box-shadow .25s var(--ease), transform .25s var(--ease); }
.pcard:hover { box-shadow: var(--sh-2); transform: translateY(-2px); }
.pcard:hover .pvisual svg.art { transform: scale(1.06) rotate(-2deg); }
.pcard__badges { position: absolute; top: 16px; left: 16px; z-index: 2; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.pcard__body { display: flex; flex-direction: column; gap: 6px; padding: 12px 6px 6px; flex: 1; }
.pcard__cat { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.pcard__name { font-size: var(--fs-sm); font-weight: 600; line-height: 1.35; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.7em; }
.pcard__name::after { content: ""; position: absolute; inset: 0; } /* toute la carte est cliquable */
.pcard .price__now { font-size: var(--fs-md); }
.pcard__foot { margin-top: auto; padding-top: 8px; position: relative; z-index: 2; }
.pcard__foot .btn { width: 100%; }
@media (min-width: 768px) { .pcard { padding: 10px; } .pcard__name { font-size: var(--fs-md); } .pcard .price__now { font-size: var(--fs-lg); } }

.grid-products { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .grid-products { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 1024px) { .grid-products { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px; } .grid-products--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Défilement horizontal (mobile) */
.hscroll { display: grid; grid-auto-flow: column; grid-auto-columns: 46%; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 16px 14px; margin: 0 -16px; scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }
.hscroll > * { scroll-snap-align: start; }
@media (min-width: 640px) { .hscroll { grid-auto-columns: 31%; } }
@media (min-width: 1024px) { .hscroll { grid-auto-flow: row; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-columns: auto; overflow: visible; margin: 0; padding: 0; gap: 22px; } }

/* ---------- Sélecteur de quantité ---------- */
.qty { display: inline-flex; align-items: center; border: 1.5px solid var(--line-2); border-radius: var(--r-pill); background: var(--white); height: 48px; }
.qty button { width: 44px; height: 100%; display: grid; place-items: center; color: var(--ink); border-radius: var(--r-pill); }
.qty button:hover { background: var(--cream-2); }
.qty button:disabled { opacity: .35; pointer-events: none; }
.qty button svg { width: 18px; height: 18px; }
.qty input { width: 38px; text-align: center; border: 0; background: transparent; font-weight: 800; -moz-appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; }
.qty--sm { height: 38px; } .qty--sm button { width: 36px; } .qty--sm input { width: 30px; font-size: var(--fs-sm); }

/* ---------- Champs de formulaire ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }
.field .req { color: var(--accent-600); }
.input, .select, .textarea {
  width: 100%; min-height: 50px; padding: 12px 15px; border-radius: var(--r-md);
  border: 1.5px solid var(--line-2); background: var(--white); color: var(--ink); font-size: 16px; /* 16px : évite le zoom iOS */
  transition: border-color .2s, box-shadow .2s;
}
.textarea { min-height: 96px; resize: vertical; }
.select { appearance: none; padding-right: 42px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2315174A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; background-size: 18px; }
.input::placeholder, .textarea::placeholder { color: #9A9CB4; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--focus); }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--danger); background: #FFFBFA; }
.field__hint { font-size: var(--fs-xs); color: var(--ink-3); }
.field__error { display: none; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--danger); }
.field__error svg { width: 14px; height: 14px; flex: none; }
.field.has-error .field__error { display: flex; }
.input-group { position: relative; }
.input-group .prefix { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); font-weight: 700; color: var(--ink-2); pointer-events: none; }
.input-group .input { padding-left: 62px; }
.form-grid { display: grid; gap: 16px; }
@media (min-width: 640px) { .form-grid--2 { grid-template-columns: 1fr 1fr; } .form-grid .span-2 { grid-column: span 2; } }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: var(--fs-sm); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--brand-500); margin: 1px 0 0; flex: none; }

/* Puces de filtre */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 15px; border-radius: var(--r-pill); border: 1.5px solid var(--line-2); background: var(--white); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; transition: all .2s; }
.chip:hover { border-color: var(--ink); }
.chip.is-active { background: var(--deep-900); border-color: var(--deep-900); color: #fff; }
.chip svg { width: 15px; height: 15px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }

/* ---------- Cartes génériques ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; }
@media (min-width: 768px) { .card { padding: 28px; } }
.card__title { font-size: var(--fs-lg); font-weight: 800; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.card__title svg { width: 22px; height: 22px; color: var(--brand-500); }

/* ---------- Alertes ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-md); font-size: var(--fs-sm); line-height: 1.5; border: 1px solid transparent; }
.alert svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert strong { display: block; margin-bottom: 2px; }
.alert--info { background: var(--info-bg); color: var(--info); }
.alert--success { background: var(--success-bg); color: var(--success); }
.alert--warning { background: var(--warning-bg); color: var(--warning); border-color: #F3DDA8; }
.alert--error { background: var(--danger-bg); color: var(--danger); }
.alert--cod { background: var(--saffron-50); color: var(--ink); border-color: var(--saffron-100); }
.alert--cod svg { color: var(--saffron-500); }

/* ---------- Toasts (notifications) ---------- */
.toasts { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); top: 14px; width: min(440px, calc(100% - 24px)); display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; border-radius: var(--r-md); background: var(--deep-900); color: #fff; box-shadow: var(--sh-3); font-size: var(--fs-sm); font-weight: 600; animation: toastIn .35s var(--ease); }
.toast.is-leaving { animation: toastOut .25s var(--ease) forwards; }
.toast > svg { width: 22px; height: 22px; flex: none; }
.toast--success > svg { color: #6BE3A4; }
.toast--error { background: var(--danger); }
.toast--warning > svg { color: #FFC857; }
.toast__msg { flex: 1; }
.toast__action { color: var(--brand-100); font-weight: 800; padding: 8px 10px; border-radius: var(--r-sm); white-space: nowrap; }
.toast__action:hover { background: rgba(255,255,255,.1); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px) scale(.98); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* ---------- Fenêtres modales & panneaux ---------- */
.overlay { position: fixed; inset: 0; z-index: 80; background: rgba(46, 26, 71, .45); backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
@media (min-width: 640px) { .overlay { align-items: center; padding: 24px; } }
.modal { width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; background: var(--white); border-radius: var(--r-xl) var(--r-xl) 0 0; padding: 26px 20px 22px; box-shadow: var(--sh-3); animation: sheetUp .3s var(--ease); }
@media (min-width: 640px) { .modal { border-radius: var(--r-xl); padding: 30px; } }
.modal--wide { max-width: 760px; }
.modal__icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 14px; background: var(--brand-50); color: var(--brand-600); }
.modal__icon svg { width: 28px; height: 28px; }
.modal__icon--danger { background: var(--danger-bg); color: var(--danger); }
.modal h3 { font-size: var(--fs-xl); margin-bottom: 8px; }
.modal__text { color: var(--ink-2); }
.modal__actions { display: flex; gap: 10px; margin-top: 24px; flex-direction: column-reverse; }
@media (min-width: 480px) { .modal__actions { flex-direction: row; justify-content: flex-end; } }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.modal__head h3 { margin: 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }

.drawer { position: fixed; inset: 0 auto 0 0; z-index: 85; width: min(340px, 86vw); background: var(--white); box-shadow: var(--sh-3); display: flex; flex-direction: column; animation: drawerIn .3s var(--ease); }
@keyframes drawerIn { from { transform: translateX(-100%); } }
.sheet { position: fixed; inset: auto 0 0 0; z-index: 85; max-height: 86vh; background: var(--white); border-radius: var(--r-xl) var(--r-xl) 0 0; display: flex; flex-direction: column; animation: sheetUp .3s var(--ease); }

/* ---------- Squelettes de chargement ---------- */
.skeleton { position: relative; overflow: hidden; background: var(--cream-2); border-radius: var(--r-sm); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px; }
.sk-card .sk-img { aspect-ratio: 1; border-radius: var(--r-md); }
.sk-line { height: 12px; margin-top: 12px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--brand-100); border-top-color: var(--brand-500); animation: spin .8s linear infinite; }

/* ---------- États vides & erreurs ---------- */
.empty { text-align: center; padding: 48px 20px; max-width: 460px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty__art { width: 132px; height: 132px; border-radius: 50%; background: var(--brand-50); display: grid; place-items: center; margin-bottom: 8px; position: relative; }
.empty__art svg { width: 58px; height: 58px; color: var(--brand-600); }
.empty__art::before { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 1.5px dashed var(--saffron-500); opacity: .6; }
.empty h2, .empty h3 { font-size: var(--fs-2xl); }
.empty p { color: var(--ink-2); }
.empty--error .empty__art { background: var(--danger-bg); }
.empty--error .empty__art svg { color: var(--danger); }

/* ---------- Timeline de suivi ---------- */
.timeline { position: relative; display: flex; flex-direction: column; gap: 0; }
.tl-step { position: relative; display: grid; grid-template-columns: 44px 1fr; gap: 14px; padding-bottom: 26px; }
.tl-step:last-child { padding-bottom: 0; }
.tl-step::before { content: ""; position: absolute; left: 21px; top: 44px; bottom: 0; width: 2px; background: var(--line-2); }
.tl-step:last-child::before { display: none; }
.tl-step.is-done::before { background: var(--brand-500); }
.tl-dot { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--white); border: 2px solid var(--line-2); color: var(--ink-3); position: relative; z-index: 1; }
.tl-dot svg { width: 20px; height: 20px; }
.tl-step.is-done .tl-dot { background: var(--brand-500); border-color: var(--brand-500); color: var(--deep-900); }
.tl-step.is-current .tl-dot { background: var(--white); border-color: var(--brand-500); color: var(--brand-600); box-shadow: 0 0 0 6px var(--brand-50); }
.tl-step.is-current .tl-dot::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 2px solid var(--brand-500); opacity: 0; animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { transform: scale(.8); opacity: .6; } 100% { transform: scale(1.25); opacity: 0; } }
.tl-body { padding-top: 9px; }
.tl-body strong { display: block; font-size: var(--fs-md); }
.tl-body span { font-size: var(--fs-sm); color: var(--ink-3); }
.tl-step.is-todo strong { color: var(--ink-3); font-weight: 600; }
@media (min-width: 900px) { /* timeline horizontale sur grand écran */
  .timeline--h { flex-direction: row; }
  .timeline--h .tl-step { flex: 1; grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 0 6px; gap: 10px; }
  .timeline--h .tl-step::before { left: calc(50% + 22px); right: calc(-50% + 22px); top: 21px; bottom: auto; width: auto; height: 2px; }
  .timeline--h .tl-body { padding-top: 0; }
}

/* ---------- Onglets ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1.5px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab { padding: 14px 4px; margin-right: 18px; font-weight: 700; color: var(--ink-3); border-bottom: 2.5px solid transparent; margin-bottom: -1.5px; white-space: nowrap; }
.tab.is-active { color: var(--ink); border-color: var(--brand-500); }
.tab-panel { padding-top: 20px; }

/* ---------- Fil d'Ariane ---------- */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--ink-3); padding: 18px 0 8px; }
.crumbs a:hover { color: var(--brand-700); }
.crumbs svg { width: 14px; height: 14px; }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }

/* ---------- Divers ---------- */
.divider { height: 1px; background: var(--line); margin: 18px 0; border: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: var(--fs-sm); }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.summary-line { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: var(--fs-sm); color: var(--ink-2); }
.summary-line strong { color: var(--ink); }
.summary-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 14px; margin-top: 8px; border-top: 1.5px dashed var(--line-2); font-weight: 800; font-size: var(--fs-lg); }
.summary-total span:last-child { font-size: var(--fs-xl); }
.progress { height: 8px; border-radius: var(--r-pill); background: var(--cream-2); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--grad-brand); transition: width .5s var(--ease); }

/* Piège à robots : hors de l'écran, jamais visible ni annoncé */
.hp { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
