/* =============================================================================
   css/screens/suppliers.css
   Where things go on the Suppliers screen (js/screens/suppliers.js): the
   list with its two cards, search and chips; the supplier page; "What we
   owe"; "Warranty items to send" (SUP-01 to SUP-04, RET-03).

   Tablet and laptop (768px and up): list on the left, the supplier or a
   report on the right, both scrolling on their own. Phone: one at a time,
   with "All suppliers" to go back. The same shape as Customers.

   Positioning only. The rows, badges, cards, the warranty row and the due
   colours 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
   ----------------------------------------------------------------------------- */

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

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

@media (max-width: 767px) {
  .suppliers {
    display: block;
    height: auto;
    padding: var(--space-3);
  }

  .suppliers[data-mode='list'] .suppliers__detail,
  .suppliers[data-mode='detail'] .suppliers__list {
    display: none;
  }

  .suppliers__list,
  .suppliers__detail {
    overflow: visible;
  }
}

.suppliers__back {
  align-self: flex-start;
}

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


/* -----------------------------------------------------------------------------
   THE LIST: title row, the two cards, search, chips, results
   ----------------------------------------------------------------------------- */

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

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

/* "What we owe" and "Warranty items to send" side by side; stacked on a
   narrow phone. */
.suppliers__cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  flex: none;
}

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

/* Each card: title, figure, note, and a chevron on the right. */
.suppliers__card-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto auto;
  gap: 0 var(--space-2);
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.suppliers__card-link > .card__title,
.suppliers__card-link > .card__value,
.suppliers__card-link > .card__note {
  grid-column: 1;
}

.suppliers__card-link > .card__title {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.suppliers__card-link > .icon {
  grid-column: 2;
  grid-row: 1 / span 3;
  color: var(--color-text-faint);
}

.suppliers__card-link[aria-pressed='true'] {
  background: var(--color-primary-faint);
}

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

.suppliers__results {
  flex: none;
}

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


/* -----------------------------------------------------------------------------
   ONE SUPPLIER, and the two reports: a card
   ----------------------------------------------------------------------------- */

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

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

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

/* "We owe Rs 15,000.00": orange while owed, red with something overdue. */
.suppliers__balance {
  font-size: var(--text-heading);
  font-weight: var(--font-bold);
  white-space: nowrap;
}

.suppliers__balance[data-owing='true'] {
  color: var(--color-warning);
}

.suppliers__balance[data-overdue='true'] {
  color: var(--color-danger);
}

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

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

/* What we buy, notes: an icon and a sentence that wraps beside it. */
.suppliers__note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0;
  color: var(--color-text-muted);
}

.suppliers__note .icon {
  flex: none;
  margin-top: var(--space-1);
}

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

.suppliers__section-title {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0 0 var(--space-2);
  font-size: var(--text-body);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
}

.suppliers__hint {
  margin: var(--space-2) 0 0;
  font-size: var(--text-small);
}

/* A supplier's name as the heading of their warranty group: a link. */
.suppliers__group-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--tap-min);
  padding: 0;
  font: inherit;
  color: var(--color-primary);
  background: none;
  border: none;
  cursor: pointer;
}


/* -----------------------------------------------------------------------------
   THE ADD / EDIT DIALOG, js/ui/supplier-form.js
   ----------------------------------------------------------------------------- */

.supplier-dialog {
  width: min(640px, calc(100vw - var(--space-6)));
}
