/*
 * Zone3Dplus Phase 3A.4 — equal-size upload/workspace panels.
 * Staging-only presentation overrides. Loaded after Phase 3A.3.
 * Existing R2 transfer events and native model cards are not changed.
 */

/* Desktop: equal WIDTHS, equal HEIGHTS, and aligned top/bottom edges. */
#m3dreader.step-0[data-z3d3a2-init="1"] #m3dreader__container {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  align-items: stretch !important;
  column-gap: 20px !important;
}

#m3dreader.step-0[data-z3d3a2-init="1"] .m3dreader__files-uploader--wrapper,
#m3dreader.step-0[data-z3d3a2-init="1"] .z3d3a-status {
  min-width: 0 !important;
  height: auto !important;
  min-height: 0 !important;
  align-self: stretch !important;
  box-sizing: border-box !important;
}

/* Keep "Your Workspace" and live counts. Remove ONLY highlighted guide copy. */
#m3dreader.step-0[data-z3d3a2-init="1"] .z3d3a-status-steps,
#m3dreader.step-0[data-z3d3a2-init="1"] .z3d3a-status-help {
  display: none !important;
}

/*
 * If many files are uploading, the transfer list scrolls within
 * "Upload your 3D models". The choose-files area, explanatory note,
 * live status tiles, and "Your Models" remain visible and unaffected.
 */
#m3dreader.step-0[data-z3d3a2-init="1"] .z3d3a2-transfer-box {
  min-width: 0 !important;
  max-width: 100% !important;
}
#m3dreader.step-0[data-z3d3a2-init="1"] .z3d3a2-transfer-list {
  display: grid !important;
  max-height: 218px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 5px;
  align-content: start;
}
#m3dreader.step-0[data-z3d3a2-init="1"] .z3d3a2-upload-item {
  min-width: 0;
}

/* A half-width desktop upload area must wrap controls instead of overflowing. */
@media (min-width: 981px) and (max-width: 1280px) {
  #m3dreader.step-0[data-z3d3a2-init="1"] .m3dreader__files-uploader {
    flex-wrap: wrap !important;
    gap: 9px 12px !important;
  }
  #m3dreader.step-0[data-z3d3a2-init="1"] .z3d3a-drop-cta {
    margin-left: 0 !important;
  }
  #m3dreader.step-0[data-z3d3a2-init="1"] .z3d3a-drop-hint {
    padding-left: 0 !important;
  }
}

/* Tablet and phone: preserve the established single-column flow. */
@media (max-width: 980px) {
  #m3dreader.step-0[data-z3d3a2-init="1"] #m3dreader__container {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 14px !important;
  }
  #m3dreader.step-0[data-z3d3a2-init="1"] .m3dreader__files-uploader--wrapper {
    order: 1 !important;
    width: 100% !important;
  }
  #m3dreader.step-0[data-z3d3a2-init="1"] .z3d3a-status {
    order: 2 !important;
    width: 100% !important;
  }
  #m3dreader.step-0[data-z3d3a2-init="1"] #m3dreader__model--uploaded:not(.hide) {
    order: 3 !important;
    width: 100% !important;
  }
  #m3dreader.step-0[data-z3d3a2-init="1"] .z3d3a2-transfer-list {
    max-height: 210px !important;
  }
}

/* Phase 3A.5: progressive workspace and user-selected note placement.
 * This file deliberately includes 3A.4 layout rules so it can be installed
 * directly after 3A.3, even if the earlier 3A.4 ZIP was not installed.
 * Only stage-0 presentation is affected. */

/* Before the first model, show only the upload panel at full width. */
#m3dreader.step-0[data-z3d3a2-init="1"][data-z3d3a5-active="0"] #m3dreader__container {
  grid-template-columns: minmax(0, 1fr) !important;
}
#m3dreader.step-0[data-z3d3a2-init="1"][data-z3d3a5-active="0"] .m3dreader__files-uploader--wrapper {
  grid-column: 1 / -1 !important;
}
#m3dreader.step-0[data-z3d3a2-init="1"][data-z3d3a5-active="0"] .z3d3a-status {
  display: none !important;
}

/* Once a model is selected, let the two panels stay equal and horizontal. */
@media (min-width: 981px) {
  #m3dreader.step-0[data-z3d3a2-init="1"][data-z3d3a5-active="1"] #m3dreader__container {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    align-items: stretch !important;
  }
  #m3dreader.step-0[data-z3d3a2-init="1"][data-z3d3a5-active="1"] .m3dreader__files-uploader--wrapper,
  #m3dreader.step-0[data-z3d3a2-init="1"][data-z3d3a5-active="1"] .z3d3a-status {
    align-self: stretch !important;
    height: auto !important;
    min-height: 0 !important;
  }
}

/* Only show the model grid once native model processing/analysis has started. */
#m3dreader.step-0[data-z3d3a2-init="1"][data-z3d3a5-models="0"] #m3dreader__model--uploaded {
  display: none !important;
}

/* Move the existing upload note below the two live counters. */
#m3dreader.step-0[data-z3d3a2-init="1"] .z3d3a-status .z3d3a5-workspace-note {
  margin: 15px 0 0 !important;
  padding: 13px 0 0 !important;
  border-top: 1px solid #e6ebf2 !important;
  color: #65748a !important;
  font: 500 12px/1.55 system-ui,-apple-system,'Segoe UI',sans-serif !important;
  overflow-wrap: anywhere;
}

/* Reduce scrolling while preserving the real per-file 0-100% upload list. */
#m3dreader.step-0[data-z3d3a2-init="1"] .z3d3a2-transfer-list {
  max-height: 180px !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
}

/* Tablets and phones retain the previous stacked arrangement. */
@media (max-width: 980px) {
  #m3dreader.step-0[data-z3d3a2-init="1"][data-z3d3a5-active="1"] #m3dreader__container {
    display: flex !important;
    flex-direction: column !important;
  }
  #m3dreader.step-0[data-z3d3a2-init="1"] .z3d3a2-transfer-list {
    max-height: 200px !important;
  }
}
