/* ==========================================================================
   Training Attendance Register — A4 print.

   The register that comes out of this is a controlled HSE document: it gets
   signed on site, filed, and produced during an audit. So it is laid out like
   a form, not like a web page that happened to be printed — real margins,
   a masthead, a session block, ruled columns and a sign-off strip.

   Column sequence is the client's own (workbook sheet "A", header row 6):
     S.N | Name | Position | Iqama/Passport | Company | B.G | SSE | Mobile No | Sign
   There is no BP/Badge column, because their register has never had one.

   Row height adapts to headcount (see .ap-density-* below): a seven-person
   toolbox talk should fill the page it is printed on, not sit in a band across
   the top of it.
   ========================================================================== */

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

  html, body { background: #fff !important; }

  /* Only the register prints. */
  body > .app-shell,
  .modal-overlay, .cmdk-overlay, .sidebar-overlay, .toast-stack { display: none !important; }

  #attendancePrintView {
    display: block !important;
    font-family: 'Inter', system-ui, sans-serif;
    color: #101828;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* ------------------------------- masthead ------------------------------ */
  .ap-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 14mm;
    padding-bottom: 3mm; margin-bottom: 4mm;
    border-bottom: 1.6pt solid #16335a;
  }
  .ap-head-brand { display: flex; align-items: flex-start; gap: 4mm; }
  .ap-print-logo:empty { display: none; }
  .ap-print-logo-img { max-height: 15mm; max-width: 38mm; object-fit: contain; }
  .ap-print-org {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 12.5pt; font-weight: 800; color: #16335a; line-height: 1.15;
  }
  .ap-print-org-sub {
    font-size: 7pt; letter-spacing: .09em; text-transform: uppercase;
    color: #6b7480; margin-top: 0.6mm;
  }
  .ap-head-doc { text-align: right; }
  .ap-print-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 13pt; font-weight: 800; letter-spacing: .02em;
    text-transform: uppercase; color: #101828; line-height: 1.2;
  }
  .ap-head-ref { font-size: 8pt; color: #6b7480; margin-top: 1mm; }
  .ap-head-ref strong { color: #16335a; font-size: 9pt; }

  /* ---------------------------- session block ---------------------------- */
  .ap-meta {
    width: 100%; border-collapse: collapse; margin-bottom: 4mm;
    font-size: 8.4pt; table-layout: fixed;
  }
  .ap-meta th, .ap-meta td {
    border: 0.5pt solid #c3cbd6; padding: 1.6mm 2mm;
    text-align: left; vertical-align: middle;
  }
  .ap-meta th {
    width: 22mm; background: #eef1f6; color: #4a5464;
    font-size: 7.2pt; font-weight: 800;
    text-transform: uppercase; letter-spacing: .05em;
  }
  .ap-meta td { font-weight: 600; }

  /* ------------------------------ the roster ----------------------------- */
  .ap-print-table {
    width: 100%; border-collapse: collapse; table-layout: fixed;
    font-size: 8.6pt;
  }
  .ap-print-table thead { display: table-header-group; }   /* repeat per page */
  .ap-print-table tr { break-inside: avoid; page-break-inside: avoid; }
  .ap-print-table th, .ap-print-table td {
    border: 0.5pt solid #b9c2cd;
    padding: 1.4mm 1.8mm;
    text-align: left; vertical-align: middle;
    overflow-wrap: anywhere;
  }
  .ap-print-table th {
    background: #16335a; color: #fff;
    font-size: 7.4pt; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em;
    text-align: center;
  }
  /* Widths total 100%. Signature gets real space because somebody has to
     physically sign inside it with a pen. */
  .ap-print-table .c-sn   { width: 5%;  text-align: center; }
  .ap-print-table .c-name { width: 18%; }
  .ap-print-table .c-pos  { width: 14%; }
  .ap-print-table .c-iq   { width: 12%; }
  .ap-print-table .c-co   { width: 11%; }
  .ap-print-table .c-bg   { width: 5%;  text-align: center; }
  .ap-print-table .c-sse  { width: 5%;  text-align: center; }
  .ap-print-table .c-mob  { width: 12%; }
  /* Widest single column: somebody signs inside this box with a pen, and the
     heading must not hyphenate into "SIGNATUR / E". */
  .ap-print-table .c-sign { width: 18%; }
  .ap-print-table th.c-sign { white-space: nowrap; }

  .ap-print-table td.c-sn,
  .ap-print-table td.c-bg,
  .ap-print-table td.c-sse { text-align: center; }
  .ap-print-table td.c-name { font-weight: 600; }
  .ap-print-table td.c-iq,
  .ap-print-table td.c-mob { white-space: nowrap; word-break: normal; }

  .ap-print-table tbody tr:nth-child(even) td { background: #f6f8fa; }

  /* Row height by headcount, so a short register still fills its page and a
     long one still fits. Applied to the table by JS. */
  .ap-density-airy   tbody td { height: 16mm; }
  .ap-density-open   tbody td { height: 11mm; }
  .ap-density-normal tbody td { height: 7.5mm; }
  .ap-density-tight  tbody td { height: 5.5mm; font-size: 8pt; }

  .ap-sig-img { max-height: 9mm; max-width: 100%; display: block; }
  .ap-print-sig-svg { width: 22mm; height: 8mm; }
  .ap-not-required { font-style: italic; color: #6b7480; font-size: 7.2pt; }

  /* ------------------------------- sign-off ------------------------------ */
  .ap-signoff {
    width: 100%; border-collapse: collapse; margin-top: 8mm;
    font-size: 8pt; break-inside: avoid;
  }
  .ap-signoff td {
    width: 33.33%; padding: 0 4mm 0 0; color: #4a5464; vertical-align: bottom;
  }
  .ap-sign-line {
    display: block; margin-top: 12mm; padding-top: 1.4mm;
    border-top: 0.6pt solid #6b7480;
    font-weight: 600; color: #101828; min-height: 4mm;
  }

  .ap-foot {
    display: flex; justify-content: space-between;
    margin-top: 5mm; padding-top: 2mm;
    border-top: 0.5pt solid #c3cbd6;
    font-size: 6.8pt; color: #8a93a0;
  }
}

/* Never visible on screen — this block exists only for the printer. */
@media screen {
  #attendancePrintView { display: none; }
}
