/* nti_receipt_builder — builder and print surfaces.
   Assumes Tabler 1.x is present in the host layout for card/button/form chrome;
   everything receipt-specific is defined here.

   Geometry is deliberately absent from the shared element classes: position and size
   always arrive inline from the builder JS or the print presenters, so builder-only
   affordances stay scoped under `.nrb-receipt-paper-elements` and never leak into the
   preview/print render partials that reuse the same bare class names. */

/* Theming: set --nrb-accent (and --nrb-accent-rgb for the translucent fills) to tint the
   builder's selection and palette affordances. Both fall back to Tabler's primary. */

/* ---- Page header shared by the editor and preview pages ---- */
.nrb-receipt-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.nrb-receipt-topbar-name {
  font-size: 1.3rem; font-weight: 800;
  letter-spacing: -0.01em; color: var(--tblr-dark);
  margin-right: 0.75rem;
}

/* ---- 3-column editor layout: settings+elements / canvas / properties ---- */
.nrb-receipt-builder {
  display: grid;
  grid-template-columns: minmax(0, 18rem) minmax(0, 1fr) minmax(0, 19rem);
  gap: 1.25rem;
  align-items: start;
}
.nrb-receipt-builder-side { display: flex; flex-direction: column; gap: 1.25rem; }
@media (max-width: 1200px) {
  .nrb-receipt-builder { grid-template-columns: 1fr; }
  .nrb-receipt-builder-side { flex-direction: row; flex-wrap: wrap; }
  .nrb-receipt-builder-side > .nrb-receipt-panel { flex: 1 1 16rem; }
}

/* ---- Shared glass-panel chrome for the editor's 4 panels ---- */
.nrb-receipt-panel {
  position: relative;
  border-radius: var(--tblr-card-border-radius, 1.25rem);
  padding: 1.25rem;
  background: #fff;
  border: 1px solid rgba(31, 41, 55, 0.06);
  box-shadow: 0 1.25rem 2.5rem -1.5rem rgba(31, 41, 55, 0.25);
  height: auto;
}
.nrb-receipt-panel .card-title { margin-bottom: 0.85rem; }
.nrb-receipt-panel--canvas { display: flex; flex-direction: column; gap: 1rem; height: auto; }
.nrb-receipt-hint { font-size: 0.82rem; margin: 0.5rem 0 0; }

/* ---- Elements palette (draggable variable/block buttons) ---- */
.nrb-receipt-palette-group + .nrb-receipt-palette-group { margin-top: 1.25rem; }
.nrb-receipt-palette-label {
  display: block;
  font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--tblr-secondary);
  margin-bottom: 0.6rem;
}
.nrb-receipt-palette { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.nrb-receipt-palette-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.8rem; font-weight: 600;
  color: var(--tblr-dark);
  background: rgba(var(--nrb-accent-rgb, var(--tblr-primary-rgb)), 0.07);
  border: 1px solid rgba(var(--nrb-accent-rgb, var(--tblr-primary-rgb)), 0.15);
  border-radius: 0.8rem;
  padding: 0.4rem 0.7rem;
  cursor: grab;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.nrb-receipt-palette-btn .material-symbols-outlined {
  font-size: 18px;
  color: var(--nrb-accent, var(--tblr-primary));
}
.nrb-receipt-palette-btn:hover {
  transform: translateY(-1px);
  background: rgba(var(--nrb-accent-rgb, var(--tblr-primary-rgb)), 0.14);
  box-shadow: 0 0.5rem 1rem -0.6rem rgba(var(--nrb-accent-rgb, var(--tblr-primary-rgb)), 0.6);
}
.nrb-receipt-palette-btn:active { cursor: grabbing; }

/* ---- Canvas toolbar (title + zoom control) ---- */
.nrb-receipt-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.nrb-receipt-zoom { display: flex; align-items: center; gap: 0.5rem; color: var(--tblr-secondary); }
.nrb-receipt-zoom input[type="range"] { width: 8rem; }
.nrb-receipt-zoom-label {
  font-size: 0.8rem; font-weight: 700;
  color: var(--tblr-dark);
  min-width: 2.5rem; text-align: right;
}

/* ---- Scrollable canvas viewport + the builder-only paper surface.
        `.nrb-receipt-paper-render` (preview/print) is a separate class —
        the builder's `.nrb-receipt-paper` never appears in rendered output. ---- */
.nrb-receipt-viewport {
  flex: 1 1 auto;
  min-height: 28rem;
  overflow: auto;
  padding: 2rem;
  background: rgba(31, 41, 55, 0.03);
  border: 1px solid rgba(31, 41, 55, 0.06);
  border-radius: 1rem;
}
.nrb-receipt-paper {
  position: relative;
  margin: 0 auto;
  background: #fff;
  border: 1px solid rgba(31, 41, 55, 0.1);
  box-shadow: 0 1.25rem 2.5rem -1.5rem rgba(31, 41, 55, 0.3);
}
/* margin guides: a visual-only inset overlay, never intercepts pointer events */
.nrb-receipt-paper-margins {
  position: absolute;
  border: 1px dashed rgba(var(--tblr-primary-rgb), 0.35);
  pointer-events: none;
}
.nrb-receipt-paper-elements { position: absolute; inset: 0; }

/* ---- Canvas element — base rule is shared with the render/print partials,
        so it must stay geometry-agnostic (position/left/top/width/height
        are always supplied inline, either by receipt_canvas_controller.js
        or by NtiReceiptBuilder::Presenters::Element#css_style / paper_style). ---- */
.nrb-receipt-element {
  position: absolute;
  box-sizing: border-box;
  overflow: hidden;
  word-break: break-word;
}
.nrb-receipt-element-body { width: 100%; height: 100%; overflow: hidden; pointer-events: none; }

/* Builder-only interactive affordances — scoped so they never leak into
   the preview/print pages, which reuse the bare `.nrb-receipt-element`. */
.nrb-receipt-paper-elements .nrb-receipt-element {
  cursor: move;
  touch-action: none;
  user-select: none;
  transition: outline-color 0.15s ease;
}
.nrb-receipt-paper-elements .nrb-receipt-element:hover {
  outline: 1px dashed rgba(var(--tblr-primary-rgb), 0.4);
  outline-offset: 1px;
}
.nrb-receipt-paper-elements .nrb-receipt-element--selected {
  outline: 2px solid var(--nrb-accent, var(--tblr-primary));
  outline-offset: 1px;
}
.nrb-receipt-paper-elements .nrb-receipt-element--hidden {
  opacity: 0.4;
  outline: 1px dashed rgba(31, 41, 55, 0.35);
  outline-offset: 1px;
}
.nrb-receipt-paper-elements .nrb-receipt-element-dragging,
.nrb-receipt-paper-elements .nrb-receipt-element-resizing {
  box-shadow: 0 0.75rem 1.5rem -0.75rem rgba(31, 41, 55, 0.45);
  cursor: grabbing;
}
.nrb-receipt-resize-handle {
  position: absolute;
  right: -5px; bottom: -5px;
  width: 0.7rem; height: 0.7rem;
  border-radius: 999px;
  background: var(--nrb-accent, var(--tblr-primary));
  border: 2px solid #fff;
  box-shadow: 0 0.15rem 0.4rem rgba(31, 41, 55, 0.35);
  cursor: nwse-resize;
  touch-action: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.nrb-receipt-paper-elements .nrb-receipt-element:hover .nrb-receipt-resize-handle,
.nrb-receipt-paper-elements .nrb-receipt-element--selected .nrb-receipt-resize-handle {
  opacity: 1;
}

/* ---- Order-lines block — shared between the builder placeholder and the
        real render partial; `-empty` only ever appears in rendered output. ---- */
.nrb-receipt-order-lines { display: block; width: 100%; }
/* `table-layout: fixed` + percentage <col> widths is what makes a row span the
   element edge-to-edge; row height comes from the inline line-height so rows
   sit directly under one another instead of in tall centred boxes. */
.nrb-receipt-order-lines-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}
/* Cells wrap rather than truncate: a receipt that hides half a product name is worse than one
   that runs to a second line. `overflow-wrap: break-word` only splits a word that cannot fit its
   column on its own — an unbroken SKU in a narrow column — so ordinary text still breaks at
   spaces. Matches `.nrb-receipt-element`, which has wrapped all along. */
.nrb-receipt-order-lines-table th,
.nrb-receipt-order-lines-table td {
  padding: 0;
  white-space: normal;
  overflow-wrap: break-word;
  vertical-align: top;
}
.nrb-receipt-order-lines-header th {
  font-weight: 700;
  border-bottom: 1px solid rgba(31, 41, 55, 0.18);
}
.nrb-receipt-order-lines-empty td { text-align: center; }

/* ---- Properties panel read-only column summary table ---- */
.nrb-receipt-columns-table { font-size: 0.8rem; }
.nrb-receipt-columns-table th {
  color: var(--tblr-secondary);
  font-weight: 700; text-transform: uppercase;
  font-size: 0.68rem; letter-spacing: 0.04em;
}

/* ---- Preview / print. `.nrb-receipt-paper-render`'s on-screen elevation
        (margin/border/box-shadow) is reset to nothing by print.html.erb's
        inline <style>, since the printed page must be the bare receipt. ---- */
.nrb-receipt-preview-frame {
  padding: 2rem;
  background: rgba(31, 41, 55, 0.03);
  border-radius: 1.25rem;
  overflow-x: auto;
}
.nrb-receipt-paper-render {
  position: relative;
  margin: 0 auto;
  background: #fff;
  border: 1px solid rgba(31, 41, 55, 0.08);
  box-shadow: 0 1.25rem 2.5rem -1.5rem rgba(31, 41, 55, 0.3);
}
.nrb-receipt-overflow-banner { margin-bottom: 1.25rem; }
.nrb-receipt-preview-modal .nrb-receipt-preview-frame { max-height: 65vh; overflow-y: auto; }

.btn-xs {
  padding: 0.15rem 0.4rem;
  border:none;
  box-shadow: none;
}

.material-symbols-outlined{
  font-size: 18px;
}