/*
 * The cashier's screens: right to left, Arabic first, built for a finger on a counter tablet — large targets,
 * high contrast, nothing that needs a hover. No inline style anywhere (the CSP allows styles from the till's own
 * files only) and no colour literal in this file: every colour is a token of tokens.css (POS-UX1), so the
 * light and dark themes and the six accents apply to the shift, refund and back-office screens as to the sale.
 *
 * The sale screen's own layouts are sale.css; its sheets and keypad, overlay.css; the settings preview, look.css.
 */

:root {
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: var(--t-body-lh);
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.bar {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  min-height: 3.25rem;
  padding: 0.4rem 1rem;
  background: var(--surface);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.bar__brand {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  color: var(--ink);
}
.bar__mark {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  background: url('/brand/mark.svg') center / contain no-repeat;
}
.bar__where,
.bar__who {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  color: var(--ink-soft);
}

.stage {
  flex: 1;
  min-height: 0;
  padding: 1rem;
}

.card {
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  max-width: 64rem;
  margin: 0 auto;
}
.card--narrow {
  max-width: 30rem;
}

h1 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
}
h2 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.5rem;
}

.muted {
  color: var(--ink-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: var(--tap);
  padding: 0 1.25rem;
  margin: 0.25rem;
  border: 1px solid var(--line-control);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:focus-visible,
.tile:focus-visible,
.link:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn--danger {
  background: var(--surface);
  border-color: var(--stop);
  color: var(--stop);
}
.btn--big {
  min-height: var(--tap-pay);
  font-size: 1.2rem;
}
.btn--huge {
  min-height: 6rem;
  min-width: 12rem;
  font-size: 1.6rem;
}
.btn--small {
  min-height: var(--tap-sm);
  font-size: 0.95rem;
}
.link {
  background: none;
  border: 0;
  color: inherit;
  text-decoration: underline;
  font: inherit;
  cursor: pointer;
}
.link--tap,
.bar .link {
  min-height: var(--tap-sm);
  min-width: var(--tap-sm);
  padding: 0 0.5rem;
}
/* r40 (M5): a till's auto-print setting: its state in words, and a toggle of its own beside it. */
.switch {
  display: inline-flex;
  gap: 0.4rem;
  align-items: baseline;
  margin-inline-start: 0.5rem;
  padding-inline-start: 0.5rem;
  border-inline-start: 1px solid var(--line);
}
.switch__state {
  font-weight: 600;
}
.switch[data-state='off'] .switch__state {
  font-weight: 400;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: flex-start;
  min-height: 7rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: start;
  cursor: pointer;
  touch-action: manipulation;
}

.chip {
  padding: 0.1rem 0.5rem;
  border-radius: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.85rem;
}
.chip--open {
  background: var(--good-bg);
  color: var(--good-ink);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
}
/* a field the screen hides is hidden: `.form label`'s flex outranked the attribute (browser drive defects 3 and 6) */
.form label[hidden] {
  display: none;
}
input,
select,
textarea {
  min-height: var(--tap);
  padding: 0 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1.25rem;
}

.notice {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border-inline-start: 4px solid var(--stop);
  background: var(--stop-bg);
  color: var(--ink);
}
.notice--info {
  border-color: var(--info);
  background: var(--info-bg);
}
.notice--warn {
  border-color: var(--info);
  background: var(--info-bg);
  font-weight: 600;
}
.notice--good {
  border-color: var(--good-ink);
  background: var(--good-bg);
}

.z {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0 1rem;
}
.z th,
.z td {
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--line);
  text-align: start;
}
.z td {
  text-align: end;
}
.z__total th,
.z__total td {
  font-weight: 700;
  font-size: 1.1rem;
}

.carts {
  list-style: none;
  padding: 0;
}
.carts li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--line);
}

.check {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

/* ------------------------------------------------------------- receipt -- */
/*
 * The receipt lives off screen and is what prints (owner-delegated decision
 * 11): an 80 mm roll by default, 58 mm as the device's option. No QR.
 * It is paper: its ink and its page are the slip tokens, whatever the theme.
 */
.receipt {
  display: none;
}
.slip {
  font-size: 11pt;
  line-height: 1.35;
  color: var(--slip-ink);
}
.slip h2 {
  font-size: 12pt;
  margin: 0.4em 0;
}
.slip__head {
  text-align: center;
  border-bottom: 1px dashed var(--slip-ink);
  padding-bottom: 0.4em;
}
.slip__small {
  font-size: 8.5pt;
}
/* Till UX slice 5: the receipt's optional English line, under its Arabic label */
.slip__en {
  display: block;
  font-size: 7.5pt;
  font-weight: 400;
}
.slip__lines,
.slip__totals {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.4em;
}
.slip__lines th,
.slip__lines td,
.slip__totals th,
.slip__totals td {
  padding: 0.15em 0;
  text-align: start;
  vertical-align: top;
}
.slip__lines td:last-child,
.slip__totals td {
  text-align: end;
}
/* Till UX slice 1: the quantity and the amount of a line are cells of the slip's own direction, apart from each other —
   «1 × 16.00 ر.س» never runs into the line's total. */
.slip__lines .slip__num {
  white-space: nowrap;
  padding-inline-start: 0.6em;
}
/* Restaurant R4 review U-L6: a long label wraps; an amount never breaks inside itself. */
.slip__totals th {
  overflow-wrap: anywhere;
}
.slip__totals td {
  white-space: nowrap;
  padding-inline-start: 0.5em;
}
.slip__grand th,
.slip__grand td {
  font-weight: 700;
  border-top: 1px dashed var(--slip-ink);
}
.slip__foot {
  border-top: 1px dashed var(--slip-ink);
  margin-top: 0.4em;
  font-size: 8.5pt;
}

@media print {
  @page {
    size: 80mm auto;
    margin: 3mm;
  }
  /* The 58 mm roll: a named page the receipt opts into. */
  @page roll58 {
    size: 58mm auto;
    margin: 3mm;
  }
  body {
    background: var(--slip-paper);
  }
  .bar,
  .stage {
    display: none;
  }
  .receipt {
    display: block;
    width: 74mm;
  }
  .receipt--58 {
    page: roll58;
    width: 52mm;
  }
  .receipt--58 .slip {
    font-size: 9pt;
  }
}

/* ---- Cashier batch B: the back-office ------------------------------------ */

.office {
  max-width: 72rem;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--line);
  padding-bottom: 0.5rem;
}

.tab {
  min-height: var(--tap);
  padding: 0 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--raised);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.tab--on {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.tab--back {
  margin-inline-start: auto;
}

.tab:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  background: var(--raised);
}

.table th,
.table td {
  text-align: start;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table th {
  color: var(--ink-soft);
  font-weight: 600;
}

.row--off td {
  color: var(--ink-soft);
}

.row--low td {
  background: var(--row-low);
}

.chip--low {
  background: var(--stop-bg);
  color: var(--stop);
  border-color: var(--stop);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.inline-form {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
  background: var(--raised);
}

.office__forms {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 1rem;
}

.field-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin: 0.5rem 0;
}

/* ---- Cashier P6: the setup wizard ---------------------------------------- */

.steps {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  display: grid;
  gap: 0.4rem;
}

.step {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--raised);
}

.step__mark {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--line);
  font-weight: 700;
}

.step--done .step__mark {
  background: var(--good-ink);
  color: var(--surface);
}

.step--now {
  border-color: var(--accent);
  box-shadow: inset 0.3rem 0 0 var(--accent);
}

/* ---- Cashier P7: a refund from the till, and parked carts ------------------ */

.card--inset {
  margin: 1rem 0;
  border-inline-start: 4px solid var(--accent);
}

/* The Z report's flag: a refund the sole operator approved himself is never quiet. */
.z__flag th,
.z__flag td {
  font-weight: 700;
  color: var(--stop);
}

.check label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-inline-end: 1rem;
}

/* ---- Cashier P8: discounts at the till ------------------------------------- */

.discount .choice {
  display: flex;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  border: 0;
}

/* The Z's discount rows under their total: quieter than the total, never hidden. */
.z__sub th {
  padding-inline-start: 1.25rem;
  font-weight: 400;
}

/* ---- Cashier P9: the X and Z slips and the reports --------------------------- */

.slip__sub th {
  padding-inline-start: 1rem;
  font-weight: 400;
}

/* The slip as the screen previews it: the receipt's own width, centred, on the card. It is paper too. */
.slip-preview {
  max-width: 24rem;
  margin: 0 auto 1rem;
  padding: 0.75rem;
  border: 1px dashed var(--line-strong);
  background: var(--slip-paper);
  color: var(--slip-ink);
}

/* ---- r38: the till's own dialogs, and the switched-off action ------------------ */

.dialog-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
}

.dialog-backdrop {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--scrim);
}

.dialog {
  width: min(100%, 30rem);
  max-height: 100%;
  overflow: auto;
  padding: 1.25rem;
  border-radius: var(--radius);
  background: var(--raised);
  color: var(--ink);
  box-shadow: 0 0.75rem 2rem var(--shadow);
}

.dialog h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.dialog__message {
  margin: 0 0 1rem;
  line-height: 1.7;
}

.dialog__field {
  display: block;
  margin-bottom: 0.5rem;
}

.dialog__field input,
.dialog__field textarea {
  display: block;
  width: 100%;
  min-height: var(--tap);
  margin-top: 0.35rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.dialog__error {
  min-height: 1.4rem;
  color: var(--stop);
}

.dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: flex-start;
  margin-top: 0.75rem;
}

/* Till UX slice 4: a dialog's answers are pinned to its foot — a long slip preview scrolls, «طباعة» and «إغلاق»
   stay in view at 1024×768 and 800×600 (they were cut below the fold). */
.dialog__actions {
  position: sticky;
  bottom: -1.25rem;
  margin: 0.75rem -1.25rem -1.25rem;
  padding: 0.6rem 1.25rem 1.25rem;
  background: var(--raised);
  border-block-start: 1px solid var(--line);
}

.action-off {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
}

@media print {
  .dialog-layer {
    display: none;
  }
  /* Restaurant R3 review (found in the lab drive): a screen that lays its stage out (the sale screen, the board)
     must not print it — only the print area prints, on a page as long as it is. Stronger than any screen's rule. */
  html body[data-screen] > main.stage,
  html body[data-screen] > header.bar {
    display: none;
  }
  html body[data-screen] {
    display: block;
    block-size: auto;
    min-block-size: 0;
    overflow: visible;
  }
}

@media (max-width: 30rem) {
  .stage {
    padding: 0.5rem;
  }
  .bar {
    padding: 0.35rem 0.6rem;
    gap: 0.5rem;
  }
  .bar__brand strong,
  .bar__where .muted {
    display: none;
  }
  .card {
    padding: 0.9rem;
  }
  .table {
    display: block;
    overflow-x: auto;
  }
}

/* r42a L4: a radio choice is a 44px touch target, and its mark is not a pin-head */
.radio-tap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--tap-sm);
  padding-inline: 0.5rem;
  cursor: pointer;
}
.radio-tap input {
  inline-size: 1.5rem;
  block-size: 1.5rem;
  margin: 0;
}
