/*
 * Print-only stylesheet for the Smart Maintenance Task Manager handbook.
 * Applied when the print-site plugin's /print_page/ is rendered to PDF via
 * headless Chromium. Uses the SMTM brand palette from extra.css.
 *
 * Kept separate from extra.css so web-view styling stays unchanged.
 */

@media print {

  /* -----------------------------------------------------------------
     Page setup — A4, generous margins, running header & footer.
  ----------------------------------------------------------------- */
  @page {
    size: A4;
    margin: 22mm 20mm 22mm 20mm;
  }

  @page :first {
    margin: 0;
  }

  /* Running header & footer on every non-cover page. */
  @page {
    @top-left {
      content: "Smart Maintenance Task Manager — User Handbook";
      font-family: Inter, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
      font-size: 8pt;
      color: #64748b;
    }
    @bottom-center {
      content: "Page " counter(page) " of " counter(pages);
      font-family: Inter, -apple-system, sans-serif;
      font-size: 8pt;
      color: #64748b;
    }
    @bottom-right {
      content: "© Pegotec Pte. Ltd.";
      font-family: Inter, -apple-system, sans-serif;
      font-size: 8pt;
      color: #64748b;
    }
  }

  /* -----------------------------------------------------------------
     Strip the Material chrome. Only the print-site content should render.
  ----------------------------------------------------------------- */
  html, body {
    background: #fff !important;
    color: #24313f !important;
    font-family: Inter, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif !important;
    font-size: 10.5pt;
    line-height: 1.55;
  }

  .md-header,
  .md-sidebar,
  .md-footer,
  .md-search,
  .md-dialog,
  .md-announce,
  .md-source,
  .md-top,
  /* Match every mkdocs-material tab and navigation element, including any
     orphaned children left after the print-site plugin's JS strips parent
     wrappers. Catches md-tabs / md-tabs__list / md-tabs__link, md-nav /
     md-nav__list / md-nav__item / md-nav__link / md-nav__title, etc. */
  [class^="md-tabs"], [class*=" md-tabs"],
  [class^="md-nav"],  [class*=" md-nav"],
  [data-md-component="navigation"],
  [data-md-component="toc"],
  [data-md-component="announce"],
  [data-md-component="palette"] {
    display: none !important;
  }

  /* Re-enable only the print-site plugin's own TOC. Children are explicitly
     un-hidden because the global hide above blocks any md-nav-classed
     descendants that the plugin reuses inside the TOC. */
  #print-page-toc,
  #print-page-toc * {
    display: revert !important;
  }

  .md-container,
  .md-main,
  .md-main__inner,
  .md-content,
  .md-content__inner,
  article {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
  }

  .md-typeset {
    font-size: 10.5pt !important;
  }

  /* -----------------------------------------------------------------
     Typography — heading hierarchy with brand navy + cyan accent.
  ----------------------------------------------------------------- */
  h1, h2, h3, h4, h5, h6 {
    color: #1e3a5f !important;
    font-weight: 700 !important;
    page-break-after: avoid;
    break-after: avoid-page;
  }

  h1 {
    font-size: 22pt !important;
    border-bottom: 3pt solid #00b5d8 !important;
    padding-bottom: 4mm !important;
    margin-top: 8mm !important;
    margin-bottom: 6mm !important;
    page-break-before: always;
    break-before: page;
  }

  h1:first-of-type {
    page-break-before: avoid;
    break-before: avoid;
  }

  h2 {
    font-size: 15pt !important;
    border-bottom: 1pt solid #d9e1e8 !important;
    padding-bottom: 2mm !important;
    margin-top: 8mm !important;
  }

  h3 {
    font-size: 12.5pt !important;
    color: #2b4a75 !important;
  }

  a {
    color: #00b5d8 !important;
    text-decoration: none !important;
  }

  /* -----------------------------------------------------------------
     Tables — full-width, dark navy header row.
  ----------------------------------------------------------------- */
  table {
    width: 100%;
    border-collapse: collapse;
    margin: 3mm 0 5mm 0;
    font-size: 9.5pt;
    page-break-inside: avoid;
  }
  th {
    background: #1e3a5f !important;
    color: #fff !important;
    text-align: left;
    font-weight: 600;
    padding: 2.5mm 3mm !important;
    border: 1pt solid #1e3a5f !important;
  }
  td {
    padding: 2mm 3mm !important;
    border: 1pt solid #d9e1e8 !important;
    vertical-align: top;
  }
  tbody tr:nth-child(even) td {
    background: #f4f7f9 !important;
  }

  /* -----------------------------------------------------------------
     Code blocks — brand left-border accent.
  ----------------------------------------------------------------- */
  pre,
  .md-typeset pre > code,
  .highlight {
    background: #f4f7f9 !important;
    border: 1pt solid #d9e1e8 !important;
    border-left: 3pt solid #00b5d8 !important;
    padding: 3mm 4mm !important;
    border-radius: 1mm;
    page-break-inside: avoid;
    white-space: pre-wrap;
  }

  code, .md-typeset code {
    background: #f4f7f9 !important;
    border: 1pt solid #d9e1e8 !important;
    padding: 0.2mm 1mm !important;
    border-radius: 1mm;
    font-size: 9pt !important;
  }

  /* -----------------------------------------------------------------
     Admonitions — brand palette, matched to web.
  ----------------------------------------------------------------- */
  .md-typeset .admonition,
  .md-typeset details {
    page-break-inside: avoid;
    border: 1pt solid #d9e1e8 !important;
    border-left: 3pt solid #00b5d8 !important;
    background: #f4f7f9 !important;
    padding: 2mm 4mm !important;
    margin: 3mm 0 !important;
  }

  .md-typeset .admonition-title,
  .md-typeset summary {
    font-weight: 700 !important;
    color: #1e3a5f !important;
    text-transform: uppercase;
    font-size: 9pt !important;
    letter-spacing: 0.04em;
    background: transparent !important;
    padding: 0 !important;
  }

  .md-typeset .admonition.info,
  .md-typeset .admonition.example {
    border-left-color: #00b5d8 !important;
    background: #e6f8fc !important;
  }
  .md-typeset .admonition.warning {
    border-left-color: #f59e0b !important;
    background: rgba(245, 158, 11, 0.08) !important;
  }
  .md-typeset .admonition.danger {
    border-left-color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.06) !important;
  }
  .md-typeset .admonition.tip {
    border-left-color: #22c55e !important;
    background: rgba(34, 197, 94, 0.05) !important;
  }

  /* -----------------------------------------------------------------
     Images — keep them on-page where possible, framed subtly.
  ----------------------------------------------------------------- */
  img {
    max-width: 100% !important;
    height: auto !important;
    border: 1pt solid #d9e1e8;
    border-radius: 1mm;
    page-break-inside: avoid;
  }

  /* -----------------------------------------------------------------
     Print-site plugin specifics.
  ----------------------------------------------------------------- */
  .print-page { padding: 0 !important; }
  .print-page-head { page-break-after: always; }

  /* Hide anchor-link icons that Material injects next to headings. */
  .md-typeset .headerlink { display: none !important; }
}

/* -----------------------------------------------------------------
   COVER PAGE + minimal contents page — injected by generate-pdf.sh.
   Both hidden on screen, visible only when rendered to PDF.
----------------------------------------------------------------- */
.smtm-pdf-cover,
.smtm-pdf-toc {
  display: none;
}

@media print {
  .smtm-pdf-toc {
    display: block !important;
    page-break-before: always;
    page-break-after: always;
    padding: 12mm 0 0 0;
  }
  .smtm-pdf-toc h1 {
    font-size: 22pt;
    color: #1e3a5f;
    border-bottom: 3pt solid #00b5d8;
    padding-bottom: 4mm;
    margin: 0 0 8mm 0;
    page-break-before: avoid;
  }
  .smtm-pdf-toc ol {
    list-style: decimal inside;
    padding: 0;
    margin: 0 0 8mm 0;
    font-size: 13pt;
    line-height: 1.9;
  }
  .smtm-pdf-toc ol li {
    color: #1e3a5f;
    font-weight: 500;
  }
  .smtm-pdf-toc-note {
    color: #64748b;
    font-size: 9.5pt;
    margin-top: 6mm;
    line-height: 1.5;
  }
}

@media print {
  .smtm-pdf-cover {
    display: block !important;
    page: first;
    page-break-after: always;
    break-after: page;
    min-height: 297mm;
    width: 210mm;
    margin: 0 !important;
    padding: 0 !important;
    background: linear-gradient(135deg, #1e3a5f 0%, #0f2236 100%) !important;
    color: #fff !important;
    font-family: Inter, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif !important;
    position: relative;
    box-sizing: border-box;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .smtm-pdf-cover .cover-inner {
    padding: 45mm 25mm 25mm 25mm;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  .smtm-pdf-cover .cover-logo {
    width: 60mm;
    height: auto;
    margin-bottom: 8mm;
    border: 0 !important;
    filter: brightness(0) invert(1);  /* white silhouette of dark logo */
  }

  .smtm-pdf-cover .cover-title {
    color: #fff !important;
    font-size: 30pt;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin: 0 0 4mm 0;
    border: 0 !important;
    padding: 0 !important;
  }

  .smtm-pdf-cover .cover-subtitle {
    color: rgba(255, 255, 255, 0.75) !important;
    font-size: 13pt;
    font-weight: 400;
    margin: 0 0 10mm 0;
    line-height: 1.4;
  }

  .smtm-pdf-cover .cover-accent {
    width: 40mm;
    height: 4pt;
    background: #00b5d8 !important;
    margin: 2mm 0 10mm 0;
  }

  .smtm-pdf-cover .cover-meta {
    margin-top: 20mm;
    display: flex;
    flex-direction: row;
    gap: 15mm;
  }
  .smtm-pdf-cover .cover-meta-item {
    display: flex;
    flex-direction: column;
  }
  .smtm-pdf-cover .cover-meta-label {
    color: #00b5d8 !important;
    font-size: 8pt;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 1.5mm;
  }
  .smtm-pdf-cover .cover-meta-value {
    color: #fff !important;
    font-size: 11pt;
    font-weight: 500;
  }

  .smtm-pdf-cover .cover-footer {
    border-top: 1pt solid rgba(255, 255, 255, 0.25);
    padding-top: 5mm;
  }
  .smtm-pdf-cover .cover-footer p {
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 9pt;
    margin: 0;
    line-height: 1.6;
  }
  .smtm-pdf-cover .cover-footer .cover-footer-url {
    color: #00b5d8 !important;
    font-weight: 600;
  }
}
