/* Custom styles to match LaTeX/Word template */

:root {
  --header-blue: rgb(203, 216, 240);
  --text-color: #333;
  --border-color: #000;
  --link-color: #468BC5;
}

/* Use sans-serif font like Helvetica */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  background: #fff;
}

/* Document info section */
.doc-info-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--header-blue);
}

.doc-title-id {
  margin-bottom: 15px;
}

.doc-id {
  font-size: 0.9em;
  font-weight: 600;
  color: #666;
  margin-bottom: 5px;
}

.doc-title {
  font-size: 1.3em;
  font-weight: 700;
  color: var(--text-color);
}

/* Status badges styling */
.status-badges {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.status-left {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.pdf-download-btn {
  padding: 8px 16px;
  background: #28a745;
  color: white !important;
  text-decoration: none !important;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.9em;
  transition: background 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pdf-download-btn:hover {
  background: #218838;
  text-decoration: none !important;
}

.related-links {
  display: flex;
  gap: 10px;
}

.related-link {
  padding: 8px 16px;
  background: #0066cc;
  color: white !important;
  text-decoration: none !important;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.9em;
  transition: background 0.2s;
}

.related-link:hover {
  background: #0052a3;
  text-decoration: none !important;
}

/* Document header styling */
.document-header {
  margin-bottom: 30px;
}

.document-header .logo-row {
  display: none;
}

@media print {
  .document-header .logo-row {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
  }

  .document-header .logo-row .logo-left,
  .document-header .logo-row .logo-right {
    flex: 0 0 auto !important;
    width: auto !important;
  }

  .document-header .logo-row .doc-logo {
    max-width: 300px !important;
    max-height: 80px !important;
  }
}

.document-header .title-row {
  padding: 15px 0;
  text-align: right;
  font-weight: bold;
  font-size: 1.2em;
}

/* Main heading styles */
h1 {
  color: var(--text-color);
  font-size: 1.8em;
  font-weight: bold;
  margin-top: 30px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--header-blue);
  padding-bottom: 10px;
}

h2 {
  color: var(--text-color);
  font-size: 1.4em;
  font-weight: bold;
  margin-top: 25px;
  margin-bottom: 15px;
  background: var(--header-blue);
  padding: 10px 15px;
  border: 1px solid var(--border-color);
}

h3 {
  color: var(--text-color);
  font-size: 1.2em;
  font-weight: bold;
  margin-top: 20px;
  margin-bottom: 10px;
}

h4 {
  color: var(--text-color);
  font-size: 1.1em;
  font-weight: bold;
  margin-top: 15px;
  margin-bottom: 10px;
}

/* Table styling to match LaTeX template */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.95em;
}

table thead tr {
  background-color: var(--header-blue);
  font-weight: bold;
}

table th,
table td {
  border: 1px solid var(--border-color);
  padding: 12px 15px;
  text-align: left;
  vertical-align: top;
}

table tbody tr:nth-child(even) {
  background-color: #f9f9f9;
}

/* Lists styling */
ul, ol {
  margin: 10px 0 10px 10px;
  padding-inline-start: 20px;
}

li {
  margin: 5px 0;
  line-height: 1.5;
}

/* Nested lists */
ul ul, ol ul, ul ol, ol ol {
  margin: 5px 0 5px 0;
  padding-inline-start: 25px;
}

/* Lists in table cells */
table td ul,
table td ol {
  margin: 5px 0 5px 5px;
  padding-inline-start: 20px;
}

table td li {
  margin: 3px 0;
  line-height: 1.4;
}

/* Metadata table at top of document */
.metadata-table {
  /* border: 2px solid var(--border-color); */
  /* margin-bottom: 30px; */
}

.metadata-table td {
  /* padding: 10px 15px; */
}

.metadata-table .label {
  background: var(--header-blue);
  font-weight: bold;
  width: 30%;
}

/* Warning boxes for critical information */
.warning-box {
  background: #fff3cd;
  border: 2px solid #856404;
  border-left: 6px solid #856404;
  padding: 15px 20px;
  margin: 20px 0;
  border-radius: 4px;
}

.danger-box {
  background: #f8d7da;
  border: 2px solid #721c24;
  border-left: 6px solid #721c24;
  padding: 15px 20px;
  margin: 20px 0;
  border-radius: 4px;
}

.info-box {
  background: #d1ecf1;
  border: 2px solid #0c5460;
  border-left: 6px solid #0c5460;
  padding: 15px 20px;
  margin: 20px 0;
  border-radius: 4px;
}

/* Code and pre blocks */
code {
  background: #f4f4f4;
  border: 1px solid #ddd;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.9em;
}

pre {
  background: #f4f4f4;
  border: 1px solid #ddd;
  padding: 15px;
  overflow-x: auto;
  border-radius: 4px;
}

pre code {
  background: none;
  border: none;
  padding: 0;
}

/* Links */
a {
  color: var(--link-color);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Header with logos */
header {
  margin-bottom: 30px;
}

.header-logos {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border: 2px solid var(--border-color);
  border-bottom: none;
  background: #fff;
}

.logo-left,
.logo-right {
  flex: 0 0 200px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-logo {
  width: auto;
  height: auto;
  object-fit: contain;
}

.logo-left .header-logo {
  max-width: 300px;
  max-height: 60px;
}

.logo-right .header-logo {
  max-width: 300px;
  max-height: 80px;
}

.doc-logo {
  width: auto;
  height: auto;
  object-fit: contain;
}

.logo-left .doc-logo {
  max-width: 300px;
  max-height: 80px;
}

.logo-right .doc-logo {
  max-width: 300px;
  max-height: 80px;
}

.header-title {
  flex: 1;
  text-align: center;
  padding: 0 30px;
}

.header-title h1 {
  margin: 0;
  font-size: 2.5em;
  border-bottom: none;
  color: #0066cc;
  font-weight: 700;
}

.header-title .subtitle {
  margin: 5px 0 0 0;
  font-size: 1.1em;
  color: #666;
  font-style: italic;
}

/* Navigation */
nav {
  background: var(--header-blue);
  border: 2px solid var(--border-color);
  padding: 15px 20px;
  margin-bottom: 30px;
}

nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

nav ul li {
  margin: 0;
}

nav a {
  color: var(--text-color);
  font-weight: 600;
  padding: 8px 15px;
  display: inline-block;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  transition: background 0.2s;
}

nav a:hover {
  background: #f0f0f0;
  text-decoration: none;
}

nav a.active {
  background: var(--text-color);
  color: #fff;
}

/* Blockquotes */
blockquote {
  border-left: 4px solid var(--header-blue);
  padding-left: 20px;
  margin: 20px 0;
  color: #666;
  font-style: italic;
}

/* HR styling */
hr {
  border: none;
  border-top: 2px solid var(--header-blue);
  margin: 30px 0;
}

/* Footer */
footer {
  margin-top: 50px;
  padding-top: 20px;
  border-top: 2px solid var(--header-blue);
  text-align: center;
  color: #666;
  font-size: 0.9em;
}

/* Print styles */
@media print {
  body {
    max-width: 100%;
    padding: 0;
  }

  /* Hide site header with logos and navigation */
  header {
    display: none;
  }

  /* Hide footer */
  footer {
    display: none;
  }

  /* Remove link underlines and use text color */
  a {
    color: var(--text-color);
    text-decoration: none;
  }

  /* Prevent page breaks inside tables */
  table {
    page-break-inside: avoid;
  }

  /* Keep document header (with logos in document) visible */
  .document-header {
    page-break-after: avoid;
  }

  /* Ensure critical safety boxes print properly */
  .critical-safety,
  .danger-box,
  .warning-box {
    page-break-inside: avoid;
  }

  /* Remove any box shadows or colors that waste ink */
  .document-card,
  .feature-box {
    box-shadow: none;
  }
}

/* Landing page specific styles */
.hero-section {
  background: linear-gradient(135deg, #004D99 0%, #468BC5 100%);
  color: white;
  padding: 10px 10px;
  border-radius: 8px;
  margin-bottom: 40px;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.hero-section h1 {
  color: white;
  font-size: 2.8em;
  margin-bottom: 15px;
  border-bottom: none;
}

.hero-section p {
  font-size: 1.3em;
  margin: 10px 0;
  opacity: 0.95;
}

.document-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 30px;
  margin: 30px 0;
}

.document-card {
  background: #fff;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 25px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.document-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.document-card h3 {
  color: #0066cc;
  margin-top: 0;
  font-size: 1.4em;
}

.document-card .card-meta {
  font-size: 0.9em;
  color: #666;
  margin: 10px 0;
  font-style: italic;
}

.document-card p {
  line-height: 1.6;
  margin: 15px 0;
}

.cta-button {
  display: inline-block;
  background: #0066cc;
  color: white !important;
  padding: 12px 24px;
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none !important;
  transition: background 0.2s;
  margin-top: 10px;
}

.cta-button:hover {
  background: #0052a3;
  text-decoration: none !important;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin: 30px 0;
}

.feature-box {
  padding: 20px;
  border-left: 4px solid #0066cc;
  background: #f8f9fa;
  border-radius: 4px;
}

.feature-box h4 {
  margin-top: 0;
  color: #0066cc;
}

/* Responsive design */
@media (max-width: 768px) {
  body {
    padding: 10px;
    font-size: 14px;
  }

  .header-logos {
    flex-direction: column;
    padding: 15px;
  }

  .logo-left,
  .logo-right {
    flex: 0 0 auto;
    width: 100%;
    margin: 10px 0;
  }

  .logo-left .header-logo {
    max-width: 150px;
    max-height: 80px;
  }

  .logo-right .header-logo {
    max-width: 150px;
    max-height: 80px;
  }

  .logo-left .doc-logo {
    max-width: 120px;
    max-height: 60px;
  }

  .logo-right .doc-logo {
    max-width: 120px;
    max-height: 60px;
  }

  .header-title {
    padding: 20px 0;
  }

  .header-title h1 {
    font-size: 1.8em;
  }

  nav ul {
    flex-direction: column;
    gap: 10px;
  }

  .hero-section {
    padding: 40px 20px;
  }

  .hero-section h1 {
    font-size: 2em;
  }

  .document-grid,
  .feature-grid {
    grid-template-columns: 1fr;
  }

  table {
    font-size: 0.85em;
  }

  table th,
  table td {
    padding: 8px 10px;
  }
}

/* Special styling for step-by-step procedures */
.procedure-step {
  margin: 20px 0;
  padding: 15px;
  background: #f9f9f9;
  border-left: 4px solid var(--header-blue);
}

.procedure-step h3,
.procedure-step h4 {
  margin-top: 0;
  color: var(--text-color);
}

/* Emergency procedures highlighting */
.emergency-procedure {
  background: #fff3cd;
  border: 2px solid #856404;
  padding: 15px 20px;
  margin: 15px 0;
  border-radius: 4px;
}

.emergency-procedure h3,
.emergency-procedure h4 {
  color: #856404;
  margin-top: 0;
}

/* Critical safety information */
.critical-safety {
  background: #f8d7da;
  border: 3px solid #721c24;
  padding: 20px;
  margin: 20px 0;
  border-radius: 4px;
  font-weight: 600;
}

.critical-safety h3,
.critical-safety h4 {
  color: #721c24;
  margin-top: 0;
}

/* Document metadata badges */
.metadata-badge {
  display: inline-block;
  background: var(--header-blue);
  border: 1px solid var(--border-color);
  padding: 5px 12px;
  margin: 5px 5px 5px 0;
  border-radius: 4px;
  font-size: 0.9em;
  font-weight: 600;
}

/* Status indicators */
.status-approved {
  color: #155724;
  background: #d4edda;
  border-color: #c3e6cb;
}

.status-draft {
  color: #856404;
  background: #fff3cd;
  border-color: #ffeaa7;
}

.status-review {
  color: #004085;
  background: #cce5ff;
  border-color: #b8daff;
}

/* Risk Assessment specific styling to match LaTeX template */

/* Metadata table at start of RA */
.metadata-table table {
  width: 100%;
  /* border: 1px solid var(--border-color); */
  /* margin-bottom: 20px; */
}

.metadata-table table td:first-child {
  background-color: var(--header-blue);
  font-weight: bold;
  width: 40%;
}

.metadata-table table td {
  /* border: 1px solid var(--border-color); */
  /* padding: 10px 15px; */
}

/* Activity and persons table */
.activity-persons-table table {
  width: 100%;
  border: 1px solid var(--border-color);
}

.activity-persons-table table th {
  background-color: var(--header-blue);
  font-weight: bold;
  padding: 12px 15px;
  border: 1px solid var(--border-color);
}

.activity-persons-table table td {
  border: 1px solid var(--border-color);
  padding: 12px 15px;
  vertical-align: top;
}

/* Legislation and methodology boxes */
.legislation-box,
.methodology-box {
  border: 1px solid var(--border-color);
  margin: 20px 0;
  padding: 0;
}

.legislation-box > p:first-child,
.methodology-box > p:first-child {
  background-color: var(--header-blue);
  padding: 12px 15px;
  font-weight: bold;
  border-bottom: 1px solid var(--border-color);
  margin: 0;
}

.legislation-box > p:first-child strong,
.methodology-box > p:first-child strong {
  font-weight: bold;
}

.legislation-box > *:not(:first-child),
.methodology-box > *:not(:first-child) {
  padding: 0 15px;
  margin: 15px 0;
}


.legislation-box p,
.methodology-box p {
  margin: 15px 0;
}

/* Hazard assessment table */
.hazard-table-wrapper {
  margin: 20px 0;
}

.hazard-table-wrapper > p {
  margin: 0;
}

.hazard-table-wrapper table {
  width: 100%;
  border: 1px solid var(--border-color);
  font-size: 0.85em;
  table-layout: fixed;
  margin: 0;
}

.hazard-table-wrapper table th {
  background-color: var(--header-blue);
  font-weight: bold;
  padding: 10px;
  border: 1px solid var(--border-color);
  text-align: left;
  vertical-align: top;
}

.hazard-table-wrapper table td {
  border: 1px solid var(--border-color);
  padding: 10px;
  vertical-align: top;
}

.hazard-table-wrapper table tr:nth-child(even) {
  background-color: #f9f9f9;
}

/* Hazard table column widths */
.hazard-table-wrapper table th:nth-child(1),
.hazard-table-wrapper table td:nth-child(1) { width: 12%; } /* Task/scenario */

.hazard-table-wrapper table th:nth-child(2),
.hazard-table-wrapper table td:nth-child(2) { width: 12%; } /* Hazards */

.hazard-table-wrapper table th:nth-child(3),
.hazard-table-wrapper table td:nth-child(3) { width: 14%; } /* Associated harm */

.hazard-table-wrapper table th:nth-child(4),
.hazard-table-wrapper table td:nth-child(4) { width: 18%; } /* Existing controls */

.hazard-table-wrapper table th:nth-child(5),
.hazard-table-wrapper table td:nth-child(5) { width: 8%; } /* Current risk */

.hazard-table-wrapper table th:nth-child(6),
.hazard-table-wrapper table td:nth-child(6) { width: 28%; } /* Additional controls */

.hazard-table-wrapper table th:nth-child(7),
.hazard-table-wrapper table td:nth-child(7) { width: 8%; } /* Residual risk */

/* Emergency controls box */
.emergency-box {
  border: 1px solid var(--border-color);
  margin: 20px 0;
  padding: 0;
}

.emergency-box > p:first-child {
  background-color: var(--header-blue);
  padding: 12px 15px;
  font-weight: bold;
  border-bottom: 1px solid var(--border-color);
  margin: 0;
}

.emergency-box > p:first-child strong {
  font-weight: bold;
}

.emergency-box > p:nth-child(2) {
  background-color: var(--header-blue);
  padding: 8px 15px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9em;
  margin: 0;
}

.emergency-box > *:not(:first-child):not(:nth-child(2)) {
  padding: 0 15px;
  margin: 15px 0;
}

.emergency-box h3,
.emergency-box h4 {
  background: none;
  border: none;
  margin-top: 15px;
  padding: 0;
}


.emergency-box p {
  margin: 15px 0;
}

/* Review table */
.review-table table {
  width: 100%;
  border: 1px solid var(--border-color);
}

.review-table table th,
.review-table table td {
  border: 1px solid var(--border-color);
  padding: 10px 15px;
}

.review-table table td:first-child {
  background-color: var(--header-blue);
  font-weight: bold;
  width: 45%;
}

/* Page breaks for print */
.page-break {
  page-break-before: always;
}

@media print {
  /* Preserve colors when printing */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* Hide elements that shouldn't print */
  .no-print,
  .doc-info-section {
    display: none !important;
  }

  .page-break {
    page-break-before: always;
  }

  /* Keep headers with their following content */
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }

  /* Prevent page breaks inside critical sections only */
  .critical-safety,
  .danger-box,
  .warning-box {
    page-break-inside: avoid;
  }

  /* Allow tables to split across pages */
  table {
    page-break-inside: auto;
  }

  /* Avoid breaking table rows */
  tr {
    page-break-inside: avoid;
  }

  /* Optimize hazard table for printing */
  .hazard-table-wrapper table {
    font-size: 8pt;
    line-height: 1.3;
  }

  .hazard-table-wrapper table th,
  .hazard-table-wrapper table td {
    padding: 6px 8px;
  }

  .hazard-table-wrapper table th {
    font-size: 8.5pt;
  }

  /* Compact spacing for lists in tables when printing */
  table ul,
  table ol {
    margin: 3px 0 3px 5px;
    padding-inline-start: 18px;
  }

  table li {
    margin: 2px 0;
    line-height: 1.3;
  }
}
