/* =========================================================
   THERMAL RECEIPT PRINTER STYLES (80mm & 58mm)
   Optimized for Xprinter XP-N160II (80mm Wi-Fi) & Standard Thermal Printers
   ========================================================= */

/* Screen Preview Container */
.receipt-preview-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-lg, 16px);
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

.receipt-format-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(225, 29, 72, 0.15);
  color: #fda4af;
  border: 1px solid rgba(225, 29, 72, 0.3);
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 14px;
}

/* Base Thermal Receipt Paper Style */
.receipt-thermal-paper {
  background: #ffffff;
  color: #111111;
  font-family: 'Courier New', Courier, 'Prompt', monospace;
  line-height: 1.35;
  padding: 20px 18px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  position: relative;
  box-sizing: border-box;
  border-radius: 2px;
}

/* 80mm Size (Xprinter XP-N160II) */
.receipt-80mm-container {
  width: 380px;
  max-width: 100%;
  font-size: 13px;
}

/* 58mm Size (Portable / Mini) */
.receipt-58mm-container {
  width: 290px;
  max-width: 100%;
  font-size: 11.5px;
  padding: 14px 12px;
}

/* Zig-zag tear edge simulation on screen preview */
.receipt-thermal-paper::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 0;
  right: 0;
  height: 8px;
  background: radial-gradient(circle, transparent, transparent 50%, #ffffff 50%, #ffffff 100%);
  background-size: 12px 12px;
}

/* Header Section */
.receipt-header {
  text-align: center;
  margin-bottom: 10px;
}

/* Logo Styling for Thermal Print */
.receipt-logo-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto 8px auto;
}

.receipt-logo-img {
  max-width: 130px;
  max-height: 130px;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: grayscale(100%) contrast(140%);
  image-rendering: -webkit-optimize-contrast;
  display: block;
}

.receipt-58mm-container .receipt-logo-img {
  max-width: 95px;
  max-height: 95px;
}

.shop-logo-fallback {
  font-size: 28px;
  margin-bottom: 4px;
}

.shop-name {
  font-size: 17px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #000;
}

.receipt-58mm-container .shop-name {
  font-size: 14px;
}

.shop-branch, .shop-address, .shop-phone, .tax-id, .receipt-header-custom {
  font-size: 11.5px;
  color: #222;
  margin-top: 1px;
}

.receipt-header-custom {
  font-style: italic;
  margin-top: 4px;
  color: #444;
}

.receipt-58mm-container .shop-branch,
.receipt-58mm-container .shop-address,
.receipt-58mm-container .shop-phone,
.receipt-58mm-container .tax-id,
.receipt-58mm-container .receipt-header-custom {
  font-size: 10px;
}

/* Dividers */
.receipt-divider {
  text-align: center;
  letter-spacing: -0.5px;
  color: #555;
  margin: 8px 0;
  overflow: hidden;
  font-size: 12px;
  white-space: nowrap;
  font-weight: 600;
}

.receipt-58mm-container .receipt-divider {
  font-size: 10px;
  margin: 5px 0;
}

/* Meta Data */
.receipt-meta {
  font-size: 11.5px;
}

.receipt-58mm-container .receipt-meta {
  font-size: 10.5px;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
}

/* Items List Table */
.receipt-items-list {
  margin: 8px 0;
}

.receipt-item-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
  font-size: 13px;
}

.receipt-58mm-container .receipt-item-row {
  font-size: 11.5px;
  margin-bottom: 3px;
}

.item-name-qty {
  display: flex;
  gap: 8px;
  max-width: 270px;
}

.receipt-58mm-container .item-name-qty {
  max-width: 190px;
  gap: 5px;
}

.item-name-qty .qty {
  font-weight: 700;
  min-width: 22px;
}

.item-name-qty .name {
  font-weight: 600;
  word-break: break-word;
}

.item-price {
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.item-modifiers {
  font-size: 11px;
  color: #444;
  padding-left: 30px;
  margin-bottom: 4px;
}

.receipt-58mm-container .item-modifiers {
  font-size: 9.5px;
  padding-left: 24px;
}

/* Summary Calculations */
.receipt-summary {
  font-size: 12px;
}

.receipt-58mm-container .receipt-summary {
  font-size: 10.5px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
}

.summary-row.discount {
  color: #c026d3;
  font-weight: 600;
}

.summary-row.grand-total {
  font-size: 16px;
  font-weight: 800;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #333;
}

.receipt-58mm-container .summary-row.grand-total {
  font-size: 13.5px;
}

.summary-row.payment-info {
  margin-top: 5px;
  font-weight: 600;
}

.summary-row.change-info {
  font-weight: 700;
}

/* Footer Section */
.receipt-footer {
  text-align: center;
  font-size: 11.5px;
  margin-top: 8px;
}

.receipt-58mm-container .receipt-footer {
  font-size: 10px;
}

.wifi-box {
  display: flex;
  flex-direction: column;
  background: #f4f4f4;
  padding: 8px;
  border-radius: 4px;
  margin: 6px 0;
  font-size: 11px;
  border: 1px dashed #ccc;
}

.receipt-58mm-container .wifi-box {
  font-size: 9.5px;
  padding: 6px;
}

.footer-msg {
  font-weight: 700;
  margin: 6px 0 2px 0;
  font-size: 12px;
}

.footer-sub-msg {
  font-size: 11px;
  color: #444;
  margin-bottom: 6px;
}

.cut-guide {
  font-size: 10px;
  color: #777;
  margin-top: 10px;
}

/* =========================================================
   PRINT MEDIA RULES (Universal 80mm / 58mm Thermal Print)
   ========================================================= */

@media print {
  @page {
    margin: 0;
    size: auto; /* Let thermal driver or body width determine roll width */
  }

  /* Hide everything on the app page */
  body * {
    visibility: hidden;
  }

  /* Only show print mount */
  #print-mount, #print-mount * {
    visibility: visible;
  }

  #print-mount {
    position: absolute;
    left: 0;
    top: 0;
    margin: 0 !important;
    padding: 2mm 3mm !important;
    background: transparent !important;
    box-sizing: border-box;
  }

  /* 80mm Print Mode (Xprinter XP-N160II: ~72-80mm width) */
  .receipt-80mm-container {
    width: 76mm !important;
    box-shadow: none !important;
    padding: 0 !important;
    font-size: 12.5px !important;
    line-height: 1.3 !important;
  }

  /* 58mm Print Mode (~54-58mm width) */
  .receipt-58mm-container {
    width: 54mm !important;
    box-shadow: none !important;
    padding: 0 !important;
    font-size: 10.5px !important;
    line-height: 1.25 !important;
  }

  .receipt-thermal-paper::after {
    display: none !important;
  }

  .receipt-format-badge {
    display: none !important;
  }

  .receipt-logo-img {
    filter: grayscale(100%) contrast(200%) !important;
  }
}
