/* Custom Invoice Generator Styles */
.invoice-logo-view {
    text-align: left !important;
}

.invoice-logo-view img {
    max-width: 180px;
    max-height: 80px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin-left: 0 !important;
    margin-right: auto !important;
}

#invoiceCard input:not(.input-group .form-control) {
    width: 100% !important;
    font-weight: 400 !important;
    border: 1px solid #ced4da !important;
    padding-top: 0.375rem !important;
    padding-bottom: 0.375rem !important;
}

#invoiceCard .input-group input {
    width: auto !important;
    flex: 1 1 auto !important;
    font-weight: 400 !important;
    border: 1px solid #ced4da !important;
    padding-top: 0.375rem !important;
    padding-bottom: 0.375rem !important;
}

.print-text-block {
    display: none;
}

/* --- BULLETPROOF SCOPED PRINT & PDF STYLING --- */
@media print {
    @page {
        size: letter portrait;
        margin: 10mm;
    }

    body, html {
        background-color: #fff !important;
        height: auto !important;
        overflow: visible !important;
    }

    /* Hide everything on the page by default when printing */
    body * {
        visibility: hidden !important;
    }

    /* Reveal only the invoice card and its contents */
    #invoiceCard, #invoiceCard * {
        visibility: visible !important;
    }

    /* Position the invoice card to take up the full print sheet */
    #invoiceCard {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        background: #fff !important;
    }

    /* Hide structural controls, buttons, files, and inputs */
    .no-print,
    button, 
    input[type="file"], 
    .form-control,
    textarea.form-control,
    .input-group-text,
    .form-text,
    hr,
    #logoLabel,
    .logo-section-title {
        display: none !important;
    }

    /* Force the logo wrapper column to clear any centering constraints */
    .invoice-logo-view, 
    .invoice-logo-view * {
        text-align: left !important;
        margin-left: 0 !important;
    }

    /* Maintain top row layout: Logo Left, Invoice Meta Right */
    .row {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .col-6 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }

    /* Ensure text alignment rules hold up */
    .text-end,
    .text-end *,
    .table td.text-end,
    .table th.text-end {
        text-align: right !important;
    }

    /* Reveal clean text blocks for print */
    .print-text-block {
        display: block !important;
        white-space: pre-wrap;
        text-align: left !important;
        font-size: 0.9rem;
    }

    span.print-text-block {
        display: inline-block !important;
    }

    /* Professional Borderless Table Styling for Print */
    .table {
        border-collapse: collapse !important;
        width: 100% !important;
        margin-bottom: 0.5rem !important;
    }
    
    .table thead th {
        background-color: #000 !important;
        color: #fff !important;
        border: none !important;
        padding: 6px !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .table td, 
    .table th {
        border-bottom: 1px solid #dee2e6 !important;
        border-top: none !important;
        border-left: none !important;
        border-right: none !important;
        padding: 6px !important;
        background: transparent !important;
    }

    .bg-light {
        background-color: transparent !important;
        border: none !important;
        padding: 0 !important;
    }
}