/* ── Print Stylesheet ──
   Clean A4 output from any portal page.
   Loaded with media="print" so it only applies when printing. */

@media print {
    /* ── Hide non-content chrome ── */
    .site-header,
    .sidebar,
    .sidebar-overlay,
    .sidebar-toggle,
    .hub-switcher,
    .hub-btn,
    .site-footer,
    .skip-link,
    .global-search-wrapper,
    .global-search-form,
    .instant-search-dropdown,
    .notification-badge,
    .lang-toggle,
    .lang-dropdown,
    .message-stack,
    .confirm-overlay,
    .confirm-dialog,
    .mention-autocomplete,
    #command-palette,
    #toast-container,
    #sidebar-overlay,
    #notification-badge-slot,
    .btn,
    .actions,
    .pagination,
    .workflow-actions,
    .record-actions {
        display: none !important;
    }

    /* ── Expand content to full A4 width ── */
    .app-layout {
        display: block !important;
    }

    .main-content,
    #app-main {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* ── Reset backgrounds and colors ── */
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt;
        line-height: 1.5;
    }

    /* ── Tables: full-width with visible borders ── */
    table {
        width: 100% !important;
        border-collapse: collapse;
    }

    th, td {
        border: 1px solid #ccc !important;
        padding: 4pt 6pt !important;
        font-size: 10pt;
    }

    th {
        background: #f5f5f5 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* ── Cards: remove shadow, keep border ── */
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
    }

    /* ── Links: show URL after link text ── */
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    /* Suppress URL display for internal/action links */
    a[href^="#"]:after,
    a[href^="javascript"]:after,
    a.btn:after,
    a.sidebar-link:after,
    a.hub-btn:after,
    a.metric-link:after,
    a.inline-link:after,
    a.mention-inline-link:after {
        content: "" !important;
    }

    /* ── Page break control ── */
    h1, h2, h3 {
        break-after: avoid;
    }

    tr {
        break-inside: avoid;
    }

    img, svg, figure {
        break-inside: avoid;
    }

    /* ── Print-specific header (hidden on screen, shown on print) ── */
    .print-header {
        display: block !important;
        text-align: center;
        margin-bottom: 1rem;
        border-bottom: 2px solid #333;
        padding-bottom: 0.5rem;
    }

    .print-header img {
        max-height: 40pt;
    }

    /* ── Status badges: ensure text is readable without color ── */
    .badge, .status-badge {
        border: 1px solid #999 !important;
        background: transparent !important;
        color: black !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* ── Remove decorative backgrounds on detail sections ── */
    .detail-section,
    .info-grid,
    .field-group {
        background: transparent !important;
        box-shadow: none !important;
    }

    /* ── Ensure charts/canvas elements get a page each ── */
    canvas {
        break-before: auto;
        break-inside: avoid;
        max-width: 100% !important;
    }
}

/* ── Hide print-only elements on screen ── */
.print-header {
    display: none;
}
