/* Coneso CF — print stylesheet (Phase E.5).
 *
 * Targets:
 *   - Order bills printed from /customerordermanagement (full + short).
 *   - Shipping labels (HAL tracking pages).
 *   - Any "Save as PDF" use of the regular admin pages.
 *
 * Strategy:
 *   - Hide navigation, sidebars, action bars, toasts, dropdowns.
 *   - Force a black-on-white surface regardless of dark/light theme.
 *   - Serif body for readability; mono for tracking codes / CF codes.
 *   - Tight margins so a bill fits one A5/A4 sheet.
 *   - Avoid breaking inside an .order-row / table row.
 *
 * Loaded last in the head partials so its `@media print` block wins.
 */
@media print {
  /* Force the lightest theme regardless of user preference. The dark
   * tokens are dropped here so labels printed at the warehouse don't
   * burn black ink. */
  :root,
  [data-theme="dark"] {
    --bg-base:        #ffffff;
    --bg-surface:     #ffffff;
    --bg-raised:      #ffffff;
    --bg-overlay:     transparent;
    --text-primary:   #000000;
    --text-secondary: #333333;
    --text-muted:     #555555;
    --text-inverse:   #ffffff;
    --border-subtle:  #cccccc;
    --border-default: #999999;
    --border-strong:  #666666;
    --shadow-sm:      none;
    --shadow-md:      none;
    --shadow-lg:      none;
  }

  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    font-family: "Noto Serif Lao", "Phetsarath OT", Georgia, "Times New Roman", serif;
    font-size: 11pt;
    line-height: 1.4;
  }

  @page {
    margin: 12mm 10mm;
  }

  /* Drop chrome that doesn't belong on paper. */
  .cf-mainnav,
  .navbar,
  .sidenav,
  nav,
  footer,
  .c-toast-stack,
  .c-toast,
  .swal2-container,
  .modal,
  .dropdown,
  .navdropdown,
  .navdropdown-content,
  .cf-langswitch,
  .cf-themeswitch,
  .nav-logout,
  .btn,
  button,
  .c-btn,
  input[type="button"],
  input[type="submit"],
  .DTFC_LeftWrapper,
  .dataTables_filter,
  .dataTables_length,
  .dataTables_info,
  .dataTables_paginate,
  .no-print {
    display: none !important;
  }

  /* Honour explicit opt-in for chrome that *should* print
   * (e.g. an order page wraps its content in `.print-only`). */
  .print-only {
    display: block !important;
  }

  /* Tables: remove the subtle blue tint, print full-width with a thin
   * black ruling so columns are still legible after a photocopy. */
  table, .c-table {
    width: 100% !important;
    border-collapse: collapse !important;
    page-break-inside: auto;
    color: #000000 !important;
    background: #ffffff !important;
  }
  table thead, .c-table thead {
    display: table-header-group;  /* repeat header on every page */
  }
  table th, table td,
  .c-table th, .c-table td {
    border: 1px solid #000000 !important;
    padding: 4px 6px !important;
    color: #000000 !important;
    background: #ffffff !important;
  }
  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  /* Tracking codes / CF codes: always mono so 0 vs O / 1 vs l don't
   * confuse the warehouse worker reading the printout. */
  .tracking-code,
  .cf-code,
  .order-id,
  code, kbd, samp, pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    letter-spacing: 0.02em;
  }

  /* Remove background-image shimmer on skeletons + badges; some printers
   * dump the gradient as a grey blob otherwise. */
  .c-skeleton {
    background: #eeeeee !important;
    animation: none !important;
  }
  .c-badge {
    border: 1px solid #000000 !important;
    background: #ffffff !important;
    color: #000000 !important;
  }

  /* Fancybox / image gallery — the raw <img> should print, not the
   * wrapper UI. */
  .fancybox-container,
  .fancybox-bg,
  .fancybox-toolbar { display: none !important; }

  /* Links should still resolve; print the URL after the anchor for
   * screen-only links (skip for `.no-link` content). */
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #555555;
  }
  a[href^="#"]::after,
  a[href^="javascript:"]::after,
  a.no-link::after { content: ""; }
}
