/* Critec Portal — print / PDF stylesheet
   Loaded by every generator's preview/print view. */

@page {
  size: A4;
  margin: 18mm 16mm 22mm 16mm;
}

@media print {
  html, body {
    background: #fff !important;
    color: #0a1020 !important;
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
    font-size: 10.5pt;
    line-height: 1.45;
  }

  .no-print, .cp-header, .cp-toolbar { display: none !important; }
  .print-only { display: block !important; }

  a { color: #143a8f; text-decoration: none; }

  h1, h2, h3, h4 {
    color: #0a1020;
    font-family: 'Inter Tight', 'Inter', sans-serif;
    page-break-after: avoid;
  }

  table { page-break-inside: avoid; }
  tr, .doc-row, .doc-card { page-break-inside: avoid; }
  .page-break { page-break-after: always; }

  .doc-page {
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
  }
}

/* On-screen "paper" preview — looks like an A4 sheet inside the dark portal */
.doc-page {
  background: #fff;
  color: #0a1020;
  width: 210mm;
  min-height: 297mm;
  margin: 24px auto;
  padding: 18mm 16mm;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(0,0,0,0.2);
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  font-size: 10.5pt;
  line-height: 1.45;
}
.doc-page h1, .doc-page h2, .doc-page h3 {
  font-family: 'Inter Tight', 'Inter', sans-serif;
  color: #0a1020;
}
.doc-page h1 { font-size: 22pt; margin: 0 0 4pt 0; letter-spacing: -0.02em; }
.doc-page h2 { font-size: 14pt; margin: 18pt 0 6pt 0; }
.doc-page h3 { font-size: 11.5pt; margin: 12pt 0 4pt 0; }
.doc-page p  { margin: 0 0 6pt 0; }

.doc-meta {
  border-top: 2pt solid #1ea7ff;
  border-bottom: 1pt solid #cbd5e1;
  padding: 8pt 0;
  margin-bottom: 14pt;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4pt 18pt;
  font-size: 9.5pt;
}
.doc-meta b { color: #0a1020; }
.doc-meta span { color: #475569; }

.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 6pt 0 12pt 0;
  font-size: 9.5pt;
}
.doc-table th, .doc-table td {
  border: 0.5pt solid #94a3b8;
  padding: 5pt 7pt;
  text-align: left;
  vertical-align: top;
}
.doc-table th {
  background: #0a1f4f;
  color: #fff;
  font-weight: 600;
  font-size: 9pt;
  letter-spacing: 0.02em;
}
.doc-table tbody tr:nth-child(even) td { background: #f7f8fb; }

.doc-cat {
  display: inline-block;
  padding: 1pt 6pt;
  border-radius: 3pt;
  font-size: 8.5pt;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.doc-cat-a { background: #ef4444; color: #fff; }
.doc-cat-b { background: #f59e0b; color: #fff; }
.doc-cat-c { background: #cbd5e1; color: #0a1020; }

.doc-footer {
  margin-top: 18pt;
  padding-top: 6pt;
  border-top: 0.5pt solid #cbd5e1;
  color: #64748b;
  font-size: 8.5pt;
  display: flex; justify-content: space-between;
}

.doc-stamp {
  display: inline-block;
  padding: 2pt 8pt;
  border: 1pt solid #1ea7ff;
  color: #1ea7ff;
  font-weight: 600;
  font-size: 9pt;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 3pt;
}

/* ============ SAT-specific layout ============ */

/* Cover sheet — flexbox top/middle/bottom (no absolute positioning) */
.sat-cover {
  display: flex;
  flex-direction: column;
  min-height: 261mm; /* 297 - top/bottom margins */
}
.sat-cover .cover-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  font-size: 9pt; color: #475569;
}
.sat-cover .cover-title {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 30pt 0;
}
.sat-cover .cover-title .eyebrow {
  color: #1ea7ff; font-size: 11pt; letter-spacing: 0.18em;
  text-transform: uppercase; margin-bottom: 18pt;
}
.sat-cover .cover-title h1 {
  font-size: 30pt; line-height: 1.1; letter-spacing: -0.02em;
  margin: 0 0 10pt 0;
}
.sat-cover .cover-title .project { font-size: 14pt; color: #475569; margin-bottom: 22pt; }
.sat-cover .cover-title .docref {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10pt; color: #0a1f4f; word-break: break-all;
}
.sat-cover .cover-foot { margin-top: auto; }

/* Each new SAT section starts on a fresh page */
.sat-page {
  page-break-before: always;
  break-before: page;
}

/* Section header strip at the top of each section page */
.sat-section-head {
  border-bottom: 1.5pt solid #1ea7ff;
  padding-bottom: 6pt;
  margin-bottom: 10pt;
  display: flex; justify-content: space-between; align-items: baseline;
}
.sat-section-head h2 { margin: 0; font-size: 16pt; }
.sat-section-head .ctx { font-size: 9pt; color: #475569; font-family: 'JetBrains Mono', monospace; }

/* Procedure mini-table — keep with the device table that follows */
.sat-proc-table {
  page-break-after: avoid;
  break-after: avoid;
  margin-bottom: 8pt;
}
.sat-proc-table th { width: 60pt; }

/* Device table — fixed layout, narrower columns, wrap long names */
.sat-dev-table {
  table-layout: fixed;
  font-size: 8.5pt;
  width: 100%;
}
.sat-dev-table th, .sat-dev-table td {
  padding: 4pt 5pt;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.sat-dev-table th {
  font-size: 8pt;
  white-space: normal;
}
.sat-dev-table .col-panel  { width: 32pt; }
.sat-dev-table .col-test   { width: 50pt; }
.sat-dev-table .col-area   { width: 22pt; text-align: center; }
.sat-dev-table .col-cams   { width: 36pt; text-align: center; font-family: 'JetBrains Mono', monospace; font-size: 8pt; }
.sat-dev-table .col-fault  { width: 80pt; }
.sat-dev-table .col-result { width: 38pt; text-align: center; }

.sat-result-pass { color: #15803d; font-weight: 700; font-size: 9pt; }
.sat-result-fail { color: #b91c1c; font-weight: 700; font-size: 9pt; }
.sat-result-na   { color: #475569; font-weight: 600; font-size: 9pt; }
.sat-result-untested { color: #94a3b8; font-style: italic; font-size: 8pt; }

/* Section coverage table on the summary page */
.sat-summary-table .num { text-align: center; font-family: 'JetBrains Mono', monospace; }

/* Avoid orphaned headings */
.doc-page h2, .doc-page h3 {
  page-break-after: avoid;
  break-after: avoid;
}

/* ============ Photos appendix ============ */
.doc-photos-page { page-break-before: always; break-before: page; }

.doc-photos-grid {
  display: grid;
  gap: 8pt;
  margin-bottom: 12pt;
}

.doc-photo-card {
  page-break-inside: avoid;
  break-inside: avoid;
  border: 0.5pt solid #94a3b8;
  border-radius: 3pt;
  overflow: hidden;
  background: #fff;
}
.doc-photo-card img {
  width: 100%;
  display: block;
  max-height: 90mm;
  object-fit: contain;
  background: #f1f5f9;
}
.doc-photo-card .caption {
  padding: 4pt 6pt;
  font-size: 8.5pt;
  color: #475569;
  border-top: 0.5pt solid #cbd5e1;
  display: flex; flex-wrap: wrap; gap: 4pt 8pt;
  align-items: baseline;
}
.doc-photo-card .caption b { color: #0a1020; font-size: 9pt; }
.doc-photo-card .caption .num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 8pt; color: #94a3b8;
}
.doc-photo-card .caption div { width: 100%; color: #475569; }

/* Inline photo-count badge inside main report tables */
.doc-photo-flag {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 8pt;
  color: #007fe0;
  background: rgba(0, 127, 224, 0.08);
  padding: 1pt 5pt; border-radius: 3pt;
  border: 0.5pt solid rgba(0, 127, 224, 0.3);
}
