/* Barcode Label Print Styles */

/* Hide non-printable elements */
@media print {
  .hide-print {
    display: none !important;
  }
  
  /* Remove default page margins */
  @page {
    margin: 0;
    size: auto;
  }
  
  body {
    margin: 0;
    padding: 0;
  }
  
  /* Remove card styling for print */
  .print-no-border-larger {
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
  }
}

/* ========================================
   CARTON LABEL (4" x 6" / 102mm x 152mm)
   Common for shipping/carton labels
   ======================================== */
@media print {
  /* Carton label page setup */
  body[data-barcode-format="carton"] {
    width: 4in;
    height: 6in;
  }
  
  body[data-barcode-format="carton"] @page {
    size: 4in 6in;
    margin: 0.25in;
  }
  
  /* Carton label content sizing */
  body[data-barcode-format="carton"] .print-no-border-larger {
    width: 3.5in;
    max-width: 3.5in;
    height: auto;
    padding: 0.25in !important;
  }
  
  /* Barcode sizing for carton */
  body[data-barcode-format="carton"] .barcode-container svg {
    max-width: 3in;
    height: auto;
  }
  
  /* Text sizing for carton */
  body[data-barcode-format="carton"] .text-3xl {
    font-size: 1.5rem;
    line-height: 1.3;
    margin-bottom: 0.25in;
  }
  
  body[data-barcode-format="carton"] .text-1xl {
    font-size: 1rem;
    line-height: 1.2;
    margin-bottom: 0.2in;
  }
}

/* ========================================
   UNIT LABEL (2" x 4" / 51mm x 102mm)
   Standard product label size
   ======================================== */
@media print {
  /* Unit label page setup */
  body[data-barcode-format="unit"] {
    width: 2in;
    height: 4in;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  body[data-barcode-format="unit"] @page {
    size: 2in 4in;
    margin: 0;
  }
  
  /* Unit label content sizing */
  body[data-barcode-format="unit"] .print-no-border-larger {
    width: 1.8in;
    max-width: 1.8in;
    height: auto;
    margin: 0 !important;
    padding: 0.05in !important;
  }
  
  /* Barcode sizing for unit */
  body[data-barcode-format="unit"] .barcode-container svg {
    max-width: 1.6in;
    height: auto;
  }
  
  /* Text sizing for unit - readable but compact */
  body[data-barcode-format="unit"] .text-sm {
    font-size: 0.7rem;
    line-height: 1.1;
    margin-top: 0 !important;
    margin-bottom: 0.05in;
  }
  
  body[data-barcode-format="unit"] .mb-0 {
    font-size: 0.8rem;
    font-weight: bold;
    margin-top: 0 !important;
    margin-bottom: 0.05in;
  }
  
  /* Remove all top margins from content */
  body[data-barcode-format="unit"] * {
    margin-top: 0 !important;
  }
  
  /* Ensure content starts at the very top */
  body[data-barcode-format="unit"] .print-no-border-larger > div {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
  
  /* Override any Tailwind classes that add margins */
  body[data-barcode-format="unit"] .text-center {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
  
  body[data-barcode-format="unit"] .max-w-md {
    margin-top: 0 !important;
  }
  
  body[data-barcode-format="unit"] .mx-auto {
    margin-top: 0 !important;
  }
  
  /* Target the specific unit label structure */
  body[data-barcode-format="unit"] .text-center > div:first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
  
  /* Ensure the barcode container has no top margin */
  body[data-barcode-format="unit"] .barcode-container {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
}

/* ========================================
   ALTERNATIVE: 2.25" x 1.25" Dymo Label
   For smaller label printers
   ======================================== */
@media print {
  /* Alternative compact size for Dymo-style labels */
  body[data-barcode-format="unit"][data-compact="true"] {
    width: 2.25in;
    height: 1.25in;
  }
  
  body[data-barcode-format="unit"][data-compact="true"] @page {
    size: 2.25in 1.25in;
    margin: 0.05in;
  }
  
  body[data-barcode-format="unit"][data-compact="true"] .print-no-border-larger {
    width: 2.15in;
    max-width: 2.15in;
    height: auto;
    padding: 0.05in !important;
  }
  
  body[data-barcode-format="unit"][data-compact="true"] .barcode-container svg {
    max-width: 2in;
    height: auto;
  }
  
  body[data-barcode-format="unit"][data-compact="true"] .text-sm {
    font-size: 0.5rem;
    line-height: 1;
    margin-bottom: 0.02in;
  }
  
  body[data-barcode-format="unit"][data-compact="true"] .mb-0 {
    font-size: 0.6rem;
    font-weight: bold;
    margin-bottom: 0.02in;
  }
}

/* ========================================
   FALLBACK: Default print sizing
   Used when no specific format is set
   ======================================== */
@media print {
  /* Default to letter size with minimal margins if no format specified */
  body:not([data-barcode-format]) @page {
    size: letter;
    margin: 0.5in;
  }
  
  body:not([data-barcode-format]) .print-no-border-larger {
    max-width: 7in;
    margin: 0 auto;
  }
}

/* ========================================
   Print utilities
   ======================================== */
@media print {
  /* Ensure proper page breaks */
  .print-no-border-larger {
    page-break-inside: avoid;
    page-break-after: auto;
  }
  
  /* Ensure black text for printing */
  body {
    color: black;
    background: white;
  }
  
  /* Remove any shadows or borders that waste ink */
  * {
    text-shadow: none !important;
    box-shadow: none !important;
  }
}

