/* ==========================================================================
   assets/css/inbound-multirow-totals.css
   Material Inbound Multi-Row Totals Footer Extension Styles
   Task: INBOUND-TOTALS-COLUMN-ALIGN-v1
   Contract: INBOUND-FORM-v1, INBOUND-MULTIROW-TOTALS-v1 & INBOUND-TOTALS-COLUMN-ALIGN-v1
   Owned by: AGY 2 (Authorized AGY Player / CSS Owner)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Footer Container Grid Contract
   - 1-source column grid geometry matching .inbound-multirow-head and .inbound-multirow-row
   - Sticky at bottom while rows scroll underneath
   - Grid tracks align pixel-for-pixel while horizontally scrolling
   - Opaque theme-aware surface so scrolling rows do not bleed through
   - Clear top border and subtle elevation shadow
   -------------------------------------------------------------------------- */
#inbound-multirow-footer.inbound-multirow-footer,
.inbound-multirow-footer {
  /* Grid geometry matching .inbound-multirow-head and .inbound-multirow-row */
  display: grid;
  grid-template-columns: var(--inbound-grid-cols);
  column-gap: 8px;
  row-gap: 0;
  align-items: center;
  width: 100%;
  min-width: var(--inbound-grid-min-width, 1310px);
  box-sizing: border-box;
  padding-left: 12px;
  padding-right: 12px;
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: 12px;
  line-height: 1.3;

  /* Sticky positioning at bottom of scrollable container */
  position: sticky;
  bottom: 0;
  z-index: 2;

  /* Opaque theme-aware surface (dark mode default) */
  background-color: var(--surface, #16202e);
  color: var(--text, #e7ebf2);

  /* Border geometry matching .inbound-multirow-head pixel-for-pixel (1px transparent left/right/bottom, visible top) */
  border-top: 1px solid var(--border, #2a3648);
  border-bottom: 1px solid transparent;
  border-left: 1px solid transparent;
  border-right: 1px solid transparent;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.28);

  /* Separation margin */
  margin-top: 6px;
  margin-bottom: 0;

  /* Semantic column variable tokens */
  --qty-col: var(--inbound-totals-qty-col, 6);
  --weight-col: var(--inbound-totals-weight-col, 7);
  --inbound-totals-leading-end: var(--inbound-totals-qty-col, 6);
}

/* --------------------------------------------------------------------------
   2. Column Layout Variants (cols-8 & cols-10)
   - cols-8:  min-width 1160px, qty in column 5, no standalone weight track
   - cols-10: min-width 1310px, qty in column 6, weight in column 7
   -------------------------------------------------------------------------- */
#inbound-multirow-footer.cols-8,
.inbound-multirow-footer.cols-8,
.inbound-multirow-scroll.cols-8 #inbound-multirow-footer,
.inbound-multirow-scroll.cols-8 .inbound-multirow-footer,
.inbound-multirow-wrap.cols-8 #inbound-multirow-footer,
.inbound-multirow-wrap.cols-8 .inbound-multirow-footer,
.inbound-multirow-footer[data-has-weight-column="false"] {
  min-width: var(--inbound-grid-min-width, 1160px);
  --qty-col: var(--inbound-totals-qty-col, 5);
  --weight-col: var(--inbound-totals-weight-col, 0);
  --inbound-totals-leading-end: var(--inbound-totals-qty-col, 5);
}

#inbound-multirow-footer.cols-10,
.inbound-multirow-footer.cols-10,
.inbound-multirow-scroll.cols-10 #inbound-multirow-footer,
.inbound-multirow-scroll.cols-10 .inbound-multirow-footer,
.inbound-multirow-wrap.cols-10 #inbound-multirow-footer,
.inbound-multirow-wrap.cols-10 .inbound-multirow-footer,
.inbound-multirow-footer[data-has-weight-column="true"] {
  min-width: var(--inbound-grid-min-width, 1310px);
  --qty-col: var(--inbound-totals-qty-col, 6);
  --weight-col: var(--inbound-totals-weight-col, 7);
  --inbound-totals-leading-end: var(--inbound-totals-qty-col, 6);
}

/* --------------------------------------------------------------------------
   3. Leading Section (.inbound-totals-leading)
   - Spans grid columns 1 through var(--inbound-totals-leading-end)
   - Stays strictly inside leading tracks without covering data cells
   - Aligns label and count toward the qty edge (right-aligned in leading region)
   -------------------------------------------------------------------------- */
.inbound-totals-leading {
  grid-column: 1 / var(--inbound-totals-leading-end);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  padding-right: 4px;
}

/* Section label badge */
.inbound-totals-label,
#inbound-totals-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
  white-space: nowrap;
  flex-shrink: 0;
  border-radius: 6px;
  color: var(--accent, #5b90d6);
  background-color: rgba(91, 144, 214, 0.14);
  border: 1px solid rgba(91, 144, 214, 0.36);
  user-select: none;
}

/* Row count badge */
.inbound-totals-count,
#inbound-totals-count {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  background-color: rgba(141, 155, 179, 0.1);
  color: var(--muted, #8d9bb3);
  font-weight: 600;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  border: 1px solid rgba(141, 155, 179, 0.18);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Base item wrapper */
.inbound-totals-item {
  min-width: 0;
  white-space: nowrap;
  line-height: 1.2;
}

/* --------------------------------------------------------------------------
   4. Metrics Section for Datasets with Weight Column (data-has-weight-column="true")
   - .inbound-totals-metrics uses display: contents to place children into grid
   - Qty cell occupies var(--qty-col)
   - Weight cell occupies var(--weight-col)
   -------------------------------------------------------------------------- */
.inbound-multirow-footer[data-has-weight-column="true"] .inbound-totals-metrics,
.inbound-totals-metrics {
  display: contents;
}

.inbound-multirow-footer[data-has-weight-column="true"] .inbound-totals-qty,
.inbound-multirow-footer[data-has-weight-column="true"] .inbound-totals-qty-cell,
.inbound-totals-qty,
.inbound-totals-qty-cell {
  grid-column: var(--qty-col);
}

.inbound-multirow-footer[data-has-weight-column="true"] .inbound-totals-weight,
.inbound-multirow-footer[data-has-weight-column="true"] .inbound-totals-weight-cell,
.inbound-totals-weight,
.inbound-totals-weight-cell {
  grid-column: var(--weight-col);
}

/* --------------------------------------------------------------------------
   5. Metrics Section for Datasets without Weight Column (data-has-weight-column="false")
   - .inbound-totals-metrics occupies qty grid column: var(--qty-col)
   - Stacks visible quantity and weight summaries within that same grid cell
   - Weight is never placed under supplier
   -------------------------------------------------------------------------- */
.inbound-multirow-footer[data-has-weight-column="false"] .inbound-totals-metrics,
.inbound-multirow-footer.cols-8 .inbound-totals-metrics {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  grid-column: var(--qty-col);
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  gap: 2px;
  text-align: right;
}

.inbound-multirow-footer[data-has-weight-column="false"] .inbound-totals-metrics .inbound-totals-qty,
.inbound-multirow-footer[data-has-weight-column="false"] .inbound-totals-metrics .inbound-totals-weight,
.inbound-multirow-footer.cols-8 .inbound-totals-metrics .inbound-totals-qty,
.inbound-multirow-footer.cols-8 .inbound-totals-metrics .inbound-totals-weight {
  grid-column: auto;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

/* --------------------------------------------------------------------------
   6. Compact Vertical Label/Value Cell Stacks
   - Fits tightly within 76px (qty) and 84px (weight) grid tracks
   - No pill/chip horizontal width overflow
   - Text aligned right, matching numeric input fields in table rows above
   -------------------------------------------------------------------------- */
.inbound-totals-qty,
#inbound-totals-qty,
.inbound-totals-weight,
#inbound-totals-weight {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 0 2px;
  margin: 0;
  border: none;
  background: none;
  background-color: transparent;
  border-radius: 0;
  font-size: 10px;
  line-height: 1.15;
  color: var(--muted, #8d9bb3);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inbound-totals-val,
#inbound-totals-qty-val,
#inbound-totals-weight-val {
  display: block;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-family: var(--font-base);
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Quantity value: Primary Accent */
.inbound-totals-qty .inbound-totals-val,
#inbound-totals-qty-val {
  color: var(--accent, #5b90d6);
}

/* Weight value: Secondary Accent (clear separation from qty) */
.inbound-totals-weight .inbound-totals-val,
#inbound-totals-weight-val {
  color: var(--accent2, #4a8fa0);
}

/* --------------------------------------------------------------------------
   7. Light Theme Support ([data-theme="light"])
   - Clean professional navy & white palette
   - Opaque white surface to block scrolling rows
   -------------------------------------------------------------------------- */
[data-theme="light"] #inbound-multirow-footer.inbound-multirow-footer,
[data-theme="light"] .inbound-multirow-footer,
body[data-theme="light"] #inbound-multirow-footer,
body[data-theme="light"] .inbound-multirow-footer {
  background-color: var(--surface, #ffffff);
  color: var(--text, #16233d);
  border-top-color: var(--border, #d7dee8);
  border-bottom-color: transparent;
  border-left-color: transparent;
  border-right-color: transparent;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .inbound-totals-label,
[data-theme="light"] #inbound-totals-label,
body[data-theme="light"] .inbound-totals-label,
body[data-theme="light"] #inbound-totals-label {
  color: var(--navy, #14284a);
  background-color: rgba(43, 94, 163, 0.1);
  border-color: rgba(43, 94, 163, 0.28);
}

[data-theme="light"] .inbound-totals-count,
[data-theme="light"] #inbound-totals-count,
body[data-theme="light"] .inbound-totals-count,
body[data-theme="light"] #inbound-totals-count {
  background-color: rgba(91, 107, 133, 0.08);
  color: var(--muted, #5b6b85);
  border-color: rgba(91, 107, 133, 0.16);
}

[data-theme="light"] .inbound-totals-qty,
[data-theme="light"] #inbound-totals-qty,
[data-theme="light"] .inbound-totals-weight,
[data-theme="light"] #inbound-totals-weight,
body[data-theme="light"] .inbound-totals-qty,
body[data-theme="light"] #inbound-totals-qty,
body[data-theme="light"] .inbound-totals-weight,
body[data-theme="light"] #inbound-totals-weight {
  color: var(--muted, #5b6b85);
}

[data-theme="light"] .inbound-totals-qty .inbound-totals-val,
[data-theme="light"] #inbound-totals-qty-val,
body[data-theme="light"] .inbound-totals-qty .inbound-totals-val,
body[data-theme="light"] #inbound-totals-qty-val {
  color: var(--accent, #2b5ea3);
}

[data-theme="light"] .inbound-totals-weight .inbound-totals-val,
[data-theme="light"] #inbound-totals-weight-val,
body[data-theme="light"] .inbound-totals-weight .inbound-totals-val,
body[data-theme="light"] #inbound-totals-weight-val {
  color: var(--accent2, #2f8f5b);
}

/* --------------------------------------------------------------------------
   8. High Contrast & Focus-Independent Readability (forced-colors: active)
   - Supports Windows High Contrast / Forced Colors active modes
   - Legible and accessible without requiring hover or focus states
   -------------------------------------------------------------------------- */
@media (forced-colors: active) {
  #inbound-multirow-footer.inbound-multirow-footer,
  .inbound-multirow-footer {
    border-top: 2px solid CanvasText;
    border-bottom: 1px solid transparent;
    border-left: 1px solid transparent;
    border-right: 1px solid transparent;
    background-color: Canvas;
    color: CanvasText;
    box-shadow: none;
  }

  .inbound-totals-label,
  #inbound-totals-label,
  .inbound-totals-count,
  #inbound-totals-count {
    border: 1px solid CanvasText;
    background-color: Canvas;
    color: CanvasText;
  }

  .inbound-totals-qty .inbound-totals-val,
  #inbound-totals-qty-val,
  .inbound-totals-weight .inbound-totals-val,
  #inbound-totals-weight-val {
    color: Highlight;
  }
}

/* --------------------------------------------------------------------------
   9. Narrow Viewport & Horizontal Scroll Safety
   - Preserves grid tracks and horizontal scrolling alignment
   - Compact padding while ensuring 12px left/right alignment
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  #inbound-multirow-footer.inbound-multirow-footer,
  .inbound-multirow-footer {
    padding-top: 4px;
    padding-bottom: 4px;
    padding-left: 12px;
    padding-right: 12px;
    font-size: 11px;
  }

  .inbound-totals-leading {
    gap: 6px;
  }

  .inbound-totals-label,
  #inbound-totals-label {
    padding: 2px 7px;
    font-size: 11px;
  }

  .inbound-totals-val {
    font-size: 11.5px;
  }
}
