/* css/print.css */

/* Hide everything by default when printing */
body * {
    visibility: hidden;
}

/* Make only the form modal and its content visible */
#form-modal-body, #form-modal-body * {
    visibility: visible;
}

/* Position the form content exactly as previewed */
#form-modal-body {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 20px;
    margin: 0;
    border: none !important;
    box-shadow: none !important;
    background: white !important;
}

/* Print styles - exactly matching screen preview */
@media print {
    /* Reset page margins to match preview */
    @page {
        margin: 0cm; /* Remove default page margins to match preview */
        size: auto;
    }
    
    /* Remove browser default print margins */
    body {
        margin: 0;
        padding: 0;
        background: white;
    }
    
    /* Ensure form modal displays exactly as previewed */
    #form-modal-body {
        position: relative;
        margin: 0 auto;
        padding: 20px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        background: white !important;
        color: black !important;
    }
    
    /* Preserve all text styling from preview */
    #form-modal-body,
    #form-modal-body * {
        visibility: visible !important;
        color: black !important;
        background: transparent !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    /* Normal text - exactly as preview */
    #form-modal-body,
    .normal-text,
    p, span, div, label, input, textarea, select {
        font-weight: normal;
        font-size: inherit;
        line-height: inherit;
        color: black;
    }
    
    /* Bold text - preserve inline and exact weight */
    b, strong, 
    .bold, 
    .fw-bold, 
    font-weight-bold,
    [style*="font-weight: bold"],
    [style*="font-weight: 700"],
    [style*="font-weight: bolder"] {
        font-weight: bold !important;
        display: inline !important;
        font-size: inherit !important;
    }
    
    /* Headings - preserve their boldness */
    h1, h2, h3, h4, h5, h6,
    .h1, .h2, .h3, .h4, .h5, .h6 {
        font-weight: bold !important;
        margin: 0.67em 0;
    }
    
    /* Preserve layout exactly as preview */
    .container, .row, .col, 
    .form-group, .form-row,
    .modal-content, .modal-body {
        display: block;
        width: 100%;
        margin: 0;
        padding: 0;
        position: relative;
    }
    
    /* Preserve flex and grid layouts from preview */
    .d-flex, .row, [style*="display: flex"],
    [style*="display: grid"] {
        display: flex !important;
        flex-wrap: wrap !important;
    }
    
    /* Preserve spacing exactly as preview */
    .m-0, .p-0, .mt-0, .mb-0, .ml-0, .mr-0 {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Preserve exact dimensions */
    [style*="width:"],
    [style*="height:"],
    [style*="min-width:"],
    [style*="max-width:"] {
        width: auto !important;
        height: auto !important;
    }
    
    /* Form elements - match preview exactly */
    input, textarea, select, button {
        border: 1px solid #ccc !important;
        background: white !important;
        color: black !important;
        font-family: inherit !important;
        font-size: inherit !important;
        padding: 6px 12px !important;
        margin: 4px 0 !important;
        box-sizing: border-box !important;
    }
    
    /* Input borders visible in print */
    input, textarea, select {
        border: 1px solid #000 !important;
    }
    
    /* Checkboxes and radio buttons */
    input[type="checkbox"],
    input[type="radio"] {
        border: 1px solid #000 !important;
        width: 16px !important;
        height: 16px !important;
        display: inline-block !important;
    }
    
    /* Preserve background colors that might be important */
    [style*="background-color"],
    [style*="background"] {
        background-color: transparent !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Force exact color printing for important elements */
    .bg-primary, .bg-success, .bg-danger, .bg-warning,
    [class*="bg-"] {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Preserve borders exactly */
    [style*="border"],
    .border, .border-top, .border-bottom, 
    .border-left, .border-right {
        border: 1px solid #000 !important;
    }
    
    /* Text alignment preservation */
    [style*="text-align"],
    .text-left, .text-center, .text-right {
        text-align: inherit !important;
    }
    
    /* Prevent unwanted page breaks inside elements */
    p, div, section, article, .form-group {
        page-break-inside: avoid;
        break-inside: avoid;
    }
    
    /* Allow page breaks only at natural breaks */
    .page-break-before {
        page-break-before: always;
        break-before: always;
    }
    
    .page-break-after {
        page-break-after: always;
        break-after: always;
    }
    
    /* Ensure URLs are visible (if any) */
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 90%;
    }
    
    /* Remove unnecessary elements for print */
    .no-print, 
    button[type="button"],
    .btn-close,
    .close-modal {
        display: none !important;
    }
    
    /* Ensure proper table rendering */
    table {
        border-collapse: collapse !important;
        width: 100% !important;
    }
    
    th, td {
        border: 1px solid #000 !important;
        padding: 8px !important;
        text-align: left !important;
    }
    
    /* Preserve list styling */
    ul, ol {
        margin: 0 0 10px 20px !important;
        padding: 0 !important;
    }
    
    /* Fix for overflowing content */
    pre, code, .pre {
        white-space: pre-wrap !important;
        word-wrap: break-word !important;
    }
}

/* Non-print fallback styles for screen */
input, textarea, select {
    border: 1px solid #ccc !important;
}

/* Preserve inline bold text */
b, strong, .bold, .fw-bold {
    font-weight: bold;
    display: inline;
}