/* =============================================================================
   css/screens/sell.css
   Where things go on the Sell screen (js/screens/sell.js) and inside the
   sheets it opens: the line editor (js/ui/line-editor.js), the payment sheet
   (js/ui/payment-sheet.js) and the bill discount sheet.

   Positioning only. The tiles, the bill line, the totals, the sheets, the
   segmented rows, the number pad and the amounts are all components in
   components.css; this file arranges them. Every value is a token
   (docs/05-ux-spec.md section 8, CLAUDE.md rule 9).
   ============================================================================= */


/* -----------------------------------------------------------------------------
   THE TWO COLUMNS
   docs/05-ux-spec.md section 4: the product browser on the left (60%), the
   bill on the right (40%). The whole thing fills the space under the header
   and never scrolls as a page; the tile grid and the bill lines scroll on
   their own inside their columns.
   ----------------------------------------------------------------------------- */

.sell {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: var(--space-4);
  height: 100%;
  min-height: 0;
  padding: var(--space-3) var(--space-4);
}

.sell__browser {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 0;
  min-width: 0;
}

.sell__browser-slot {
  flex: 1 1 auto;
  min-height: 0;
}

/* Park bill, the parked chips and Full load, along the bottom of the left
   column, where docs/05-ux-spec.md section 4 draws them. */
.sell__tools {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: none;
  min-width: 0;
}

.sell__parked {
  flex: 1 1 auto;
  min-width: 0;
}

.sell__parked:empty {
  display: none;
}


/* -----------------------------------------------------------------------------
   THE BILL PANEL
   A card: head, the lines (which scroll), the totals, then payment and Save
   pinned at the bottom.
   ----------------------------------------------------------------------------- */

.sell__bill {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.sell__bill-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: none;
  min-height: var(--tap-min);
  padding: 0 var(--space-3);
  border-bottom: var(--border-width) solid var(--color-border);
}

.sell__bill-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-line);
  font-weight: var(--font-bold);
}

.sell__bill-when {
  font-size: var(--text-body);
}

.sell__lines {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sell__empty {
  height: 100%;
  justify-content: center;
}

.sell__bill > .bill-totals {
  flex: none;
}

.sell__pay {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex: none;
  padding: var(--space-3);
}

.sell__actions {
  display: flex;
  gap: var(--space-3);
}

/* Save is the primary action of the whole screen: 64px tall (rule 2.2) and
   it takes the room; New sits beside it. */
.sell__save {
  flex: 3 1 0;
  min-height: var(--tap-primary);
  font-size: var(--text-line);
}

.sell__new {
  flex: 1 1 0;
  min-height: var(--tap-primary);
}


/* -----------------------------------------------------------------------------
   THE UNIT CHOOSER (SELL-05)
   A dialog with one big option per selling unit.
   ----------------------------------------------------------------------------- */

.unit-chooser .dialog__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-bottom: var(--space-5);
}


/* -----------------------------------------------------------------------------
   THE LINE EDITOR (SELL-06, SELL-07)
   Fields on the left, the line total and the number pad on the right, the
   buttons under the pad.
   ----------------------------------------------------------------------------- */

.line-editor__columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-5);
  align-items: start;
}

.line-editor__fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.line-editor__side {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: max-content;
}

.line-editor__total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
  padding: 0 var(--space-2);
  font-size: var(--text-heading);
  font-weight: var(--font-bold);
}

/* The two choices under Price and the Rs / % switch under Discount sit
   tucked under their box, a little inset so they read as belonging to it. */
.line-editor__scope,
.line-editor__mode {
  margin: calc(-1 * var(--space-2)) 0 0 var(--space-4);
}

.line-editor__units {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.line-editor__status,
.payment-sheet__status {
  margin: 0;
  color: var(--color-text-muted);
}

.payment-sheet__status {
  margin-top: var(--space-3);
}

.line-editor__status.is-danger,
.payment-sheet__status.is-danger {
  padding: var(--space-2) var(--space-3);
  color: var(--color-danger);
  font-weight: var(--font-medium);
  background: var(--color-danger-faint);
  border-radius: var(--radius-sm);
}

/* "100% (Rs 900.00) off. Tap again if that is right" (SELL-06, SELL-08),
   and "No commission… Tap again" on the Full load sheet (COMM-01). */
.line-editor__status.is-warning,
.discount-sheet__status.is-warning,
.load-sheet__status.is-warning {
  padding: var(--space-2) var(--space-3);
  color: var(--color-warning);
  font-weight: var(--font-medium);
  background: var(--color-warning-faint);
  border-radius: var(--radius-sm);
}

.discount-sheet__status {
  margin: 0;
}

/* "That comes to 13.2 pcs, not whole pieces." */
.amount__hint[data-kind='warning'] {
  color: var(--color-warning);
  font-weight: var(--font-medium);
}


/* -----------------------------------------------------------------------------
   THE PAYMENT SHEET (PAY-01, PAY-02)
   ----------------------------------------------------------------------------- */

.payment-sheet__body {
  padding-top: var(--space-4);
}

.payment-sheet__columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-5);
  align-items: start;
}

.payment-sheet__fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

/* Transfer and Credit have no pad, so one column of a comfortable width. */
.payment-sheet__fields--single {
  max-width: 560px;
}

.payment-sheet__quick {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Split: the three parts side by side. */
.payment-sheet__parts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.customer-picker {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.customer-picker__chosen {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.customer-picker__find,
.customer-picker__new {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.customer-picker__new .row {
  display: flex;
  gap: var(--space-3);
}

.customer-picker__new .row > .btn--primary {
  flex: 2 1 0;
}


/* -----------------------------------------------------------------------------
   THE BILL DISCOUNT SHEET (SELL-08)
   ----------------------------------------------------------------------------- */

.discount-sheet__columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-5);
  align-items: start;
  padding-top: var(--space-4);
}

.discount-sheet__fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}


/* -----------------------------------------------------------------------------
   THE FULL LOAD SHEET (SELL-14, COMM-01), js/ui/commission-sheet.js
   The fields on the left, the pad and the two buttons on the right, as the
   discount and payment sheets. The two figures sit side by side, each a
   tappable amount that the pad types into. On a narrow screen the pad
   drops under the fields.
   ----------------------------------------------------------------------------- */

.load-sheet__columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-5);
  align-items: start;
  padding-top: var(--space-3);
}

.load-sheet__fields,
.load-sheet__side {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.load-sheet__figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

/* A picked item has three: how many loads, and the two prices. */
.load-sheet__figures[data-count='3'] {
  grid-template-columns: minmax(0, 0.7fr) repeat(2, minmax(0, 1fr));
}

/* The search box beside one sideways-swiping row of load tiles. */
.load-sheet__tiles {
  padding-top: var(--space-2);
}

.load-sheet__chosen {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}

.load-sheet__chosen-name {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-line);
  font-weight: var(--font-bold);
}

.load-sheet__choices {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.load-sheet__choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.load-sheet__choice-label {
  font-size: var(--text-small);
  color: var(--color-text-muted);
}

/* Supplier, address, site phone: the supplier's name needs the room. */
.load-sheet__where {
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.2fr) minmax(0, 1fr);
}

.load-sheet__empty {
  padding: var(--space-5) 0;
}

.load-sheet__status {
  margin: 0;
}

.load-sheet__status.is-danger {
  padding: var(--space-2) var(--space-3);
  color: var(--color-danger);
  font-weight: var(--font-medium);
  background: var(--color-danger-faint);
  border-radius: var(--radius-sm);
}

@media (max-width: 767px) {
  .load-sheet__columns {
    grid-template-columns: 1fr;
  }
}

/* While a load's figures are on screen the sheet stands at its full height
   (data-steady, js/ui/commission-sheet.js). A bottom sheet grows upwards,
   so a warning line appearing under the figures used to lift the pad by a
   line mid-number and the next tap landed on the wrong key (Shehan, on the
   tablet, 27 September 2026). The pad's column starts at the top and the
   fields grow downwards on the left, so the keys never move. */
.load-sheet[data-steady] {
  height: calc(var(--app-height, 100dvh) - var(--tap-min));
}
