/* The order sheet (OrderSheet.razor): the print page and the order PDF share this file. Plain values only: the PDF
   engine reads it without the site's custom properties. Black and greys with hairline borders, so it prints the same
   on a laser printer as on screen. Every row of blocks is a table, which the PDF engine lays out reliably; the Arabic
   PDF reverses the cells itself (sheet-mirror), so alignment there is set by hand. */

@page {
  size: A4 portrait;
  margin: 14mm 14mm 16mm;
  @bottom-center {
    content: counter(page) " / " counter(pages);
    font-family: 'DM Sans', 'IBM Plex Sans Arabic', sans-serif;
    font-size: 8pt;
    color: #8a8a8a;
  }
}

/* Direction from the dir attribute, stated outright for the PDF engine, and isolated runs for numbers and names. */
.order-sheet[dir="rtl"], .order-sheet [dir="rtl"] { direction: rtl; }
.order-sheet[dir="ltr"], .order-sheet [dir="ltr"] { direction: ltr; }
.order-sheet bdi, .order-sheet .sheet-iso { unicode-bidi: isolate; }
/* A left-to-right block (a phone, an email, the order number) keeps the alignment of its cell on an Arabic sheet. */
.order-sheet[dir="rtl"] .sheet-start div[dir="ltr"] { text-align: right; }
.order-sheet[dir="rtl"] .sheet-end div[dir="ltr"] { text-align: left; }

.order-sheet {
  max-width: 760px;
  margin: 0 auto;
  font-family: 'DM Sans', 'IBM Plex Sans Arabic', sans-serif;
  font-size: 9.5pt;
  line-height: 1.4;
  color: #1c1b19;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.order-sheet[lang="ar"] { font-family: 'IBM Plex Sans Arabic', 'DM Sans', sans-serif; }
.order-sheet table { width: 100%; border-collapse: collapse; }
.order-sheet td, .order-sheet th { padding: 0; vertical-align: top; }

/* Shared pieces. */
.sheet-label { font-size: 8pt; color: #6b665f; }
.sheet-sub { margin-top: 6px; }
.sheet-muted { color: #6b665f; }
.sheet-strong { font-weight: 500; }
.sheet-start { text-align: start; }
.sheet-end { text-align: end; }
.sheet-center { text-align: center; }
.sheet-num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.sheet-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header: the wagon and the store's branches, the order number opposite. */
.sheet-head { margin-bottom: 14px; }
.sheet-head > tbody > tr > td, .sheet-head > tr > td { vertical-align: middle; }
.sheet-brand { width: auto; }
.sheet-brand td { vertical-align: middle; }
.sheet-logo-cell { width: 104px; }
.sheet-logo { display: block; width: 92px; height: 87px; }
.sheet-brand-name { margin-bottom: 2px; font-size: 17pt; font-weight: 500; line-height: 1.2; letter-spacing: -0.01em; }
.order-sheet[lang="ar"] .sheet-brand-name { letter-spacing: 0; }
.sheet-brand .sheet-muted { font-size: 8.5pt; }
.sheet-title { width: 40%; }
.sheet-number { font-size: 22pt; font-weight: 500; line-height: 1.15; letter-spacing: -0.01em; }

/* The facts strip between two rules. */
.sheet-facts { border-top: 1.5px solid #1c1b19; border-bottom: 1px solid #d9d4cc; }
.sheet-fact { padding: 8px 12px 8px 0; }
.order-sheet[dir="rtl"] .sheet-fact { padding: 8px 0 8px 12px; }

/* Cards: where it goes and who ordered it, then the notes. */
.sheet-cards { margin-top: 14px; }
.order-sheet .sheet-cards { border-collapse: separate; border-spacing: 0; }
.order-sheet .sheet-card { width: 50%; padding: 10px 12px; border: 1px solid #d9d4cc; border-radius: 8px; }
.sheet-card .sheet-label { margin-bottom: 2px; }
.order-sheet .sheet-note { border-color: #1c1b19; }
.sheet-gap { width: 12px; }
.sheet-gap-wide { width: 28px; }

/* Items: number, photo, name with its codes, then the figures in narrow columns that fit a portrait page. */
.sheet-items { margin-top: 18px; }
.sheet-items thead { display: table-header-group; }
.sheet-items tr { page-break-inside: avoid; break-inside: avoid; }
.sheet-items th { padding: 6px 6px; font-size: 8pt; font-weight: 400; color: #6b665f; background: #f3f1ed; border-bottom: 1px solid #1c1b19; }
.sheet-items td { padding: 6px 6px; vertical-align: middle; border-bottom: 1px solid #e4dfd7; }
.sheet-index { width: 22px; }
.sheet-photo-col { width: 104px; }
.sheet-photo-box { width: 96px; height: 96px; border: 1px solid #e4dfd7; border-radius: 6px; background: #fff; overflow: hidden; }
.sheet-photo { display: block; width: 96px; height: 96px; object-fit: contain; }
.sheet-item-name { font-weight: 500; }
.sheet-codes { margin-top: 2px; font-size: 8pt; color: #6b665f; }
.sheet-dot { color: #a8a299; }
.sheet-line-discount { margin-top: 2px; font-size: 8pt; color: #1f6a35; }
.sheet-price-col { width: 86px; }
.sheet-qty-col { width: 44px; }
.sheet-total-col { width: 92px; }
.sheet-qty { display: inline-block; min-width: 24px; padding: 1px 4px; border: 1px solid #1c1b19; border-radius: 4px; font-weight: 500; text-align: center; }

/* Counts for packing on one side, the totals on the other. */
.sheet-summary { margin-top: 14px; page-break-inside: avoid; break-inside: avoid; }
.sheet-counts { vertical-align: top; }
.sheet-counts table { width: auto; }
.sheet-count-value { font-size: 14pt; font-weight: 500; }
.sheet-totals-cell { width: 300px; }
.sheet-totals td { padding: 3px 6px; }
.sheet-grand td { padding-top: 8px; padding-bottom: 8px; font-size: 13pt; font-weight: 500; border-top: 1.5px solid #1c1b19; border-bottom: 1.5px solid #1c1b19; }

.sheet-thanks { margin: 28px 0 0; padding-top: 10px; text-align: center; font-size: 9pt; color: #6b665f; border-top: 1px solid #e4dfd7; }

/* Arabic: weights stay at 400 where IBM Plex Sans Arabic 500 is too heavy at small sizes. */
.order-sheet[lang="ar"] .sheet-items th, .order-sheet[lang="ar"] .sheet-label { font-weight: 400; }

/* The Arabic PDF: the engine lays out left to right, so the markup is mirrored and alignment is set by hand. */
.sheet-mirror, .sheet-mirror .sheet-start { text-align: right; }
.sheet-mirror .sheet-end { text-align: left; }
.sheet-mirror .sheet-brand { margin-left: auto; }

/* The print page around the sheet. */
.print-page { padding: 32px 16px; background: #f4f1ec; min-height: 100vh; }
.print-page .order-sheet { padding: 40px; background: #fff; border-radius: 12px; }
.print-tools { display: flex; justify-content: center; gap: 8px; max-width: 760px; margin: 0 auto 16px; }

@media print {
  .print-page { min-height: 0; padding: 0; background: #fff; }
  .print-page .order-sheet { max-width: none; padding: 0; border-radius: 0; }
  .print-tools { display: none; }
}
