/* Point of Sale workspace */
.layout:has(.pos-workspace) > .sidebar,
.main:has(.pos-workspace) #menuBtn {
  display: none;
}

body[data-page="pos"] .main,
.main:has(.pos-workspace) {
  margin-inline-start: 0;
}

.main:has(.pos-workspace) .content {
  max-width: 1600px;
  padding-inline: clamp(12px, 2vw, 28px);
}

.main:has(.pos-workspace) .topbar .grow,
.main:has(.pos-workspace) #posQuick {
  display: none;
}

.main:has(.pos-workspace) .topbar #branchSel {
  margin-inline-end: auto;
  max-width: min(48vw, 200px);
}

.main:has(.pos-workspace) .topbar {
  padding-inline: clamp(12px, 2vw, 28px);
}

.pos-header {
  flex: 0 0 100%;
  min-width: 0;
}

.pos-header:empty {
  display: none;
}

.pos-header .pos-heading {
  max-width: 1544px;
  margin-inline: auto;
  padding: 8px 0 0;
  border: 0;
  border-block-start: 1px solid var(--line);
  border-radius: 0;
}

.pos-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--brand-text);
  font-weight: 800;
  font-size: 17px;
  text-decoration: none;
  white-space: nowrap;
  padding-inline-end: 12px;
  border-inline-end: 1px solid var(--line);
}

.pos-workspace {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  gap: 14px;
}

.pos-heading-actions,
.pos-shift,
.pos-cart-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pos-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "title actions" "search search";
  align-items: center;
  gap: 10px 16px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.pos-heading-title {
  grid-area: title;
  min-width: 0;
}

.pos-heading h1 {
  font-size: clamp(21px, 2vw, 28px);
  line-height: 1.25;
}

[dir="rtl"] :is(.pos-workspace, .pos-header) :is(h1, h2, h3) {
  letter-spacing: normal;
}

.pos-heading-actions {
  grid-area: actions;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.pos-product-search {
  grid-area: search;
  min-width: 0;
}

@media (min-width: 1100px) {
  .pos-heading {
    grid-template-columns: minmax(0, auto) minmax(270px, 1fr) auto;
    grid-template-areas: "title search actions";
  }
}

.pos-shift {
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.pos-shift b {
  color: var(--brand-text);
}

.pos-shift-closed b {
  color: var(--ink);
}

.pos-shift-dot {
  inline-size: 7px;
  block-size: 7px;
  border-radius: 50%;
  background: var(--ok);
}

.pos-shift-closed .pos-shift-dot {
  background: var(--danger);
}

.pos-shift button {
  min-height: 28px;
  color: var(--brand-text);
  padding-block: 2px;
}

:is(.pos-workspace, .pos-header) kbd {
  font: inherit;
  font-size: 11px;
  line-height: 1.5;
  padding-inline: 4px;
  border: 1px solid currentColor;
  border-radius: 4px;
  opacity: .75;
}

.pos-wrap {
  display: grid;
  flex: 1;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) clamp(310px, 34%, 420px);
  align-items: start;
  gap: 14px;
}

.pos-catalog,
.cart-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.pos-catalog {
  padding: 14px;
  scroll-margin-top: calc(var(--pos-header-height, 60px) + 12px);
}

.pos-search-controls,
.pos-search-filters {
  display: flex;
  gap: 6px;
}

.pos-search-field {
  flex: 1;
  min-width: 0;
  position: relative;
}

.pos-search-filters,
.pos-category-bar,
.pos-result-count,
.cart-head {
  flex: none;
}

.pos-search-field :is(.ic, kbd) {
  position: absolute;
  inset-block-start: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.pos-search-field .ic {
  inset-inline-start: 12px;
}

.pos-search-field kbd {
  inset-inline-end: 12px;
}

.pos-product-search #posSearch {
  min-height: 44px;
  padding-inline: 38px 44px;
}

body #posScanBarcode {
  min-height: 44px;
  white-space: nowrap;
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-text);
}

body #posScanBarcode:hover {
  background: var(--surface-2);
}

.pos-category-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 6px;
  margin-top: 10px;
}

body .pos-category-arrow {
  width: 30px;
  padding: 0;
}

#posCategoryOptions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

body #posCategoryOptions button {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 58px;
  padding: 4px;
  text-align: center;
  font-size: 12px;
  line-height: 1.3;
}

#posCategoryOptions span {
  overflow-wrap: anywhere;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

#posCategoryOptions .ic {
  color: var(--brand-text);
  flex: none;
}

.pos-category-bar button[aria-pressed="true"],
.pos-search-filters button[aria-pressed="true"] {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-text);
}

.pos-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.pos-pager[hidden] {
  display: none;
}

.pos-result-count {
  color: var(--muted);
  font-size: 12px;
  margin: 8px 0;
}

.prod-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: max-content;
  gap: 10px;
  padding: 3px;
}

body .prod-card {
  background: var(--surface);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: start;
  gap: 0;
  padding: 0;
  overflow: hidden;
  text-align: start;
  min-width: 0;
}

body .prod-card:hover:enabled {
  border-color: var(--brand);
  background: var(--brand-soft);
}

body .prod-card:disabled {
  opacity: 1;
}

.prod-card:disabled .pimg {
  opacity: .45;
}

.pimg-wrap {
  position: relative;
  display: block;
  background: var(--surface-2);
  min-height: 96px;
}

.pimg-wrap > .ic {
  position: absolute;
  top: 38%;
  inset-inline: 0;
  margin-inline: auto;
  color: var(--muted);
}

.pimg {
  position: relative;
  width: 100%;
  height: 96px;
  object-fit: cover;
  display: block;
}

.stock-badge {
  position: absolute;
  bottom: 5px;
  inset-inline-start: 5px;
  background: #182333;
  color: #fff;
  font-size: 11px;
  border-radius: 5px;
  padding: 2px 6px;
}

.stock-badge.low {
  background: #92400e;
}

.stock-badge.out {
  background: #991b1b;
}

.pbody {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  min-width: 0;
}

.pname {
  font-size: 13px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
  overflow-wrap: anywhere;
}

.prod-card .price {
  font-weight: 700;
  color: var(--brand-text);
  font-size: 14px;
}

.pmeta {
  font-size: 11px;
  color: var(--muted);
  overflow-wrap: anywhere;
  direction: ltr;
  text-align: start;
}

[dir="rtl"] .pmeta {
  text-align: right;
}

.pos-quantity input,
.pos-payment input {
  direction: ltr;
}

.cart-head,
.pos-cart-items,
.pos-cart-footer {
  padding: 12px 14px;
}

.cart-head {
  border-bottom: 1px solid var(--line);
}

.pos-cart-title {
  justify-content: space-between;
  margin-bottom: 10px;
}

.pos-cart-title h2 {
  margin: 0;
}

.pos-cart-title span,
.pos-line-name small,
.pos-empty {
  color: var(--muted);
  font-size: 12px;
}

.pos-cart-empty {
  min-height: 100%;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 8px;
  padding: 16px 6px;
  text-align: center;
  color: var(--muted);
}

.pos-cart-empty > .ic {
  color: var(--brand-text);
}

.pos-cart-empty strong {
  color: var(--ink);
}

.pos-cart-empty p {
  margin: 0;
  font-size: 13px;
}

.pos-empty {
  grid-column: 1 / -1;
  padding: 18px 10px;
  text-align: center;
}

.pos-cart-items {
  flex: 1;
  min-height: 100px;
  padding-block: 4px;
}

.pos-cart-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 10px;
  row-gap: 5px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.pos-line-name {
  display: grid;
  gap: 2px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.pos-line-total {
  text-align: end;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.pos-quantity {
  display: grid;
  grid-template-columns: 36px 72px 36px;
  gap: 4px;
  width: fit-content;
}

.pos-quantity input {
  text-align: center;
  padding-inline: 3px;
  appearance: textfield;
}

.pos-quantity input::-webkit-inner-spin-button,
.pos-quantity input::-webkit-outer-spin-button {
  appearance: none;
}

body .qtybtn,
body .pos-remove {
  min-width: 36px;
  padding: 0;
}

.pos-remove {
  justify-self: end;
  font-size: 19px;
}

.pos-cart-footer {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
}

.pos-cart-footer summary {
  cursor: pointer;
  color: var(--brand-text);
  font-weight: 600;
  padding-block: 7px;
}

.pos-discount-fields {
  padding: 6px 0;
}

.pos-discount-fields > div {
  display: flex;
  gap: 5px;
  margin-bottom: 6px;
}

.pos-discount-fields input {
  min-width: 0;
}

.pos-promos {
  color: var(--brand-text);
  font-size: 12px;
  padding-bottom: 4px;
}

.pos-totals {
  display: grid;
  gap: 3px;
  font-size: 12px;
  margin: 0;
}

.pos-totals > div {
  display: flex;
  gap: 6px;
  justify-content: space-between;
  color: var(--muted);
}

.pos-totals dd {
  margin: 0;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.pos-totals .grand {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  border-top: 1px solid var(--line);
  padding-top: 4px;
}

.pos-cart-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.pos-cart-actions button {
  flex: 1;
  padding-inline: 6px;
  white-space: nowrap;
}

body .pos-pay {
  width: 100%;
  justify-content: space-between;
  text-align: start;
  min-height: 50px;
  font-size: 16px;
  gap: 8px;
}

.pos-payment-bar {
  padding: 0 14px 12px;
  background: var(--surface);
  border-radius: 0 0 var(--radius) var(--radius);
}

[dir="rtl"] .pos-receipt {
  text-align: start;
}

.pos-pay small {
  display: block;
  font-size: 11px;
}

.pos-pane-controls,
.pos-mobile-action {
  display: none;
}

:is(.pos-workspace, .pos-header) :is(button, summary):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

@media (min-width: 760px) and (min-height: 460px) {
  .cart-panel {
    position: sticky;
    top: calc(var(--pos-header-height, 60px) + 12px);
  }

  .pos-payment-bar {
    position: sticky;
    bottom: 0;
  }
}

@media (max-width: 759px) {
  .main:has(.pos-workspace) .topbar {
    padding: 8px 10px;
    gap: 5px;
  }

  .main:has(.pos-workspace) .topbar #branchSel {
    flex: 1;
    min-width: 0;
    margin-inline-end: 0;
    padding-inline: 5px;
    font-size: 12px;
  }

  .pos-brand {
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    min-width: 30px;
    min-height: 36px;
    padding-inline-end: 0;
    border: 0;
    font-size: 10px;
    line-height: 1.1;
  }

  .pos-brand .brand-symbol {
    width: 22px;
    height: 22px;
  }

  .pos-heading {
    padding: 8px 10px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "title" "search" "actions";
  }

  .pos-heading-actions {
    justify-content: flex-start;
  }

  .main:has(.pos-workspace) .content {
    padding: 12px 10px;
  }

  .pos-workspace {
    gap: 8px;
  }

  .pos-heading-actions button {
    min-height: 40px;
    padding: 4px 8px;
    font-size: 12px;
  }

  :is(.pos-workspace, .pos-header) kbd {
    display: none;
  }

  .pos-wrap {
    grid-template-columns: minmax(0, 1fr);
  }

  .pos-pane-controls {
    display: flex;
    gap: 6px;
  }

  .pos-pane-controls > button {
    flex: 1;
    min-height: 42px;
  }

  .pos-pane-controls > [aria-pressed="true"] {
    background: var(--brand-soft);
    border-color: var(--brand);
    color: var(--brand-text);
  }

  .pos-workspace[data-pos-pane="products"] .cart-panel,
  .pos-workspace[data-pos-pane="cart"] :is(.pos-catalog, .pos-mobile-action) {
    display: none;
  }

  .pos-catalog {
    padding: 8px;
  }

  .pos-category-bar,
  #posCategoryOptions {
    gap: 4px;
  }

  body .pos-category-arrow {
    width: 24px;
  }

  body #posCategoryOptions button {
    font-size: 10px;
  }

  #posScanBarcode {
    font-size: 12px;
    padding-inline: 6px;
  }

  .prod-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  :is(.pos-workspace, .pos-header) :is(#posSearch, #cartCustSel, #couponIn, #invDisc, [data-qty]) {
    font-size: 16px;
  }

  .pos-product-search #posSearch {
    padding-inline-end: 10px;
  }

  .pos-mobile-action {
    display: block;
    z-index: 10;
    background: var(--bg);
    padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  }

  .pos-quantity {
    grid-template-columns: 44px 72px 44px;
  }

  .pos-quantity > *,
  body .pos-remove {
    min-height: 44px;
  }
  .pos-mobile-action,
  .pos-payment-bar {
    position: fixed;
    inset-inline: 10px;
    bottom: 0;
    z-index: 10;
  }

  .pos-payment-bar {
    padding: 6px 10px max(6px, env(safe-area-inset-bottom));
    border: 1px solid var(--line);
  }

  .pos-workspace {
    padding-bottom: 66px;
  }
}

/* Refund rows share the modal, rather than the checkout cart layout. */
.cart-line {
  display: flex;
  gap: 8px;
  align-items: center;
  border-bottom: 1px dashed var(--line);
  padding: 8px 0;
}

.pos-payment {
  display: grid;
  gap: 12px;
}

.pos-payment-heading,
.pos-payment-status > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.pos-payment-heading h3,
.pos-payment-heading strong {
  font-size: 20px;
  margin: 0;
}

.pos-payment-heading strong {
  color: var(--brand-text);
}

.pos-payment-customer {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.pos-payment-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 10px;
}

.pos-payment input:disabled {
  opacity: .55;
}

.pos-cash {
  margin: 0;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.pos-cash legend {
  padding-inline: 4px;
  font-size: 13px;
  font-weight: 600;
}

.pos-cash .denoms {
  margin-top: 8px;
}

.pos-payment-status {
  display: grid;
  gap: 4px;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin: 0;
}

.pos-payment-status dd {
  font-weight: 700;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.pos-payment-actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
}

.pos-payment-actions button {
  min-height: 46px;
}

@media (max-width: 400px) {
  .pos-payment-fields {
    gap: 8px;
  }

  .pos-payment select {
    padding-inline: 5px;
  }

  .pos-payment :is(input, select) {
    font-size: 16px;
  }

  .modal:has(.pos-payment) {
    padding: 12px;
  }
}
