/* ═══════════════════════════════════════════════════════════════
   print.css — Centralized print styles for all printable pages.
   Loaded in portal layouts (_Layout_Admin, _LayoutGeneral).
   ═══════════════════════════════════════════════════════════════ */

/* ── General Print Rules ─────────────────────────────────────── */
@media print {

    /* Page margins */
    @page {
        margin: 1.5cm;
        size: A4;
    }

    /* Hide non-printable UI elements */
    .no-print,
    .no-print *,
    .noprint,
    .noprint *,
    .no-print2,
    .no-print2 * {
        display: none !important;
    }

    /* Hide common portal chrome */
    .left-sidebar,
    .app-header,
    .customizer-btn,
    .offcanvas,
    .modal-backdrop,
    .btn-print,
    .breadcrumb,
    nav[aria-label="breadcrumb"],
    footer,
    .scroll-sidebar,
    #ai-chat-widget,
    .sidebar-nav,
    .page-wrapper > .container-fluid > .card:first-child > .card-body > .d-flex > .btn,
    [data-bs-toggle="tooltip"],
    .toast-container {
        display: none !important;
    }

    /* Full-width content when sidebar is hidden */
    .page-wrapper {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .body-wrapper {
        margin-left: 0 !important;
    }

    .container-fluid {
        padding: 0 !important;
        max-width: 100% !important;
    }

    /* Reset backgrounds for paper */
    body,
    .page-wrapper,
    .body-wrapper,
    .card {
        background: #fff !important;
        color: #000 !important;
    }

    .card {
        border: none !important;
        box-shadow: none !important;
    }

    /* Ensure links show their URL */
    a[href]:not(.no-print-url)::after {
        content: none; /* Disabled by default — too noisy for invoices */
    }

    /* Table styles for print */
    .table {
        border-collapse: collapse !important;
    }

    .table th,
    .table td {
        background: #fff !important;
        color: #000 !important;
        border: 1px solid #ccc !important;
        padding: 6px 8px !important;
        font-size: 11px !important;
    }

    .table thead th {
        background: #f0f0f0 !important;
        font-weight: 600 !important;
    }

    /* Badges readable in B&W */
    .badge {
        border: 1px solid #666 !important;
        color: #000 !important;
        background: #fff !important;
    }

    /* Page break utilities */
    .page-break,
    .print-page-break {
        page-break-before: always;
        break-before: page;
    }

    .page-break-inside-avoid {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Keep headings with content */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
        break-after: avoid;
    }

    /* Prevent orphan rows */
    tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Images */
    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
}


/* ── Invoice / Statement Print ───────────────────────────────── */
@media print {

    .invoice-application {
        border: none !important;
        box-shadow: none !important;
    }

    .invoice-header {
        border-bottom: 2px solid #000 !important;
        padding-bottom: 10px !important;
    }

    .invoice-header h4 {
        font-size: 16px !important;
        font-weight: 700 !important;
    }

    .invoice-number {
        font-size: 11px !important;
        text-align: right !important;
    }

    /* Invoice line items */
    .invoice-123 .table td,
    .invoice-123 .table th {
        font-size: 10px !important;
        padding: 4px 6px !important;
    }

    /* Totals row */
    .invoice-123 .table tfoot td {
        font-weight: 700 !important;
        border-top: 2px solid #000 !important;
    }
}


/* ── Property Detail Print ───────────────────────────────────── */
@media print {

    /* Property header */
    .property-header {
        page-break-inside: avoid;
    }

    .property-header h2,
    .property-header h3 {
        font-size: 18px !important;
    }

    /* Image grid — 2 per row for print */
    .image-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .image-grid img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Property images carousel — show first image only */
    .carousel-inner .carousel-item:not(.active) {
        display: none !important;
    }

    .carousel-control-prev,
    .carousel-control-next,
    .carousel-indicators {
        display: none !important;
    }

    /* Accordion sections — expand all for print */
    .accordion-collapse {
        display: block !important;
        height: auto !important;
    }

    .accordion-button::after {
        display: none !important;
    }

    /* Map — hide (not useful on paper) */
    #map,
    .gm-style,
    [id^="map-"] {
        display: none !important;
    }

    /* Key features grid */
    .property-features .row {
        page-break-inside: avoid;
    }
}


/* ── Deal Print ──────────────────────────────────────────────── */
@media print {

    .print-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: #fff;
        padding: 10px 0;
        border-bottom: 1px solid #ccc;
    }

    .print-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        padding: 10px 0;
        border-top: 1px solid #ccc;
        font-size: 9px;
        text-align: center;
    }

    /* Offset body so header doesn't overlap */
    .printable-section {
        padding-top: 2cm;
        padding-bottom: 1.5cm;
    }
}


/* ── Compliance Certificate Print ────────────────────────────── */
@media print {

    .compliance-card {
        page-break-inside: avoid;
        border: 1px solid #ccc !important;
        margin-bottom: 10px !important;
    }

    /* Status badges — ensure readable */
    .compliance-card .badge {
        font-size: 10px !important;
        padding: 2px 6px !important;
    }
}


/* ── Report / Dashboard Print ────────────────────────────────── */
@media print {

    /* Charts — ApexCharts renders as SVG, generally prints OK */
    .apexcharts-canvas {
        page-break-inside: avoid;
    }

    /* Stat cards — 2 per row */
    .stat-card,
    .info-card {
        page-break-inside: avoid;
    }

    /* Filter bars — hide */
    .filter-bar,
    .search-filters,
    .card > .card-body > .row.g-3.align-items-end {
        display: none !important;
    }

    /* Pagination — hide */
    #btnPrev, #btnNext, #pageInfo, #resultCount,
    .pagination {
        display: none !important;
    }
}


/* ── Tenant Agreement / Contract Print ───────────────────────── */
@media print {

    .agreement-content {
        font-size: 11px !important;
        line-height: 1.6 !important;
    }

    .agreement-content h5 {
        font-size: 13px !important;
        font-weight: 700 !important;
        margin-top: 16px !important;
    }

    .signature-block {
        page-break-inside: avoid;
        border-top: 1px solid #000;
        margin-top: 40px;
        padding-top: 10px;
    }
}


/* ── Property Statement Print ────────────────────────────────── */
@media print {

    .statement-print-header {
        display: block !important;
        border-bottom: 2px solid #000;
        padding-bottom: 10px;
        margin-bottom: 15px;
    }

    .statement-print-header h4 {
        font-size: 16px !important;
        font-weight: 700 !important;
        margin-bottom: 4px !important;
    }

    .statement-print-header .statement-meta td {
        border: none !important;
        padding: 2px 12px 2px 0 !important;
        font-size: 11px !important;
        background: #fff !important;
    }

    /* Keep summary visible but compact */
    .statement-summary .card-body {
        padding: 8px !important;
    }

    .statement-summary .fs-5 {
        font-size: 13px !important;
    }

    /* Hide filter controls on print */
    .statement-filters {
        display: none !important;
    }

    /* Preserve income/expense colors */
    .text-success { color: #198754 !important; }
    .text-danger { color: #dc3545 !important; }

    /* Statement closing row */
    .statement-closing {
        border-top: 2px solid #000 !important;
        font-weight: 700 !important;
    }
}


/* ── Print Button (screen only) ──────────────────────────────── */
@media screen {
    .print-only {
        display: none !important;
    }
}

@media print {
    .screen-only {
        display: none !important;
    }

    .print-only {
        display: block !important;
    }
}
