/* ═══════════════════════════════════════════════════════════════
   AWB Label — Professional Shipping Label Stylesheet
   Supports three templates: classic, compact, bold
   ═══════════════════════════════════════════════════════════════ */

* {
  box-sizing: border-box;
}

a {
  text-decoration: none;
}

/* ── Page wrapper ── */
.awb-page {
  width: 100mm;
  min-height: 150mm;
  margin: 0 auto;
  background: #fff;
  color: #000;
  font-family: Arial, Helvetica, sans-serif;
  page-break-after: always;
  break-after: page;
}

/* ── Label outer border ── */
.awb-label {
  width: 100%;
  border: 2px solid #000;
  background: #fff;
}

/* ══════════════════════════════════════════════════════════════════
   TEMPLATE 1 — CLASSIC AWB  (2-column rows, barcode at bottom)
   ══════════════════════════════════════════════════════════════════ */

/* ── Shared row styles ── */
.awb-label--classic .awb-row {
  display: flex;
  border-bottom: 1.5px solid #000;
}

.awb-label--classic .awb-row:last-child {
  border-bottom: 0;
}

/* ── 2-column split ── */
.awb-label--classic .awb-cell-left {
  flex: 0 0 55%;
  border-right: 1.5px solid #000;
  padding: 4px 5px;
}

.awb-label--classic .awb-cell-right {
  flex: 1;
  padding: 4px 5px;
}

/* ── Full-width cell ── */
.awb-label--classic .awb-full-cell {
  width: 100%;
  padding: 4px 5px;
}

/* ── ROW 1: Header — Logo+Sender | Meta ── */
.awb-label--classic .awb-header-row {
  min-height: 22mm;
}

.awb-label--classic .awb-logo-sender {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  padding: 5px;
}

.awb-logo-wrap {
  flex: 0 0 auto;
  width: 18mm;
  height: 18mm;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ccc;
  background: #f5f5f5;
  overflow: hidden;
}

.awb-logo-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.awb-logo-fallback {
  font-size: 11pt;
  font-weight: 800;
  letter-spacing: 1pt;
  text-align: center;
  color: #111;
}

.awb-label--classic .awb-sender-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
}

.awb-sender-name {
  font-size: 8pt;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: .2pt;
}

.awb-sender-addr,
.awb-sender-phone {
  font-size: 6.5pt;
  color: #333;
  line-height: 1.3;
}

/* Meta box (right of header) */
.awb-meta-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  text-align: center;
}

.awb-meta-line {
  line-height: 1.3;
}

.awb-meta-line.is-hidden {
  display: none;
}

.awb-meta-value {
  font-size: 8.5pt;
  font-weight: 700;
}

/* ── ROW 2: SKU ── */
.awb-label--classic .awb-sku-row {
  min-height: 7mm;
  background: #fafafa;
}

.awb-sku-cell {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
}

.awb-sku-value {
  font-size: 7.5pt;
  font-weight: 700;
  word-break: break-word;
}

.awb-item-count {
  font-size: 7pt;
  font-weight: 800;
  background: #000;
  color: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
  margin-left: auto;
}

/* ── ROW 3: Recipient | QR ── */
.awb-label--classic .awb-recipient-row {
  min-height: 35mm;
}

.awb-to-block {
  padding: 5px 6px;
}

.awb-to-label {
  font-size: 7pt;
  font-weight: 700;
  color: #555;
  margin-bottom: 2px;
}

.awb-buyer-name {
  font-size: 10pt;
  font-weight: 800;
  letter-spacing: .3pt;
  margin-bottom: 3px;
  line-height: 1.15;
}

.awb-addr-line {
  font-size: 9.5pt;
  line-height: 1.35;
  color: #000;
  font-weight: 500;
}

.awb-addr-city {
  font-size: 11pt;
  font-weight: 800;
  margin-top: 2px;
  color: #000;
}

.awb-addr-country {
  font-size: 8pt;
  color: #333;
  margin-top: 1px;
}

.awb-addr-phone {
  font-size: 10.5pt;
  font-weight: 800;
  color: #000;
  margin-top: 3px;
  letter-spacing: .3px;
}

/* QR panel */
.awb-qr-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.awb-qr-panel.is-hidden {
  background: #fafafa;
}

.awb-qr-wrap {
  width: 28mm;
  height: 28mm;
}

.awb-qr-wrap .qr,
.qr {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── ROW 4: Shipping info | Payment ── */
.awb-label--classic .awb-info-row {
  min-height: 20mm;
}

.awb-shipping-info {
  padding: 5px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  justify-content: center;
}

.awb-shipping-type {
  font-size: 9pt;
  font-weight: 800;
  letter-spacing: .2pt;
  margin-bottom: 2px;
}

.awb-order-line,
.awb-track-line,
.awb-date-line {
  font-size: 6.5pt;
  color: #222;
  line-height: 1.4;
}

.awb-info-label {
  font-weight: 700;
}

.awb-payment-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  padding: 5px 4px;
}

.awb-payment-method {
  font-size: 7pt;
  font-weight: 800;
  padding: 3px 5px;
  border-radius: 3px;
  letter-spacing: .3pt;
}

.awb-cod {
  background: #000;
  color: #fff;
}

.awb-prepaid {
  background: #eee;
  color: #333;
  border: 1px solid #999;
}

.awb-cod-amount {
  font-size: 8pt;
  font-weight: 800;
}

.awb-sort-code,
.awb-threepl-code {
  font-size: 7.5pt;
  font-weight: 700;
  color: #333;
}

/* ── ROW 5: Barcode ── */
.awb-label--classic .awb-barcode-row {
  flex-direction: column;
  align-items: center;
  padding: 6px 4px 4px;
  border-top: 1.5px solid #000;
  min-height: 22mm;
}

.awb-barcode-wrap {
  display: block;
  width: 100%;
  text-align: center;
}

.awb-barcode-wrap .bc {
  display: block !important;
  width: 100% !important;
}

.awb-barcode-wrap .bc-svg {
  width: 100% !important;
  max-width: 100% !important;
  display: block;
}

.awb-barcode-text {
  font-size: 7pt;
  font-weight: 700;
  text-align: center;
  margin-top: 3px;
  letter-spacing: .5pt;
  width: 100%;
}

/* ══════════════════════════════════════════════════════════════════
   TEMPLATE 2 — COMPACT SLIP  (single-column, stacked)
   ══════════════════════════════════════════════════════════════════ */

.awb-label--compact {
  font-family: Arial, Helvetica, sans-serif;
}

/* Barcode on top */
.awb-cpt-barcode {
  padding: 6px 6px 4px;
  border-bottom: 1.5px solid #000;
  text-align: center;
}

/* Sender line */
.awb-cpt-sender {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-bottom: 1.5px solid #000;
  background: #f8f8f8;
}

.awb-cpt-logo {
  flex: 0 0 auto;
  width: 12mm;
  height: 12mm;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.awb-cpt-logo .awb-logo-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.awb-cpt-logo .awb-logo-fallback {
  font-size: 7pt;
  font-weight: 800;
}

.awb-cpt-sender-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.awb-cpt-sender-name {
  font-size: 7.5pt;
  font-weight: 800;
}

.awb-cpt-sender-addr,
.awb-cpt-sender-phone {
  font-size: 6pt;
  color: #444;
}

/* Recipient */
.awb-cpt-recipient {
  padding: 6px 8px;
  border-bottom: 1.5px solid #000;
  min-height: 28mm;
}

.awb-cpt-to-label {
  font-size: 6pt;
  font-weight: 700;
  color: #888;
  letter-spacing: 1px;
  margin-bottom: 3px;
}

.awb-cpt-buyer {
  font-size: 11pt;
  font-weight: 900;
  letter-spacing: .3pt;
  margin-bottom: 3px;
  line-height: 1.1;
}

.awb-cpt-addr {
  font-size: 9.5pt;
  line-height: 1.3;
  color: #000;
  font-weight: 500;
}

.awb-cpt-city {
  font-size: 11pt;
  font-weight: 800;
  margin-top: 2px;
  color: #000;
}

.awb-cpt-country {
  font-size: 8pt;
  color: #333;
}

.awb-cpt-phone {
  font-size: 10.5pt;
  font-weight: 800;
  color: #000;
  margin-top: 3px;
  letter-spacing: .3px;
}

/* Meta grid */
.awb-cpt-meta {
  padding: 4px 6px;
  border-bottom: 1.5px solid #000;
}

.awb-cpt-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 10px;
}

.awb-cpt-meta-item {
  display: flex;
  justify-content: space-between;
  font-size: 6.5pt;
  line-height: 1.5;
}

.awb-cpt-meta-key {
  font-weight: 700;
  color: #555;
}

.awb-cpt-meta-val {
  font-weight: 600;
  text-align: right;
}

/* SKU */
.awb-cpt-sku {
  padding: 3px 6px;
  border-bottom: 1.5px solid #000;
  background: #fafafa;
}

/* Footer: Payment + QR */
.awb-cpt-footer {
  display: flex;
  border-top: 0;
}

.awb-cpt-payment {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px;
  text-align: center;
}

.awb-cpt-qr {
  flex: 0 0 auto;
  padding: 4px;
  border-left: 1.5px solid #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.awb-cpt-qr .awb-qr-wrap {
  width: 24mm;
  height: 24mm;
}

/* ══════════════════════════════════════════════════════════════════
   TEMPLATE 3 — BOLD COURIER  (big recipient, courier-readable)
   ══════════════════════════════════════════════════════════════════ */

.awb-label--bold {
  font-family: Arial, Helvetica, sans-serif;
}

/* Top bar */
.awb-bld-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  border-bottom: 2px solid #000;
  background: #f5f5f5;
  min-height: 14mm;
}

.awb-bld-sender {
  display: flex;
  align-items: center;
  gap: 5px;
}

.awb-bld-logo {
  width: 12mm;
  height: 12mm;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.awb-bld-logo .awb-logo-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.awb-bld-logo .awb-logo-fallback {
  font-size: 7pt;
  font-weight: 800;
}

.awb-bld-sender-name {
  font-size: 7.5pt;
  font-weight: 800;
}

.awb-bld-sender-phone {
  font-size: 6pt;
  color: #555;
  margin-left: 4px;
}

.awb-bld-badges {
  display: flex;
  align-items: center;
  gap: 5px;
}

.awb-bld-amount {
  font-size: 9pt;
  font-weight: 900;
}

/* Big recipient */
.awb-bld-recipient {
  padding: 8px 8px 6px;
  border-bottom: 2px solid #000;
  min-height: 38mm;
}

.awb-bld-buyer {
  font-size: 14pt;
  font-weight: 900;
  letter-spacing: .5pt;
  line-height: 1.1;
  margin-bottom: 4px;
}

.awb-bld-city {
  font-size: 12pt;
  font-weight: 800;
  margin-bottom: 4px;
  line-height: 1.1;
}

.awb-bld-addr {
  font-size: 10pt;
  line-height: 1.3;
  color: #000;
  font-weight: 500;
}

.awb-bld-country {
  font-size: 8pt;
  color: #333;
  margin-top: 1px;
}

.awb-bld-phone {
  font-size: 11.5pt;
  font-weight: 800;
  margin-top: 4px;
  letter-spacing: .3px;
}

/* Info row */
.awb-bld-info {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 8px;
  padding: 4px 6px;
  border-bottom: 1.5px solid #000;
  font-size: 6.5pt;
}

.awb-bld-info-item {
  white-space: nowrap;
}

.awb-bld-info-item b {
  color: #555;
  margin-right: 2px;
}

/* SKU */
.awb-bld-sku {
  padding: 3px 6px;
  border-bottom: 1.5px solid #000;
  background: #fafafa;
}

/* Bottom: barcode + QR side by side */
.awb-bld-bottom {
  display: flex;
  min-height: 24mm;
}

.awb-bld-barcode {
  flex: 1;
  padding: 5px 4px;
  text-align: center;
}

.awb-bld-qr {
  flex: 0 0 auto;
  padding: 4px;
  border-left: 1.5px solid #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.awb-bld-qr .awb-qr-wrap {
  width: 22mm;
  height: 22mm;
}


/* ── Utility ── */
.is-hidden {
  display: none !important;
}

/* ── Preview shell on labels.php ── */
.preview-shell {
  background: #f1f5f9;
  padding: 16px;
  display: flex;
  justify-content: center;
}

/* ── Print sheet ── */
@page {
  margin: 0;
  size: 100mm 150mm;
}

@media print {

  /* Force browser to render colors exactly — no lightening */
  html {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  html,
  body {
    background: #fff !important;
    margin: 0;
    padding: 0;
    color: #000000 !important;
  }

  /* Every element: pure black, full opacity, no grey */
  * {
    color: #000000 !important;
    -webkit-text-fill-color: #000000 !important;
    opacity: 1 !important;
    text-shadow: none !important;
  }

  @media print {

    /* Thick stroke for maximum darkness on thermal/laser printers */
    p,
    span,
    div,
    td,
    th,
    b,
    strong,
    font,
    a,
    label,
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    .awb-sender-name,
    .awb-buyer-name,
    .awb-meta-value,
    .awb-shipping-type,
    .awb-info-label,
    .awb-barcode-text,
    .awb-sku-value,
    .awb-cod-amount,
    .awb-sort-code,
    .awb-threepl-code,
    .awb-payment-method,
    .awb-cpt-buyer,
    .awb-cpt-sender-name,
    .awb-cpt-city,
    .awb-bld-buyer,
    .awb-bld-city,
    .awb-bld-sender-name,
    .awb-bld-amount {
      /* 1. Force Pure Solid Black */
      color: #000000 !important;
      -webkit-text-fill-color: #000000 !important;
      -webkit-text-stroke: 0.3pt #000000 !important;
      font-weight: bold !important;

      /* 2. Override Browser Print Settings */
      print-color-adjust: exact !important;
      -webkit-print-color-adjust: exact !important;

      /* 3. NEW: Remove Any Fading, Shading, or Transparency */
      opacity: 1 !important;
      /* Ensures text is 100% solid, never see-through */
      text-shadow: none !important;
      /* Removes fuzzy drop-shadows that print as grey smudges */
      filter: none !important;
      /* Strips away any CSS filters washing out the color */
      background: transparent !important;
      /* Prevents background colors from bleeding into text */
    }
  }

  /* Borders: solid black, not grey */
  .awb-label,
  .awb-row,
  .awb-cell-left,
  .awb-barcode-row,
  .awb-cpt-barcode,
  .awb-cpt-sender,
  .awb-cpt-recipient,
  .awb-cpt-meta,
  .awb-cpt-sku,
  .awb-cpt-qr,
  .awb-bld-topbar,
  .awb-bld-recipient,
  .awb-bld-info,
  .awb-bld-sku,
  .awb-bld-qr {
    border-color: #000000 !important;
  }

  /* Barcode SVG: crisp black bars */
  .awb-barcode-wrap svg rect[fill='#000'],
  .awb-barcode-wrap svg rect[fill='black'] {
    fill: #000000 !important;
  }

  .awb-barcode-wrap svg {
    shape-rendering: crispEdges !important;
  }

  .awb-barcode-wrap .bc-svg {
    filter: contrast(2) !important;
    -webkit-filter: contrast(2) !important;
  }

  /* QR code image: boost contrast */
  .awb-qr-wrap img {
    filter: contrast(1.5) !important;
    -webkit-filter: contrast(1.5) !important;
  }

  /* COD badge background must print */
  .awb-cod {
    background: #000000 !important;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    -webkit-text-stroke: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Item count badge */
  .awb-item-count {
    background: #000000 !important;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    -webkit-text-stroke: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .noprint,
  .toolbar {
    display: none !important;
  }

  .awb-page {
    margin: 0;
    width: 100mm;
    min-height: 150mm;
    page-break-after: always;
    break-after: page;
  }

  .awb-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }
}