/**

 * POS thermal receipt (58mm / 80mm ESC/POS browser print)

 * Load after print.css so logo rules override global `img { max-width: 60px }`.

 */



:root {

    --pos-thermal-logo-max-h-screen: 72px;

    --pos-thermal-logo-max-w-58-print: 42mm;

    --pos-thermal-logo-max-w-80-print: 54mm;

    --pos-thermal-logo-max-h-print: 15mm;

    --pos-thermal-font: "Courier New", Courier, monospace;

}



/* ─── Screen preview (thermal-safe monospace) ─── */

.pos-receipt.thermal-receipt-80:not(.invoice-receipt-thermal),

.pos-receipt.thermal-receipt-58:not(.invoice-receipt-thermal) {

    font-family: var(--pos-thermal-font);

    font-size: 13px;

    font-weight: 600;

    line-height: 1.25;

    color: #000;

}



.receipt-logo-thermal {

    display: flex;

    justify-content: center;

    align-items: center;

    width: 100%;

    margin: 0 auto 8px;

    color-scheme: only light;

    -webkit-print-color-adjust: exact;

    print-color-adjust: exact;

}



.receipt-logo-thermal-img {

    display: block;

    margin: 0 auto;

    padding: 0;

    border: 0;

    outline: none;

    box-shadow: none;

    background: #fff;

    max-width: min(54mm, 100%);

    max-height: var(--pos-thermal-logo-max-h-screen);

    width: auto;

    height: auto;

    object-fit: contain;

    object-position: center center;

    filter: grayscale(1) contrast(1.3) brightness(1.03);

    -webkit-filter: grayscale(1) contrast(1.3) brightness(1.03);

    image-rendering: -webkit-optimize-contrast;

    image-rendering: crisp-edges;

    -ms-interpolation-mode: nearest-neighbor;

}



.receipt-logo-fallback-text {

    font-family: var(--pos-thermal-font);

    font-size: 15px;

    font-weight: 800;

    letter-spacing: 0.04em;

    text-transform: uppercase;

    text-align: center;

    line-height: 1.2;

    color: #000;

    max-width: 100%;

    padding: 6px 4px;

    margin: 0 auto;

}



.pos-receipt.thermal-receipt-58 .receipt-logo-thermal-img {

    max-width: min(42mm, 100%);

}



/* ─── Print: logo + full receipt text clarity ─── */

@media print {

    body.pos-thermal-printing .pos-receipt,

    body:has(.thermal-print-80) .pos-receipt,

    body:has(.thermal-print-58) .pos-receipt,

    .pos-receipt.thermal-receipt-80,

    .pos-receipt.thermal-receipt-58 {

        font-family: var(--pos-thermal-font) !important;

        font-size: 12px !important;

        font-weight: 600 !important;

        line-height: 1.3 !important;

        color: #000 !important;

        -webkit-font-smoothing: none !important;

        text-rendering: optimizeSpeed !important;

    }



    body.pos-thermal-printing .pos-receipt *,

    body:has(.thermal-print-80) .pos-receipt *,

    body:has(.thermal-print-58) .pos-receipt * {

        color: #000 !important;

    }



    .pos-receipt.thermal-receipt-80 .receipt-company-name,

    .pos-receipt.thermal-receipt-58 .receipt-company-name {

        font-size: 14px !important;

        font-weight: 700 !important;

    }



    .pos-receipt.thermal-receipt-80 .receipt-title,

    .pos-receipt.thermal-receipt-58 .receipt-title {

        font-size: 15px !important;

        font-weight: 700 !important;

    }



    .pos-receipt.thermal-receipt-80 .receipt-item-name,

    .pos-receipt.thermal-receipt-58 .receipt-item-name {

        font-size: 13px !important;

        font-weight: 700 !important;

    }



    .pos-receipt.thermal-receipt-80 .receipt-info-row,

    .pos-receipt.thermal-receipt-58 .receipt-info-row,

    .pos-receipt.thermal-receipt-80 .receipt-total-row,

    .pos-receipt.thermal-receipt-58 .receipt-total-row,

    .pos-receipt.thermal-receipt-80 .receipt-payment-row,

    .pos-receipt.thermal-receipt-58 .receipt-payment-row,

    .pos-receipt.thermal-receipt-80 .receipt-items-header,

    .pos-receipt.thermal-receipt-58 .receipt-items-header {

        font-size: 12px !important;

        font-weight: 600 !important;

    }



    .pos-receipt.thermal-receipt-80 .receipt-total-row.grand-total,

    .pos-receipt.thermal-receipt-58 .receipt-total-row.grand-total {

        font-size: 14px !important;

        font-weight: 800 !important;

    }



    .pos-receipt.thermal-receipt-80 .receipt-footer,

    .pos-receipt.thermal-receipt-58 .receipt-footer,

    .pos-receipt.thermal-receipt-80 .receipt-footer *,

    .pos-receipt.thermal-receipt-58 .receipt-footer * {

        font-size: 11px !important;

        font-weight: 600 !important;

    }



    .pos-receipt.thermal-receipt-80 .receipt-items-box,

    .pos-receipt.thermal-receipt-58 .receipt-items-box,

    .pos-receipt.thermal-receipt-80 .receipt-totals,

    .pos-receipt.thermal-receipt-58 .receipt-totals {

        border-top: 1px solid #000 !important;

        border-bottom: 1px solid #000 !important;

    }



    .pos-receipt.thermal-receipt-80 .receipt-items-header,

    .pos-receipt.thermal-receipt-58 .receipt-items-header {

        border-bottom: 1px solid #000 !important;

    }



    .receipt-logo-thermal {

        -webkit-print-color-adjust: exact !important;

        print-color-adjust: exact !important;

        color-adjust: exact !important;

        color-scheme: only light !important;

    }



    .receipt-logo-thermal-img {

        max-height: var(--pos-thermal-logo-max-h-print) !important;

        width: auto !important;

        height: auto !important;

        min-width: 0 !important;

        min-height: 0 !important;

        margin: 0 auto !important;

        padding: 0 !important;

        object-fit: contain !important;

        object-position: center center !important;

        background: #fff !important;

        filter: grayscale(1) contrast(1.5) brightness(1.06) !important;

        -webkit-filter: grayscale(1) contrast(1.5) brightness(1.06) !important;

        -webkit-print-color-adjust: exact !important;

        print-color-adjust: exact !important;

        image-rendering: -webkit-optimize-contrast !important;

        image-rendering: crisp-edges !important;

        -ms-interpolation-mode: nearest-neighbor !important;

        page-break-inside: avoid;

        break-inside: avoid;

    }



    .pos-receipt.thermal-receipt-80 .receipt-logo-thermal-img {

        max-width: var(--pos-thermal-logo-max-w-80-print) !important;

    }



    .pos-receipt.thermal-receipt-58 .receipt-logo-thermal-img {

        max-width: var(--pos-thermal-logo-max-w-58-print) !important;

    }



    .receipt-logo-fallback-text {

        color: #000 !important;

        -webkit-print-color-adjust: exact !important;

        print-color-adjust: exact !important;

    }



    body.pos-thermal-printing,

    body:has(.pos-rcpt-modal-overlay.thermal-print-58),

    body:has(.pos-modal-overlay.thermal-print-58) {

        width: 58mm !important;

        max-width: 58mm !important;

    }



    body.pos-thermal-printing.thermal-print-80,

    body:has(.pos-rcpt-modal-overlay.thermal-print-80),

    body:has(.pos-modal-overlay.thermal-print-80) {

        width: 80mm !important;

        max-width: 80mm !important;

    }



    .pos-rcpt-modal-overlay.thermal-print-58,

    .pos-rcpt-modal-overlay.thermal-print-58 .pos-rcpt-modal,

    .pos-rcpt-modal-overlay.thermal-print-58 .print-area,

    .pos-rcpt-modal-overlay.thermal-print-58 .pos-receipt,

    .pos-modal-overlay.thermal-print-58,

    .pos-modal-overlay.thermal-print-58 .pos-modal,

    .pos-modal-overlay.thermal-print-58 .print-area,

    .pos-modal-overlay.thermal-print-58 .pos-receipt {

        width: 58mm !important;

        max-width: 58mm !important;

    }



    .pos-rcpt-modal-overlay.thermal-print-80,

    .pos-rcpt-modal-overlay.thermal-print-80 .pos-rcpt-modal,

    .pos-rcpt-modal-overlay.thermal-print-80 .print-area,

    .pos-rcpt-modal-overlay.thermal-print-80 .pos-receipt,

    .pos-modal-overlay.thermal-print-80,

    .pos-modal-overlay.thermal-print-80 .pos-modal,

    .pos-modal-overlay.thermal-print-80 .print-area,

    .pos-modal-overlay.thermal-print-80 .pos-receipt {

        width: 80mm !important;

        max-width: 80mm !important;

    }



    body.pos-thermal-printing .print-area .pos-receipt.thermal-receipt-80,

    body.pos-thermal-printing .print-area .pos-receipt.paper-3inch {

        width: 78mm !important;

        max-width: 78mm !important;

    }



    body.pos-thermal-printing .print-area .pos-receipt.thermal-receipt-58,

    body.pos-thermal-printing .print-area .pos-receipt.paper-2inch {

        width: 56mm !important;

        max-width: 56mm !important;

    }

}



/* ─── Thermal print v2: pt typography (print / isolated frame only) ─── */

body.pos-thermal-print-popup {
    margin: 0;
    padding: 2mm;
    background: #fff;
    -webkit-font-smoothing: none;
    text-rendering: optimizeSpeed;
}

@media print {
    body.pos-thermal-print-popup,
    body.pos-thermal-printing.pos-thermal-print-popup {
        width: 80mm !important;
        max-width: 80mm !important;
    }

    body.pos-thermal-print-popup.thermal-print-58,
    body.pos-thermal-printing.pos-thermal-print-popup.thermal-print-58 {
        width: 58mm !important;
        max-width: 58mm !important;
    }

    /* Isolated HTML print only — do not override modal preview / WYSIWYG capture */
    body.pos-thermal-print-popup .pos-receipt {
        font-family: var(--pos-thermal-font) !important;
        font-size: 10pt !important;
        font-weight: 600 !important;
        line-height: 1.35 !important;
        color: #000 !important;
        -webkit-font-smoothing: none !important;
        text-rendering: optimizeSpeed !important;
    }

    body.pos-thermal-print-popup .pos-receipt.invoice-receipt-thermal {
        font-family: var(--pos-invoice-font, Arial, Helvetica, sans-serif) !important;
        font-size: 11pt !important;
        font-weight: 400 !important;
        line-height: 1.4 !important;
    }

    body.pos-thermal-print-popup .pos-receipt * {
        font-family: var(--pos-thermal-font) !important;
        color: #000 !important;
        transform: none !important;
    }

    body.pos-thermal-print-popup .pos-receipt *:not(.receipt-logo-thermal-img) {
        filter: none !important;
    }
}

/* Legacy fallback: keep print identical to on-screen receipt preview */
@media print {
    body.pos-print-match-preview .pos-receipt.thermal-receipt-80,
    body.pos-print-match-preview .pos-receipt.paper-3inch {
        font-size: 13px !important;
        font-weight: 600 !important;
        line-height: 1.25 !important;
        padding: 5px !important;
        width: 80mm !important;
        max-width: 80mm !important;
        -webkit-font-smoothing: auto !important;
        text-rendering: auto !important;
    }

    body.pos-print-match-preview .pos-receipt.thermal-receipt-58,
    body.pos-print-match-preview .pos-receipt.paper-2inch {
        width: 58mm !important;
        max-width: 58mm !important;
    }

    body.pos-print-match-preview .pos-receipt .receipt-company-name {
        font-size: 16px !important;
    }

    body.pos-print-match-preview .pos-receipt .receipt-location-name {
        font-size: 14px !important;
    }

    body.pos-print-match-preview .pos-receipt .receipt-title {
        font-size: 15px !important;
    }

    body.pos-print-match-preview .pos-receipt .receipt-contact-info {
        font-size: 11px !important;
    }

    body.pos-print-match-preview .pos-receipt .receipt-table {
        font-size: 11px !important;
    }

    body.pos-print-match-preview .pos-receipt .receipt-total-row {
        font-size: 12px !important;
    }

    body.pos-print-match-preview .pos-receipt .receipt-footer {
        font-size: 11px !important;
        font-style: italic !important;
    }

    body.pos-print-match-preview .pos-receipt [style*="font-size"] {
        font-size: inherit !important;
    }
}

/* ─── POS Invoice: boxed layout (matches KOT-style reference) ─── */
.pos-receipt.invoice-receipt-thermal {
    --pos-invoice-font: Arial, Helvetica, sans-serif;
    --pos-invoice-fs-base: 14px;
    --pos-invoice-fs-sm: 11px;
    --pos-invoice-fs-md: 13px;
    --pos-invoice-fs-lg: 16px;
    --pos-invoice-fs-xl: 18px;
    --pos-invoice-fs-title: 18px;
    font-family: var(--pos-invoice-font) !important;
    font-size: var(--pos-invoice-fs-base);
    font-weight: 400;
    line-height: 1.4;
    color: #000 !important;
    padding: 4px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.pos-receipt.invoice-receipt-thermal .receipt-logo-thermal {
    margin-bottom: 6px;
}

.pos-receipt.invoice-receipt-thermal .receipt-box {
    border: 1px solid #000;
    padding: 6px 8px;
    margin-bottom: 6px;
    background: #fff;
    color: #000;
}

.pos-receipt.invoice-receipt-thermal .receipt-header-box {
    text-align: center;
}

.pos-receipt.invoice-receipt-thermal .receipt-title {
    font-size: var(--pos-invoice-fs-title);
    font-weight: 700;
    text-transform: uppercase;
    text-decoration: none;
    margin: 2px 0 4px;
    color: #000;
}

.pos-receipt.invoice-receipt-thermal .receipt-company-name {
    font-size: var(--pos-invoice-fs-lg);
    font-weight: 700;
    text-transform: none;
    margin-bottom: 2px;
    color: #000;
}

.pos-receipt.invoice-receipt-thermal .receipt-location-name {
    font-size: var(--pos-invoice-fs-lg);
    font-weight: 700;
    margin-bottom: 2px;
    color: #000;
}

.pos-receipt.invoice-receipt-thermal .receipt-contact-info {
    font-size: var(--pos-invoice-fs-md);
    font-weight: 400;
    margin-bottom: 2px;
    color: #000;
}

.pos-receipt.invoice-receipt-thermal .receipt-kv-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 3px;
    font-size: var(--pos-invoice-fs-base);
    line-height: 1.4;
    width: 100%;
}

.pos-receipt.invoice-receipt-thermal .receipt-kv-row:last-child {
    margin-bottom: 0;
}

.pos-receipt.invoice-receipt-thermal .receipt-kv-between {
    justify-content: space-between;
}

.pos-receipt.invoice-receipt-thermal .receipt-kv-label {
    font-weight: 700;
    color: #000;
    flex: 0 0 auto;
    text-align: left;
    white-space: nowrap;
}

.pos-receipt.invoice-receipt-thermal .receipt-kv-value {
    font-weight: 400;
    color: #000;
    flex: 0 1 auto;
    max-width: 68%;
    text-align: right;
    word-break: break-word;
}

.pos-receipt.invoice-receipt-thermal .receipt-kv-between .receipt-kv-value {
    flex: 0 1 auto;
    text-align: right;
}

.pos-receipt.invoice-receipt-thermal .receipt-items-box .receipt-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: var(--pos-invoice-fs-base);
}

.pos-receipt.invoice-receipt-thermal .receipt-items-box .receipt-table th {
    font-weight: 700;
    color: #000;
    border: none;
    border-bottom: 1px solid #000;
    padding: 4px 0;
    background: transparent;
}

.pos-receipt.invoice-receipt-thermal .receipt-items-box .receipt-table td {
    font-weight: 400;
    color: #000;
    padding: 3px 0;
    vertical-align: top;
}

.pos-receipt.invoice-receipt-thermal .receipt-items-box .receipt-table tr.item-separator td {
    border-bottom: 1px dotted #999;
    padding-bottom: 4px;
}

.pos-receipt.invoice-receipt-thermal .receipt-item-meta {
    font-size: var(--pos-invoice-fs-sm);
    font-weight: 400;
    color: #000;
}

.pos-receipt.invoice-receipt-thermal .receipt-barcode-wrap {
    text-align: center;
    margin: 8px 0;
}

.pos-receipt.invoice-receipt-thermal .receipt-barcode-wrap .receipt-voucher-no {
    font-size: var(--pos-invoice-fs-sm);
    font-weight: 400;
    margin-top: 4px;
    color: #000;
}

.pos-receipt.invoice-receipt-thermal .receipt-footer-box {
    text-align: center;
    font-size: var(--pos-invoice-fs-md);
    font-weight: 400;
    font-style: normal;
}

.pos-receipt.invoice-receipt-thermal .receipt-footer-box .receipt-policy-title {
    font-weight: 700;
    margin-top: 4px;
    font-style: normal;
}

.pos-receipt.invoice-receipt-thermal .receipt-footer-box .receipt-policy-note {
    font-size: var(--pos-invoice-fs-sm);
    font-weight: 400;
    margin-top: 2px;
}

.pos-receipt.invoice-receipt-thermal .receipt-divider {
    display: none;
    border: none;
    border-top: 1px dashed #000;
    margin: 6px 0;
    height: 0;
}

.pos-receipt.invoice-receipt-thermal .receipt-item-name {
    font-weight: 700;
    font-size: var(--pos-invoice-fs-base);
}

.pos-receipt.invoice-receipt-thermal .receipt-item-code {
    font-size: var(--pos-invoice-fs-sm);
    font-weight: 400;
    margin-left: 6px;
}

.pos-receipt.invoice-receipt-thermal .receipt-tax-title {
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.pos-receipt.invoice-receipt-thermal .receipt-trn {
    margin-top: 2px;
}

.pos-receipt.invoice-receipt-thermal .receipt-kv-mid {
    font-weight: 400;
    color: #000;
    margin-left: auto;
    margin-right: 8px;
}

.pos-receipt.invoice-receipt-thermal .receipt-discount-row .receipt-kv-value {
    flex: 0 1 auto;
    text-align: right;
    white-space: nowrap;
}

.pos-receipt.invoice-receipt-thermal .receipt-totals-qty-line {
    text-align: center;
    font-weight: 700;
    font-size: var(--pos-invoice-fs-base);
    margin-top: 6px;
    color: #000;
}

.pos-receipt.invoice-receipt-thermal .receipt-thank-you {
    font-style: italic;
    margin-bottom: 4px;
}

/* ─── Style 1: dashed dividers, no section boxes (reference screenshot) ─── */
.pos-receipt.invoice-receipt-thermal.receipt-style-1 .receipt-divider {
    display: block;
}

.pos-receipt.invoice-receipt-thermal.receipt-style-1 .receipt-box {
    border: none;
    padding: 4px 2px;
    margin-bottom: 0;
}

.pos-receipt.invoice-receipt-thermal.receipt-style-1 .receipt-tax-title {
    text-decoration: underline;
}

.pos-receipt.invoice-receipt-thermal.receipt-style-1 .receipt-items-box .receipt-table th {
    border-top: 1px dashed #000;
    border-bottom: 1px dashed #000;
}

.pos-receipt.invoice-receipt-thermal.receipt-style-1 .receipt-items-box .receipt-table tr.item-separator td {
    border-bottom: 1px dashed #999;
}

.pos-receipt.invoice-receipt-thermal.receipt-style-1 .receipt-footer-box {
    border: none;
    padding-top: 4px;
}

/* ─── Style 2: boxed sections with solid borders ─── */
.pos-receipt.invoice-receipt-thermal.receipt-style-2 .receipt-divider {
    display: none;
}

.pos-receipt.invoice-receipt-thermal.receipt-style-2 .receipt-box {
    border: 1px solid #000;
    padding: 6px 8px;
    margin-bottom: 6px;
}

.pos-receipt.invoice-receipt-thermal.receipt-style-2 .receipt-tax-title {
    text-decoration: none;
}

.pos-receipt.invoice-receipt-thermal.receipt-style-2 .receipt-items-box .receipt-table th {
    border-bottom: 1px solid #000;
}

.pos-receipt.invoice-receipt-thermal.receipt-style-2 .receipt-items-box .receipt-table tr.item-separator td {
    border-bottom: 1px dotted #999;
}

@media print {
    .pos-receipt.invoice-receipt-thermal {
        font-size: 14px !important;
        line-height: 1.4 !important;
    }

    .pos-receipt.invoice-receipt-thermal,
    .pos-receipt.invoice-receipt-thermal * {
        font-family: var(--pos-invoice-font, Arial, Helvetica, sans-serif) !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .pos-receipt.invoice-receipt-thermal .receipt-title {
        font-size: 18px !important;
    }

    .pos-receipt.invoice-receipt-thermal .receipt-company-name,
    .pos-receipt.invoice-receipt-thermal .receipt-location-name {
        font-size: 16px !important;
    }

    .pos-receipt.invoice-receipt-thermal .receipt-contact-info,
    .pos-receipt.invoice-receipt-thermal .receipt-kv-row,
    .pos-receipt.invoice-receipt-thermal .receipt-items-box .receipt-table,
    .pos-receipt.invoice-receipt-thermal .receipt-item-name,
    .pos-receipt.invoice-receipt-thermal .receipt-totals-qty-line {
        font-size: 14px !important;
    }

    .pos-receipt.invoice-receipt-thermal .receipt-footer-box {
        font-size: 13px !important;
    }

    .pos-receipt.invoice-receipt-thermal .receipt-item-meta,
    .pos-receipt.invoice-receipt-thermal .receipt-item-code,
    .pos-receipt.invoice-receipt-thermal .receipt-barcode-wrap .receipt-voucher-no,
    .pos-receipt.invoice-receipt-thermal .receipt-footer-box .receipt-policy-note {
        font-size: 11px !important;
    }

    .pos-receipt.invoice-receipt-thermal.receipt-style-2 .receipt-box {
        border: 1px solid #000 !important;
    }

    .pos-receipt.invoice-receipt-thermal.receipt-style-1 .receipt-box {
        border: none !important;
    }

    .pos-receipt.invoice-receipt-thermal.receipt-style-1 .receipt-divider {
        display: block !important;
        border-top: 1px dashed #000 !important;
    }

    .pos-receipt.invoice-receipt-thermal.receipt-style-2 .receipt-divider {
        display: none !important;
    }
}


