/*
 * Screen Styles (Unchanged - for screen preview outside print media)
 * These styles make the print preview look good on a computer screen.
*/
.print-header { font-size: 20pt; font-weight: bold; }
.print-row-header { font-size: 12pt; font-weight: bold; }
.printable-table { margin-top: 5mm; border: 0.75mm solid black; } /* Main table border for screen */
.printable-table td,
.printable-table th { /* Cell borders for screen */
    border: 0.25mm solid black;
    padding: 5px;
    vertical-align: top;
}
.signature-box { border: 3px solid black; }
.print-large { font-size: 26pt; font-weight: bold; }
.print-row-header-strong { font-size: 18pt; font-weight: bold; }
.print-small { font-size: 11pt; }
.print-td-value { margin-left: 5px; }


/*
 * Print Styles (REVISED AGAIN FOR BOOTSTRAP 5)
 * These styles are only applied when the user prints the page.
*/
@media print {
    @page {
        size: A4 portrait;
        margin: 0 5mm; /* Consistent margins */
    }

    .dashboard_content h1,
    .dashboard_content h2 {
        display: none !important;
    }

    /* --- General Reset for Print --- */
    body {
        padding-top: 0 !important; /* Force remove top padding */
        background: transparent !important; /* Ensure no background colors */
        font-size: 7pt !important; /* Smaller base font size for print */
        color: black !important;
        -webkit-print-color-adjust: exact; /* Ensure background colors are printed if used for design */
        print-color-adjust: exact;
    }

    /* Universal reset for elements that might introduce unwanted space or styling */
    * {
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        text-shadow: none !important;
        transition: none !important;
        border-color: black !important; /* Ensure borders are black */
    }

    /* --- Hide Unwanted Elements --- */
    #sidebarMenu,
    footer.footer,
    nav[aria-label="breadcrumb"],
    #djDebug,
    .screen-only,
    .h2 {
        display: none !important;
    }

    /* --- Handle the Main Navbar and Logo --- */
    /* Only allow specific elements within the navbar to show */
    .navbar {
        min-height: auto !important; /* Remove min-height */
        padding: 0 !important; /* Remove padding */
        margin-bottom: 5mm !important; /* Add space below the logo */
    }

    .navbar-brand {
        display: block !important; /* Ensure brand is visible */
        text-align: left !important;
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important; /* Allow image to define height */
    }
    .navbar-brand img {
        max-height: 1.2cm !important; /* Smaller logo for print */
        width: auto !important;
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Hide other navbar components */
    .navbar button,
    .navbar .navbar-toggler,
    .navbar .navbar-nav,
    .navbar .container-fluid > div:not(.navbar-brand), /* Hide other elements in navbar-fluid */
    .navbar .offcanvas {
        display: none !important;
    }

    /* --- Table Specific Print Styles --- */
    .printable-table {
        margin-top: 2mm !important;
        border: none !important; /* Remove outer table border if cell borders are active */
    }

    .printable-table table {
        width: 100% !important; /* Ensure table spans full width */
        border-collapse: collapse !important; /* Crucial for clean cell borders */
        /* Removed the table-level border as we're doing cell borders */
    }

    .printable-table td,
    .printable-table th {
        border: 0.25mm solid black !important; /* RE-ADDED: Cell borders for print */
        padding: 0.5mm !important; /* Reduced padding for more content */
        vertical-align: top !important;
        font-size: inherit !important; /* Inherit font size from body */
        line-height: 1.2 !important;
    }

    /* --- Adjust Print Content Font Sizing --- */
    /* Further reduction of font sizes to fit more on the page */
    .print-header { font-size: 10pt !important; }
    .print-row-header-strong { font-size: 9pt !important; }
    .print-row-header { font-size: 7pt !important; }
    .print-small { font-size: 6pt !important; }
    .print-large { font-size: 16pt !important; }

    /* --- Page Break Rules --- */
    .page_break {
        page-break-after: always !important;
        margin-top: 1cm !important; /* Add space between pages */
    }
    .no_page_break {
        page-break-inside: avoid !important;
    }
}