/* Enhanced A4 Print Styles */
@page { 
    size: A4; 
    margin: 15mm; 
}

@media print {
    /* Ensure printable containers are visible and full-width */
    #printable-invoice-area,
    .a4-document,
    #printable-transaction,
    .printable-content {
        visibility: visible !important;
        display: block !important;
        position: static !important;
        left: auto !important;
        top: auto !important;
        width: auto !important;
        max-width: none !important;
        z-index: auto !important;
    }

    /* Hide common interactive elements and admin panels */
    .no-print,
    button:not(.print-button), 
    a:not(.print-link), 
    input:not(.print-input), 
    textarea:not(.print-textarea), 
    select:not(.print-select),
    .close-btn, 
    .modal, 
    .modal-overlay,
    .modal-dialog,
    .mobile-only, 
    .desktop-only,
    header:not(.print-header), 
    .header:not(.print-header), 
    .app-header, 
    .top-panel, 
    .page-top, 
    footer:not(.print-footer), 
    .footer:not(.print-footer), 
    .app-footer, 
    .bottom-panel, 
    .page-bottom,
    nav:not(.print-nav), 
    .sidebar, 
    .side-panel, 
    .fixed:not(.print-fixed), 
    .sticky:not(.print-sticky),
    .status-bar,
    .admin-header,
    .bottom-nav,
    .admin-header-left,
    .admin-header-right,
    .user-profile-actions,
    .back-button,
    .nav-item,
    .cart-widget,
    .chat-widget,
    .toast-container {
        display: none !important;
        visibility: hidden !important;
    }
    
    html, body { 
        background: #fff !important; 
        font-size: 12px !important;
        line-height: 1.4 !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    * {
        box-shadow: none !important;
        text-shadow: none !important;
        border-radius: 0 !important; /* Remove border radius for cleaner print */
    }
    
    .a4-document,
    .printable-content {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        background: white !important;
    }
    
    /* Ensure content fills the page properly */
    .content-section {
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        background: white !important;
    }
    
    /* Fix table printing */
    table {
        border-collapse: collapse !important;
        width: 100% !important;
    }
    
    th, td {
        border: 1px solid #333 !important;
        padding: 3mm 2mm !important;
        font-size: 10px !important;
    }
    
    /* Prevent page breaks inside important elements */
    .a4-header,
    .a4-party-info,
    .a4-summary {
        page-break-inside: avoid !important;
    }
}

.a4-document { 
    background: #fff; 
    font-family: 'Inter', Arial, sans-serif;
    font-size: 11px;
    line-height: 1.5;
    color: #333; 
    padding: 15mm;
    box-sizing: border-box;
}

/* Header */
.a4-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: flex-start; 
    border-bottom: 2px solid #333; 
    padding-bottom: 10mm; 
    margin-bottom: 8mm;
}

.a4-brand-info .a4-brand { 
    font-size: 24px; 
    font-weight: 800; 
    color: #0056b3;
    margin: 0;
}
.a4-brand-info .a4-company-details {
    font-size: 10px;
    color: #666;
    margin-top: 2mm;
    line-height: 1.4;
}

.a4-doc-meta .a4-doc-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 2mm 0;
    text-align: right;
    text-transform: uppercase;
}
.a4-doc-meta .a4-doc-details {
    text-align: right;
    font-size: 10px;
}
.a4-doc-meta .a4-doc-details div { margin-bottom: 1mm; }
.a4-doc-meta .a4-doc-details b { font-weight: 600; min-width: 70px; display: inline-block; }

/* Parties Info (Customer/Supplier) */
.a4-parties {
    display: flex;
    justify-content: space-between;
    margin: 8mm 0;
}
.a4-party-info {
    max-width: 45%;
}
.a4-party-title {
    font-size: 10px;
    font-weight: 700;
    color: #666;
    margin-bottom: 2mm;
    border-bottom: 1px solid #ddd;
    padding-bottom: 1mm;
    text-transform: uppercase;
}
.a4-party-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 1mm;
}
.a4-party-details {
    font-size: 10px;
    line-height: 1.5;
}

/* Items Table */
.a4-table { 
    width: 100%; 
    border-collapse: collapse;
    margin: 8mm 0;
}
.a4-table thead {
    background: #f1f3f4;
}
.a4-table th, .a4-table td {
    border: 1px solid #ddd;
    padding: 3mm 2mm;
    text-align: left;
    font-size: 10px;
}
.a4-table th {
    font-weight: 700;
}
.a4-table .text-right { text-align: right; }
.a4-table .text-center { text-align: center; }

/* Summary/Totals */
.a4-summary {
    display: flex;
    justify-content: flex-end;
    margin-top: 8mm;
}
.a4-summary-table {
    width: 50%;
    border-collapse: collapse;
}
.a4-summary-table td {
    padding: 2.5mm 3mm;
    border-bottom: 1px solid #eee;
}
.a4-summary-table .label {
    color: #666;
    font-weight: 600;
}
.a4-summary-table .value {
    font-weight: 700;
    text-align: right;
}
.a4-summary-total {
    border-top: 2px solid #333;
    font-size: 14px;
    font-weight: 800;
}

/* Signatures & Footer */
.a4-signatures {
    display: flex;
    justify-content: space-between;
    margin: 20mm 0 10mm 0;
}
.a4-signature-block {
    text-align: center;
    width: 40%;
}
.a4-signature-line {
    border-top: 1px solid #333;
    margin-top: 20mm;
    padding-top: 2mm;
    font-size: 10px;
    color: #666;
}
.a4-footer {
    margin-top: 15mm;
    padding-top: 5mm;
    border-top: 1px solid #ddd;
    font-size: 9px;
    color: #666;
    text-align: center;
    line-height: 1.6;
}