/* Print / PDF page */
@page {
    size: A4 portrait;
    margin: 12mm 14mm;
}

@media print {
    html, body {
        width: 100%;
        height: auto;
        margin: 0;
        padding: 0;
        background: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .billing-invoice-doc__status-badge {
        display: none !important;
    }

    .billing-invoice-doc {
        color: #111827 !important;
    }

    .billing-invoice-doc__meta,
    .billing-invoice-doc__copy-label,
    .billing-invoice-doc__dates-label,
    .billing-invoice-doc__items .item-desc,
    .billing-invoice-doc__items .tax-pct,
    .billing-invoice-doc__words,
    .billing-invoice-doc__signature p {
        color: #374151 !important;
    }

    .billing-invoice-doc__company-name,
    .billing-invoice-doc__doc-title,
    .billing-invoice-doc__section-label,
    .billing-invoice-doc__party-name,
    .billing-invoice-doc__items .item-name,
    .billing-invoice-doc__bank-title,
    .billing-invoice-doc__terms-title {
        color: #0f172a !important;
    }

    .billing-invoice-doc__doc-number,
    .billing-invoice-doc__dates-value,
    .billing-invoice-doc__addresses p,
    .billing-invoice-doc__items tbody td,
    .billing-invoice-doc__bank p,
    .billing-invoice-doc__terms p,
    .billing-invoice-doc__totals td {
        color: #111827 !important;
    }

    .billing-invoice-doc__items thead th {
        background: #334155 !important;
        color: #fff !important;
        border-color: #1e293b !important;
        border-bottom: 2px solid #0f172a !important;
    }

    .billing-invoice-doc__items tbody td {
        border-color: #cbd5e1 !important;
    }

    .billing-invoice-doc__amount-due {
        background: #3577f1 !important;
        color: #fff !important;
    }

    .billing-invoice-doc__totals .total-row td {
        background: #e8faf6 !important;
        border-top: 2px solid #0ab39c !important;
    }

    .billing-invoice-doc__totals .total-row td {
        color: #0f172a !important;
    }

    .billing-invoice-doc__totals .due-row td {
        color: #1d4ed8 !important;
    }

    .billing-invoice-doc__words strong {
        color: #111827 !important;
    }

    .billing-invoice-doc__dates {
        border-collapse: separate !important;
        border-spacing: 1rem 0.2rem !important;
        width: auto !important;
    }

    .billing-invoice-doc__dates-label {
        width: 1% !important;
        padding-right: 0 !important;
    }

    .billing-invoice-doc__dates-gap {
        width: 1.25rem !important;
        min-width: 1.25rem !important;
        padding: 0 !important;
    }

    .billing-invoice-doc__company .billing-invoice-doc__meta,
    .billing-invoice-doc__addresses .billing-invoice-doc__meta,
    .billing-invoice-doc__addresses p {
        line-height: 1.15 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .billing-invoice-doc__addresses {
        line-height: 1.15 !important;
    }

    .no-print,
    .billing-print-toolbar {
        display: none !important;
    }

    .billing-print-page {
        padding: 0 !important;
        margin: 0 !important;
    }

    .billing-invoice-doc {
        max-width: none !important;
        width: 100% !important;
        min-height: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        page-break-after: auto;
    }

    .billing-invoice-doc__items {
        page-break-inside: auto;
    }

    .billing-invoice-doc__items tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    .billing-invoice-doc__items thead {
        display: table-header-group;
    }

    .billing-invoice-doc__bottom,
    .billing-invoice-doc__bank,
    .billing-invoice-doc__totals {
        page-break-inside: avoid;
    }

    a[href]:after {
        content: none !important;
    }
}

/* Print-only layout page */
.billing-print-body {
    margin: 0;
    padding: 0;
    background: #e9ecef;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.billing-print-toolbar {
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.billing-print-toolbar__inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    max-width: 220mm;
    margin: 0 auto 0.35rem;
}

.billing-print-toolbar__title {
    font-weight: 600;
    font-size: 0.9rem;
    flex: 1;
}

.billing-print-toolbar__actions {
    display: flex;
    gap: 0.5rem;
}

.billing-print-toolbar__hint {
    font-size: 0.75rem;
    color: #6c757d;
    text-align: center;
    max-width: 220mm;
    margin: 0 auto;
}

.billing-print-page {
    max-width: 210mm;
    margin: 1.5rem auto;
    padding: 14mm 16mm;
    background: #fff;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.billing-print-page .billing-invoice-doc {
    max-width: 100%;
}

.billing-print-body[data-layout="a5"] .billing-print-page,
.billing-invoice-doc[data-layout="a5"] {
    max-width: 148mm;
}

/* Admin show page — print from preview */
@media print {
    body.billing-admin #layout-wrapper,
    body.billing-admin .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }

    body.billing-admin #page-topbar,
    body.billing-admin .app-menu,
    body.billing-admin .navbar-header,
    body.billing-admin .vertical-overlay,
    body.billing-admin .page-title-box,
    body.billing-admin .footer,
    body.billing-admin #back-to-top,
    body.billing-admin #preloader,
    body.billing-admin .alert,
    body.billing-admin .billing-invoice-preview__toolbar,
    body.billing-admin .billing-invoice-preview__sidebar,
    body.billing-admin .container-fluid > .row:first-child {
        display: none !important;
    }

    body.billing-admin .container-fluid {
        padding: 0 !important;
        max-width: none !important;
    }

    body.billing-admin .page-content {
        padding: 0 !important;
    }

    body.billing-admin .billing-invoice-preview {
        margin: 0 !important;
        min-height: 0 !important;
        background: #fff !important;
    }

    body.billing-admin .billing-invoice-preview__body,
    body.billing-admin .billing-invoice-preview__main {
        width: 100% !important;
        max-width: 100% !important;
        flex: none !important;
    }

    body.billing-admin .billing-invoice-preview__canvas {
        padding: 0 !important;
        background: #fff !important;
        display: block !important;
    }

    body.billing-admin .billing-invoice-preview__canvas .billing-invoice-doc {
        box-shadow: none !important;
        padding: 0 !important;
        min-height: 0 !important;
        max-width: none !important;
    }
}
