/* =============================================================================
   css/screens/bills.css
   Where things go on the bill history screen (js/screens/bills.js): the
   list with its filters, and the bill detail (BILL-01 to BILL-05).

   Tablet and laptop (768px and up): list on the left, the chosen bill on
   the right, both scrolling on their own. Phone: one at a time; #/bills is
   the list, #/bills/:id is the bill with a back arrow (docs/05-ux-spec.md
   section 3, PWA-03).

   Positioning only. The rows, badges, timeline, bill lines and summary
   are components in components.css; every value here is a token
   (docs/05-ux-spec.md section 8, CLAUDE.md rule 9).
   ============================================================================= */


/* -----------------------------------------------------------------------------
   THE TWO PANES
   ----------------------------------------------------------------------------- */

.bills {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: var(--space-4);
  height: 100%;
  min-height: 0;
  padding: var(--space-3) var(--space-4);
}

.bills__list,
.bills__detail {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Phone: one pane fills the screen; which one is data-mode on the root. */
@media (max-width: 767px) {
  .bills {
    display: block;
    height: auto;
    padding: var(--space-3);
  }

  .bills[data-mode='list'] .bills__detail,
  .bills[data-mode='detail'] .bills__list {
    display: none;
  }

  .bills__list,
  .bills__detail {
    overflow: visible;
  }
}

/* The back arrow is only for a phone; on a tablet the list is beside. */
.bills__back {
  align-self: flex-start;
}

@media (min-width: 768px) {
  .bills__back {
    display: none;
  }
}


/* -----------------------------------------------------------------------------
   THE LIST: title row, filters, results
   ----------------------------------------------------------------------------- */

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

.bills__title h1 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--text-heading);
}

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

/* Two dropdowns side by side; on a phone they stack. */
.bills__selects {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

@media (max-width: 480px) {
  .bills__selects {
    grid-template-columns: 1fr;
  }
}

/* From and to, when "Pick dates" is chosen. */
.bills__dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  align-items: end;
}

/* Never shrunk: the column scrolls as a whole, so the count line always
   sits under the last row rather than over it. */
.bills__results {
  flex: none;
}

.bills__count {
  flex: none;
  font-size: var(--text-small);
}


/* -----------------------------------------------------------------------------
   THE DETAIL: a card with the bill in it
   ----------------------------------------------------------------------------- */

.bills__card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.bills__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.bills__no {
  margin: 0;
  font-size: var(--text-heading);
  font-weight: var(--font-bold);
  font-variant-numeric: tabular-nums;
}

.bills__total-figure {
  font-size: var(--text-heading);
  font-weight: var(--font-bold);
  white-space: nowrap;
}

.bills__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  color: var(--color-text-muted);
}

.bills__meta span,
.bills__meta a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

/* The customer's name opens their page (CUST-03). */
.bills__customer-link {
  color: var(--color-primary);
  text-decoration: none;
  min-height: var(--tap-min);
}

/* The lines, boxed like the bill panel on Sell. */
.bills__lines {
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.bills__section-title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-body);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
}

/* Share, Print and Void. Void goes to the right, on its own. */
.bills__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.bills__actions .spacer {
  flex: 1 1 auto;
}

@media (max-width: 480px) {
  .bills__actions .btn {
    flex: 1 1 40%;
  }
}

/* Why Void is greyed ("Day is closed"), under the buttons. */
.bills__void-note {
  margin: 0;
  font-size: var(--text-small);
  color: var(--color-text-muted);
}

/* The void dialog: the reason box and the hold button. */
.void-dialog .dialog__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding-bottom: var(--space-5);   /* the buttons are inside the body */
}

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

.void-dialog__actions > :first-child {
  flex: 1 1 auto;
}

/* The past-bill dialog: the list of days and the time. */
.past-dialog .dialog__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding-bottom: var(--space-5);   /* the buttons are inside the body */
}

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

.past-dialog__actions > :first-child {
  flex: 1 1 auto;
}


/* -----------------------------------------------------------------------------
   THE RETURNS SHEET (RET-01 to RET-03), js/ui/return-sheet.js
   Fields on the left, the number pad and the buttons on the right, as the
   line editor on Sell. On a phone the pad drops under the fields.
   ----------------------------------------------------------------------------- */

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

@media (max-width: 767px) {
  .return-sheet__columns {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .return-sheet__side {
    justify-self: stretch;
  }

  .return-sheet__pad {
    display: flex;
    justify-content: center;
  }
}

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

.return-sheet__done {
  gap: var(--space-4);
  padding-top: var(--space-3);
}

.return-sheet__sold,
.return-sheet__label,
.return-sheet__swap {
  margin: 0;
}

.return-sheet__label {
  margin-bottom: var(--space-2);
  font-size: var(--text-small);
}

.return-sheet__reasons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.return-sheet__status {
  margin: 0;
  color: var(--color-text-muted);
}

.return-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);
}

/* The Returns section on a bill: one row per return, with its badge. */
.bills__returns {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
