@media print {
  /* Set the @page rule explicitly for A4 dimensions */
  @page {
    size: 210mm 297mm; /* A4 dimensions */
    margin: 10mm; /* Set a small margin to maximize space */
  }

  /* General print styles applied to both A4 and A5 */
  .table_data th {
    background-color: #007bff !important; /* Blue header background */
    color: white !important; /* White text color */
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .info {
    text-align: center;
    margin-bottom: 5px;
  }

   /* Full width table  A5 ပြောင်းရန်  */
   .table_data {
    width: 100%;
    max-width: 100%; /* Ensure the table doesn't shrink */
    border-collapse: collapse;
    margin-left: 0mm; /* Add left margin for spacing */
  }

  .table_data thead tr {
    background: linear-gradient(to right, #a0c4ff, #c4dfff);
    color: white;
    font-weight: bold;
  }

  .table_data th {
    font-size: 15px;
    padding: 4px 6px;
    text-align: center;
    border: none;
  }

  /* Rounded corners for header */
  .table_data thead th:first-child {
    border-top-left-radius: 8px;
  }
  .table_data thead th:last-child {
    border-top-right-radius: 8px;
  }

  /* Default column width */
  .table_data th:nth-child(1), .table_data td:nth-child(1) { width: 10%; } /* No */
  .table_data th:nth-child(3), .table_data td:nth-child(3) { width: 10%; } /* Qty */
  .table_data th:nth-child(4), .table_data td:nth-child(4) { width: 15%; } /* Price */
  
  /* Adjust column widths for A4 */
  .table_data th:nth-child(2), .table_data td:nth-child(2) { width: 45%; } /* Wider Item Name */
  .table_data th:nth-child(5), .table_data td:nth-child(5) { width: 20%; } /* Total Price */

  /* Body cell styling */
  .table_data td {
    padding: 8px 10px;
    border: 0.1px dotted #252729;
    text-align: center;
    font-size: 15px; /* Slightly larger font for readability */
  }

  /* Payment and change table */
  .change {
    width: 100%; /* Ensure it is also full width */
    font-size: 8px;
    margin: 10px auto;
  }

  /* Styling for "Paid By," "Amount," and "Change Return" rows */
  .table_data .no-border-below-top {
    border-top: none;
    border-bottom: none;
    border-left: none;
  }

  /* Barcode and Note area */
  #legalcopy {
    margin-top: 5mm;
    text-align: center;
  }
  #bar {
    text-align: center;
  }

  /* Centering the entire invoice content for A4 */
  #invoice-POS {
    max-width: 210mm; /* Full A4 width */
    width: 100%;
    margin: 0;
  }

  /* Button alignment */
  .b-modal-footer {
    text-align: center;
  }

  /* Footer button for Print */
  .btn-outline-primary {
    font-size: 10px;
    padding: 5px 10px;
    margin-top: 5px;
  }

  /* Alternative A5-specific adjustments */
  @media print and (max-width: 198mm) {
    /* A5-specific layout */
    .table_data th:nth-child(2), .table_data td:nth-child(2) { width: 60%; } /* Narrower Item Name */
    .table_data th:nth-child(5), .table_data td:nth-child(5) { width: 15%; } /* Smaller Total Price */
    .table_data td {
      font-size: 12px;
      padding: 6px 8px;
    }
  }
}
