@media print {
  body * {
    visibility: hidden;
  }
  
  #receipt-container, 
  #receipt-container *,
  #inventoryView .inventory-table-container,
  #inventoryView .inventory-table,
  #salesHistoryView .sales-table-container,
  #salesHistoryView .sales-table,
  #reportsView .reports-grid,
  #reportsView .report-section,
  #reportsView .metric-grid,
  #reportsView .metric-card,
  #reportsView .chart-container {
    visibility: visible;
  }
  
  #receipt-container {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    max-width: 100%;
    box-shadow: none;
    border-radius: 0;
    box-sizing: border-box;
  }
  
  #inventoryView .inventory-table-container,
  #salesHistoryView .sales-table-container {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    box-shadow: none;
    border-radius: 0;
  }
  
  #reportsView .reports-grid {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
  
  #reportsView .report-section {
    break-inside: avoid;
    box-shadow: none;
    border-radius: 0;
  }
  
  /* Hide unnecessary elements when printing */
  .back-btn,
  .header-actions,
  .controls-bar,
  .pagination-container,
  .dropdown,
  .icon-btn {
    display: none !important;
  }
  
  /* Ensure tables use full width */
  .inventory-table,
  .sales-table {
    width: 100%;
    border-collapse: collapse;
  }
  
  /* Ensure proper spacing for printed content */
  .main-content {
    padding: 0 !important;
  }
  
  /* Improve contrast for printed tables */
  .inventory-table th,
  .sales-table th {
    background-color: #e5e7eb !important;
    color: #000 !important;
    border: 1px solid #000;
  }
  
  .inventory-table td,
  .sales-table td {
    border: 1px solid #000;
  }
  
  /* Ensure low stock items are visible */
  .low-stock {
    color: #000 !important;
    font-weight: bold;
  }
  
  .warning-row {
    background-color: #fef3c7 !important;
  }
  
  /* Ensure metric cards print properly */
  .metric-card {
    border: 1px solid #000;
    break-inside: avoid;
  }
  
  .metric-card.primary,
  .metric-card.secondary,
  .metric-card.success,
  .metric-card.warning {
    background: #e5e7eb !important;
    color: #000 !important;
  }
  
  /* Ensure chart prints properly */
  .chart-container {
    border: 1px solid #000;
  }
  
  .bar-fill {
    background: #009640 !important;
  }
  
  /* Mobile-specific print fixes */
  @media (max-width: 768px) {
    #receipt-container {
      font-size: 12px;
      padding: 10px;
    }
    
    #receipt-container * {
      font-family: 'Courier New', Courier, monospace !important;
      color: #000 !important;
    }
    
    #receipt-items > div {
      page-break-inside: avoid;
      break-inside: avoid;
    }
    
    .receipt-item-row {
      margin-bottom: 5px !important;
    }
  }
}

/* Fix to ensure New Sale Modal elements are visible normally (not just during print) */
@media screen {
  #newSaleModal #receipt-container {
    visibility: visible !important;
    display: flex !important;
  }
}