/**
 * Fichier  : assets/css/movements-terrain.css
 * Auteur   : KREMER Régis
 * Version  : 2.6.79
 * Date     : 2026-07-17
 * Description : Mouvements — parcours terrain mobile/tablette, cartes natives, filtres et scanner.
 *
 * Changelog :
 *   v2.6.79 (2026-07-17) — Création du rendu terrain distinct du tableau desktop.
 */

/* ================================================================
   Mouvements : affichage desktop par défaut
   ================================================================ */
.mv-terrain-launch,
.mv-mobile-filterbar,
.mv-mobile-history {
  display: none;
}

/* ================================================================
   Composants partagés du flux terrain
   ================================================================ */
.mv-operation-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.mv-operation-choice {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}

.mv-operation-choice:hover,
.mv-operation-choice:active {
  border-color: var(--blue, #2563eb);
  background: var(--bg-hover, #f8fafc);
}

.mv-operation-choice__icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--bg-elevated, var(--bg-body));
  font-size: 23px;
}

.mv-operation-choice__copy {
  min-width: 0;
}

.mv-operation-choice__copy strong {
  display: block;
  margin-bottom: 3px;
  font-size: 15px;
  font-weight: 850;
}

.mv-operation-choice__copy small {
  display: block;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.4;
}

.mv-operation-choice__arrow {
  color: var(--text-muted);
  font-size: 20px;
}

.mv-terrain-flow {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.mv-terrain-flow .ms-flow__header {
  margin-bottom: 12px;
}

.mv-terrain-flow .ms-flow__steps {
  overflow-x: auto;
  scrollbar-width: none;
}

.mv-terrain-flow .ms-flow__steps::-webkit-scrollbar {
  display: none;
}

.mv-terrain-flow .ms-flow__indicator {
  min-width: 108px;
}

.mv-terrain-step__lead {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.mv-terrain-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.mv-terrain-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.mv-terrain-field > label,
.mv-terrain-field > .lbl {
  color: var(--text-secondary, var(--text-primary));
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .02em;
}

.mv-terrain-field .inp,
.mv-terrain-field .sel,
.mv-terrain-flow input,
.mv-terrain-flow select,
.mv-filter-drawer input,
.mv-filter-drawer select {
  width: 100%;
  min-height: 48px;
  font-size: 16px;
}

.mv-terrain-field--wide {
  grid-column: 1 / -1;
}

.mv-terrain-scan {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--blue, #2563eb) 42%, var(--border));
  background: color-mix(in srgb, var(--blue, #2563eb) 8%, var(--bg-card));
}

.mv-terrain-scan__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.mv-terrain-scan__head strong {
  display: block;
  font-size: 14px;
}

.mv-terrain-scan__head small {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
}

.mv-terrain-scan__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.mv-terrain-scan__row .btn {
  min-width: 48px;
  min-height: 48px;
}

.mv-terrain-stock {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated, var(--bg-body));
}

.mv-terrain-stock__item span {
  display: block;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.mv-terrain-stock__item strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.mv-terrain-review {
  display: grid;
  gap: 12px;
}

.mv-terrain-review__summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.mv-terrain-review__summary > div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated, var(--bg-body));
}

.mv-terrain-review__summary dt {
  margin: 0 0 3px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.mv-terrain-review__summary dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
}

.mv-terrain-submit {
  width: 100%;
  min-height: 52px;
  justify-content: center;
  font-size: 15px;
  font-weight: 850;
}

.mv-filter-drawer {
  display: grid;
  gap: 14px;
}

.mv-filter-drawer__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.mv-filter-drawer__hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

.mv-camera-panel {
  min-height: 100%;
  display: grid;
  align-content: start;
  gap: 12px;
}

.mv-camera-reader {
  width: 100%;
  min-height: 300px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #05070b;
}

.mv-camera-help {
  margin: 0;
  color: var(--text-muted);
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
}

/* ================================================================
   Téléphone et tablette : rendu natif, pas de faux tableau
   ================================================================ */
@media (max-width: 1199px) {
  #pgMovements {
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }

  #pgMovements .mv-desktop-filters,
  #pgMovements #mvAdvancedWrap,
  #pgMovements .mv-desktop-actions-wrap,
  #pgMovements .mv-desktop-table {
    display: none !important;
  }

  .mv-terrain-launch {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin-bottom: 10px;
  }

  .mv-terrain-launch .btn {
    min-height: 52px;
    justify-content: center;
    font-weight: 850;
  }

  .mv-terrain-launch svg,
  .mv-mobile-filterbar svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mv-terrain-launch__scan {
    min-width: 116px;
  }

  .mv-mobile-filterbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin-bottom: 14px;
  }

  .mv-mobile-search {
    min-width: 0;
    min-height: 48px;
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
  }

  .mv-mobile-search:focus-within {
    border-color: var(--blue, #2563eb);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue, #2563eb) 18%, transparent);
  }

  .mv-mobile-search svg {
    color: var(--text-muted);
  }

  .mv-mobile-search input {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-primary);
    font-size: 16px;
  }

  .mv-mobile-filterbar__button {
    position: relative;
    min-width: 112px;
    min-height: 48px;
    justify-content: center;
  }

  .mv-filter-count {
    min-width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    padding: 0 5px;
    background: var(--blue, #2563eb);
    color: #fff;
    font-size: 11px;
    font-weight: 900;
  }

  .mv-mobile-history {
    display: block;
  }

  .mv-mobile-history__head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
  }

  .mv-mobile-history__head h2 {
    margin: 2px 0 0;
    color: var(--text-primary);
    font-size: 18px;
    line-height: 1.25;
  }

  .mv-mobile-history__kicker {
    display: block;
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 850;
    letter-spacing: .065em;
    text-transform: uppercase;
  }

  .mv-mobile-list {
    display: grid;
    gap: 16px;
    min-width: 0;
  }

  .mv-date-group {
    display: grid;
    gap: 8px;
    min-width: 0;
  }

  .mv-date-group__title {
    position: sticky;
    top: calc(var(--header-h, 62px) + 2px);
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 34px;
    margin: 0;
    padding: 7px 9px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg-body) 92%, transparent);
    backdrop-filter: blur(8px);
    color: var(--text-secondary, var(--text-primary));
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .035em;
  }

  .mv-date-group__title span:last-child {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 750;
  }

  .mv-date-group__cards {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 9px;
  }

  .mv-native-card {
    position: relative;
    min-width: 0;
    display: grid;
    gap: 11px;
    padding: 13px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--blue, #2563eb);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm, none);
  }

  .mv-native-card[data-type="remove"] { border-left-color: var(--red, #dc2626); }
  .mv-native-card[data-type="transfer"] { border-left-color: #0ea5e9; }
  .mv-native-card[data-type="inventory"] { border-left-color: var(--orange, #f59e0b); }
  .mv-native-card.is-delivery-selected {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px color-mix(in srgb, #2563eb 18%, transparent);
  }

  .mv-native-card__head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
  }

  .mv-native-card__identity {
    min-width: 0;
  }

  .mv-native-card__eyebrow {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    margin-bottom: 4px;
  }

  .mv-native-card__time {
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 700;
  }

  .mv-native-card__title {
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 900;
    line-height: 1.32;
  }

  .mv-native-card__meta {
    margin: 3px 0 0;
    overflow-wrap: anywhere;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.4;
  }

  .mv-native-card__qty {
    min-width: 78px;
    text-align: right;
  }

  .mv-native-card__qty strong {
    display: block;
    font-family: var(--font-mono, monospace);
    font-size: 18px;
    font-weight: 900;
    line-height: 1.2;
  }

  .mv-native-card__qty span {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 750;
  }

  .mv-native-card__facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    margin: 0;
  }

  .mv-native-card__fact {
    min-width: 0;
  }

  .mv-native-card__fact dt {
    margin: 0 0 2px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: .045em;
    text-transform: uppercase;
  }

  .mv-native-card__fact dd {
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--text-primary);
    font-size: 12.5px;
    font-weight: 750;
    line-height: 1.38;
  }

  .mv-native-card__actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
    gap: 7px;
    padding-top: 9px;
    border-top: 1px solid var(--border-light, var(--border));
  }

  .mv-native-card__actions .btn,
  .mv-native-card__actions button,
  .mv-native-card__actions a,
  .mv-native-card__actions .mv-delivery-select {
    min-height: 44px;
    justify-content: center;
  }

  .mv-native-card__details {
    display: grid;
    gap: 8px;
    padding-top: 9px;
    border-top: 1px dashed var(--border);
  }

  .mv-native-card__details[hidden] {
    display: none !important;
  }

  .mv-native-card__detail-line {
    display: grid;
    grid-template-columns: minmax(90px, .75fr) minmax(0, 1.25fr);
    gap: 10px;
    font-size: 12.5px;
    line-height: 1.4;
  }

  .mv-native-card__detail-line span:first-child {
    color: var(--text-muted);
    font-weight: 750;
  }

  .mv-native-card__detail-line span:last-child {
    overflow-wrap: anywhere;
    color: var(--text-primary);
    font-weight: 700;
  }

  .mv-group-lines {
    display: grid;
    gap: 7px;
  }

  .mv-group-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 8px;
    border: 1px solid var(--border-light, var(--border));
    background: var(--bg-elevated, var(--bg-body));
  }

  .mv-group-line strong,
  .mv-group-line small {
    display: block;
    overflow-wrap: anywhere;
  }

  .mv-group-line small {
    margin-top: 2px;
    color: var(--text-muted);
  }

  .mv-group-line__qty {
    color: var(--green, #16a34a);
    font-family: var(--font-mono, monospace);
    font-weight: 900;
  }

  .mv-mobile-empty {
    min-height: 180px;
    display: grid;
    place-items: center;
    padding: 24px;
    border: 1px dashed var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    text-align: center;
  }

  .mv-mobile-load-more {
    width: 100%;
    min-height: 48px;
    justify-content: center;
  }

  #pgMovements .mv-delivery-bulk-bar {
    bottom: calc(var(--bottom-nav-h, 68px) + env(safe-area-inset-bottom, 0px) + 8px);
    z-index: 35;
    margin-top: 12px;
  }

  body.ms-soft-keyboard-open #pgMovements .mv-delivery-bulk-bar {
    display: none !important;
  }
}

@media (min-width: 600px) and (max-width: 1199px) {
  .mv-operation-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mv-terrain-fields,
  .mv-filter-drawer__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mv-date-group__cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mv-terrain-launch {
    grid-template-columns: minmax(240px, 1fr) minmax(150px, .45fr);
  }
}

@media (max-width: 599px) {
  .mv-terrain-launch {
    grid-template-columns: minmax(0, 1fr) 104px;
  }

  .mv-terrain-launch__scan {
    min-width: 0;
  }

  .mv-terrain-launch__scan span {
    display: none;
  }

  .mv-mobile-filterbar {
    grid-template-columns: minmax(0, 1fr) 54px;
  }

  .mv-mobile-filterbar__button {
    min-width: 54px;
    padding-inline: 0;
  }

  .mv-mobile-filterbar__button > span:not(.mv-filter-count) {
    display: none;
  }

  .mv-filter-count {
    position: absolute;
    top: -5px;
    right: -5px;
  }

  .mv-native-card__facts,
  .mv-terrain-review__summary,
  .mv-terrain-stock {
    grid-template-columns: minmax(0, 1fr);
  }

  .mv-terrain-scan__row {
    grid-template-columns: minmax(0, 1fr) 52px;
  }

  .mv-terrain-flow .ms-flow__indicator {
    min-width: 94px;
    padding-inline: 8px;
  }
}

@media (orientation: landscape) and (max-width: 1199px) and (max-height: 560px) {
  .mv-terrain-flow .ms-flow__header {
    padding-block: 8px;
  }

  .mv-terrain-flow [data-ms-flow-step] {
    padding-block: 10px;
  }

  .mv-camera-reader {
    min-height: 210px;
  }
}

@media print {
  .mv-terrain-launch,
  .mv-mobile-filterbar,
  .mv-mobile-history {
    display: none !important;
  }

  #pgMovements .mv-desktop-table,
  #pgMovements .mv-desktop-filters,
  #pgMovements .mv-desktop-actions-wrap {
    display: block !important;
  }
}

/* Badge de stock piloté par la logique historique MvPage._onProdChange. */
.mv-stock-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated, var(--bg-body));
  color: var(--text-secondary, var(--text-primary));
  font-size: 11px;
  font-weight: 850;
  line-height: 1.25;
}
.mv-stock-ok { border-color: color-mix(in srgb, var(--green, #16a34a) 35%, var(--border)); color: var(--green, #16a34a); }
.mv-stock-low { border-color: color-mix(in srgb, var(--orange, #f59e0b) 45%, var(--border)); color: #b45309; }
.mv-stock-zero { border-color: color-mix(in srgb, var(--red, #dc2626) 38%, var(--border)); color: var(--red, #dc2626); }

@media (max-width: 1199px) {
  .mv-native-card__actions .mv-delivery-select {
    width: 100%;
    min-width: 44px;
    display: inline-flex;
    gap: 7px;
    padding-inline: 10px;
  }
  .mv-delivery-action-label {
    color: var(--text-secondary, var(--text-primary));
    font-size: 12px;
    font-weight: 850;
  }
}
