/* ============================================================================
   rapport-commande-v1.css — page-specific styles for the redesigned
   /rapport-commande. The shared design system comes from reports-advanced-v2.css
   (the mounted root carries .advrep-root). Scoped under .rapcmd-root.
   ============================================================================ */

/* Hide the React-rendered page while our root is mounted on /rapport-commande.
   Unlike /reports, this page's wrapper is NOT .page — so hide every direct
   child of .main-content except our root (React nodes stay mounted, just
   invisible; toasts render under document.body, unaffected). */
html.rapcmd-on .main-content > :not(.rapcmd-root) { display: none !important; }

/* two-column zone: most-ordered table (wide) + stock watch (narrow) */
.rapcmd-root .rapcmd-cols {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
}

/* ------------------------------------------------------- stock-watch KPIs */
.rapcmd-root .rapcmd-swkpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px 0 4px;
}
.rapcmd-root .rapcmd-swkpis .sk {
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 0;
  overflow: hidden;
}
.rapcmd-root .rapcmd-swkpis .sk b {
  display: block;
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rapcmd-root .rapcmd-swkpis .sk span {
  display: block;
  margin-top: 2px;
  color: #94a3b8;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.rapcmd-root .rapcmd-swkpis .sk.bad { background: #fef2f2; }
.rapcmd-root .rapcmd-swkpis .sk.bad b { color: #dc2626; }
.rapcmd-root .rapcmd-swkpis .sk.warn { background: #fffbeb; }
.rapcmd-root .rapcmd-swkpis .sk.warn b { color: #d97706; }

/* ---------------------------------------------------------- state badges */
.rapcmd-root .rapcmd-state {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.rapcmd-root .rapcmd-state.ok  { background: #f0fdf4; color: #16a34a; }
.rapcmd-root .rapcmd-state.low { background: #fffbeb; color: #d97706; }
.rapcmd-root .rapcmd-state.out { background: #fef2f2; color: #dc2626; }
.rapcmd-root .rapcmd-state.unt { background: #f1f5f9; color: #94a3b8; }

/* ------------------------------------------------------------- duplicates */
.rapcmd-root .rapcmd-duplist { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.rapcmd-root .rapcmd-dup {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff7f5;
  border: 1px solid #ffe1d6;
  border-radius: 12px;
  padding: 9px 12px;
}
.rapcmd-root .rapcmd-dup .m { flex: 1; min-width: 0; }
.rapcmd-root .rapcmd-dup .n { font-weight: 800; font-size: 13.5px; color: #0f172a; }
.rapcmd-root .rapcmd-dup .n em {
  font-style: normal; font-weight: 700; font-size: 11px; color: #94a3b8; margin-left: 6px;
}
.rapcmd-root .rapcmd-dup .s { color: #64748b; font-size: 12px; margin-top: 1px; }
.rapcmd-root .rapcmd-dup .hh {
  font-weight: 800; font-size: 15px; color: #dc2626; font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------- recent orders */
.rapcmd-root .rapcmd-orders {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.rapcmd-root .rapcmd-order {
  background: #f8fafc;
  border: 1px solid #eef2f7;
  border-radius: 14px;
  padding: 12px 13px;
  min-width: 0;
}
.rapcmd-root .rapcmd-order-head { display: flex; align-items: center; gap: 10px; }
.rapcmd-root .advrep-ava.sm { width: 34px; height: 34px; font-size: 12.5px; }
.rapcmd-root .rapcmd-order-id { flex: 1; min-width: 0; }
.rapcmd-root .rapcmd-order-id b {
  display: block; font-size: 13.5px; font-weight: 800; color: #0f172a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rapcmd-root .rapcmd-order-id span { display: block; color: #64748b; font-size: 11.5px; margin-top: 1px; }
.rapcmd-root .rapcmd-print {
  flex: none;
  font-size: 10.5px; font-weight: 800;
  padding: 3px 9px; border-radius: 999px;
  background: #f1f5f9; color: #94a3b8;
}
.rapcmd-root .rapcmd-print.ok { background: #f0fdf4; color: #16a34a; }
.rapcmd-root .rapcmd-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.rapcmd-root .rapcmd-chip {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rapcmd-root .rapcmd-chip.dup {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
  font-weight: 700;
}
.rapcmd-root .rapcmd-chip.hit { outline: 2px solid #e65100; }
.rapcmd-root .rapcmd-chips .mut { color: #94a3b8; font-size: 12px; }

/* --------------------------------------------------------------- pagination */
.rapcmd-root .rapcmd-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}
.rapcmd-root .rapcmd-pg {
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 10px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
}
.rapcmd-root .rapcmd-pg:hover:not(:disabled) { border-color: #e65100; color: #e65100; }
.rapcmd-root .rapcmd-pg:disabled { opacity: .45; cursor: default; }
.rapcmd-root .rapcmd-pg.num { min-width: 36px; text-align: center; padding: 7px 9px; }
.rapcmd-root .rapcmd-pg.num.on {
  background: #e65100;
  border-color: #e65100;
  color: #fff;
  cursor: default;
}
.rapcmd-root .rapcmd-pgdots { color: #94a3b8; font-weight: 700; padding: 0 2px; }

/* ------------------------------------------------------------ search input */
.rapcmd-root .rapcmd-search {
  width: 240px;
  max-width: 100%;
  font-size: 16px; /* >=16px: no iOS zoom */
}

/* ------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .rapcmd-root .rapcmd-cols { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .rapcmd-root .rapcmd-orders { grid-template-columns: 1fr; }
  .rapcmd-root .rapcmd-search { width: 100%; margin-top: 8px; }
}
