/*
 * Invoices.
 *
 * Its own file, linked from the layout the buyer's screens use. The @media
 * print block at the foot is the reason this feature needs no PDF library at
 * all: the browser's own Save as PDF produces a selectable, searchable file at
 * the reader's paper size, which is better than anything dompdf would render.
 *
 * Everything is scoped under .wz-invoice-page except the print rules, which
 * necessarily reach the page chrome in order to hide it.
 */

.wz-invoice-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

/* -------------------------------------------------------------- the notices */

.wz-inv-notice {
    margin: 0 0 20px;
    padding: 18px 20px;
    border: 1px solid #f3d9a4;
    border-left: 4px solid #d98324;
    border-radius: 8px;
    background: #fffaf0;
    color: #4a3a1d;
}

.wz-inv-notice--stop {
    border-color: #f1c7c4;
    border-left-color: #b3261e;
    background: #fdf6f5;
    color: #4a2320;
}

.wz-inv-notice__title {
    margin: 0 0 8px;
    font-size: 1.05rem;
    font-weight: 700;
}

.wz-inv-notice p {
    margin: 0 0 8px;
    font-size: 0.88rem;
    line-height: 1.55;
}

.wz-inv-notice__list {
    margin: 0 0 8px;
    padding-left: 20px;
    font-size: 0.86rem;
}

.wz-inv-notice code {
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.06);
    font-size: 0.85em;
}

.wz-inv-notice__foot {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/* ------------------------------------------------------- the billing form */

.wz-inv-billing {
    padding: 26px 28px;
    border: 1px solid #e3e9f2;
    border-radius: 10px;
    background: #fff;
}

.wz-inv-billing__title {
    margin: 0 0 6px;
    color: #2b3445;
    font-size: 1.25rem;
    font-weight: 700;
}

.wz-inv-billing__sub {
    margin: 0 0 22px;
    color: #7a879e;
    font-size: 0.88rem;
}

.wz-inv-field {
    margin: 0 0 18px;
}

/*
 * Its own class rather than .font-weight-bold, which carries
 * font-size: 1.25rem !important in this theme and would make every field label
 * the size of a heading.
 */
.wz-inv-label {
    display: block;
    margin: 0 0 6px;
    color: #2b3445;
    font-size: 0.86rem;
    font-weight: 600;
}

.wz-inv-optional {
    color: #9aa6bd;
    font-weight: 400;
}

.wz-inv-input {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #d5dde9;
    border-radius: 8px;
    color: #2b3445;
    font-size: 0.9rem;
    font-family: inherit;
    line-height: 1.45;
}

.wz-inv-input:focus {
    border-color: #1a56db;
    outline: 2px solid rgba(26, 86, 219, 0.18);
    outline-offset: 0;
}

.wz-inv-help {
    margin: 5px 0 0;
    color: #8a95a9;
    font-size: 0.78rem;
    line-height: 1.5;
}

.wz-inv-error {
    margin: 5px 0 0;
    color: #b3261e;
    font-size: 0.8rem;
}

.wz-inv-save {
    min-height: 44px;
    padding: 11px 22px;
    border: 0;
    border-radius: 8px;
    background: #1a56db;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.wz-inv-save:hover {
    background: #164bc0;
}

/* ------------------------------------------------------------- the actions */

.wz-inv-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 16px;
}

.wz-inv-back {
    color: #5a6782;
    font-size: 0.86rem;
    text-decoration: none;
}

.wz-inv-back:hover {
    color: #1a56db;
    text-decoration: underline;
}

.wz-inv-print {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border: 1px solid #1a56db;
    border-radius: 8px;
    background: #fff;
    color: #1a56db;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
}

.wz-inv-print:hover {
    background: #1a56db;
    color: #fff;
}

/* ------------------------------------------------------------ the document */

.wz-inv {
    padding: 34px 36px;
    border: 1px solid #e3e9f2;
    border-radius: 10px;
    background: #fff;
    color: #2b3445;
}

.wz-inv__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 20px;
    border-bottom: 2px solid #2b3445;
}

.wz-inv__seller-name {
    margin: 0 0 6px;
    font-size: 1.3rem;
    font-weight: 700;
}

.wz-inv__addr {
    margin: 0 0 6px;
    color: #56637c;
    font-size: 0.84rem;
    line-height: 1.55;
    white-space: pre-line;   /* an address typed with line breaks keeps them */
}

.wz-inv__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin: 0;
    color: #56637c;
    font-size: 0.8rem;
}

.wz-inv__meta--stack {
    flex-direction: column;
    gap: 4px;
}

.wz-inv__meta b {
    color: #2b3445;
    font-weight: 600;
}

.wz-inv__stamp {
    flex: 0 0 auto;
    text-align: right;
}

.wz-inv__kind {
    margin: 0 0 4px;
    color: #1a56db;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* A draft must not be mistakable for the real thing at a glance. */
.wz-inv__kind--draft {
    color: #d98324;
}

.wz-inv__no {
    margin: 0 0 4px;
    font-size: 1.02rem;
    font-weight: 700;
}

.wz-inv__date {
    margin: 0;
    color: #7a879e;
    font-size: 0.8rem;
}

.wz-inv__parties {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 28px;
    padding: 22px 0;
    border-bottom: 1px solid #e8ecf3;
}

.wz-inv__party-h {
    margin: 0 0 7px;
    color: #8a95a9;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.wz-inv__party-name {
    margin: 0 0 4px;
    font-size: 0.98rem;
    font-weight: 700;
}

.wz-inv__soft {
    color: #9aa6bd;
}

/* ---------------------------------------------------------------- the lines */

.wz-inv__lines {
    width: 100%;
    margin: 22px 0 0;
    border-collapse: collapse;
    font-size: 0.86rem;
}

.wz-inv__lines th {
    padding: 9px 10px;
    border-bottom: 1px solid #d5dde9;
    color: #56637c;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-align: left;
    text-transform: uppercase;
}

.wz-inv__lines td {
    padding: 12px 10px;
    border-bottom: 1px solid #f0f3f8;
    vertical-align: top;
}

.wz-inv__num {
    text-align: right;
    /* Figures line up in a column when they are the same width. */
    font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- the totals */

.wz-inv__totals {
    display: flex;
    justify-content: flex-end;
    padding: 18px 0 0;
}

.wz-inv__sum {
    width: 100%;
    max-width: 320px;
    margin: 0;
}

.wz-inv__row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 6px 0;
    font-size: 0.87rem;
}

.wz-inv__row dt {
    color: #56637c;
    font-weight: 400;
}

.wz-inv__row dd {
    margin: 0;
    font-variant-numeric: tabular-nums;
}

.wz-inv__row--total {
    margin-top: 6px;
    padding-top: 10px;
    border-top: 2px solid #2b3445;
    font-size: 1rem;
    font-weight: 700;
}

.wz-inv__row--total dt {
    color: #2b3445;
    font-weight: 700;
}

.wz-inv__foot {
    margin-top: 26px;
    padding-top: 16px;
    border-top: 1px solid #e8ecf3;
}

.wz-inv__note {
    margin: 0 0 5px;
    color: #7a879e;
    font-size: 0.78rem;
    line-height: 1.55;
}

/* ----------------------------------------------------------------- the list */

.wz-invlist__head {
    margin: 0 0 20px;
}

.wz-invlist__title {
    margin: 0 0 4px;
    color: #2b3445;
    font-size: 1.4rem;
    font-weight: 700;
}

.wz-invlist__sub {
    margin: 0;
    color: #7a879e;
    font-size: 0.88rem;
}

/* The table scrolls inside its own box rather than pushing the page sideways. */
.wz-invlist__wrap {
    overflow-x: auto;
    border: 1px solid #e3e9f2;
    border-radius: 10px;
    background: #fff;
}

.wz-invlist {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
    font-size: 0.87rem;
}

.wz-invlist th {
    padding: 12px 14px;
    border-bottom: 1px solid #e3e9f2;
    color: #56637c;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-align: left;
    text-transform: uppercase;
}

.wz-invlist td {
    padding: 13px 14px;
    border-bottom: 1px solid #f0f3f8;
    color: #2b3445;
}

.wz-invlist tr:last-child td {
    border-bottom: 0;
}

.wz-invlist__no {
    font-weight: 700;
}

.wz-invlist__draft {
    padding: 2px 8px;
    border-radius: 999px;
    background: #fff4e5;
    color: #8a5a16;
    font-size: 0.75rem;
    font-weight: 600;
}

.wz-invlist__order {
    color: #56637c;
    font-size: 0.82rem;
}

.wz-invlist__open {
    color: #1a56db;
    font-weight: 600;
    text-decoration: none;
}

.wz-invlist__open:hover {
    text-decoration: underline;
}

.wz-inv-empty {
    padding: 46px 20px;
    border: 1px solid #e3e9f2;
    border-radius: 10px;
    background: #fff;
    text-align: center;
}

.wz-inv-empty__ic {
    display: block;
    margin-bottom: 12px;
    color: #c3cede;
    font-size: 2rem;
}

.wz-inv-empty__title {
    margin: 0 0 6px;
    color: #2b3445;
    font-size: 1.05rem;
    font-weight: 700;
}

.wz-inv-empty p {
    margin: 0;
    color: #7a879e;
    font-size: 0.88rem;
}

/* ----------------------------------------------------------------- phones */

@media (max-width: 575.98px) {
    .wz-invoice-page {
        padding: 16px 12px 36px;
    }

    .wz-inv {
        padding: 20px 16px;
    }

    /* The header and the parties stack: side by side they are unreadable. */
    .wz-inv__head {
        flex-direction: column;
        gap: 14px;
    }

    .wz-inv__stamp {
        text-align: left;
    }

    .wz-inv__parties {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .wz-inv__sum {
        max-width: none;
    }

    .wz-inv-actions {
        flex-wrap: wrap;
    }

    .wz-inv-print {
        flex: 1 1 100%;
        justify-content: center;
    }
}

/* ------------------------------------------------------------------ print
 *
 * This block is the whole reason no PDF library is needed. What prints is the
 * document: no sidebar, no navbar, no footer, no buttons, no shadows, and
 * nothing on a background that would eat a cartridge.
 */
@media print {
    /*
     * The application chrome, by the selectors this layout ACTUALLY uses.
     *
     * The first version of this block hid .left-sidebar and .sidebar-nav, which
     * do not exist here -- the sidebar is <aside id="sidebar" class="mdc-drawer">
     * and the bar at the top is <header class="mdc-top-app-bar wz-topbar">.
     * Nothing looked wrong: the rules were valid CSS and simply matched no
     * element. The sidebar is position: fixed and 1400px tall, so it stayed on
     * the page and pushed the printed invoice onto a second sheet.
     *
     * Measured with Chrome in print media: 2 pages before, 1 after.
     */
    #sidebar,
    .mdc-drawer,
    .wz-topbar,
    .mdc-top-app-bar,
    .wz-footer,
    .page-titles,
    .wz-inv-actions,
    .phpdebugbar,
    .phpdebugbar-openhandler {
        display: none !important;
    }

    /*
     * The layout indents the content to clear a sidebar that is now gone, and
     * .page-wrapper is a flex column with a min-height sized to the viewport,
     * which on paper becomes a page of white space after the invoice.
     */
    .page-wrapper,
    #main-wrapper,
    body,
    html {
        display: block !important;
        min-height: 0 !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }

    .wz-invoice-page {
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .wz-inv {
        padding: 0;
        border: 0;
        border-radius: 0;
    }

    /* Printers drop backgrounds by default; the rules that carry meaning are
       restated as borders and weight so nothing is lost on paper. */
    .wz-inv__kind {
        color: #000 !important;
    }

    .wz-inv__head {
        border-bottom-color: #000;
    }

    .wz-inv__row--total {
        border-top-color: #000;
    }

    /* A table that breaks across a page must repeat its headings. */
    thead {
        display: table-header-group;
    }

    tr {
        break-inside: avoid;
    }

    @page {
        margin: 16mm;
    }
}

/*
 * The link from an order card to its invoice.
 *
 * In this file rather than in the My Orders stylesheet, so the link and the
 * page it opens cannot end up styled by two files that disagree.
 */
.wz-mo-invoice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 5px 12px;
    /* Readable on the band it actually sits on.
       --------------------------------------------------------------------
       This was #1a56db with no background -- written when the order header
       was a white card. The header is now
       `linear-gradient(120deg, #0b2350, #1d4ed8)`, so the link was blue text
       on blue and the word "Invoice" could not be made out. The two styles
       live in different files (this one and wizbrand-advertiser.css), which
       is why the change to one never reached the other.

       A solid pill instead: #0b2350 on white is about 14:1, and it reads as
       something to press rather than as part of the heading. */
    border: 1px solid #ffffff;
    border-radius: 999px;
    background: #ffffff;
    color: #0b2350;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.wz-mo-invoice:hover,
.wz-mo-invoice:focus-visible {
    border-color: #ffffff;
    background: #e8eefb;
    color: #0b2350;
    text-decoration: none;
}

/* Phones (2026-12-03): .page-wrapper is a flex container; without min-width:0 this page grows
   to the invoice table's width instead of letting .wz-invlist__wrap scroll. */
.wz-invoice-page { min-width: 0; max-width: 100%; }
