/* Telecom Voucher — print stylesheet (A4 landscape, thead repeat, banner-ready).
 * Loaded globally from _Layout.cshtml so all pages benefit.
 * Print-specific page content uses .tv-print-document and .tv-no-print guards.
 */

@media print {
  @page {
    size: A4 landscape;
    margin: 10mm 8mm;
  }

  /* Force colour accuracy for branded elements */
  html {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    height: auto !important;
    overflow: visible !important;
  }

  /* Reset theme background to white; text to near-black */
  body,
  body.tv-theme {
    height: auto !important;
    overflow: visible !important;
    background: #ffffff !important;
    background-image: none !important;
    color: #0f172a !important;
    font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif !important;
    font-size: 11pt !important;
  }

  .tv-app {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  /* ── Hide app chrome ──────────────────────────────────────────────────── */
  .tv-sidebar,
  .tv-sidebar-backdrop,
  .tv-topbar,
  .tv-footer,
  #tv-sidebar-open,
  .tv-no-print,
  /* Action buttons, modals, toasts */
  .modal,
  .offcanvas,
  .notyf,
  .tv-page-loader-overlay {
    display: none !important;
  }

  /* ── DataTables: hide toolbar, paging, global search ─────────────────── */
  .tv-dt-toolbar,
  .tv-dt-bottom-bar,
  .dataTables_filter,
  .dataTables_paginate,
  .dataTables_info,
  .dataTables_length,
  .dt-buttons {
    display: none !important;
  }

  /* ── Full-width layout ───────────────────────────────────────────────── */
  .tv-shell-main {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: none !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  .tv-page-wrap {
    padding: 0 !important;
    max-width: none !important;
  }

  .tv-page-content-shell {
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  /* Bootstrap cards — remove elevated shadow on print */
  .tv-card,
  .card {
    box-shadow: none !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 0 !important;
  }

  /* ── Scroll regions become natural height on paper ───────────────────── */
  .tv-table-scroll,
  .tv-table-wrap,
  .tv-table-enterprise-wrap,
  .dataTables_scrollBody,
  .dataTables_scrollHead {
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Sticky column headers become static */
  .tv-theme .tv-shell-main main table.table thead th,
  .tv-table-enterprise thead th,
  .dataTables_scrollHead thead th {
    position: static !important;
    box-shadow: none !important;
  }

  /* ── Typography for print ────────────────────────────────────────────── */
  h1, h2, h3 {
    color: #0f172a !important;
    page-break-after: avoid;
  }

  a {
    color: #0f172a !important;
    text-decoration: none !important;
  }

  /* ── Document body — full page width ─────────────────────────────────── */
  .tv-print-document {
    max-width: 100% !important;
    width: 100% !important;
    box-shadow: none !important;
    border: none !important;
  }

  .tv-print-document thead {
    display: table-header-group;
  }

  .tv-print-document thead th {
    position: static !important;
    background: #f8fafc !important;
    color: #334155 !important;
    font-size: 9pt !important;
  }

  .tv-print-document tbody tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* ── Print banner (header area on document pages) ────────────────────── */
  .tv-print-banner {
    border: 1px solid #1e3a8a;
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 10px;
    background: linear-gradient(
      145deg,
      #0f172a 0%,
      #134e4a 45%,
      #0a9c76 100%
    ) !important;
    color: #fff !important;
    box-shadow: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .tv-table-enterprise thead th {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  /* ── Watermark for draft documents ──────────────────────────────────── */
  [data-print-watermark="draft"]::after {
    content: attr(data-print-watermark);
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-35deg);
    font-size: 80pt;
    font-weight: 700;
    color: rgba(220, 38, 38, 0.08);
    text-transform: uppercase;
    pointer-events: none;
    z-index: 9999;
  }
}
