/* 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. Logical properties keep Arabic sheets mirrored. */

@page {
  size: A4;
  margin: 16mm 14mm 18mm;
  @bottom-center {
    content: counter(page) " / " counter(pages);
    font-family: 'DM Sans', 'IBM Plex Sans Arabic', sans-serif;
    font-size: 9pt;
    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; }

.order-sheet {
  max-width: 800px;
  margin: 0 auto;
  font-family: 'DM Sans', 'IBM Plex Sans Arabic', sans-serif;
  font-size: 10.5pt;
  line-height: 1.45;
  color: #1c1b19;
}

.order-sheet[lang="ar"] { font-family: 'IBM Plex Sans Arabic', 'DM Sans', sans-serif; }
.order-sheet[lang="ar"] h1, .order-sheet[lang="ar"] h2, .order-sheet[lang="ar"] th,
.order-sheet[lang="ar"] .sheet-brand, .order-sheet[lang="ar"] .sheet-grand td { font-weight: 400; }
.sheet-address { display: flex; flex-direction: column; }

.order-sheet h1 { margin: 0 0 4px; font-size: 18pt; font-weight: 500; }
.order-sheet h2 { margin: 0 0 4px; font-size: 9pt; font-weight: 500; color: #8a8a8a; text-transform: none; }

.sheet-head { display: flex; justify-content: space-between; gap: 24px; padding-block-end: 16px; border-block-end: 2px solid #1c1b19; }
.sheet-brand { display: block; font-size: 16pt; font-weight: 500; color: #1f7a3a; }
.sheet-meta { text-align: end; }
.sheet-muted { color: #6b665f; }
.sheet-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.sheet-parties { display: flex; gap: 48px; padding-block: 16px; }
.sheet-parties > div { flex: 1; display: flex; flex-direction: column; gap: 2px; }

.sheet-items { width: 100%; border-collapse: collapse; margin-block-start: 8px; }
.sheet-items thead { display: table-header-group; }
.sheet-items tr { page-break-inside: avoid; break-inside: avoid; }
.sheet-items th { padding: 6px 4px; text-align: start; font-size: 9pt; font-weight: 500; color: #6b665f; border-bottom: 1px solid #bdb7ad; }
.sheet-items td { padding: 6px 4px; vertical-align: middle; border-bottom: 1px solid #e7e2da; }
.sheet-photo-col { width: 44px; }
.sheet-photo { display: block; width: 40px; height: 40px; object-fit: contain; border-radius: 4px; }
.sheet-line-discount { display: block; font-size: 8.5pt; color: #1f7a3a; }
.sheet-start { text-align: start; }
.sheet-end { text-align: end; }
.sheet-num { white-space: nowrap; font-variant-numeric: tabular-nums; }

.sheet-totals { width: 280px; margin-block-start: 12px; margin-inline-start: auto; border-collapse: collapse; }
.sheet-totals td { padding: 3px 4px; }
.sheet-grand td { padding-top: 8px; font-size: 13pt; font-weight: 500; border-top: 1px solid #1c1b19; }

.sheet-note { margin-block-start: 20px; padding: 10px 12px; border-radius: 6px; background: #f4f1ec; }
.sheet-note p { margin: 0; }

/* The Arabic PDF: the engine lays out left to right, so the markup is mirrored and alignment is set by hand. */
.sheet-mirror .sheet-head, .sheet-mirror .sheet-parties { flex-direction: row-reverse; }
.sheet-mirror .sheet-meta { text-align: left; }
.sheet-mirror .sheet-head > div:first-child, .sheet-mirror .sheet-parties > div { text-align: right; }
.sheet-mirror .sheet-address { align-items: flex-end; }
.sheet-mirror .sheet-start { text-align: right; }
.sheet-mirror .sheet-end { text-align: left; }
.sheet-mirror .sheet-totals { margin-left: 0; margin-right: auto; }

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

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