/* ============================================================================
   Engineering Document Stylesheet — Boiler Plant Control System
   Professional print-ready styling for weasyprint PDF generation
   ============================================================================ */

/* --- Page Setup for PDF (weasyprint) --- */
@page {
  size: letter;
  margin: 1in 0.75in 1in 0.75in;
  @bottom-left {
    content: "Boiler Plant Control System";
    font-size: 8pt;
    color: #666;
    font-family: "Helvetica Neue", Arial, sans-serif;
  }
  @bottom-center {
    content: "CONFIDENTIAL";
    font-size: 8pt;
    color: #999;
    font-family: "Helvetica Neue", Arial, sans-serif;
  }
  @bottom-right {
    content: "Page " counter(page) " of " counter(pages);
    font-size: 8pt;
    color: #666;
    font-family: "Helvetica Neue", Arial, sans-serif;
  }
}

@page :first {
  @bottom-left { content: none; }
  @bottom-center { content: none; }
  @bottom-right { content: none; }
}

@page landscape {
  size: letter landscape;
}

/* --- Base Typography --- */
* {
  box-sizing: border-box;
}

body {
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 11pt;
  line-height: 1.5;
  color: #212529;
  max-width: 8.5in;
  margin: 0 auto;
  padding: 0.5in;
  background: #fff;
}

h1, h2, h3, h4, h5, h6 {
  font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
  color: #1a1a1a;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  page-break-after: avoid;
}

h1 {
  font-size: 16pt;
  font-weight: 700;
  border-bottom: 2px solid #333;
  padding-bottom: 4px;
}

h2 {
  font-size: 13pt;
  font-weight: 600;
  border-bottom: 1px solid #999;
  padding-bottom: 3px;
}

h3 {
  font-size: 11pt;
  font-weight: 600;
}

h4 {
  font-size: 11pt;
  font-weight: 600;
  font-style: italic;
}

p {
  margin: 0.5em 0;
}

/* --- Title Block --- */
.title-block {
  margin-bottom: 2em;
  page-break-after: avoid;
}

.title-table {
  width: 100%;
  border: 2px solid #333;
  border-collapse: collapse;
}

.title-table td {
  border: 1px solid #333;
  padding: 8px 12px;
  vertical-align: middle;
}

.title-table .project-cell {
  width: 30%;
  background: #333;
  color: #fff;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 11pt;
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
}

.title-table .doc-title {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 16pt;
  font-weight: 700;
  text-align: center;
  background: #f0f0f0;
}

.title-table .meta-label {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 9pt;
  font-weight: 600;
  color: #666;
  width: 15%;
}

.title-table .meta-value {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 10pt;
}

/* --- Revision History --- */
.revision-history {
  margin-bottom: 2em;
}

.revision-history h2 {
  font-size: 11pt;
  border-bottom: none;
  margin-bottom: 0.3em;
}

/* --- Table of Contents --- */
.toc {
  margin: 1.5em 0 2em 0;
  page-break-after: always;
}

.toc h2 {
  font-size: 14pt;
  border-bottom: 2px solid #333;
}

.toc ol {
  list-style: none;
  padding-left: 0;
}

.toc > ol > li {
  margin: 0.4em 0;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 11pt;
}

.toc > ol > li > ol {
  padding-left: 1.5em;
}

.toc > ol > li > ol > li {
  margin: 0.2em 0;
  font-size: 10pt;
  color: #444;
}

.toc a {
  color: #212529;
  text-decoration: none;
}

.toc a:hover {
  text-decoration: underline;
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 10pt;
  page-break-inside: auto;
}

thead {
  display: table-header-group;
}

tr {
  page-break-inside: avoid;
}

th, td {
  border: 1px solid #555;
  padding: 5px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #e8e8e8;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-weight: 600;
  font-size: 9pt;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #333;
}

/* Alternating row colors */
tbody tr:nth-child(even) {
  background: #f8f8f8;
}

/* Compact table variant */
table.compact th,
table.compact td {
  padding: 3px 6px;
  font-size: 9pt;
}

/* Wide table for C&E matrix */
table.matrix {
  font-size: 8pt;
}

table.matrix th,
table.matrix td {
  padding: 2px 4px;
  text-align: center;
}

table.matrix th {
  font-size: 7pt;
}

table.matrix td:first-child,
table.matrix td:nth-child(2) {
  text-align: left;
}

/* --- Color Coding for Alarm Priorities --- */
.priority-critical {
  background: #fee2e2 !important;
  font-weight: 600;
}

.priority-high {
  background: #ffedd5 !important;
}

.priority-medium {
  background: #fef9c3 !important;
}

.priority-low {
  background: #dbeafe !important;
}

.priority-critical td:first-child,
.priority-high td:first-child,
.priority-medium td:first-child,
.priority-low td:first-child {
  font-weight: 600;
}

/* Status indicator dots */
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.dot-red { background: #dc2626; }
.dot-orange { background: #ea580c; }
.dot-yellow { background: #ca8a04; }
.dot-blue { background: #2563eb; }
.dot-green { background: #16a34a; }
.dot-gray { background: #6b7280; }

/* C&E matrix check marks */
.ce-x {
  font-weight: 700;
  color: #dc2626;
  font-size: 11pt;
}

.ce-check {
  font-weight: 700;
  color: #16a34a;
}

/* --- Code / Monospace --- */
code {
  font-family: "Courier New", Courier, monospace;
  font-size: 9.5pt;
  background: #f3f3f3;
  padding: 1px 4px;
  border-radius: 2px;
}

pre {
  font-family: "Courier New", Courier, monospace;
  font-size: 9pt;
  background: #f5f5f5;
  border: 1px solid #ddd;
  padding: 10px 14px;
  overflow-x: auto;
  line-height: 1.4;
  page-break-inside: avoid;
}

/* --- Lists --- */
ul, ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

li {
  margin: 0.25em 0;
}

/* --- Page Breaks --- */
.page-break {
  page-break-before: always;
}

.no-break {
  page-break-inside: avoid;
}

section {
  page-break-before: auto;
}

section > h1 {
  page-break-before: always;
}

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

/* --- Notes and Callouts --- */
.note {
  background: #f0f7ff;
  border-left: 4px solid #3b82f6;
  padding: 10px 14px;
  margin: 1em 0;
  font-size: 10pt;
}

.warning {
  background: #fff7ed;
  border-left: 4px solid #ea580c;
  padding: 10px 14px;
  margin: 1em 0;
  font-size: 10pt;
}

.danger {
  background: #fef2f2;
  border-left: 4px solid #dc2626;
  padding: 10px 14px;
  margin: 1em 0;
  font-size: 10pt;
  font-weight: 500;
}

.note strong,
.warning strong,
.danger strong {
  font-family: "Helvetica Neue", Arial, sans-serif;
}

/* --- SAT Test Checkboxes --- */
.test-step {
  margin: 0.8em 0;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 3px;
  page-break-inside: avoid;
}

.test-step .step-num {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
  font-size: 10pt;
  color: #333;
}

.checkbox {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #555;
  margin-right: 6px;
  vertical-align: middle;
  border-radius: 2px;
}

.result-field {
  display: inline-block;
  border-bottom: 1px solid #999;
  width: 120px;
  margin-left: 8px;
}

.signature-line {
  border-bottom: 1px solid #333;
  width: 250px;
  display: inline-block;
  margin: 0 10px;
}

/* --- SVG Diagrams --- */
.diagram-container {
  margin: 1.5em 0;
  text-align: center;
  page-break-inside: avoid;
}

.diagram-container svg {
  max-width: 100%;
  height: auto;
}

.diagram-caption {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 9pt;
  font-style: italic;
  color: #666;
  margin-top: 0.5em;
  text-align: center;
}

/* --- Document Footer --- */
.doc-footer {
  margin-top: 3em;
  padding-top: 1em;
  border-top: 1px solid #999;
  font-size: 9pt;
  color: #666;
  font-family: "Helvetica Neue", Arial, sans-serif;
}

/* --- Landscape Page Override --- */
.landscape-section {
  page: landscape;
}

/* --- Print Overrides --- */
@media print {
  body {
    padding: 0;
    max-width: none;
  }

  .no-print {
    display: none !important;
  }

  a {
    text-decoration: none;
    color: inherit;
  }

  .title-block {
    margin-top: 0;
  }
}

/* --- Screen-only navigation (index page) --- */
@media screen {
  .index-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1em;
    margin: 1.5em 0;
  }

  .index-card {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 1em;
    transition: box-shadow 0.2s;
  }

  .index-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  }

  .index-card h3 {
    margin-top: 0;
    font-size: 11pt;
  }

  .index-card .doc-num {
    font-family: "Courier New", monospace;
    font-size: 9pt;
    color: #666;
  }

  .index-card p {
    font-size: 10pt;
    color: #555;
  }
}

@media print {
  .index-grid {
    display: block;
  }

  .index-card {
    margin: 0.5em 0;
    padding: 0.5em 0;
    border-bottom: 1px solid #ddd;
  }
}
