/* print.css */

/* Ensure tables fit within the page margins */
@media print {
    body {
        font-family: Arial, sans-serif;
    }

    .table-container {
        width: 100%;
        overflow-x: auto; /* Add horizontal scroll if needed */
        page-break-inside: avoid; /* Avoid breaking inside the container */
    }

    table {
        width: 100%;
        max-width: 100%; /* Ensure the table does not exceed the page width */
        border-collapse: collapse;
        table-layout: auto; /* Adjust column widths based on content */
        word-wrap: break-word; /* Ensure long words break to fit within cells */
        page-break-inside: auto; /* Allow breaking inside the table */
    }

    th, td {
        padding: 8px;
        border: 1px solid #ddd;
        text-align: left;
        page-break-inside: avoid; /* Avoid breaking inside table cells */
        word-wrap: break-word; /* Ensure long words break to fit within cells */
    }

    th {
        background-color: #f4f4f4;
    }

    /* Ensure proper page breaks for long tables */
    tr {
        page-break-inside: avoid; /* Avoid breaking inside rows */
        page-break-after: auto; /* Allow breaking after rows */
    }

    thead {
        display: table-header-group; /* Ensure thead is repeated on new pages */
    }

    tfoot {
        display: table-footer-group; /* Ensure tfoot is repeated on new pages */
    }

    /* Ensure wide tables are handled properly */
    table, th, td {
        max-width: 100%;
        white-space: normal; /* Allow wrapping */
    }

    /* Ensure the image and the table are not split across pages */
    img {
        page-break-before: auto;
        page-break-after: avoid;
        page-break-inside: avoid;
    }

    .image-and-table {
        page-break-inside: avoid; /* Avoid breaking inside this container */
    }

    .page-break {
        page-break-before: always;
    }
}
