/* ─────────────────────────────────────────────────────────────
   Babykare ERP — Mobile patches
   Additive breakpoints for <sm (< 640px) and <md (< 768px).
   Never overrides desktop behaviour.

   Sections:
     1. Layout — main padding for fixed bottom nav + safe areas
     2. Topbar — denser filter header on mobile
     3. Combobox triggers — 40px min-height for touch
     4. Tables — scrollable with min-width inside narrow cards
     5. Sidebar drawer — off-canvas overlay (desktop unaffected)
     6. PWA install button — bottom-fixed, mobile only
     7. Notifications drawer — slide-in panel from right
     8. Generic touch-target helpers
   ───────────────────────────────────────────────────────────── */

/* ── 1. Layout safe-area + bottom nav clearance ───────────── */
@media (max-width: 639px) {
  /* Reserve space for the fixed mobile nav (58px) and the home indicator. */
  main#main-content {
    padding-left: var(--space-3) !important;
    padding-right: var(--space-3) !important;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Mobile nav respects the iPhone home indicator. */
  nav[aria-label="Navigation mobile"] {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* ── 2. Topbar — denser filter header on mobile ──────────── */
@media (max-width: 767px) {
  /* The dashboard v2 filter header (header[role="banner"] inside
     content_for :custom_topbar). Mobile layout:
       Row 1 — hamburger | logo | title (mr-auto) | bell  → action row
       Row 2 — three comboboxes (horizontally scrollable) | CTA
     We keep the title visible and skip the period subline so the topbar
     stays around 110-120px instead of 200+. */
  .filters-topbar {
    padding: var(--space-2) var(--space-3) !important;
  }

  /* Hide the verbose period subline + freshness indicator on mobile —
     room is the bottleneck. The title still says what's selected via
     its •Analytics suffix and the user can re-open the period combobox
     to see the dates. The freshness <p> has an inline `display: flex`
     so we have to !important the override. */
  .filters-topbar__title p { display: none !important; }
  .filters-topbar__title h1 {
    font-size: 13px;
    line-height: 1.2;
  }

  /* The form + CTA wrap together onto a second row that scrolls
     horizontally as one unit. */
  .filters-topbar > form {
    flex-basis: 100%;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    min-width: 0;
  }
  .filters-topbar > form::-webkit-scrollbar { display: none; }
  .filters-topbar > form > * { flex-shrink: 0; }

  /* CTA sits on the same horizontal-scroll row visually by wrapping
     to be the last item of row 2 when there's no space. Easier: keep
     it on its own row but compact. */
  .filters-topbar > a.btn-primary {
    margin-left: auto;
  }
}

/* ── 3. Combobox triggers — 40px min-height for touch ─────── */
@media (max-width: 767px) {
  .combobox-trigger,
  .btn-primary,
  .btn-secondary,
  .btn-danger {
    min-height: 40px;
  }

  /* Combobox menus get a wider min-width and stay anchored under their
     trigger when the topbar row scrolls horizontally.
     Left-anchor on mobile: the base rule pins the menu's RIGHT edge to the
     trigger (`right:0`), so a left-aligned filter trigger pushes the 240px
     menu off the LEFT edge of the screen (cut off, bottom-left). Anchoring
     left keeps it on-screen, and max-width clamps it to the viewport. */
  .combobox-menu {
    min-width: 220px;
    width: max-content;
    max-width: calc(100vw - 32px);
    max-height: 60vh;
    left: 0;
    right: auto;
  }
}

/* ── 4. Tables — scrollable with min-width inside narrow cards ─ */
@media (max-width: 767px) {
  .card__body table,
  .card__body .erp-table,
  .overflow-x-auto > table {
    min-width: 480px;
  }

  /* Wrap tall geo cards so they don't stretch the layout. */
  .card__body { padding: var(--space-3) !important; }
  .card__header,
  .card-header { padding: var(--space-2) var(--space-3) !important; }
}

/* ── 5. Sidebar drawer — off-canvas overlay for <sm ─────── */
/* When the body has data-mobile-drawer-open="true", the sidebar slides in
   from the left and a backdrop dims the rest. Stimulus controller
   `mobile_drawer` toggles the body attribute. */
@media (max-width: 639px) {
  /* Force-show the desktop sidebar as an off-canvas drawer on mobile.
     The desktop selectors use `hidden sm:flex` so we override with
     position+transform — no JS class additions to the aside itself. */
  aside[aria-label="Navigation principale"] {
    /* Desktop sets `hidden sm:flex sm:flex-col` — at <sm none of the
       sm:* utilities apply, so we have to force display + direction
       ourselves. */
    display: flex !important;
    flex-direction: column !important;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform var(--duration-normal) var(--ease-out-expo);
    box-shadow: var(--shadow-lg);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    /* Hide internal flex children that overflow horizontally while the
       drawer is closed (the user profile <p> uses `min-width: 0` +
       `truncate` but its bounding box still extends past the aside's
       right edge by ~60px, which would peek through at x=0 because the
       aside has its right edge ON-SCREEN at x=0 when translateX(-100%)). */
    overflow: hidden;
  }

  body[data-mobile-drawer-open="true"] aside[aria-label="Navigation principale"] {
    transform: translateX(0);
  }

  /* Backdrop — appended by the Stimulus controller, faded in via attribute. */
  .mobile-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(26, 18, 8, 0.45);
    z-index: 55;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-normal) var(--ease-default);
  }
  body[data-mobile-drawer-open="true"] .mobile-drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* Lock body scroll while the drawer is open. */
  body[data-mobile-drawer-open="true"] {
    overflow: hidden;
  }
}

/* Hamburger button — visible only on mobile. */
.mobile-drawer-trigger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-primary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--duration-fast) var(--ease-default);
}
.mobile-drawer-trigger:hover { background: var(--color-bg); }
.mobile-drawer-trigger:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
@media (max-width: 639px) {
  .mobile-drawer-trigger { display: inline-flex; }
}

/* ── 6. PWA install button — bottom-fixed, mobile only ────── */
.pwa-install-btn {
  display: none;
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  /* Sits ABOVE the bottom mobile nav (58px) + safe area. */
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  z-index: 45;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  /* WCAG AA : blanc sur --color-accent = 3,54:1 (FAIL). --color-accent-text
     est la teinte terracotta assombrie déjà validée AA (6,1:1 sur blanc,
     cf. tokens.css) — même identité chaude, texte lisible. */
  background: var(--color-accent-text);
  color: white;
  font-size: 13px;
  font-weight: 700;
  border: 0;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-default),
              transform var(--duration-fast) var(--ease-default);
  animation: pwa-install-rise 0.3s var(--ease-out-expo);
}
.pwa-install-btn:hover { background: var(--color-sidebar-active-text); }
.pwa-install-btn:active { transform: translateX(-50%) translateY(1px); }
.pwa-install-btn[hidden] { display: none !important; }
.pwa-install-btn[data-visible="true"] { display: inline-flex; }

/* Desktop never shows it. */
@media (min-width: 1024px) {
  .pwa-install-btn[data-visible="true"] { display: none; }
}

/* iOS hint tooltip — replaces the install button on iOS where the
   beforeinstallprompt event never fires. */
.pwa-ios-hint {
  display: none;
  position: fixed;
  left: var(--space-3);
  right: var(--space-3);
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  z-index: 45;
  padding: var(--space-3);
  background: var(--color-text-primary);
  color: white;
  font-size: 13px;
  line-height: 1.4;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: pwa-install-rise 0.3s var(--ease-out-expo);
}
.pwa-ios-hint[data-visible="true"] { display: block; }
.pwa-ios-hint__close {
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.75);
  font-weight: 700;
  cursor: pointer;
  padding: 0 4px;
  margin-left: 8px;
  font-size: 16px;
  line-height: 1;
}

@keyframes pwa-install-rise {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .pwa-install-btn,
  .pwa-ios-hint { animation: none; }
}

/* ── 7. Notifications drawer — slide-in panel from right ─── */
.notifications-drawer-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-default);
}
.notifications-drawer-trigger:hover {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}
.notifications-drawer-trigger:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.notifications-drawer-trigger__dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid var(--color-surface);
}

.notifications-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(380px, 90vw);
  z-index: 70;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform var(--duration-normal) var(--ease-out-expo);
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
body[data-notifications-drawer-open="true"] .notifications-drawer {
  transform: translateX(0);
}
.notifications-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.notifications-drawer__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
}
.notifications-drawer__close {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-text-muted);
}
.notifications-drawer__close:hover {
  background: var(--color-bg);
  color: var(--color-text-primary);
}
.notifications-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}
.notifications-drawer__empty {
  text-align: center;
  padding: var(--space-7) var(--space-4);
  color: var(--color-text-muted);
  font-size: 13px;
}
.notifications-drawer__empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-bg);
  margin: 0 auto var(--space-3);
}

.notifications-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 18, 8, 0.45);
  z-index: 65;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease-default);
}
body[data-notifications-drawer-open="true"] .notifications-drawer-backdrop {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 639px) {
  body[data-notifications-drawer-open="true"] {
    overflow: hidden;
  }
}

/* ── 7b. Notifications list + card (partials _list / _notification) ── */

.notifications-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.notifications-list__actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 var(--space-1);
}

/* Small modifier for compact action buttons inside the drawer */
.btn--sm {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
}

/* Icon-only button modifier (square, centered icon, no text padding) */
.btn--icon {
  flex-shrink: 0;
  padding: var(--space-1);
  font-size: var(--text-xs);
  line-height: 1;
}

.notification-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

.notification-card__content {
  flex: 1;
  min-width: 0;
}

.notification-card__title {
  font-weight: 600;
  color: var(--color-text-primary);
  font-size: var(--text-sm);
  margin: 0 0 var(--space-1);
}

.notification-card__link {
  color: inherit;
  text-decoration: none;
}

.notification-card__body {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  margin: 0 0 var(--space-1);
}

.notification-card__time {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  margin: 0;
}

/* Empty-state text inside the notification drawer */
.notifications-list__empty-title {
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-1);
}

.notifications-list__empty-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ── 7c. Shared text-color utilities (token aliases) ─────── */
.text-muted {
  color: var(--color-text-muted);
}

.text-secondary {
  color: var(--color-text-secondary);
}

.text-danger {
  color: var(--color-danger);
}

/* ── 8. Touch-target helper ──────────────────────────────── */
.touch-target {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── 9. SAV inbox — two-tab mobile (Ouverts / En cours) ───── */
/* Below the desktop breakpoint the inbox collapses to the two actionable
   status tabs; Résolus + Tous (.sav-chip--desk) and the list/kanban view
   toggle are desktop-only. The list view already renders on mobile (the
   kanban board is display:none < 1024px). The marketplace/category
   comboboxes share the row and wrap underneath the two tabs. */
@media (max-width: 1023px) {
  .sav-chip--desk { display: none !important; }

  /* The two remaining tabs (Ouverts / En cours) split the full width as a
     segmented control; the marketplace/category filter forms wrap onto the
     next row (the container keeps flex-wrap). */
  .sav-status-tabs { width: 100%; }
  .sav-status-tabs > .btn-chip {
    flex: 1 1 40%;
    justify-content: center;
    min-height: 42px;
  }
}

/* ── 10. SAV ticket — top-bar Actions dropdown + Profil client (mobile) ── */
/* Desktop (≥1024px): the quick actions render inline as before — the dropdown
   toggle is hidden and the menu is a normal flex row. Mobile: the pinned top
   bar shows two pills — "Profil client" (opens the right drawer) and "Actions"
   (a <details> dropdown holding every quick action) — so the bar stays compact
   and both are always reachable from the fixed header. */
/* Desktop: menu inline (NB: unlayered rules beat Tailwind utilities in v4, so
   we cannot rely on lg:hidden for elements that also carry .sav-topbar-pill —
   we drive their display from our OWN media queries instead). */
.sav-actions-dd__menu { display: flex; }

/* Desktop (≥1024px) — RÉGRESSION #836 corrigée : Chrome récent masque le contenu
   d'un <details> FERMÉ via le pseudo ::details-content { content-visibility:hidden },
   que le display:flex ci-dessus ne suffit plus à outrepasser → la Quick Action Bar
   collapsait à width:0 sur desktop (toggle « Actions » étant lg:hidden, plus rien
   n'était accessible : changement de statut, Rembourser, étiquette retour…). On
   force le slot de contenu visible sur desktop. Les navigateurs sans ::details-content
   (Safari/Firefox) ignorent la règle pseudo et s'appuient sur le display:flex.
   ⚠️ NE PAS retirer sans demande explicite d'Alex + double confirmation desktop/mobile. */
@media (min-width: 1024px) {
  .sav-actions-dd::details-content { content-visibility: visible !important; }
  .sav-actions-dd > .sav-actions-dd__menu { display: flex !important; }
}

/* Top-bar pills (Profil client + Actions summary) — mobile-only: hidden by
   default (desktop), shown < lg via the media query below. */
.sav-topbar-pill {
  display: none;
  align-items: center;
  gap: 0.375rem;
  font-size: 13px;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  min-height: 40px;
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border-strong);
  cursor: pointer;
  white-space: nowrap;
  list-style: none;
}
.sav-topbar-pill::-webkit-details-marker { display: none; }
.sav-topbar-pill--accent {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  border-color: transparent;
}
/* Profil client cale a droite de la rangee d'actions (mobile). */
.sav-topbar-pill--right { margin-left: auto; }

@media (max-width: 1023px) {
  .sav-topbar-pill { display: inline-flex; }
  /* Anchor the dropdown to the FULL action row (not the narrow trigger) and
     open it LEFT-aligned: with right:0 on a left-positioned trigger the menu
     extended off-screen left and got cropped. left:0 + viewport-clamped
     max-width keeps it fully on screen on every mobile width. */
  .sav-actions-row { position: relative; }
  .sav-actions-dd { position: static; }
  .sav-actions-dd__menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: auto;
    z-index: 60;
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
    width: max-content;
    max-width: calc(100vw - 24px);
    max-height: 70vh;
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2);
    gap: var(--space-1);
  }
  .sav-actions-dd[open] > .sav-actions-dd__menu { display: flex; }
  /* Each action spans the dropdown width, left-aligned. */
  .sav-actions-dd__menu > *,
  .sav-actions-dd__menu form { width: 100%; }
  .sav-actions-dd__menu > button,
  .sav-actions-dd__menu > a,
  .sav-actions-dd__menu form button { justify-content: flex-start; }
  /* Drop the vertical divider separators inside the vertical menu. */
  .sav-actions-dd__menu > span.self-stretch { display: none !important; }
}

/* ── 11. SAV ticket detail — density + client side-drawer ──── */
/* < lg (1024px) the layout is a single column. We (a) tighten the conversation
   so more messages fit, and (b) move the customer panel (right column on
   desktop) into a slide-in drawer from the right, opened by the "Profil client"
   pill in the pinned top bar. */
@media (max-width: 1023px) {
  /* Density — tighter conversation padding + message spacing. */
  .sav-thread-body {
    padding: var(--space-3) var(--space-2) !important;
  }
  .sav-thread-body.space-y-6 > :not([hidden]) ~ :not([hidden]) {
    margin-top: var(--space-4) !important; /* 24px → 16px between messages */
  }

  /* Customer panel — HIDDEN BY DEFAULT on mobile (display:none, bulletproof:
     it cannot render in-flow / "show by default", even on iOS Safari where
     position:fixed inside the transformed <main> misbehaves). It only becomes
     a drawer once the controller portals it to <body> AND adds .is-drawer on
     open. !important on the offsets beats the element's inline `top:var(--space-5)`
     (desktop sticky column) so the drawer is full-height. */
  .sav-client-panel { display: none !important; }
  .sav-client-panel.is-drawer {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: auto !important;
    width: min(360px, 88vw);
    max-height: none !important;
    margin: 0;
    z-index: 70;
    padding: var(--space-3);
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform var(--duration-normal) var(--ease-out-expo);
    overflow-y: auto;
  }
  body[data-sav-client-open="true"] .sav-client-panel.is-drawer { transform: translateX(0); }
  body[data-sav-client-open="true"] { overflow: hidden; }

  .sav-client-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(26, 18, 8, 0.45);
    z-index: 65;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-normal) var(--ease-default);
  }
  body[data-sav-client-open="true"] .sav-client-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Phones — give the thread messages nearly the full screen width: minimal card
   padding, smaller avatars, tighter row gaps, and bubbles allowed to use 100%. */
@media (max-width: 639px) {
  .sav-thread-body { padding: var(--space-2) var(--space-1) !important; }
  .sav-thread-body .w-8.h-8 { width: 1.625rem !important; height: 1.625rem !important; }
  .sav-thread-body [class*="gap-3"] { gap: 0.5rem !important; }
  .sav-thread-body .max-w-\[90\%\],
  .sav-thread-body .max-w-\[85\%\] { max-width: 100% !important; }
  .sav-thread-body .px-4 { padding-left: 0.7rem !important; padding-right: 0.7rem !important; }
}

@media (prefers-reduced-motion: reduce) {
  .sav-client-panel { transition: none; }
}

/* ── 12. Mode expédition (/orders/shipping) — cartes mobile ──── */
/* Validation shipping on-the-go : liste de cartes remplace la table
   desktop en dessous de 640px (cf. section 4 pour les tables restées en
   table+scroll). Toute la carte est cliquable via
   dispatch-selection#toggleCard (Stimulus, jamais de handler inline). */

/* Modale récap : padding cohérent sur le corps, l'en-tête, la zone de
   boutons et la table interne (signalement Alex 26/07 : « manque de
   padding partout »). `.card` n'a pas de padding par défaut (cf.
   tailwind/application.css), donc le corps et les actions ont besoin de
   leurs propres classes ; l'en-tête garde `.card-header` qui est déjà
   paddé. Ces règles s'appliquent à toutes les tailles d'écran ; les
   overrides mobile ci-dessous ne touchent que la disposition. */
.dispatch-recap-modal__body {
  padding: var(--space-4);
}
.dispatch-recap-modal__actions {
  padding: var(--space-3) var(--space-4) var(--space-4);
  border-top: 1px solid var(--color-border);
}

/* Table interne de la modale récap : jamais d'ascenseur horizontal
   (signalement Alex 26/07, 2e revue : « il y a largement la place »).
   `.erp-table-wrap` impose overflow-x:auto + min-width:640px sur son
   `.erp-table` (cf. tailwind/application.css) pour les tables pleine page ;
   dans la modale (max-width 640px, 92vw) ça déclenche un scroll horizontal
   inutile. On neutralise les deux et on s'appuie sur `.erp-table--fixed`
   (déjà posée sur la table dans la vue) pour répartir les 3 colonnes dans
   la largeur disponible, y compris à 390px. */
.dispatch-recap-modal .erp-table-wrap {
  overflow-x: hidden;
  background: var(--color-surface);
}
.dispatch-recap-modal .erp-table-wrap .erp-table {
  min-width: 0;
}

/* Case de confirmation « Je confirme la création réelle… » : zone de tap
   pleine largeur ≥44px (WCAG 2.5.5), label cliquable englobant le texte
   (comportement natif <label for=…>), checkbox agrandie à 22px comme les
   checkboxes des cartes mobile (.wdb-order-card__checkbox) plutôt qu'une
   case 16px isolée difficile à toucher au doigt. */
.dispatch-recap-modal__confirm {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-2) 0;
  cursor: pointer;
  font-size: var(--text-xs, 12px);
  color: var(--color-text-secondary);
}
.dispatch-recap-modal__confirm-checkbox {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  accent-color: var(--color-accent);
}

@media (max-width: 639px) {
  .wdb-order-card-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
  }

  .wdb-order-card {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    box-shadow: var(--shadow-xs);
    cursor: pointer;
  }
  .wdb-order-card:active { background: var(--color-accent-soft); }

  /* Zone de frappe ≥44px (WCAG 2.5.5) autour de la checkbox visuelle,
     plus petite pour rester proportionnée dans la carte. */
  .wdb-order-card__check-zone {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .wdb-order-card__checkbox {
    width: 22px;
    height: 22px;
    accent-color: var(--color-accent);
  }

  .wdb-order-card__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-1) 0;
  }
  .wdb-order-card__head {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
  }
  .wdb-order-card__prio { font-size: 1rem; line-height: 1; }
  .wdb-order-card__deadline { margin-left: auto; font-size: 11px; white-space: nowrap; }
  .wdb-order-card__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-top: var(--space-1);
    flex-wrap: wrap;
  }

  /* Modale récap utilisable à 390px : largeur pleine moins marges,
     boutons empilés pleine largeur. */
  .dispatch-recap-modal {
    max-width: calc(100vw - var(--space-4)) !important;
    width: calc(100vw - var(--space-4)) !important;
  }
  .dispatch-recap-modal__actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .dispatch-recap-modal__actions > button {
    width: 100%;
  }
}

/* ── 13. Batch d'expédition (/warehouse_dispatch_batches/:id) — cartes mobile ── */
@media (max-width: 639px) {
  .wdb-item-card-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
  }
  .wdb-item-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    box-shadow: var(--shadow-xs);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
  }
  .wdb-item-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
  }
  .wdb-item-card__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    font-size: 12px;
    padding-top: var(--space-1);
    border-top: 1px solid var(--color-border);
  }
}
