/* CSS Print Stylesheet - Targets window.print() PDF layout */

@page {
  size: auto;
  margin: 0mm; /* Removes browser headers (title/date) and footers (URL) */
}

@media print {
  /* Hide all non-printable elements */
  .no-print, 
  header, 
  footer, 
  .btn, 
  .theme-toggle-btn, 
  .ad-slot, 
  .explainer-section, 
  .invoice-logo-section input[type="file"],
  #remove-logo-btn,
  #add-item-btn,
  #reset-invoice-btn,
  #print-invoice-btn,
  .delete-item-col {
    display: none !important;
  }

  /* Reset body and page margins, adding padding to prevent content touching paper edges */
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt !important;
    line-height: 1.4 !important;
    padding: 20mm 15mm !important;
    margin: 0 !important;
  }

  .container {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Force card to be borderless and full width */
  .printable-invoice.card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    backdrop-filter: none !important;
  }

  /* Show print-only text blocks */
  .print-only-text {
    display: block !important;
  }
  
  .print-only-text.whitespace-pre {
    white-space: pre-wrap !important;
  }

  /* Styles for alignment and grids during print */
  .invoice-header-row {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    margin-bottom: 2rem !important;
  }

  .invoice-logo-section {
    width: 45% !important;
  }

  .logo-preview-box {
    border: none !important;
    background: transparent !important;
    width: 150px !important;
    height: auto !important;
    min-height: auto !important;
    justify-content: flex-start !important;
  }

  .logo-preview-box img {
    max-width: 150px !important;
    max-height: 80px !important;
  }

  .invoice-meta-section {
    width: 45% !important;
    text-align: right !important;
  }

  .invoice-title-block {
    font-size: 24pt !important;
    font-weight: 800 !important;
    color: #000000 !important;
    margin-bottom: 0.5rem !important;
  }

  .invoice-details-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 2rem !important;
    margin-bottom: 2rem !important;
  }

  .invoice-details-grid h4 {
    color: #000000 !important;
    border-bottom: 2px solid #000000 !important;
    font-size: 11pt !important;
    font-weight: 700 !important;
    margin-bottom: 0.5rem !important;
    text-transform: uppercase !important;
  }

  /* Invoice Table Print Formatting */
  .invoice-table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-top: 1.5rem !important;
    margin-bottom: 2rem !important;
  }

  .invoice-table th {
    background-color: #f1f5f9 !important;
    color: #000000 !important;
    border-bottom: 2px solid #000000 !important;
    font-size: 10pt !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    padding: 0.5rem !important;
  }

  .invoice-table td {
    padding: 0.6rem 0.5rem !important;
    border-bottom: 1px solid #e2e8f0 !important;
    color: #000000 !important;
    font-size: 10pt !important;
  }

  .invoice-table tr:last-child td {
    border-bottom: 1px solid #e2e8f0 !important; /* Keep it uniform */
  }

  /* Line Item Print Forms replacement */
  .item-print-desc {
    font-weight: 600 !important;
  }
  
  .item-print-details {
    font-size: 9pt !important;
    color: #475569 !important;
  }

  /* Invoice Totals Print Layout */
  .invoice-summary-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 3rem !important;
    margin-top: 1rem !important;
    page-break-inside: avoid !important;
  }

  .totals-row {
    display: flex !important;
    justify-content: space-between !important;
    font-size: 10pt !important;
    color: #000000 !important;
  }

  .totals-row.total-large {
    font-size: 13pt !important;
    font-weight: 800 !important;
    border-top: 2px solid #000000 !important;
    padding-top: 0.5rem !important;
  }
  
  hr {
    display: none !important;
  }

  /* General Print Helper */
  .font-bold {
    font-weight: 700 !important;
  }
}
