/* Print Styles for NovaInvoice */

@media print {
    /* Hide navigation, header, footer, buttons, and other non-essential elements */
    nav, 
    header, 
    footer, 
    .bg-gray-50.px-6.py-4.border-b.border-gray-200,
    .invoice-container > div:first-child,
    button,
    a.border,
    a.bg-indigo-600,
    #actions-dropdown-container,
    #signature-link-toast,
    .hidden {
        display: none !important;
    }
    
    /* Reset background colors and remove shadows for better printing */
    body, 
    .min-h-screen, 
    .bg-gray-100, 
    .bg-gray-50, 
    .bg-white {
        background-color: white !important;
        background: white !important;
        box-shadow: none !important;
        min-height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Remove borders and shadows from the invoice container */
    .invoice-container {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        overflow: visible !important;
    }
    
    /* Ensure the invoice content is fully visible */
    .p-8 {
        padding: 0.5cm !important;
    }
    
    /* Adjust font sizes for better printing */
    body {
        font-size: 12pt !important;
    }
    
    h1 {
        font-size: 18pt !important;
    }
    
    h2 {
        font-size: 16pt !important;
    }
    
    /* Ensure page breaks don't occur in the middle of important sections */
    .mb-8 {
        page-break-inside: avoid;
    }
    
    /* Improved Bill To section spacing for print */
    .mb-8 h3.text-gray-700.font-semibold {
        margin-bottom: 10px !important;
        font-size: 14pt !important;
        font-weight: bold !important;
    }
    
    .mb-8 .font-bold.text-lg.text-gray-800 {
        margin-bottom: 8px !important;
        font-size: 12pt !important;
    }
    
    .mb-8 .text-gray-600.mt-2 > div {
        margin-bottom: 5px !important;
        line-height: 1.4 !important;
    }
    
    /* Improved Items table spacing for print */
    table.w-full {
        margin-top: 20px !important;
        margin-bottom: 20px !important;
    }
    
    table.w-full th {
        padding: 8px 12px !important;
        font-weight: bold !important;
        border-bottom: 1pt solid #000 !important;
    }
    
    table.w-full td {
        padding: 10px 12px !important;
        vertical-align: top !important;
        border-bottom: 0.5pt solid #ddd !important;
    }
    
    table.w-full td .font-medium.text-gray-700 {
        margin-bottom: 5px !important;
        display: block !important;
        font-weight: normal !important;
    }
    
    /* Hide browser's default header and footer (URL, page numbers, date) */
    @page {
        margin: 0;
        size: auto;
    }
    
    /* Hide URL and date from print */
    html {
        height: 100%;
    }
    
    body {
        position: relative;
        margin: 1cm !important;
        padding: 0 !important;
        min-height: 100%;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Additional styles to hide browser-added content */
    @media print {
        body::before, body::after {
            content: none !important;
        }
    }
    
    /* Print only the invoice content */
    @media print {
        body * {
            visibility: hidden;
        }
        #printable-invoice, #printable-invoice * {
            visibility: visible;
        }
        #printable-invoice {
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
        }
    }
    
    /* Force background colors to print */
    .text-gray-600, 
    .text-gray-700, 
    .text-gray-800 {
        color: #000 !important;
    }
    
    /* Ensure tables print properly */
    table {
        width: 100% !important;
        border-collapse: collapse !important;
    }
    
    th, td {
        padding: 0.25cm !important;
    }
    
    /* Make signature size larger for print */
    .signature-section img {
        max-width: 220px !important;
        max-height: 90px !important;
        display: inline-block !important;
    }
    
    /* Ensure signature text is properly sized */
    .signature-section p {
        font-size: 10pt !important;
        margin-top: 0.2cm !important;
        margin-bottom: 0.2cm !important;
    }
    
    /* Improve signature container appearance */
    .signature-section .flex.justify-center {
        display: block !important;
        text-align: center !important;
    }
    
    /* Remove all borders from signature section */
    .signature-section div,
    .signature-section span {
        border: none !important;
    }
    
    /* Hide success messages */
    .bg-green-50,
    .border-green-400,
    .border-l-4 {
        display: none !important;
    }
    
    /* Enhanced totals section styling for mobile printing */
    .flex.justify-end.mb-8 {
        justify-content: flex-end !important;
        margin-bottom: 1cm !important;
    }
    
    .flex.justify-end.mb-8 > div {
        background: white !important;
        padding: 0.4cm !important;
        width: auto !important;
        min-width: 7cm !important;
        max-width: 9cm !important;
        border: none !important;
        border-radius: 0 !important;
    }
    
    /* Compact totals row layout for mobile */
    .flex.justify-between.py-2 {
        justify-content: space-between !important;
        padding: 0.15cm 0 !important;
        align-items: center !important;
    }
    
    .flex.justify-between.py-2 > div:first-child {
        font-size: 11pt !important;
        color: #333 !important;
        font-weight: 500 !important;
        min-width: 4cm !important;
    }
    
    .flex.justify-between.py-2 > div:last-child {
        font-size: 11pt !important;
        color: #333 !important;
        font-weight: 600 !important;
        text-align: right !important;
        min-width: 3cm !important;
    }
    
    /* Total row special styling */
    .flex.justify-between.py-3.mt-2.border-t.border-gray-200 {
        border-top: 1pt solid #333 !important;
        padding: 0.2cm 0 0.1cm 0 !important;
        margin-top: 0.3cm !important;
    }
    
    .flex.justify-between.py-3.mt-2.border-t.border-gray-200 > div:first-child {
        font-size: 12pt !important;
        font-weight: bold !important;
        color: #000 !important;
    }
    
    .flex.justify-between.py-3.mt-2.border-t.border-gray-200 > div:last-child {
        font-size: 14pt !important;
        font-weight: bold !important;
        color: #000 !important;
    }
    
    /* Header layout preservation - business left, invoice details right */
    .flex.justify-between.items-start.mb-8 {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        gap: 1cm !important;
        margin-bottom: 1cm !important;
    }
    
    /* Target the specific header container */
    .p-6 > .flex.justify-between.items-start.mb-8,
    .p-8 > .flex.justify-between.items-start.mb-8 {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        gap: 1cm !important;
        margin-bottom: 1cm !important;
    }
    
    /* Business details column (left) */
    .flex.justify-between.items-start.mb-8 > div:first-child {
        width: 48% !important;
        flex: none !important;
    }
    
    /* Invoice details column (right) */
    .flex.justify-between.items-start.mb-8 > div:last-child {
        width: 48% !important;
        flex: none !important;
        background: white !important;
        padding: 0.4cm !important;
        border: none !important;
        border-radius: 0 !important;
    }
    
    /* Invoice details grid formatting */
    .grid.grid-cols-2 {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.2cm !important;
    }
    
    .grid.grid-cols-2 > div:nth-child(even) {
        text-align: right !important;
        font-weight: 600 !important;
    }
    
    /* Alternative selectors for different layouts */
    div[class*="flex"][class*="justify-between"][class*="items-start"][class*="mb-8"] {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        gap: 1cm !important;
        margin-bottom: 1cm !important;
    }
    
    div[class*="flex"][class*="justify-between"][class*="items-start"][class*="mb-8"] > div:first-child {
        width: 48% !important;
        flex: none !important;
    }
    
    div[class*="flex"][class*="justify-between"][class*="items-start"][class*="mb-8"] > div:last-child {
        width: 48% !important;
        flex: none !important;
        background: white !important;
        padding: 0.4cm !important;
        border: none !important;
        border-radius: 0 !important;
    }
    
    /* Mobile-specific improvements */
    @media print and (max-width: 480px) {
        .flex.justify-end.mb-8 > div {
            min-width: 6cm !important;
            max-width: 7cm !important;
            padding: 0.3cm !important;
        }
        
        .flex.justify-between.py-2 > div:first-child {
            font-size: 10pt !important;
            min-width: 3cm !important;
        }
        
        .flex.justify-between.py-2 > div:last-child {
            font-size: 10pt !important;
            min-width: 2.5cm !important;
        }
        
        .flex.justify-between.py-3.mt-2.border-t.border-gray-200 > div:first-child {
            font-size: 11pt !important;
        }
        
        .flex.justify-between.py-3.mt-2.border-t.border-gray-200 > div:last-child {
            font-size: 12pt !important;
        }
        
        /* Smaller header layout for mobile */
        .flex.justify-between.items-start.mb-8 {
            flex-direction: column !important;
            gap: 0.5cm !important;
        }
        
        .flex.justify-between.items-start.mb-8 > div:first-child,
        .flex.justify-between.items-start.mb-8 > div:last-child {
            width: 100% !important;
        }
        
        div[class*="flex"][class*="justify-between"][class*="items-start"][class*="mb-8"] {
            flex-direction: column !important;
            gap: 0.5cm !important;
        }
        
        div[class*="flex"][class*="justify-between"][class*="items-start"][class*="mb-8"] > div:first-child,
        div[class*="flex"][class*="justify-between"][class*="items-start"][class*="mb-8"] > div:last-child {
            width: 100% !important;
        }
    }
    
    /* Ensure proper page breaks */
    .invoice-container {
        page-break-after: always;
    }
    
    /* Improve table appearance for printing */
    tr {
        page-break-inside: avoid;
    }
    
    /* Remove any background colors from status badges */
    [class*="bg-"].text-xs.font-medium.rounded-md {
        background-color: transparent !important;
        border: 1px solid #000 !important;
        color: #000 !important;
    }
    
    /* Ensure footer has no border when content sections are missing */
    .text-center.text-gray-500.text-sm.mt-8 {
        border-top: none !important;
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
    
    /* Only show border when content exists */
    .border-t.border-gray-200.pt-6 {
        border-top: 1px solid #e5e7eb !important;
    }
}
