/**************************************************
 * PRINT STYLES - ALL MODULES
 * 
 * Comprehensive print styles for all modules
 * ensuring clean, professional document output
 **************************************************/

@media print {
    @page {
        size: A3;
        margin: 5mm;
    }
    
    /* Hide ALL interface elements */
    .no-print, 
    .module-controls, 
    header, 
    .tabs, 
    button,
    .button,
    .control-btn,
    .control-buttons,
    .add-row-btn,
    .remove-row-btn,
    .remove-item,
    .remove-term,
    .sidebar,
    nav,
    .action-column,
    [onclick] {
       display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        width: 0 !important;
        height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        position: absolute !important;
        top: -9999px !important;
        left: -9999px !important;
    }

    /* CRITICAL: Force natural page flow */
    html, body {
        width: auto !important;
        height: auto !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Remove ALL container constraints */
    * {
        position: static !important;
        float: none !important;
        max-width: none !important;
        max-height: none !important;
        overflow: visible !important;
        transform: none !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        border: none !important;
        outline: none !important;
        box-shadow: none !important;
    }
    
    /* Force all module containers to flow naturally */
    .quotation-container,
    .invoice-container,
    .receipt-container,
    .calculator-container,
    .tracker-container,
    .dashboard-container,
    .module-container,
    .main-content,
    .app-container {
         width: 100% !important;
        max-width: none !important;
        
        position: static !important;
        overflow: visible !important;
        height: auto !important;
        min-height: 0 !important;
        top: 0 !important;
        left: 0 !important;
        page-break-before: auto !important;
        page-break-after: auto !important;
    }
    
    /* FIX 1: COMPREHENSIVE FORM CONTROL HIDING */
    /* Hide ALL form control indicators and dropdowns */
    input[type="date"]::-webkit-calendar-picker-indicator,
    input[type="date"]::-webkit-inner-spin-button,
    input[type="number"]::-webkit-outer-spin-button,
    input[type="number"]::-webkit-inner-spin-button,
    select::-ms-expand,
    select::-webkit-appearance,
    input::-webkit-outer-spin-button,
    input::-webkit-inner-spin-button,
    textarea::-webkit-resizer {
        display: none !important;
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        width: 0 !important;
        height: 0 !important;
    }
    
    /* Clean form fields appearance */
    input, textarea, select {
        border: none !important;
        background: transparent !important;
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
        color: inherit !important;
        font-family: inherit !important;
        font-size: inherit !important;
        padding: 0 !important;
        margin: 0 !important;
        outline: none !important;
        resize: none !important;
    }
    
    /* FIX 2: PROPER TABLE LAYOUT WITH CONTENT CONTAINMENT */
    table {
        width: 100% !important;
        border-collapse: collapse !important;
        table-layout: fixed !important;
        page-break-inside: auto !important;
        margin-bottom: 15px !important;
        border: 1px solid #ddd !important;
    }
    
    th, td {
        border: 1px solid #ddd !important;
        padding: 5px 8px !important;
        text-align: left !important;
        vertical-align: top !important;
        font-size: 11px !important;
        line-height: 1.3 !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        hyphens: auto !important;
        overflow: hidden !important;
    }
    
    th {
        background-color: #f8f8f8 !important;
        font-weight: bold !important;
        page-break-after: avoid;
    }
    
    tr {
        page-break-inside: avoid;
    }
    
    /* Hide action columns completely */
    th:last-child,
    td:last-child,
    .action-column {
        display: none !important;
        width: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* SPECIFIC TABLE LAYOUTS - Fixed column widths that add up to 100% */
    
    /* Invoice items table (6 columns after hiding action) */
    .invoice-items-table th:nth-child(1),
    .invoice-items-table td:nth-child(1) { width: 6% !important; }
    
    .invoice-items-table th:nth-child(2),
    .invoice-items-table td:nth-child(2) { width: 24% !important; }
    
    .invoice-items-table th:nth-child(3),
    .invoice-items-table td:nth-child(3) { width: 38% !important; }
    
    .invoice-items-table th:nth-child(4),
    .invoice-items-table td:nth-child(4) { width: 12% !important; }
    
    .invoice-items-table th:nth-child(5),
    .invoice-items-table td:nth-child(5) { width: 8% !important; }
    
    .invoice-items-table th:nth-child(6),
    .invoice-items-table td:nth-child(6) { width: 12% !important; }
    
    /* Receipt table (3 columns after hiding action) */
    .receipt-items-table th:nth-child(1),
    .receipt-items-table td:nth-child(1) { width: 8% !important; }
    
    .receipt-items-table th:nth-child(2),
    .receipt-items-table td:nth-child(2) { width: 67% !important; }
    
    .receipt-items-table th:nth-child(3),
    .receipt-items-table td:nth-child(3) { width: 25% !important; }
    
    /* Quotation budget table (6 columns after hiding action) */
    #budget-table th:nth-child(1),
    #budget-table td:nth-child(1) { width: 6% !important; }
    
    #budget-table th:nth-child(2),
    #budget-table td:nth-child(2) { width: 20% !important; }
    
    #budget-table th:nth-child(3),
    #budget-table td:nth-child(3) { width: 38% !important; }
    
    #budget-table th:nth-child(4),
    #budget-table td:nth-child(4) { width: 8% !important; }
    
    #budget-table th:nth-child(5),
    #budget-table td:nth-child(5) { width: 13% !important; }
    
    #budget-table th:nth-child(6),
    #budget-table td:nth-child(6) { width: 15% !important; }
    
    /* Timeline table (3 columns after hiding action) */
    #timeline-table th:nth-child(1),
    #timeline-table td:nth-child(1) { width: 6% !important; }
    
    #timeline-table th:nth-child(2),
    #timeline-table td:nth-child(2) { width: 69% !important; }
    
    #timeline-table th:nth-child(3),
    #timeline-table td:nth-child(3) { width: 25% !important; }
    
    /* Payment schedule table (4 columns after hiding action) */
    .payment-schedule-table th:nth-child(1),
    .payment-schedule-table td:nth-child(1) { width: 25% !important; }
    
    .payment-schedule-table th:nth-child(2),
    .payment-schedule-table td:nth-child(2) { width: 10% !important; }
    
    .payment-schedule-table th:nth-child(3),
    .payment-schedule-table td:nth-child(3) { width: 45% !important; }
    
    .payment-schedule-table th:nth-child(4),
    .payment-schedule-table td:nth-child(4) { width: 20% !important; }
    
    /* Right-align amounts */
    .amount, .item-total, .term-amount,
    #invoiceTotal, #receiptTotal, #grand-total,
    td:nth-child(6), td:nth-child(4), td:nth-child(3) {
        text-align: right !important;
    }
    
    /* Typography */
   /* ADD THESE UPDATES TO YOUR EXISTING print.css */

    /* Replace the Typography section with these smaller sizes */
    body {
        font-family: 'Open Sans', Arial, sans-serif !important;
        font-size: 9pt !important;  /* was 12pt */
        line-height: 1.2 !important;  /* was 1.4 */
        color: black !important;
    }

    h1, .title {
        font-size: 16pt !important;  /* was 24pt */
        color: black !important;
        margin-bottom: 8px !important;  /* was 15px */
        page-break-after: avoid;
    }

    h2, h3, .section-title {
        font-size: 11pt !important;  /* was 14pt */
        font-weight: bold !important;
        color: black !important;
        margin: 8px 0 5px 0 !important;  /* was 15px 0 10px 0 */
        page-break-after: avoid;
    }

    /* Company names - smaller */
    .company-name, 
    #invoice-company-name,
    #receipt-company-name {
        font-size: 10pt !important;  /* was 13pt */
        font-weight: bold !important;
    }

    /* Update table cells for tighter spacing */
    th, td {
        border: 1px solid #ddd !important;
        padding: 3px 5px !important;  /* was 5px 8px */
        text-align: left !important;
        vertical-align: top !important;
        font-size: 8pt !important;  /* was 11px */
        line-height: 1.1 !important;  /* was 1.3 */
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        hyphens: auto !important;
        overflow: hidden !important;
        background: white !important;
        color: black !important;
    }

    /* Compress table margins */
    table {
        width: 100% !important;
        border-collapse: collapse !important;
        table-layout: fixed !important;
        page-break-inside: auto !important;
        margin-bottom: 6px !important;  /* was 15px */
        border: 1px solid #ddd !important;
    }

    /* Make item descriptions even smaller */
    .invoice-items-table td:nth-child(3),
    #budget-table td:nth-child(3) {
        font-size: 7pt !important;
        line-height: 1.0 !important;
    }

    /* Compress all margins and spacing */
    .invoice-container,
    .quotation-container,
    .receipt-container {
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Smaller spacing between sections */
    .section-title {
        margin: 5px 0 3px 0 !important;
    }

    /* Compress address and contact info */
    .company-address,
    .bill-to-address,
    .client-info {
        font-size: 7pt !important;
        line-height: 1.0 !important;
        margin: 2px 0 !important;
    }

    /* Notes section - very compact */
    .notes,
    .payment-notes,
    .invoice-notes {
        font-size: 7pt !important;
        line-height: 1.1 !important;
        margin: 4px 0 !important;
    }

    /* Invoice/document numbers and dates */
    .invoice-number,
    .document-number,
    .invoice-date {
        font-size: 8pt !important;
        margin: 1px 0 !important;
    }
    /* Images */
    img {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        max-width: 150px !important;
        height: auto !important;
        page-break-inside: avoid;
    }
    
    /* Logo specific */
    .logo-container img,
    #companyLogoDisplay,
    #receipt-logo-display {
        max-width: 120px !important;
        max-height: 80px !important;
    }
    
    /* Signature specific */
    .signature-container img,
    #signatureDisplay,
    #receipt-signature-display {
        max-width: 150px !important;
        max-height: 60px !important;
    }
    
    .section-title{
        color: black;
    }
    
    /* Timeline visibility control */
    .timeline-section.timeline-hidden {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Hide timeline toggle controls */
    #timeline-toggle,
    .timeline-toggle-container label {
        display: none !important;
    }
}