/* MSP Worx -- customer portal (this sheet also reaches the public proposal and
   invoice pages, which the portal app serves under /portal/quote/<token> and
   /portal/invoice/<token>).

   Invoices are created, sent and paid in QuickBooks and mirrored into PSA Worx
   read-only (the QuickBooks mirror). Signing a proposal is allowed, because
   that is how a customer accepts a contract, but patch P12 stops acceptance
   issuing an invoice. So every control here that would pay for something, or
   open an invoice acceptance no longer produces, is hidden; the routes behind
   them return 403 anyway (see nginx.conf).

   Loaded by the </head> sub_filter on /portal/ in nginx.conf; bump the ?v= on
   that line when editing this file, or browsers keep the old copy. */

/* Paying an invoice, in the portal and on a public invoice link. */
[data-testid="invoice-pay-button"],
[data-testid="public-invoice-pay"],
/* Paying a proposal deposit, and the "View invoice" link shown after signing:
   with P12 the accepted proposal leaves an unnumbered draft the portal never
   lists, so the link would lead nowhere. */
[data-testid="quote-pay"],
[data-testid="quote-accepted-invoice"] {
  display: none !important;
}

/* After signing, the portal says "Accepted. Your invoice is ready." (or "This
   proposal has been accepted."). Neither is true of an offer: signing bills
   nothing (P12), and nothing changes until MSP Worx countersigns. CSS cannot
   change text, so the portal's words are shrunk to nothing and ours drawn in
   their place; the box keeps its size, colour and role="status". */
[data-testid="quote-accept-success"] > p {
  font-size: 0 !important;
}
[data-testid="quote-accept-success"] > p::after {
  content: "Signed \2014  thank you. MSP Worx will countersign, and the fully signed copy will then be under Documents.";
  font-size: 0.875rem;
  line-height: 1.25rem;
}

/* The portal's Service page shows our "Your services" page instead
   (mw-portal.js). Its own content is hidden from the first paint, so it never
   flashes before our frame appears; the markers are the page's own test ids
   (empty, deliverables, key dates, error). */
#portal-main:has([data-testid^="portal-service-"]) > :not(iframe.mw-embed) {
  display: none !important;
}
#portal-main > iframe.mw-embed {
  display: block;
  width: 100%;
  min-height: 320px;
  border: 0;
  background: transparent;
}

/* On the Proposals page, MSP Worx's own proposals (mw-portal.js), above the
   portal's list; shown only when there are some. */
#portal-main iframe.mw-embed-proposals {
  display: block;
  width: 100%;
  margin: 0 0 1.5rem;
  border: 0;
  background: transparent;
}
#portal-main iframe.mw-embed-proposals.mw-empty-frame {
  height: 0;
  margin: 0;
}

/* Room for the scroll bar is always kept, so going between a short page and a
   long one does not shift everything sideways as the bar comes and goes. */
html {
  scrollbar-gutter: stable;
}
