@page {
  size: A4 portrait;
  margin: 10mm 12mm 10mm 12mm;
}

@media print {
  *, *::before, *::after {
    background: transparent !important;
    color: #000000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  html, body {
    width: 100% !important;
    height: auto !important;
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 10.5pt !important;
    font-family: 'Khmer OS Siemreap', 'Siemreap', 'Kantumruy Pro', sans-serif !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .shadcn-navbar,
  .auth-gateway-screen,
  .stepperize-container,
  .stepwise-form-col,
  .no-print,
  .btn,
  .modal-overlay,
  .toast-container,
  .navbar-actions,
  .doc-action-bar,
  #form-tab,
  #morning-tab,
  #issues-tab,
  #history-tab,
  #settings-tab {
    display: none !important;
  }

  /* Exclude all uploaded photos strictly from Print and PDF Export */
  .doc-photo-gallery,
  .doc-photo-item,
  .doc-gallery-img,
  .doc-photo-gallery img,
  #doc-opening-photos,
  #doc-closing-photos,
  #doc-morning-photo-gallery,
  #print-opening-photos,
  #print-closing-photos,
  #print-update-photos,
  .doc-opening-photos-container,
  .doc-closing-photos-container,
  .photo-card,
  .photo-preview-grid {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: hidden !important;
  }

  #main-app-wrapper,
  .shadcn-container,
  #document-tab {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
  }

  .a4-document-wrapper {
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
  }

  .a4-page {
    width: 100% !important;
    min-height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border: none !important;
    page-break-after: auto;
  }

  .doc-section,
  .doc-grid-box,
  .doc-signature-section {
    page-break-inside: avoid;
  }

  .doc-meta-value,
  .doc-content-block,
  .doc-highlight-inline,
  .doc-issue-status-tag {
    background-color: transparent !important;
    border: none !important;
    border-radius: 0 !important;
  }

  .doc-issue-status-tag.status-tag-incomplete {
    color: #dc2626 !important;
    font-weight: 700 !important;
  }

  .doc-issue-status-tag.status-tag-complete {
    color: #059669 !important;
    font-weight: 700 !important;
  }

  .doc-company-logo-img {
    height: 60px !important;
    width: auto !important;
    object-fit: contain !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .doc-company-title {
    color: #000000 !important;
    font-size: 1.05rem !important;
    font-weight: 800 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .official-seal-stamp,
  .official-seal-stamp * {
    border-color: #dc2626 !important;
    color: #dc2626 !important;
  }

  .doc-footer {
    border-top: 1px solid #333 !important;
    margin-top: 1.5rem !important;
    padding-top: 0.5rem !important;
  }

  /* =========================================================================
     BRANCH REPORT HISTORY PRINT MODE (body.printing-history)
     ========================================================================= */
  body.printing-history #document-tab {
    display: none !important;
  }

  body.printing-history #history-tab {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
  }

  body.printing-history .shadcn-card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
  }

  body.printing-history .card-header,
  body.printing-history .history-action-buttons,
  body.printing-history .table-filter-grid,
  body.printing-history .history-quick-filter-chips,
  body.printing-history .reports-pagination,
  body.printing-history .table-actions-group,
  body.printing-history th:last-child,
  body.printing-history td:last-child,
  body.printing-history .table-photos-cell .table-photo-thumb-btn {
    display: none !important;
  }

  /* Corporate Letterhead for History Report Print */
  body.printing-history .history-print-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.85rem !important;
    margin-bottom: 1rem !important;
    border-bottom: 2px solid #000000 !important;
  }

  body.printing-history .history-print-brand {
    display: flex !important;
    align-items: center;
    gap: 0.85rem !important;
  }

  body.printing-history .history-print-logo {
    width: 48px !important;
    height: 48px !important;
    object-fit: contain !important;
  }

  body.printing-history .history-print-company {
    font-family: 'Inter', sans-serif !important;
    font-size: 11pt !important;
    font-weight: 800 !important;
    letter-spacing: 0.5px !important;
    color: #000000 !important;
  }

  body.printing-history .history-print-title {
    font-family: 'Khmer OS Muol Light', 'Moul', var(--font-khmer), serif !important;
    font-size: 13pt !important;
    color: #000000 !important;
    margin: 0.15rem 0 0 0 !important;
  }

  body.printing-history .history-print-meta {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.75rem !important;
    font-size: 8.5pt !important;
    text-align: right !important;
  }

  body.printing-history .history-meta-chip {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.25rem !important;
  }

  body.printing-history .history-meta-chip .meta-label {
    color: #444444 !important;
  }

  body.printing-history .history-meta-chip .meta-val {
    font-weight: 700 !important;
    color: #000000 !important;
  }

  /* Printable Table Grid Layout */
  body.printing-history .reports-table-wrapper {
    overflow: visible !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.printing-history .reports-table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 8.5pt !important;
  }

  body.printing-history .reports-table thead {
    display: table-header-group !important;
  }

  body.printing-history .reports-table tr {
    page-break-inside: avoid !important;
  }

  body.printing-history .reports-table th,
  body.printing-history .reports-table td {
    border: 1px solid #333333 !important;
    padding: 5px 6px !important;
    color: #000000 !important;
    background: transparent !important;
    vertical-align: middle !important;
  }

  body.printing-history .reports-table th {
    font-weight: 700 !important;
    background-color: #f3f4f6 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body.printing-history .table-branch-pill {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    font-weight: 700 !important;
  }

  body.printing-history .table-reporter-avatar {
    display: none !important;
  }

  body.printing-history .badge-present,
  body.printing-history .badge-absent,
  body.printing-history .table-status-pill {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    font-weight: 600 !important;
    color: #000000 !important;
  }

  body.printing-history .table-challenge-badge {
    border: 1px dashed #666666 !important;
    background: transparent !important;
    color: #000000 !important;
  }
}
