/* ============================================================================
   RESPONSIVE ADDITIONS (see the breakpoint legend at the top of this file).
   Editor stacking + touch reorder, dense-row wrapping, popover clamps, and
   invoice-preview reflow. Desktop (>=1024px) is unaffected.
   ============================================================================ */

/* ---- Invoice editor: Edit/Preview toggle (shown only on tablet/phone) ---- */
.editor-viewtab {
  display: none;
  margin-left: auto;
  gap: 2px;
  padding: 3px;
  background: var(--panel-subtle);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.editor-viewtab-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  font-size: 13px;
  padding: 6px 16px;
  border-radius: 999px;
  cursor: pointer;
}

/* Ink, not the brand colour: Built for Shopify keeps controls in Polaris's
   colours, and the brand belongs on the document. */
.editor-viewtab-btn.is-active {
  background: var(--text);
  color: #fff;
}

/* ---- Toolbars wrap instead of overflowing ---- */
.toolbar {
  flex-wrap: wrap;
}

/* ---- lg: stack the two-pane template editors and reveal the view toggle ---- */
@media (max-width: 1023px) {
  .editor-viewtab {
    display: inline-flex;
  }

  /* Both editors: the invoice preview and the packing sheet are the same pane
     in this layout, so the toggle has to know about both. */
  .split-layout[data-editor-view="edit"] .template-preview,
  .split-layout[data-editor-view="edit"] .pack-editor-preview {
    display: none;
  }

  .split-layout[data-editor-view="preview"] .invoice-editor-shell {
    display: none;
  }
}

/* ---- md: dense editor rows wrap so their controls stop overflowing ---- */
@media (max-width: 767px) {
  .column-item,
  .order-item,
  .cf-item,
  .cs-item .cs-top {
    flex-wrap: wrap;
  }

  .column-item .col-label {
    flex: 1 1 100%;
  }

  .style-tool-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- sm: invoice preview sheet reflows for phones ---- */
@media (max-width: 639px) {
  .print-sheet {
    padding: 16px;
  }

  /* Let a wide line-item table scroll within the sheet rather than bleed off. */
  .template-preview {
    overflow-x: auto;
  }

  .preview-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

}

/* Invoice line-item columns need horizontal breathing room. Cells have no
   inline padding by default, so a right-aligned Qty butts against a
   right-aligned Rate ("3$32.00"). Add a gap before every column after the
   first; outer edges stay flush with the rest of the sheet. Placed last (and
   scoped via .template-preview) so it wins over the per-density / per-template
   padding shorthands that would otherwise reset padding-left to 0. */
.template-preview .preview-line-items th:not(:first-child),
.template-preview .preview-line-items td:not(:first-child) {
  padding-left: 16px;
}

