/* =========================================================================
   CONSTRUCTIA - FORMAL PROPOSAL & PRINT STYLES
   ========================================================================= */

.formal-doc-wrapper {
    background: #f8fafc;
    color: #0f172a;
    padding: 2.5rem;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    border-radius: 0.75rem;
    max-width: 54rem;
    margin: 0 auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    line-height: 1.5;
}

.formal-header-grid {
    display: grid;
    grid-template-columns: 1.8fr 1.2fr;
    gap: 1.5rem;
    border-bottom: 2.5px solid #2E3532;
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
}

.formal-company-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: #2E3532;
    letter-spacing: -0.02em;
}

.formal-quote-box {
    background: #f0fdfa;
    border: 1px solid #99f6e4;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.formal-client-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    background: #f1f5f9;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1.25rem;
    font-size: 0.82rem;
    border: 1px solid #cbd5e1;
}

.formal-letter-text {
    font-size: 0.86rem;
    color: #1e293b;
    margin-bottom: 1.25rem;
    line-height: 1.6;
    background: #ffffff;
    padding: 1rem 1.25rem;
    border-left: 4px solid #ED6056;
    border-radius: 0.35rem;
    border-top: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
}

.formal-section-heading {
    font-size: 0.95rem;
    font-weight: 800;
    color: #2E3532;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1.5px solid #cbd5e1;
    padding-bottom: 0.35rem;
    margin: 1.5rem 0 0.65rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.formal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    margin-top: 0.4rem;
    background: #fff;
}

.formal-table th {
    background: #2E3532;
    color: #ffffff;
    font-weight: 700;
    padding: 0.5rem 0.65rem;
    text-align: left;
    border: 1px solid #2E3532;
}

.formal-table td {
    padding: 0.45rem 0.65rem;
    border: 1px solid #cbd5e1;
    color: #1e293b;
}

.formal-table tr:nth-child(even) td {
    background: #f8fafc;
}

.formal-table tfoot td {
    font-weight: 700;
    background: #f1f5f9;
}

.formal-table tfoot tr.grand-total-row td {
    background: #EEF7E1;
    color: #2E3532;
    font-size: 1.05rem;
    font-weight: 900;
    border-top: 2px solid #ED6056;
}

.formal-terms-box {
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    padding: 1rem;
    font-size: 0.78rem;
    color: #334155;
    line-height: 1.5;
    margin-top: 1.25rem;
}

.formal-signatures-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3.5rem;
    margin-top: 3rem;
    padding-top: 1rem;
    page-break-inside: avoid;
}

.formal-sig-box {
    border-top: 1.5px dashed #64748b;
    padding-top: 0.5rem;
    text-align: center;
    font-size: 0.8rem;
    color: #334155;
}

/* =========================================================================
   PRINT MEDIA RULES (A4 / LETTER OPTIMIZED)
   Only the formal document is printed. Screen calculators and UI are hidden.
   ========================================================================= */
@page {
    size: A4 portrait;
    margin: 10mm 12mm 12mm 12mm;
}

@media print {
    /* 1. Hide the entire application shell, navigation, tabs and screen calculator boxes */
    html, body {
        background: #ffffff !important;
        color: #0f172a !important;
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
        min-height: auto !important;
        overflow: visible !important;
    }

    .nav-bar,
    .nav-tabs,
    .tab-view,
    .cad-toolbar,
    .cad-container,
    .bim-container,
    .catalog-container,
    .estimator-header-bar,
    .estimator-summary-bar,
    .estimator-workspace,
    .estimator-grid,
    .calc-card,
    .calc-inputs-grid,
    .calc-results-panel,
    .client-proposal-banner,
    .version-corner-badge,
    .update-toast-banner,
    .toast-container,
    .toast-jump-3d,
    .version-popover,
    .modal-card-header,
    .btn-table-del,
    #btnExportCsv,
    #btnPrintPdf,
    #btnImportFromModel,
    .modal-card-footer,
    .no-print,
    #clientDirectoryModal,
    #clientProposalModal,
    #catalogProductModal,
    .bim-materials-floating-hud {
        display: none !important;
    }

    /* 2. Display ONLY the formal proposal modal container */
    #formalProposalPreviewModal {
        display: block !important;
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible !important;
        box-shadow: none !important;
        border: none !important;
        z-index: 9999 !important;
    }

    #formalProposalPreviewModal .modal-card {
        display: block !important;
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
        overflow: visible !important;
    }

    #formalProposalPreviewModal .modal-card-body {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        overflow: visible !important;
    }

    /* 3. The formal document itself */
    #formalDocPrintArea,
    .formal-doc-wrapper {
        display: block !important;
        position: relative !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        background: #ffffff !important;
    }

    .formal-header-grid {
        page-break-inside: avoid;
        margin-bottom: 1.25rem !important;
    }

    .formal-client-grid {
        page-break-inside: avoid;
        margin-bottom: 1rem !important;
    }

    .formal-letter-text {
        background: #f8fafc !important;
        page-break-inside: avoid;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .formal-section-heading {
        page-break-after: avoid;
    }

    .formal-table {
        page-break-inside: auto;
        margin-bottom: 1.25rem !important;
    }

    .formal-table tr {
        page-break-inside: avoid;
    }

    .formal-table th {
        background: #2E3532 !important;
        color: #ffffff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .formal-table tfoot tr.grand-total-row td {
        background: #EEF7E1 !important;
        color: #000000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .formal-quote-box {
        background: #f0fdfa !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .formal-terms-box {
        page-break-inside: avoid;
        background: #f8fafc !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .formal-signatures-grid {
        page-break-inside: avoid;
        margin-top: 1.5rem !important;
    }
}
