﻿@media print {
  /* Hide everything except the dialog content */
  .mud-appbar, .mud-drawer, .mud-dialog-actions, .no-print, button {
    display: none !important;
  }

  /* Expand the dialog to full page */
  .mud-dialog {
    box-shadow: none !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .mud-table-container {
    height: auto !important; /* Allow table to grow vertically for printing */
  }

  @page {
    size: A4 landscape; /* Forces the PDF to be wide */
    margin: 1cm; /* Professional narrow margins */
  }
  table {
    width: 100% !important;
    table-layout: auto !important; /* Let browser calculate optimal widths */
    border-collapse: collapse;
    font-size: 8.5pt !important;
  }

  /* Professional scaling: reduce font size slightly for print */
  th, td {
    font-size: 9pt !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal !important; /* Allows text to go to next line */
    padding: 4px !important;
  }

  /* Hide UI elements that shouldn't be in a PDF */
  .mud-table-pagination, .mud-button, .no-print {
    display: none !important;
  }
  thead {
    display: table-header-group; /* This makes headers repeat on every page */
  }

  tr {
    page-break-inside: avoid; /* Prevents a single row from splitting across two pages */
  }
  body::before {
    content: "CONFIDENTIAL - INTERNAL USE ONLY";
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 5rem;
    color: rgba(200, 200, 200, 0.2);
    z-index: -1;
    pointer-events: none;
    white-space: nowrap;
  }

  /* 3. Page Numbers & Footer Metadata */
  body::after {
    content: "Generated on: " attr(data-date) " | Page " counter(page);
    position: fixed;
    bottom: 0;
    right: 0;
    font-size: 10pt;
    color: #555;
  }

  /* 4. Formatting the Table for PDF */
  .mud-table-container {
    height: auto !important;
    overflow: visible !important;
  }
}
/* --- MASTER EXPORT SPECIFIC OVERRIDES --- */
@media print {
  /* If this specific container exists, force these rules */
  .master-pdf-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: white !important;
    z-index: 9999 !important; /* Sit on top of the sidebar/header */
    visibility: visible !important;
  }

    /* Hide the Dashboard Sidebar and Appbar when Master Export is printing */
    .master-pdf-container ~ *,
    .mud-drawer,
    .mud-appbar,
    .mud-nav-menu {
      display: none !important;
      visibility: hidden !important;
    }

    /* Target the analytics layout inside Master Export */
    .master-pdf-container .row {
      display: flex !important;
      flex-direction: row !important;
      flex-wrap: nowrap !important;
    }

    .master-pdf-container .col-6 {
      width: 50% !important;
      flex: 0 0 50% !important;
      max-width: 50% !important;
    }

  /* Force the cover page to take up the full first sheet */
  .pdf-page {
    page-break-after: always !important;
    margin-bottom: 2cm;
  }

  /* Ensure Charts don't get cut off or disappear */
  .mud-chart {
    max-width: 100% !important;
    height: auto !important;
  }
}