/* Print Styles for Daily Accounting Report */
@media print {
    @page {
        size: letter landscape;
        margin: 0.5in 0.5in 1in 0.5in; /* top right bottom left - more space for footer */
    }
    
    /* Force color printing */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    
    /* Hide screen elements */
    .action-buttons,
    .no-print,
    .loading,
    .no-data,
    .spinner {
        display: none !important;
    }
    
    /* Reset body and containers */
    body {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
        font-family: Arial, sans-serif !important;
        font-size: 8pt !important;
        color: #000 !important;
        max-width: 100% !important;
    }
    
    #reportContent {
        display: block !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Header styling */
    .report-header {
        text-align: center !important;
        margin-bottom: 30px !important;
        padding-bottom: 15px !important;
        border-bottom: 2px solid #000 !important;
        background: none !important;
    }
    
    .report-header h1 {
        font-size: 14pt !important;
        margin: 0 !important;
        color: #000 !important;
        font-weight: bold !important;
    }
    
    .report-date {
        font-size: 8pt !important;
        margin-top: 5px !important;
        color: #333 !important;
    }
    
    /* Sections */
    .report-section {
        page-break-inside: avoid !important;
        margin-bottom: 25px !important;
        padding: 0 !important;
        border: none !important;
        background: none !important;
        box-shadow: none !important;
        /* Add padding-top to ensure content isn't cut off at page break */
        padding-top: 20px !important;
    }
    
    /* Ensure first section on any page has proper spacing */
    .report-section:first-child {
        padding-top: 0 !important;
    }
    
    /* Special handling for Patient Details section to prevent cutoff */
    .report-section:has(#patientDetailsTable) {
        page-break-before: auto !important;
        margin-top: 40px !important;
        padding-top: 30px !important;
    }
    
    .section-title {
        font-size: 7pt !important;
        font-weight: bold !important;
        margin-bottom: 10px !important;
        padding-bottom: 3px !important;
        border-bottom: 1px solid #000 !important;
        color: #000 !important;
        /* Prevent title from being separated from content */
        page-break-after: avoid !important;
        break-after: avoid !important;
        /* Add margin-top for better spacing */
        margin-top: 10px !important;
    }
    
    /* Summary cards */
    .summary-grid {
        display: table !important;
        width: 100% !important;
        margin-bottom: 20px !important;
    }
    
    .summary-card {
        display: table-cell !important;
        width: 25% !important;
        text-align: center !important;
        padding: 10px !important;
        border: 1px solid #000 !important;
        background: #f5f5f5 !important;
    }
    
    .summary-card h3 {
        font-size: 8pt !important;
        margin: 0 0 5px 0 !important;
        color: #333 !important;
        font-weight: normal !important;
    }
    
    .summary-value {
        font-size: 10pt !important;
        font-weight: bold !important;
        color: #000 !important;
    }
    
    /* Tables */
    .data-table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin-top: 10px !important;
        page-break-inside: auto !important;
    }
    
    /* Ensure table headers stay with content */
    .data-table thead {
        display: table-header-group !important;
    }
    
    /* Specific fix for patient details table */
    #patientDetailsTable {
        margin-top: 20px !important;
    }
    
    .data-table th {
        background-color: #333 !important;
        color: #fff !important;
        padding: 5px !important;
        text-align: left !important;
        font-size: 7pt !important;
        font-weight: bold !important;
        border: 1px solid #000 !important;
    }
    
    .data-table td {
        padding: 4px !important;
        border: 1px solid #ccc !important;
        font-size: 7pt !important;
    }
    
    /* Patient grouping */
    .patient-group-even {
        background-color: #f5f5f5 !important;
    }
    
    .patient-group-odd {
        background-color: #fff !important;
    }
    
    .patient-group-separator td {
        border-bottom: 2px solid #000 !important;
    }
    
    /* Revenue breakdown */
    .revenue-breakdown {
        display: table !important;
        width: 100% !important;
    }
    
    .breakdown-section {
        display: table-cell !important;
        width: 50% !important;
        padding: 10px !important;
        border: 1px solid #000 !important;
        vertical-align: top !important;
    }
    
    .breakdown-section h4 {
        font-size: 7pt !important;
        margin: 0 0 10px 0 !important;
        font-weight: bold !important;
    }
    
    .breakdown-item {
        display: flex !important;
        justify-content: space-between !important;
        padding: 4px 0 !important;
        border-bottom: 1px solid #ccc !important;
    }
    
    /* Footer styles */
    .report-footer {
        display: block !important;
        position: fixed;
        bottom: 0.25in; /* Position footer within printable area */
        left: 0.5in;
        right: 0.5in;
        height: 25px;
        line-height: 25px;
        background: white;
        border-top: 1px solid #000;
        text-align: center;
        font-size: 9pt;
        font-weight: normal;
        color: #333;
        z-index: 1000;
    }
    
    /* Alternative footer positioning for better compatibility */
    @supports not (position: fixed) {
        .report-footer {
            position: absolute;
            margin-top: 20px;
        }
    }
    
    /* Ensure content doesn't overlap footer */
    .report-container {
        padding-bottom: 50px !important; /* Space for footer */
        margin-bottom: 0 !important;
    }
    
    /* Ensure proper spacing on all pages */
    body {
        position: relative !important;
        min-height: 100vh !important;
    }
    
    /* Page number (limited browser support) */
    .page-number::after {
        content: counter(page);
    }
    
    /* Prevent orphaned headers */
    .report-section {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
    
    .section-title {
        page-break-after: avoid !important;
        break-after: avoid !important;
    }
    
    /* Special handling for Patient Details section to prevent cutoff */
    .report-section:nth-of-type(3) { /* Assuming Patient Details is the 3rd section */
        page-break-before: auto !important;
        margin-top: 30px !important;
    }
    
    /* Alternative: Target by heading content if possible */
    .report-section:has(.section-title:contains("Patient Details")) {
        margin-top: 30px !important;
    }
    
    /* Target Patient Details section specifically by table ID */
    .report-section:has(#patientDetailsTable) {
        page-break-before: auto !important;
        margin-top: 40px !important;
        padding-top: 30px !important;
    }
    
    /* Ensure the Patient Details table header row stays with content */
    #patientDetailsTable thead {
        display: table-header-group !important;
    }
    
    #patientDetailsTable thead tr {
        page-break-inside: avoid !important;
        page-break-after: avoid !important;
    }
    
    /* Ensure tables don't break awkwardly */
    .data-table {
        page-break-inside: auto !important;
    }
    
    .data-table tr {
        page-break-inside: avoid !important;
        page-break-after: auto !important;
    }
}