/* ===========================================================================
   print.css  --  print / PDF rendering rules for ptaWebApp
   ---------------------------------------------------------------------------
   Site.css and ptaInfo.css describe a fixed-width screen layout: report tables
   carry pixel widths (250px, 320px, 400px ...) and white-space:nowrap, sized
   for a 960px page. A4 leaves roughly 190mm of usable width, so that layout is
   clipped or squeezed when printed -- which is why the generated PDFs have
   always looked poor.

   This file overrides those rules for print only. Screen rendering is
   untouched: everything here sits inside @media print.

   Most of the widths and nowrap settings come from GridView HeaderStyle and
   ItemStyle attributes, which ASP.NET emits as *inline* style attributes.
   Inline styles outrank a stylesheet, so the overrides below need !important.
   That is deliberate, not carelessness.

   Used by: ptaList, ptaBeneficiaries, ptaDocuments, search results and
   ptaVersionGlobalInfo -- i.e. every page carrying a PDF/export button.
   =========================================================================== */

@media print {

    /* -- paper ------------------------------------------------------------
       The report grids are wide. Portrait fits them once the fixed widths
       are removed and text is allowed to wrap; switch the line below to
       "size: A4 landscape;" if a particular report still feels cramped. */
    @page {
        size: A4;
        margin: 12mm 10mm;
    }

    /* -- site chrome: nothing navigational belongs on paper -------------- */
    #banner,
    #footer,
    .header,
    .mainmenu,
    div.ptaMenu,
    #table_grid_tools,
    #td_printable_version,
    .tooltiptext,
    .updateProgress,
    .progressBackgroundFilter,
    .maintbltl, .maintbltop, .maintbltr,
    .maintblleft, .maintblright,
    .maintblbl, .maintblbot, .maintblbr {
        display: none !important;
    }

    /* -- page shell -------------------------------------------------------
       Drop the screen layout's minimum heights and fixed widths so content
       flows to the paper width instead of being clipped. */
    html,
    body {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        color: #000 !important;
        min-height: 0 !important;
        height: auto !important;
    }

    body {
        font-family: Arial, Helvetica, sans-serif !important;
        font-size: 8pt !important;
    }

    #page,
    .pagestyle,
    #content,
    .main,
    #div_pta_list,
    #ReportDiv,
    #div_export_pdf_region {
        width: auto !important;
        max-width: none !important;
        min-height: 0 !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        overflow: visible !important;
    }

    /* The search results grid sits in a div with an inline max-width:958px,
       and the notification tree carries min-height:500px. */
    div[style*="max-width"] {
        max-width: none !important;
    }

    .tree_view {
        min-height: 0 !important;
        overflow: visible !important;
    }

    /* -- tables -----------------------------------------------------------
       The core fix: release the pixel widths and let cells wrap. */
    table {
        width: 100% !important;
        border-collapse: collapse !important;
        table-layout: auto !important;
    }

    th,
    td {
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        white-space: normal !important;
        overflow: visible !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
        vertical-align: top !important;
    }

    /* Borders only on the report grids, not on the table-based page layout. */
    .tr_row td,
    .th_header,
    .th_headerx,
    .th_headery,
    .th_header2,
    .th_header3 {
        border: 0.5pt solid #999 !important;
        padding: 2pt 3pt !important;
    }

    /* -- table headers ----------------------------------------------------
       On screen these are white text on dark blue. Browsers omit background
       colours when printing unless the user opts in, which would render the
       header text white on white -- invisible. Restyle rather than rely on
       print-color-adjust, which is not honoured everywhere. */
    .th_header,
    .th_headerx,
    .th_headery,
    .th_header2,
    .th_header3,
    .datagrid_header,
    .datagrid_benef_header {
        background: none !important;
        background-color: transparent !important;
        color: #000 !important;
        font-weight: bold !important;
        border-bottom: 1pt solid #000 !important;
    }

    .th_header a,
    .th_header a:link,
    .th_header a:visited {
        color: #000 !important;
        text-decoration: none !important;
    }

    /* Zebra striping is set as an inline background-color on the row and
       prints as flat grey. Drop it; the cell borders carry the structure. */
    tr,
    tr td,
    .alternatingRow {
        background: transparent !important;
        background-color: transparent !important;
    }

    /* Repeat the header row across page breaks. Note: GridView only emits a
       real <thead> when UseAccessibleHeader is true and the header row's
       TableSection is set to TableHeader -- worth doing in code-behind, at
       which point this rule starts working. */
    thead {
        display: table-header-group;
    }

    tfoot {
        display: table-footer-group;
    }

    tr,
    img {
        page-break-inside: avoid;
    }

    /* -- columns hidden on screen must stay hidden on paper ---------------
       ptaInfo.css defines .hidden_column twice; the winning definition sets
       width/height/font-size to zero but not display, so these columns still
       take up space when the layout is reflowed. */
    .hidden_column {
        display: none !important;
    }

    /* -- info boxes and label/value pairs --------------------------------- */
    td.td_label,
    td.td_text {
        white-space: normal !important;
        width: auto !important;
        min-width: 0 !important;
        overflow: visible !important;
    }

    td.td_pta_benef_box_header,
    td.td_pta_box_header,
    td.td_pta_box_header_main,
    td.td_pta_box_header0,
    td.td_link_grp_title {
        background: none !important;
        background-color: transparent !important;
        color: #000 !important;
        font-weight: bold !important;
        border-bottom: 1pt solid #000 !important;
    }

    span.span_page_title {
        color: #000 !important;
        font-size: 12pt !important;
        margin-left: 0 !important;
    }

    span.label_subtitle {
        color: #000 !important;
        font-size: 10pt !important;
    }

    /* -- links ------------------------------------------------------------
       Blue underlined links waste ink and read poorly on paper. The URLs are
       not printed after them: these reports are dense tables and appending
       every href would double their length. */
    a,
    a:link,
    a:visited {
        color: #000 !important;
        text-decoration: none !important;
    }

    /* -- form controls ----------------------------------------------------
       Buttons and inputs are meaningless on paper; drop-downs would print as
       an empty box. Hide them, keeping any text already rendered elsewhere. */
    input[type="button"],
    input[type="submit"],
    input[type="image"],
    button,
    select {
        display: none !important;
    }

    /* Sort-arrow and command-column icons inside grids. */
    .tr_row td img,
    .th_header img {
        display: none !important;
    }
}
