/* css/print.css */
/* Material Design 3 Enterprise - Print & PDF Export Styles */

/* ========================================================================
   BASE PRINT RULES
   ======================================================================== */
@media print {
  /* Reset Backgrounds & Text Colors for ink saving */
  body {
    background-color: #FFFFFF !important;
    color: #000000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Hide entire application structure by default */
  .sidebar,
  .topbar,
  .nav,
  .menu-toggle,
  .toast,
  .modal-overlay,
  .drawer-overlay,
  .form-actions,
  .toolbar,
  .smart-paste-area,
  .help-panel,
  .floating-save-bar,
  .no-print {
    display: none !important;
  }

  /* Hide views that are not meant to be printed */
  #view-dashboard,
  #view-entry,
  #view-records,
  #view-settings,
  #view-orders {
    display: none !important;
  }

  /* Reset main container layout for printing */
  .app,
  .main,
  .content {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Force Generate View to be visible */
  #view-generate {
    display: block !important;
  }

  /* Hide the configuration panel within the Generate view */
  .generate-layout > .panel:first-child {
    display: none !important;
  }

  /* ========================================================================
     QUOTE PREVIEW (The actual document to print)
     ======================================================================== */
  .preview-panel {
    background-color: #FFFFFF !important;
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  .preview-panel .panel-header {
    display: none !important;
  }

  .quote-sheet {
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    max-width: none !important;
    width: 100% !important;
  }

  /* Ensure the title bar maintains its styling in print */
  .qs-title-bar {
    background-color: #F8F9FA !important;
    border-left: 4px solid var(--md-sys-color-primary) !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Ensure table headers maintain shading */
  .qs-table th {
    background-color: #F1F5F9 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* ========================================================================
     DUAL-TRACK INDEPENDENT BILLING ENGINE (SOA & FOB)
     ======================================================================== */
  
  /* The .print-only class is hidden in screen view (base.css) */
  .print-only {
    display: none;
  }

  /* When activated for printing, it overrides everything */
  .print-active,
  .print-active * {
    visibility: visible !important;
  }

  .print-active {
    display: block !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    background-color: #FFFFFF !important;
    color: #000000 !important;
    padding: 20mm !important; /* Standard print margin */
    font-family: var(--md-sys-typescale-font-body);
    box-sizing: border-box !important;
    z-index: 9999 !important;
  }

  /* SOA & FOB Table Overrides for Print */
  .soa-table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-top: 20px !important;
    font-size: 10pt !important;
  }

  .soa-table th, 
  .soa-table td {
    border: 1px solid #CCCCCC !important;
    padding: 8px !important;
    text-align: left !important;
  }

  .soa-table th {
    background-color: #F0F0F0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Hide elements marked specifically not for PDF/Print */
  .no-print-pdf {
    display: none !important;
  }

  /* ========================================================================
     PAGE BREAK MANAGEMENT
     ======================================================================== */
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }
  
  table, figure, img {
    page-break-inside: avoid;
  }
  
  .qs-total {
    page-break-inside: avoid;
  }
}
