/* Wholesale portal. Builds on inventory.css (palette) and auth.css (forms, cards). */

.ws-welcome { max-width: 1080px; }
.ws-intro { margin: 8px 0 20px; }
.ws-intro h1 { margin: 0 0 6px; font: 700 32px/1.15 var(--font-head); }
.ws-intro p { margin: 0; max-width: 60ch; color: var(--muted); font-size: 16px; }

.ws-cards { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.ws-cards .card { width: 100%; }
.ws-cards h2 { margin: 0 0 12px; font: 700 22px/1.2 var(--font-head); }
.ws-forgot { margin-top: 4px; }

/* Catalog + cart */
.ws-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.ws-catalog { min-width: 0; } /* lets the table scroll inside instead of widening the page */
.ws-catalog .toolbar { margin-bottom: 12px; }
.ws-table td { white-space: nowrap; }
.ws-table td.ws-prod { white-space: normal; min-width: 200px; } /* long names wrap instead of pushing Packs off */
.ws-table .prod-sku { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.ws-table .qty { width: 72px; }
.ws-table td.ws-avail { white-space: normal; }
.ws-table .avail-inline { display: none; }
.ws-table .prod-name { font-weight: 600; }
.ws-table .prod-label { display: block; font-size: 13px; color: var(--muted); }
.ws-table tr.in-cart td { background: #f2f9f8; }

.qty {
  width: 84px; height: 36px; padding: 0 8px; text-align: right;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--sand);
}
.qty:focus { border-color: var(--channel); }

.avail { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.avail::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--channel); }
.avail.low::before { background: var(--low-fill); }
.avail.backorder::before { background: var(--out); }
.avail.backorder { color: var(--out); }
.avail.low { color: var(--low); }

.ws-cart { position: sticky; top: 16px; width: 100%; padding: 20px; }
.ws-cart h2 { margin: 0 0 8px; font: 700 20px/1.2 var(--font-head); }
.cart-lines { list-style: none; margin: 0 0 12px; padding: 0; max-height: 40vh; overflow: auto; }
.cart-line {
  display: grid; grid-template-columns: 1fr auto auto; gap: 2px 10px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid #e6eeec; font-size: 14px;
}
.cart-line .name { font-weight: 600; }
.cart-line .sub { grid-column: 1 / 2; font-size: 12px; color: var(--muted); }
.cart-line .line-total { text-align: right; font-weight: 600; }
.cart-line .remove {
  border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 0 2px;
}
.cart-line .remove:hover { color: var(--out); }
.cart-line .bo { grid-column: 1 / 4; font-size: 12px; color: var(--low); }

.cart-totals { display: grid; gap: 4px; margin: 0 0 12px; }
.cart-totals div { display: flex; justify-content: space-between; }
.cart-totals dt { color: var(--muted); }
.cart-totals dd { margin: 0; font-weight: 700; }
.cart-totals div:last-child dd { font: 700 22px/1.2 var(--font-head); }
.ws-cart .field { margin-bottom: 12px; }
.ws-place { width: 100%; height: 44px; }
.ws-cart .hint { margin: 10px 0 0; font-size: 12px; }

.ws-order-dialog { width: min(640px, calc(100vw - 32px)); }
.ws-order-dialog .table-box { margin: 12px 0; max-height: 50vh; }

/* Staff order entry (Admin -> Wholesale orders -> New order) */
dialog.modal.no-dialog { width: min(1040px, calc(100vw - 32px)); }
.no-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.no-pick { min-width: 0; }
.no-pick .field { margin-bottom: 12px; }
.no-pick select { width: 100%; height: 40px; }
.no-search { width: 100%; margin-bottom: 10px; }
.no-search input { width: 100%; }
.no-items { max-height: 52vh; }
.no-table { width: 100%; }
.no-table td { white-space: nowrap; }
/* The item cell wraps (name, size, SKU stacked) so On hand, Price and Packs always fit. */
.no-table td.no-prod { white-space: normal; width: 100%; }
.no-table td.no-prod .prod-sku { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.no-table .qty { width: 72px; }
.no-onhand-inline { display: none; font-size: 12px; color: var(--muted); }
.no-table .prod-name { font-weight: 600; }
.no-table .prod-label { display: block; font-size: 13px; color: var(--muted); }
.no-table tr.in-cart td { background: #f2f9f8; }
.no-items .short { color: var(--out); font-weight: 600; }
.no-summary h3 { margin: 0 0 8px; font: 700 18px/1.2 var(--font-head); }
.no-summary .cart-lines { max-height: 30vh; }
.no-summary textarea { width: 100%; font: inherit; }
.no-summary .field { margin-bottom: 10px; }

/* The order panel drops below the list before the Packs box would be squeezed off. */
@media (max-width: 1080px) {
  .ws-layout { grid-template-columns: minmax(0, 1fr); }
  .ws-cart { position: static; }
}
@media (max-width: 960px) {
  .no-layout { grid-template-columns: minmax(0, 1fr); }
  .ws-cards { grid-template-columns: 1fr; }
}
/* Small screens: drop MSRP so product, availability, price and the quantity box stay on screen. */
@media (max-width: 700px) {
  .ws-table th:nth-child(4), .ws-table td:nth-child(4) { display: none; }
}
@media (max-width: 560px) {
  /* Order entry on a phone: item, on hand, price, packs. */
  /* Phone: no photo, On hand moves under the name, so the Packs box stays on screen. */
  .no-table td { padding: 8px 6px; }
  .no-table th:nth-child(2), .no-table td:nth-child(2) { display: none; }
  .no-table td.no-prod .thumb { display: none; }
  .no-table td.no-prod .with-thumb { gap: 0; }
  .no-onhand-inline { display: block; margin-top: 2px; }
  .no-table .qty { width: 64px; }
  .ws-table td, .ws-table th { padding: 8px; }
  .ws-table td.ws-prod { min-width: 0; }
  /* Availability moves under the name; its column goes. */
  .ws-table th:nth-child(2), .ws-table td:nth-child(2) { display: none; }
  .ws-table .avail-inline { display: inline-flex; margin-top: 4px; }
  .ws-table .qty { width: 60px; }
  .ws-table td { white-space: normal; }
  .qty { width: 64px; }
}

/* Staff preview of the wholesale site */
.ws-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; justify-content: space-between;
  margin: 0 0 16px; padding: 12px 16px; border-radius: 10px; background: #fff5d6; border: 1px solid #ecd48a; }
.ws-preview p { margin: 0; flex: 1 1 320px; }
.ws-preview label { display: flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.ws-preview select { font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid #cdbf8f; background: #fff; }
/* Preview banner on a phone: the "View as" box fits the screen. */
@media (max-width: 560px) {
  .ws-preview label { white-space: normal; flex-wrap: wrap; width: 100%; }
  .ws-preview select { width: 100%; min-width: 0; }
}
.ws-cart #place-order { white-space: normal; height: auto; min-height: 44px; }


/* Admin → System */
.sys-checks { list-style: none; margin: 8px 0 20px; padding: 0; display: grid; gap: 8px; }
.sys-check { display: grid; grid-template-columns: 26px 110px 1fr; gap: 4px 10px; align-items: start; padding: 10px 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.sys-check.bad { border-color: #f0c9c3; background: #fdf1ef; }
.sys-dot { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-weight: 700; font-size: 13px;
  background: #e3f1ee; color: #0d6e78; }
.sys-check.bad .sys-dot { background: var(--out, #b42318); color: #fff; }
.sys-detail { grid-column: 3; }
.sys-sub { margin: 8px 0 4px; font: 700 17px/1.2 var(--font-head); }
@media (max-width: 560px) { .sys-check { grid-template-columns: 26px 1fr; } .sys-check > span:last-of-type, .sys-detail { grid-column: 2; } }
