/* =========================================================
   invoice-print.css
   CSS custom properties দিয়ে theme করা যায় (InvoiceDocument.razor
   এর RootStyle থেকে ইনজেক্ট হয়)। Root-এ ডিফল্ট ভ্যালুও রাখা আছে
   যাতে ভ্যারিয়েবল পাস না হলেও ভাঙবে না।
   ========================================================= */

:root {
    --inv-primary: #1d4ed8;
    --inv-accent: #eef2ff;
    --inv-text: #1f2937;
    --inv-th-bg: #1d4ed8;
    --inv-th-text: #ffffff;
    --inv-row-alt: #f8f9fc;
    --inv-border: #e5e7eb;
    --inv-danger: #dc2626;
    --inv-success: #16a34a;
}

* {
    box-sizing: border-box;
}

.inv-doc-outer {
    position: relative;
    color: var(--inv-text);
    background: #fff;
}

.inv-doc {
    position: relative;
    z-index: 1;
    max-width: 1040px;
    margin: 0 auto;
    padding: 14px 20px;
}

/* ===================== Watermark ===================== */
/*.inv-watermark {
    position: fixed;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 90px;
    font-weight: 800;
    letter-spacing: 4px;
    color: var(--inv-danger);
    opacity: 0.10;
    z-index: 0;
    pointer-events: none;
    white-space: nowrap;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}*/

/* ===================== Header grid ===================== */
.inv-header-grid {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    border-bottom: 1px solid var(--inv-primary);
    padding-bottom: 4px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.inv-header-left {
    flex: 1 1 320px;
    min-width: 260px;
}

.inv-brand-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
}

.inv-logo {
    height: 46px;
    max-width: 100px;
    object-fit: contain;
}

.inv-hex {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--inv-primary);
    color: #fff;
    font-weight: 800;
    font-size: 18px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.inv-company-name {
    font-size: 18px;
    font-weight: 800;
    color: #111827;
    margin: 0;
    letter-spacing: .2px;
    line-height: 1.2;
}

.inv-company-meta {
    margin-top: 2px;
}

.inv-meta-line {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 11px;
    color: #4b5563;
    margin-bottom: 1px;
    line-height: 1.3;
}

    .inv-meta-line i {
        color: var(--inv-primary);
        width: 12px;
        text-align: center;
        margin-top: 1px;
    }

.inv-header-right {
    min-width: 350px;
    flex: 0 0 350px;
    text-align: right;
}
.inv-doc-title {
    font-size: 19px;
    font-weight: 800;
    color: var(--inv-primary);
    letter-spacing: .6px;
    margin: 0 0 4px;
    line-height: 1.2;
}

/*.inv-barcode-box {
    grid-column: 1 / -1;
    width: 100%;
}

.inv-barcode {
    display: block;
    width: 100%;
    height: 34px;
    object-fit: fill;
}
.inv-no-card,
.inv-info-row {
    display: grid;
    grid-template-columns: 105px 1fr;
    align-items: center;
    column-gap: 12px;
    padding: 0;
    margin-bottom: 4px;
    text-align: left;
    font-size: 10.5px;
    line-height: 1.3;
}

.inv-no-card {
    justify-content: flex-start;
}

    .inv-no-card i {
        color: var(--inv-primary);
        font-size: 13px;
    }

.inv-no-label {
    font-size: 9.5px;
    color: #6b7280;
    font-weight: 700;
    letter-spacing: .4px;
    text-transform: uppercase;
    text-align: left;
    white-space: nowrap;
}

.inv-no-value {
    font-size: 13px;
    font-weight: 800;
    color: var(--inv-primary);
    text-align: right;
    white-space: nowrap;
}

.inv-info-row {
    display: grid;
    grid-template-columns: 125px 115px;
    align-items: center;
    column-gap: 12px;
    width: 252px;
    margin-left: auto;
    margin-bottom: 4px;
    padding: 0;
    font-size: 10.5px;
    line-height: 1.3;
}

.inv-info-label {
    color: #111827;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}

.inv-info-value {
    font-weight: 700;
    color: #111827;
    text-align: right;
    white-space: nowrap;
}

.inv-status-chip {
    justify-self: end;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 70px;
    height: 20px;
    padding: 0 12px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 10px;
    line-height: 1;
}*/

.inv-right-grid {
    display: grid;
    grid-template-columns: auto auto;
    column-gap: 12px;
    row-gap: 6px;
    width: fit-content;
    margin-left: auto;
    justify-items: end;
}

.inv-barcode-box {
    grid-column: 1 / -1;
    width: 100%;
}

.inv-barcode {
    display: block;
    width: 100%;
    height: 34px;
    object-fit: fill;
}

.inv-info-row {
    display: contents;
}

.inv-info-label {
    grid-column: 1;
    justify-self: start;
    color: #111827;
    font-weight: 600;
    white-space: nowrap;
}

.inv-info-value {
    grid-column: 2;
    justify-self: end;
    font-weight: 700;
    color: #111827;
    white-space: nowrap;
}

.inv-status-chip {
    grid-column: 2;
    justify-self: end;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 70px;
    height: 20px;
    padding: 0 12px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 10px;
    line-height: 1;
}

    .inv-status-chip.unpaid, .inv-status-chip.due {
        background: #fee2e2;
        color: var(--inv-danger);
    }

    .inv-status-chip.paid, .inv-status-chip.completed {
        background: #dcfce7;
        color: var(--inv-success);
    }

    .inv-status-chip.partial, .inv-status-chip.pending {
        background: #fef3c7;
        color: #b45309;
    }

    .inv-status-chip.draft {
        background: #f3f4f6;
        color: #4b5563;
    }

/* ===================== Bill To / Ship To ===================== */
.inv-customer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin-bottom: 6px;
}

    .inv-customer-grid.two-col {
        grid-template-columns: 1fr 1fr;
    }

.inv-bill-card {
    background: none;
    border: none;
    border-top: 1px solid var(--inv-border);
    border-radius: 0;
    padding: 4px 0 0;
}

.inv-section-title {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 800;
    color: var(--inv-primary);
    letter-spacing: .4px;
    margin-bottom: 3px;
    text-transform: uppercase;
}

.inv-bill-name {
    font-size: 13px;
    font-weight: 800;
    color: #111827;
    margin: 0 0 2px;
    line-height: 1.3;
}

.inv-bill-line {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 11.5px;
    color: #374151;
    margin-bottom: 1px;
    line-height: 1.3;
}

    .inv-bill-line i {
        color: var(--inv-primary);
        width: 11px;
        margin-top: 1px;
    }

/* ===================== Items table ===================== */
.inv-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2px;
    font-size: 11.5px;
}

    .inv-items-table thead {
        display: table-header-group; /* মূল কৌশল: প্রতি পেজে হেডার রিপিট হবে */
    }

        .inv-items-table thead th {
            background: var(--inv-th-bg);
            color: var(--inv-th-text);
            font-size: 10px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: .3px;
            padding: 5px 8px;
            text-align: left;
            print-color-adjust: exact;
            -webkit-print-color-adjust: exact;
        }

    .inv-items-table tbody td {
        padding: 4px 8px;
        border-bottom: 1px solid #f1f2f4;
        vertical-align: top;
        line-height: 1.3;
    }

    .inv-items-table tbody tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .inv-items-table.zebra tbody tr:nth-child(even) {
        background: var(--inv-row-alt);
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

.col-num {
    text-align: right;
}

.col-sl {
    width: 4%;
}

.col-batch {
    width: 9%;
}

.inv-item-name {
    font-weight: 700;
    color: #111827;
    line-height: 1.3;
}

.inv-item-desc {
    color: #9aa0a8;
    font-size: 10px;
    margin-top: 1px;
    line-height: 1.3;
}

.inv-item-amount {
    font-weight: 800;
    color: #111827;
}

.inv-items-summary {
    display: flex;
    gap: 24px;
    font-size: 11px;
    color: #4b5563;
    padding: 3px 0 6px;
    border-bottom: 1px dashed var(--inv-border);
    margin-bottom: 6px;
}

    .inv-items-summary b {
        color: var(--inv-primary);
    }

/* ===================== Summary / totals ===================== */
/*.inv-summary-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-bottom: 6px;
}

.inv-lower-right {
    width: auto;
    max-width: 300px;
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
}

.inv-totals-line {
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    gap: 10px;
    font-size: 12px;
    color: #374151;
    margin-bottom: 2px;
    line-height: 1.3;
}

    .inv-totals-line span:first-child {
        color: #6b7280;
    }

    .inv-totals-line span:last-child {
        font-weight: 600;
        min-width: 70px;
        text-align: right;
    }

    .inv-totals-line.discount span:last-child {
        color: var(--inv-danger);
    }

    .inv-totals-line.receive span:last-child {
        color: var(--inv-success);
        font-weight: 700;
    }

.inv-totals-divider {
    border-top: 1px solid var(--inv-border);
    margin: 3px 0;
    width: 100%;
}

.inv-grand-total {
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    gap: 10px;
    font-size: 14px;
    font-weight: 800;
    color: var(--inv-primary);
    background: none;
    border-radius: 0;
    padding: 1px 0;
    margin-bottom: 2px;
}

    .inv-grand-total span:last-child {
        min-width: 70px;
        text-align: right;
    }

.inv-balance-line {
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    gap: 10px;
    font-size: 13px;
    font-weight: 800;
    color: var(--inv-danger);
    margin-top: 1px;
    padding-top: 3px;
    border-top: 1px dashed var(--inv-border);
}

    .inv-balance-line span:last-child {
        min-width: 70px;
        text-align: right;
    }

.inv-words-box {
    max-width: 300px;
    margin-top: 4px;
    font-size: 11px;
    color: #4b5563;
    background: none;
    border: none;
    padding: 0;
    text-align: left;
}

.inv-words-label {
    font-weight: 700;
    color: #b45309;
}*/
/* ===================== Summary / totals ===================== */

.inv-summary-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: 100%;
    margin-bottom: 6px;
}

.inv-lower-right {
    width: 300px;
    max-width: 300px;
    background: none;
    border: none;
    padding: 0;
}


/* ===================== Normal Total Rows ===================== */

.inv-totals-line {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    width: 100%;
    margin-bottom: 3px;
    padding: 0;
    font-size: 12px;
    line-height: 1.3;
}


    /* Label */
    .inv-totals-line span:first-child {
        text-align: left;
        white-space: nowrap;
        color: #6b7280;
    }


    /* Amount */
    .inv-totals-line span:last-child {
        min-width: 105px;
        text-align: right;
        white-space: nowrap;
        font-weight: 600;
        color: #374151;
    }


    /* Discount */
    .inv-totals-line.discount span:last-child {
        color: var(--inv-danger);
    }


    /* Paid Amount */
    .inv-totals-line.receive span:last-child {
        color: var(--inv-success);
        font-weight: 700;
    }


/* ===================== Divider ===================== */

.inv-totals-divider {
    width: 100%;
    border-top: 1px solid var(--inv-border);
    margin: 4px 0;
}


/* ===================== Grand Total ===================== */

.inv-grand-total {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    width: 100%;
    padding: 3px 0;
    margin-bottom: 2px;
    font-size: 18px;
    font-weight: 800;
    color: var(--inv-primary);
}


    /* Grand Total Label */
    .inv-grand-total span:first-child {
        text-align: left;
        white-space: nowrap;
    }


    /* Grand Total Amount */
    .inv-grand-total span:last-child {
        min-width: 105px;
        text-align: right;
        white-space: nowrap;
    }


/* ===================== Balance Due ===================== */

.inv-balance-line {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    width: 100%;
    margin-top: 2px;
    padding-top: 4px;
    border-top: 1px dashed var(--inv-border);
    font-size: 14px;
    font-weight: 800;
    color: var(--inv-danger);
}


    /* Balance Label */
    .inv-balance-line span:first-child {
        text-align: left;
        white-space: nowrap;
    }


    /* Balance Amount */
    .inv-balance-line span:last-child {
        min-width: 105px;
        text-align: right;
        white-space: nowrap;
    }


/* ===================== In Words ===================== */

.inv-words-box {
    width: 100%;
    max-width: 300px;
    margin-top: 4px;
    padding: 0;
    font-size: 11px;
    line-height: 1.4;
    text-align: left;
    color: #4b5563;
}

.inv-words-label {
    font-weight: 700;
    color: #b45309;
}

/* ===================== Signature / QR / Footer ===================== */
.inv-bottom-wrap {
    margin-top: 4px;
}
.inv-sign-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: nowrap;
    break-inside: avoid;
}
.inv-qr-box {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

    .inv-qr-box img {
        width: 56px;
        height: 56px;
        border: 1px solid var(--inv-border);
        border-radius: 4px;
        object-fit: contain;
    }

.inv-qr-title {
    font-weight: 700;
    color: #111827;
    font-size: 11px;
    line-height: 1.3;
}

.inv-qr-sub {
    font-size: 10px;
    color: #6b7280;
}

.inv-sign-group {
    display: flex;
    justify-content: flex-end;
    gap: 20px;
    flex-wrap: nowrap;
    flex: 1 1 auto;
    min-width: 0;
}

.inv-sign-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    width: auto;
    min-width: 100px;
    max-width: 160px;
    flex: 0 1 auto;
    min-height: 56px;
    text-align: center;
}
.inv-sign-img {
    display: block;
    max-height: 38px;
    max-width: 140px;
    width: auto;
    margin: 0 auto;
    object-fit: contain;
}

.inv-sign-line {
    width: 100%;
    border-top: 1px dashed #9ca3af;
    padding-top: 3px;
    margin-top: 2px;
    font-size: 10.5px;
    color: #374151;
    white-space: nowrap;
}

.inv-footer {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    text-align: center;
    margin-top: 10px;
    padding-top: 6px;
    border-top: 1px solid var(--inv-border);
    color: #6b7280;
    font-size: 10.5px;
    break-inside: avoid;
}

    .inv-footer i {
        margin-right: 4px;
    }

        .inv-footer i.fa-heart {
            color: var(--inv-danger);
        }

        .inv-footer i.fa-file-lines {
            color: var(--inv-primary);
        }

        .inv-footer i.fa-cloud {
            color: #6366f1;
        }

    .inv-footer b {
        color: var(--inv-primary);
    }

/* ===================== Print rules ===================== */
@media print {
    .inv-sign-row, .inv-footer {
        break-inside: avoid;
    }

    body {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ===================== Thermal mode override ===================== */
.thermal-mode .inv-doc {
    padding: 6px;
    font-size: 10px;
    max-width: 100%;
}

.thermal-mode .inv-header-grid {
    flex-direction: column;
}

.thermal-mode .inv-doc-title {
    font-size: 14px;
    text-align: center;
}

.thermal-mode .inv-header-right {
    text-align: center;
}

.thermal-mode .inv-watermark {
    font-size: 34px;
}

.thermal-mode .inv-customer-grid.two-col {
    grid-template-columns: 1fr;
}

.thermal-mode .inv-summary-wrap {
    align-items: center;
}

.thermal-mode .inv-lower-right {
    width: 100%;
    max-width: 100%;
}

.thermal-mode .inv-sign-group {
    justify-content: center;
    width: 100%;
}

/* ===================== Paper size (for screen preview only;
   actual PDF size is controlled by Playwright PdfOptions) ===================== */
.paper-a4 {
    width: 210mm;
    margin: 0 auto;
}

.paper-a5 {
    width: 148mm;
    margin: 0 auto;
}

.paper-2inch {
    width: 2in;
    margin: 0 auto;
}

.paper-3inch {
    width: 3in;
    margin: 0 auto;
}

.paper-4inch {
    width: 4in;
    margin: 0 auto;
}
