/* Print-specific styles for invoice page */
@page {
    size: 8.5in 11in portrait;
    margin: 12mm;
}

@media print {
    /* Reset backgrounds and colors */
    * {
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    .text-danger {
        color: #b30000 !important;
    }
    body, html {
        background: #fff !important;
    }

    /* Hide navigation, sidebar, footer and interactive elements (allow inputs and selects in invoice table) */
    #sidebar-menu,
    .app-background,
    footer,
    .btn,
    button,
    .itemdelete,
    .paydelete,
    #addnewitem,
    #register_payment,
    .eliminarbtn,
    .autocomplete-results {
        display: none !important;
    }

    /* Ensure main content takes full width */
    #content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    /* Table borders and layout: fixed to fit page width */
    table {
        border-collapse: collapse !important;
        width: 100% !important;
        table-layout: auto !important;
        max-width: 100% !important;
    }
    table th,
    table td {
        border: 1px solid #c9c9c9 !important;
        padding: 3px 5px !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    /* Avoid page breaks inside rows */
    tr, img {
        page-break-inside: avoid !important;
    }

    /* Print header and footer text styling */
    .title, .theformbtn {
        color: #000 !important;
    }

    /* Remove input appearance for text-only look */
    .itemtable select,
    .itemtable input:not(.d-print-none),
    input:not(.d-print-none),
    select,
    textarea {
        display: table-cell !important;
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
        appearance: none;
        color: #000;
        max-width: 100% !important;
        white-space: normal !important;
    }

    .itemtable .product-input,
    .c_phone,
    .c_contact,
    .c_name {
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .itemtable col.col-remove {
        width: 35px !important;
    }

    .itemtable col.col-qty {
        width: 70px !important;
    }

    .itemtable col.col-price-regular,
    .itemtable col.col-price-special,
    .itemtable col.col-total {
        width: 90px !important;
    }

    .itemtable thead th:nth-last-child(-n+3),
    .itemtable tbody td:nth-last-child(-n+3) {
        white-space: nowrap !important;
    }

    .d-print-none {
        display: none !important;
    }

    /* Font size for tables and form fields */
    table, table th, table td, input, select, textarea {
        font-size: 11px !important;
    }

    /* Body padding is handled by @page margins; ensure no additional padding */
    body {
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box;
        background: #fff !important;
    }
    html {
        margin: 0;
        padding: 0;
    }
    /* Expand containers to available print width within @page margins */
    .container,
    .container-fluid {
        width: 100% !important;
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    /* Ensure content area spans full container width */
    #content {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Ensure responsive containers fill width and allow horizontal space */
    .table-responsive {
        width: 100% !important;
        overflow-x: visible !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Invoice header columns occupy half width each */
    .row.g-3,
    .d-flex.justify-content-between.align-items-top,
    .d-flex.justify-content-between.align-items-center {
        display: flex !important;
        flex-wrap: wrap !important;
    }
    .row.g-3 > div,
    .d-flex.justify-content-between.align-items-top > div,
    .d-flex.justify-content-between.align-items-center > div {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }

    input, select, textarea {
        border: none !important;
        box-shadow: none !important;
    }

    .input-group {
        display: inline-flex !important;
        align-items: center !important;
        gap: 3px !important;
        width: auto !important;
    }

    .input-group-text {
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        font-weight: 400 !important;
        color: #000 !important;
    }

}
