/* =========================================================================
   base.css — reset, typographie, primitives UI partagées front + admin + setup
   Chaque composant porte en commentaire son identifiant manifeste proposé.
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; min-width: 0; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0; background: var(--background); color: var(--text-primary);
  font: 400 var(--fs-md)/1.6 var(--font-body); overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Typographie */
h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); font-weight: 300; line-height: 1.12; margin: 0 0 var(--sp-3); text-wrap: balance; letter-spacing: -.015em; }
h4, h5, h6 { font-weight: 500; letter-spacing: 0; }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--sp-4); }
small, .small { font-size: var(--fs-sm); }
.muted { color: var(--text-muted); }
.lead { font-size: var(--fs-lg); color: var(--text-secondary); max-width: 60ch; }
.price, .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
code { font-family: ui-monospace, Menlo, monospace; font-size: .92em; background: var(--surface-alt); padding: 1px 6px; border-radius: 6px; overflow-wrap: anywhere; }

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: max(4vw, 16px); }
.band { padding-block: clamp(40px, 6vw, 88px); }
.stack-sm > * + * { margin-top: var(--sp-2); }
.gx-row { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.gx-row-between { display: flex; gap: var(--sp-3); align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* UI-BUTTON-001 — boutons */
.btn {
  --b-bg: color-mix(in srgb, #fff 45%, transparent); --b-fg: var(--primary); --b-bd: color-mix(in srgb, var(--primary) 30%, transparent);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px; border-radius: var(--radius-sm);
  background: var(--b-bg); color: var(--b-fg); border: 1.5px solid var(--b-bd);
  font-weight: 500; font-size: 15px; text-decoration: none; cursor: pointer; white-space: nowrap; box-shadow: var(--glass-hi);
  transition: background var(--dur) var(--ease), border-color var(--dur), transform var(--dur), box-shadow var(--dur);
}
.btn:hover { color: var(--b-fg); border-color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn-primary { --b-bg: var(--primary); --b-fg: var(--text-on-primary); --b-bd: var(--primary); box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 10px 20px -14px var(--primary-hover); }
.btn-primary:hover { --b-bg: var(--primary-hover); border-color: var(--primary-hover); }
.btn-frost { --b-bg: var(--frost); --b-fg: #fff; --b-bd: var(--frost); }
.btn-frost:hover { --b-bg: #3c6573; border-color: #3c6573; }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; box-shadow: none; }
.btn-ghost:hover { --b-bg: var(--surface-alt); border-color: transparent; }
.btn-danger { --b-bg: var(--surface); --b-fg: var(--danger); --b-bd: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn-lg { min-height: 54px; padding: 0 28px; font-size: 16.5px; }
.btn-block { width: 100%; }
.btn-icon { width: 44px; padding: 0; }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
/* UI-LOADER-BUTTON-001 */
.btn.is-loading { pointer-events: none; color: transparent !important; position: relative; }
.btn.is-loading::after { content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--b-fg); border-inline-end-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* UI-ICON-001 — icônes SVG inline (en production : Font Awesome 6, charte §41) */
.ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic-sm { width: 16px; height: 16px; }
[dir="rtl"] .ic-flip { transform: scaleX(-1); }

/* UI-BADGE-001 — badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 500; line-height: 1.5; white-space: nowrap; background: var(--surface-alt); color: var(--text-secondary); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info, .badge-frost { background: var(--frost-soft); color: var(--frost); }
.badge-pistache { background: var(--secondary-soft); color: var(--secondary); }
.badge-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* UI-CHIP-001 — chips / options */
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--radius-pill); border: 1px solid var(--hair); background: color-mix(in srgb, #fff 55%, transparent); font-size: 14.5px; font-weight: 500; color: var(--text-secondary); cursor: pointer; transition: all var(--dur) var(--ease); white-space: nowrap; }
.chip:hover { border-color: var(--primary); }
.chip[aria-pressed="true"], .chip.is-selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip[aria-disabled="true"] { opacity: .45; cursor: not-allowed; text-decoration: line-through; }
.chip .x { margin-inline-start: 2px; opacity: .7; }

/* UI-CARD-001 */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.glass { background: var(--glass); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border: 1px solid var(--glass-edge); box-shadow: var(--glass-hi), var(--shadow-md); border-radius: var(--radius-lg); }
.card-pad { padding: var(--sp-5); }

/* UI-ALERT-001 */
.alert { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-md); background: var(--info-soft); color: #1f4c5c; font-size: 14.5px; border: 1px solid color-mix(in srgb, currentColor 18%, transparent); }
.alert .ic { margin-top: 2px; }
.alert strong { display: block; }
.alert-warning { background: var(--warning-soft); color: #6d4306; }
.alert-danger { background: var(--danger-soft); color: #7d1420; }
.alert-success { background: var(--success-soft); color: #1d5233; }

/* UI-FORM-001 — champs */
.field { display: grid; gap: 6px; margin-bottom: var(--sp-4); align-content: start; }
.field > label, .label { font-weight: 500; font-size: 14.5px; color: var(--text-primary); }
.req { color: var(--danger); margin-inline-start: 2px; }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; font-size: 16px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.textarea { min-height: 104px; resize: vertical; line-height: 1.5; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a1f43' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-inline-end: 40px; }
[dir="rtl"] .select { background-position: left 14px center; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 14%, transparent); }
.input:disabled, .select:disabled { background: var(--surface-alt); color: var(--text-muted); }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--danger); background: #fffafa; }
.field-error { display: none; color: var(--danger); font-size: 13.5px; font-weight: 550; }
.field.has-error .field-error { display: flex; gap: 6px; align-items: center; }
.field-help { color: var(--text-muted); font-size: 13.5px; }
.counter { font-size: 13px; color: var(--text-muted); text-align: end; font-variant-numeric: tabular-nums; }
.counter.is-over { color: var(--danger); font-weight: 650; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--sp-4); }
@media (max-width: 600px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* UI-SWITCH-001 */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14.5px; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 44px; height: 26px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background var(--dur); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur) var(--ease); }
.switch input:checked + .track { background: var(--success); }
.switch input:checked + .track::after { transform: translateX(18px); }
[dir="rtl"] .switch input:checked + .track::after { transform: translateX(-18px); }
.switch input:focus-visible + .track { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }
.switch.is-loading .track { opacity: .55; }

/* UI-RADIOCARD-001 — choix en carte */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.choice { position: relative; display: grid; gap: 2px; padding: 14px; border-radius: var(--radius-md); border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; transition: all var(--dur) var(--ease); }
.choice:hover { border-color: var(--primary); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .t { font-weight: 600; font-size: 15px; }
.choice .s { font-size: 13px; color: var(--text-muted); }
.choice .p { font-size: 13px; color: var(--primary); font-weight: 650; }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.choice:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }
.choice:has(input:disabled) { opacity: .45; cursor: not-allowed; background: var(--surface-alt); }
.choice .why { font-size: 12px; color: var(--danger); }

/* UI-SWATCH-001 — couleurs du décor */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1.5px var(--border-strong); cursor: pointer; position: relative; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2.5px var(--primary); }
.swatch[aria-pressed="true"]::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 800; text-shadow: 0 1px 2px rgba(0,0,0,.5); }

/* UI-QTY-001 */
.qty { display: inline-flex; align-items: center; border: 1.5px solid var(--border-strong); border-radius: var(--radius-pill); background: var(--surface); }
.qty button { width: 40px; height: 40px; border: 0; background: none; cursor: pointer; font-size: 18px; border-radius: 50%; }
.qty button:hover { background: var(--surface-alt); }
.qty output { min-width: 28px; text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }

/* UI-STEPPER-001 — wizard */
.stepper { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 var(--sp-5); counter-reset: st; overflow-x: auto; scrollbar-width: none; }
.stepper li { flex: 1 0 auto; counter-increment: st; }
.stepper button { width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 8px; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--text-muted); font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.stepper button::before { content: counter(st); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1.5px solid var(--border-strong); font-size: 13px; flex: none; }
.stepper .is-current button { background: var(--primary-soft); color: var(--primary); }
.stepper .is-current button::before { background: var(--primary); border-color: var(--primary); color: #fff; }
.stepper .is-done button { color: var(--text-secondary); }
.stepper .is-done button::before { content: "✓"; background: var(--secondary-soft); border-color: var(--secondary); color: var(--secondary); }
.stepper .has-error button::before { content: "!"; background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.stepper.compact { flex-wrap: wrap; overflow: visible; }
.stepper.compact li { flex: 0 0 auto; }
.stepper.compact li.is-current { flex: 1 0 auto; }
.stepper.compact li:not(.is-current) .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.stepper.compact li:not(.is-current) button { padding-inline-end: 8px; }
.progress { height: 6px; border-radius: 99px; background: var(--surface-alt); overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: inherit; transition: width .3s var(--ease); }

/* UI-SKELETON-001 */
.skeleton { background: linear-gradient(90deg, var(--surface-alt) 0%, #fff 50%, var(--surface-alt) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; border-radius: var(--radius-md); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* UI-EMPTY-STATE-001 */
.empty { text-align: center; padding: var(--sp-7) var(--sp-4); display: grid; justify-items: center; gap: 8px; }
.empty .empty-art { width: 120px; height: 96px; margin-bottom: 8px; }
.empty h3 { margin: 0; }
.empty p { color: var(--text-muted); max-width: 42ch; margin: 0 0 8px; }

/* UI-TOAST-001 (en production : SweetAlert2 Toast, charte §47) */
.toasts { position: fixed; z-index: 90; inset-block-end: 20px; inset-inline-end: 20px; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-md); background: color-mix(in srgb, var(--surface-ink) 92%, transparent); backdrop-filter: blur(10px); color: #fff; box-shadow: var(--shadow-lg); font-size: 14.5px; animation: toastIn var(--dur) var(--ease); }
.toast .ic { color: #b8e0c2; margin-top: 1px; }
.toast.is-error .ic { color: #ffb3bb; }
.toast.is-out { opacity: 0; transform: translateY(8px); transition: all var(--dur); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* UI-MODAL-001 / UI-DRAWER-001 (en production : Bootstrap 5 modal/offcanvas) */
.overlay { position: fixed; inset: 0; z-index: 80; background: rgba(42, 18, 25, .45); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity var(--dur); }
.overlay.is-open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; z-index: 85; inset-block: 0; inset-inline-end: 0; width: min(440px, 100vw); background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; transform: translateX(105%); transition: transform 240ms var(--ease); }
[dir="rtl"] .drawer { transform: translateX(-105%); }
.drawer.is-open { transform: none !important; }
.drawer.drawer-start { inset-inline-end: auto; inset-inline-start: 0; transform: translateX(-105%); }
[dir="rtl"] .drawer.drawer-start { transform: translateX(105%); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.drawer-head h3 { margin: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-foot { padding: 16px 20px; border-top: 1px solid var(--border); background: var(--surface-alt); }
.modal { position: fixed; z-index: 85; inset: 0; display: grid; place-items: center; padding: 16px; pointer-events: none; }
.modal-box { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 24px; opacity: 0; transform: translateY(12px) scale(.98); transition: all var(--dur) var(--ease); }
.modal.is-open { pointer-events: auto; }
.modal.is-open .modal-box { opacity: 1; transform: none; }
@media (max-width: 600px) { .modal { place-items: end center; padding: 0; } .modal-box { border-radius: var(--radius-lg) var(--radius-lg) 0 0; } }

/* Tableaux */
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: start; font-weight: 650; color: var(--text-muted); font-size: 13px; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:hover td { background: #fffafa; }
.table .end { text-align: end; }
.scroll { overflow-x: auto; }
@media (max-width: 700px) {
  .table.stack thead { display: none; }
  .table.stack tr { display: grid; padding-block: 10px; border-bottom: 1px solid var(--border); }
  .table.stack td { display: flow-root; border: 0; padding: 4px 0; padding-inline-start: 8.5em; text-align: start; }
  .table.stack td::before { content: attr(data-l); float: inline-start; width: 8em; margin-inline-start: -8.5em; color: var(--text-muted); font-size: 13px; }
  .table.stack td:empty { display: none; }
}


/* UI-BRAND-001 / UI-ICONBTN-001 — partagés front + admin */
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text-primary); flex: none; }
.brand-seal { width: 42px; height: 42px; }
.brand-name { font-family: var(--font-mark); font-size: 26px; font-weight: 600; line-height: 1; letter-spacing: .02em; text-transform: uppercase; }
.brand-name small { display: block; font-family: var(--font-body); font-size: 9.5px; font-weight: 600; color: var(--text-secondary); letter-spacing: .18em; margin-top: 5px; text-transform: uppercase; }
.icon-btn { position: relative; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; border: 0; background: transparent; cursor: pointer; color: var(--text-primary); }
.icon-btn:hover { background: var(--surface-alt); }
.cart-count { position: absolute; top: 3px; inset-inline-end: 1px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px; background: var(--primary); color: #fff; font-size: 11.5px; font-weight: 750; display: grid; place-items: center; }
.cart-count:empty, .cart-count[data-n="0"] { display: none; }
.cart-count.bump { animation: bump .4s var(--ease); }
