/* Professional Print Styles for Business Documents */
@media print {
  /* Page setup for A4 */
  @page {
    size: A4 portrait;
    margin: 15mm 12mm 15mm 12mm; /* top right bottom left - reduced margins */
    /* Avoid default browser headers and footers */
    marks: none;
  }
  
  html, body {
    width: 210mm;
    height: 297mm;
    margin: 0 !important;
    padding: 0 !important;
    font-family: 'Roboto', 'Helvetica', 'Arial', sans-serif !important;
    font-size: 10pt !important;
    line-height: 1.4 !important;
    background: white !important;
    color: black !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* Document structure */
  .document-container {
    position: relative !important;
    box-sizing: border-box !important;
    width: 100% !important;
    min-height: 100% !important;
    background-color: white !important;
    page-break-after: always !important;
  }
  
  /* Header styling */
  .document-header {
    margin-bottom: 7mm !important; /* Reduced margin */
    page-break-inside: avoid !important;
  }
  
  /* Footer must be fixed at the bottom of the page */

  /* Logo sizes for consistency */
  .document-header img.logo {
    height: 16mm !important; /* Slightly smaller logo */
    max-width: 50mm !important;
    object-fit: contain !important;
  }
  
  .document-footer img {
    max-height: 6mm !important;
  }

  /* Company info in header */
  .company-info {
    line-height: 1.4 !important;
    font-size: 9pt !important; /* Slightly smaller text */
  }

  .company-info .company-name {
    font-weight: bold !important;
    font-size: 12pt !important;
    margin-bottom: 1mm !important;
  }

  /* Document title */
  .document-title {
    font-size: 15pt !important; /* Slightly smaller title */
    font-weight: 700 !important;
    color: #1a1a1a !important;
    margin-bottom: 1mm !important; /* Reduced margin */
  }

  .document-number {
    font-weight: bold !important;
    font-size: 10pt !important; /* Slightly smaller */
    margin-bottom: 1mm !important; /* Reduced margin */
    color: #333 !important;
  }

  /* Table styling for items */
  table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-bottom: 5mm !important; /* Reduced margin */
  }
  
  thead {
    display: table-header-group !important;
    background-color: #2c3e50 !important;
    color: white !important;
  }
  
  tfoot {
    display: table-footer-group !important;
  }
  
  tr {
    page-break-inside: avoid !important;
    page-break-after: auto !important;
  }
  
  th {
    border: 0.5pt solid #ddd !important;
    padding: 2mm 2mm !important; /* Reduced padding */
    text-align: left !important;
    font-weight: bold !important;
    font-size: 9pt !important;
    color: white !important;
  }
  
  td {
    border: 0.5pt solid #ddd !important;
    padding: 1.5mm 2mm !important; /* Reduced padding */
    vertical-align: top !important;
    font-size: 9pt !important;
  }
  
  /* Alternating row colors */
  tbody tr:nth-child(even) {
    background-color: #f8f9fa !important;
  }
  
  /* Customer info box */
  .customer-info {
    border: 0.5pt solid #ddd !important;
    border-radius: 2mm !important;
    padding: 3mm !important; /* Reduced padding */
    margin-bottom: 4mm !important; /* Reduced margin */
    background-color: #f8f9fa !important;
    page-break-inside: avoid !important;
  }

  .customer-info h3 {
    font-size: 10pt !important;
    font-weight: 600 !important;
    margin-bottom: 2mm !important;
    color: #2c3e50 !important;
  }

  .customer-info p {
    margin: 1mm 0 !important;
  }

  /* Totals section */
  .totals-section {
    page-break-inside: avoid !important;
    margin-top: 3mm !important; /* Reduced margin */
  }
  
  .totals-table {
    width: 60% !important;
    margin-left: auto !important;
    border-collapse: collapse !important;
  }
  
  .totals-table td {
    padding: 2mm !important;
    text-align: right !important;
  }
  
  .totals-table .total-row {
    font-weight: bold !important;
    border-top: 1pt solid #333 !important;
    background-color: #f0f0f0 !important;
  }
  
  /* Signature area */
  .signature-area {
    page-break-inside: avoid !important;
    margin-top: 15mm !important; /* Increased margin */
    margin-bottom: 10mm !important; /* Reduced margin */
  }
  
  .signature-container {
    display: flex !important;
    justify-content: space-between !important;
  }
  
  .signature-box {
    width: 45% !important;
  }
  
  .signature-img {
    max-height: 18mm !important;
    max-width: 35mm !important;
    margin-bottom: 1mm !important;
  }
  
  .signature-line {
    border-bottom: 0.5pt solid #333 !important;
    padding-bottom: 1mm !important;
    margin-bottom: 3mm !important; /* Increased margin */
    min-width: 60mm !important;
  }

  .signature-date {
    font-size: 7pt !important;
    color: #666 !important;
  }

  .signature-title {
    font-weight: 600 !important;
    font-size: 9pt !important;
    margin-bottom: 5mm !important;
    color: #2c3e50 !important;
  }

  .signature-name {
    font-weight: 500 !important;
    margin-bottom: 1mm !important;
  }

  /* Typography */
  h1 {
    font-size: 16pt !important;
    margin-bottom: 4mm !important;
    color: #2c3e50 !important;
  }
  
  h2 {
    font-size: 13pt !important;
    margin-bottom: 3mm !important;
    color: #2c3e50 !important;
  }
  
  h3 {
    font-size: 11pt !important;
    margin-bottom: 2mm !important;
    color: #2c3e50 !important;
  }

  p {
    margin-bottom: 1.5mm !important;
  }
  
  /* Status badges */
  .status-badge {
    display: inline-block !important;
    padding: 1mm 3mm !important;
    border-radius: 1mm !important;
    font-size: 8pt !important;
    font-weight: bold !important;
  }

  .status-badge.pending {
    color: #e67e22 !important;
    background-color: #fff4e5 !important;
    border: 0.5pt solid #e67e22 !important;
  }

  .status-badge.approved, .status-badge.paid, .status-badge.delivered {
    color: #27ae60 !important;
    background-color: #e7f5ea !important;
    border: 0.5pt solid #27ae60 !important;
  }

  .status-badge.rejected, .status-badge.cancelled {
    color: #c0392b !important;
    background-color: #fbeae8 !important;
    border: 0.5pt solid #c0392b !important;
  }

  /* Hide UI elements */
  button, nav, .no-print, header, footer:not(.document-footer) {
    display: none !important;
  }

  /* No background colors for body/html */
  body, html {
    background: white !important;
  }
  
  /* Notes section fix */
  .notes, .footer-notes {
    page-break-inside: avoid !important;
    margin-bottom: 3mm !important; /* Reduced margin */
    border: 0.5pt solid #ddd !important;
    padding: 2mm !important; /* Reduced padding */
    background-color: #f8f9fa !important;
  }
  
  .notes h3, .footer-notes h3 {
    margin-top: 0 !important;
    color: #2c3e50 !important;
  }
  
  /* Properly align text */
  .text-right {
    text-align: right !important;
  }
  
  .text-center {
    text-align: center !important;
  }
  
  /* Remove unwanted elements */
  .print-hide {
    display: none !important;
  }

  /* Ensure no red text appears in the document */
  * {
    color: black !important;
  }
  
  .document-footer * {
    color: #666 !important;
  }

  /* Make sure signatures appear correctly */
  .signature-box {
    display: inline-block !important;
    margin-bottom: 2mm !important;
  }

  /* Table specific alignments */
  th.text-center, td.text-center {
    text-align: center !important;
  }
  
  th.text-right, td.text-right {
    text-align: right !important;
  }

  /* Improved row spacing */
  tr {
    height: 8mm !important; /* Minimum row height */
  }

  /* Document sections */
  .document-section {
    margin-bottom: 3mm !important; /* Reduced margin */
    page-break-inside: avoid !important;
  }
  
  .section-title {
    font-weight: 600 !important;
    font-size: 11pt !important;
    margin-bottom: 2mm !important; /* Reduced margin */
    color: #2c3e50 !important;
    border-bottom: 0.5pt solid #ddd !important;
    padding-bottom: 1mm !important;
  }
  
  /* Legal mentions and terms */
  .legal-mentions {
    font-size: 7pt !important;
    color: #666 !important;
    margin-top: 5mm !important;
    border-top: 0.5pt solid #ddd !important;
    padding-top: 2mm !important;
  }
  
  /* Payment information box */
  .payment-info {
    border: 0.5pt solid #ddd !important;
    background-color: #f5f5f5 !important;
    padding: 4mm !important;
    border-radius: 2mm !important;
    margin-bottom: 10mm !important;
  }
  
  .payment-info h3 {
    font-size: 9pt !important;
    color: #2c3e50 !important;
    margin-bottom: 2mm !important;
  }
  
  /* Bank details table */
  .bank-details {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 8pt !important;
  }
  
  .bank-details th {
    background-color: #f0f0f0 !important;
    color: #2c3e50 !important;
    font-weight: bold !important;
    padding: 1.5mm !important;
    border: 0.5pt solid #ddd !important;
    text-align: left !important;
  }
  
  .bank-details td {
    padding: 1.5mm !important;
    border: 0.5pt solid #ddd !important;
  }
  
  /* Header container with logo and company info */
  .header-container {
    display: flex !important;
    justify-content: space-between !important;
    margin-bottom: 8mm !important;
  }
  
  /* Logo container */
  .logo-container {
    width: 25% !important;
  }
  
  /* Document type header */
  .document-type-header {
    text-align: right !important;
    margin-bottom: 5mm !important;
  }
  
  .document-type {
    font-size: 16pt !important;
    font-weight: bold !important;
    color: #2c3e50 !important;
    text-transform: uppercase !important;
  }
  
  /* Line items table */
  .line-items-table {
    margin: 5mm 0 !important;
  }
  
  .line-items-table th {
    background-color: #2c3e50 !important;
    color: white !important;
  }
  
  /* Product description styling */
  .product-description {
    font-size: 7pt !important; /* Slightly smaller */
    color: #555 !important;
    margin-top: 1mm !important;
  }

  /* Page break control */
  .page-break {
    page-break-after: always !important;
  }
  
  .no-break {
    page-break-inside: avoid !important;
  }
  
  /* Document information section */
  .document-info-section {
    margin-bottom: 4mm !important; /* Reduced margin */
    page-break-inside: avoid !important;
    display: flex !important;
    justify-content: space-between !important;
  }
  
  /* Two column layout */
  .two-columns {
    display: flex !important;
    justify-content: space-between !important;
  }
  
  .column {
    width: 48% !important;
  }
  
  /* Box with background */
  .info-box {
    background-color: #f8f9fa !important;
    border: 0.5pt solid #ddd !important;
    border-radius: 2mm !important;
    padding: 3mm !important;
    margin-bottom: 4mm !important;
  }
  
  /* Additional information */
  .additional-info {
    font-size: 8pt !important;
    color: #666 !important;
    margin-top: 2mm !important;
  }

  /* Tax ID and registration info */
  .tax-info {
    font-size: 7pt !important;
    color: #666 !important;
  }
  
  /* QR code placeholder */
  .qr-code {
    width: 25mm !important;
    height: 25mm !important;
    border: 0.5pt solid #ddd !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  /* Watermark for specific document statuses */
  .watermark {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) rotate(-45deg) !important;
    font-size: 60pt !important;
    color: rgba(200, 200, 200, 0.2) !important;
    z-index: -1 !important;
    pointer-events: none !important;
    user-select: none !important;
  }
}