/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@600;700&family=Inter:wght@400;500;600&display=swap');

/* Color tokens */
:root{
  --bg: #EAE9DF;
  --card: #FCF9F5;
  --text: #101519;
  --header: #202831;
  --accent: #EF9645;
}

/* Base */
body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

.container {
  width: 80%;
  max-width: 900px;
  background-color: var(--card);
  padding: 25px;
  border-radius: 10px;
  box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1);
  text-align: center;
  margin-top: 20px;
  overflow-y: auto;
  max-height: 90vh;
}

::selection {
  background-color: var(--header);
  color: var(--accent);
}

/* Progress */
.progress-container {
  width: 100%;
  background-color: #e0e0e0;
  border-radius: 10px;
  margin-bottom: 20px;
  font-family: 'DM Sans', sans-serif;
}

.progress-bar {
  height: 20px;
  background-color: var(--header);
  border-radius: 10px;
  text-align: center;
  color: var(--accent);
  font-size: 12px;
}

/* Headings and emphasis */
h1, h2, h3, .control-header, strong {
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  color: var(--header);
}

/* Groups and criteria */
.control-group {
  margin: 20px 0;
  text-align: left;
}

.control-header {
  font-size: 18px;
  margin-bottom: 10px;
}

.criteria {
  margin: 10px 0;
}

.criteria p {
  font-weight: 500;
  margin-bottom: 5px;
  font-family: 'Inter', sans-serif;
  color: var(--text);
}

.criteria select {
  padding: 8px 10px;
  border-radius: 5px;
  border: 1px solid var(--accent);
  background-color: #f7f9fc;
  color: var(--text);
  width: 100%;
  font-family: 'Inter', sans-serif;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  margin: 10px 5px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
}

.btn-primary, .btn-secondary {
  background-color: var(--accent);
  color: var(--text);
}

.btn-primary:hover, .btn-secondary:hover {
  background-color: #d97f39;
  text-decoration: none;
}

/* Final score summary container */
#final-page {
  display: none; /* Initially hidden */
  padding: 20px;
  background-color: #f7f9fc;
  border: 1px solid var(--accent);
  border-radius: 10px;
  margin-top: 20px;
  font-family: 'Inter', sans-serif;
  text-align: left;
  box-sizing: border-box;
}

/* Header for the final score summary */
#final-page h2 {
  color: var(--header);
  font-size: 24px;
  margin-bottom: 15px;
  font-weight: 600;
  page-break-after: avoid;
}

/* Page scores */
.page-score {
  font-size: 16px;
  color: #4a4a4a;
  margin-bottom: 10px;
}

/* Final score styling */
.final-score {
  font-size: 18px;
  font-weight: 600;
  color: var(--header);
  margin-top: 15px;
  margin-bottom: 15px;
  border-top: 2px solid var(--header);
  padding-top: 10px;
}

/* CMMC fully met controls styling */
.fully-met-controls {
  font-size: 18px;
  font-weight: 600;
  color: var(--header);
  margin-top: 15px;
  border-top: 2px solid var(--header);
  padding-top: 10px;
}

/* Pass/Fail banner styling */
.pass-banner {
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  border-radius: 5px;
  page-break-after: avoid;
  margin-bottom: 20px;
  color: var(--text);
}
.pass-banner.pass { background-color: #00AB4E; }
.pass-banner.fail { background-color: #DA1A32; }

/* Table styling for results */
#final-page table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  page-break-inside: avoid;
  table-layout: fixed;
  margin-top: 12px;
}

#final-page th,
#final-page td {
  border: 1px solid #000;
  background-color: #fff;
  color: var(--text);
  line-height: 1.4;
  vertical-align: top;
  padding: 8px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
}

#final-page tr {
  page-break-inside: avoid;
  page-break-after: auto;
}

#final-page th {
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  background-color: #f5f5f5;
  padding: 8px;
}

#final-page td ul {
  margin: 4px 0;
  padding-left: 16px;
  list-style-position: inside;
}

#final-page td li {
  margin: 4px 0;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  text-indent: -12px;
  padding-left: 12px;
}

/* Passed controls section */
.passed-controls {
  margin-top: 20px;
  padding: 15px;
  background-color: #f8f9fa;
  border-radius: 4px;
}
.passed-controls h3 {
  color: var(--header);
  margin-bottom: 10px;
}

.not-met-section h3 {
  margin-bottom: 15px;
  page-break-before: avoid;
}

/* Header container and logo styling (for PDF header area) */
.header-container {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 20px;
  width: 100%;
  position: relative;
}

.header-container h2 { margin: 0; }

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: flex-end;
}

.hive-logo {
  height: 60px;
  width: auto;
  object-fit: contain;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.header-container .btn { margin: 0; }

/* Column widths for regular view */
#final-page th:nth-child(1),
#final-page td:nth-child(1) { width: 100px; }
#final-page th:nth-child(2),
#final-page td:nth-child(2) { width: 60px; }
#final-page th:nth-child(3),
#final-page td:nth-child(3) { width: 35%; }
#final-page th:nth-child(4),
#final-page td:nth-child(4) { width: auto; }

/* Warning message styling */
.warning-message {
  color: #a94442;
  background-color: #f2dede;
  border: 1px solid #ebccd1;
  padding: 15px;
  margin: 15px 0;
  border-radius: 4px;
  font-family: 'Inter', sans-serif;
}

/* Print styles */
@media print {
  body * { visibility: hidden; }
  #final-page, #final-page * { visibility: visible; }

  #final-page {
    position: absolute;
    left: 0;
    top: 0;
    width: 210mm;
    height: 297mm;
    padding: 6mm;
    margin: 0;
    background: white;
    border: none;
    box-sizing: border-box;
    overflow: visible;
    border-radius: 0;
    box-shadow: none;
  }

  #final-page h2,
  .pass-banner,
  .not-met-section h3,
  .not-met-section table {
    page-break-after: avoid;
    page-break-before: avoid;
    margin-top: 2px;
    margin-bottom: 2px;
  }

  .not-met-section {
    margin: 4px 0;
    page-break-before: avoid;
    page-break-inside: avoid;
    text-align: center;
  }

  .not-met-section h3 { text-align: left; }

  .pass-banner {
    margin: 2px 0 15px 0;
    padding: 0;
    border-radius: 0;
    font-size: 11pt;
    background-color: transparent;
    border: none;
    color: #000;
    line-height: 1.2;
  }

  #final-page h2 {
    margin: 2px 0;
    font-size: 11pt;
    line-height: 1.2;
  }

  .not-met-section h3 {
    margin: 2px 0 4px 0;
    font-size: 10pt;
    line-height: 1.2;
  }

  #final-page table {
    width: 100%;
    max-width: 198mm;
    border-collapse: collapse;
    margin: 4px auto;
    page-break-inside: avoid;
    table-layout: fixed;
  }

  #final-page th,
  #final-page td {
    padding: 2px;
    font-size: 8pt;
    line-height: 1.1;
    text-align: left;
  }

  /* Column widths - important for PDF layout */
  #final-page th:nth-child(1),
  #final-page td:nth-child(1) { width: 8% !important; text-align: left; }
  #final-page th:nth-child(2),
  #final-page td:nth-child(2) { width: 60px !important; text-align: left; }
  #final-page th:nth-child(3),
  #final-page td:nth-child(3) { width: 36% !important; text-align: left; }
  #final-page th:nth-child(4),
  #final-page td:nth-child(4) { width: 54% !important; text-align: left; padding-right: 4px; }

  #final-page td ul,
  #final-page td li {
    text-align: left;
    padding-left: 8px;
  }

  h2, h3 {
    margin: 2px 0;
    page-break-after: avoid;
    font-size: 11pt;
  }

  p {
    margin: 2px 0;
    line-height: 1.2;
    font-size: 10pt;
  }

  .btn { display: none; }

  .score-definition,
  .warning-message,
  .fully-met-controls,
  .pass-fail-result,
  .pass-fail-def {
    font-size: 8pt;
    line-height: 1.1;
    margin: 4px 0;
    color: #000;
    background-color: transparent;
    border: none;
    padding: 0;
  }

  #final-page td ul {
    margin: 2px 0;
    padding-left: 8px;
    list-style-position: inside;
  }

  #final-page td li {
    margin: 2px 0;
    line-height: 1.1;
    text-indent: -8px;
    padding-left: 8px;
  }

  .header-container {
    margin-bottom: 15px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    visibility: visible;
    position: relative;
    page-break-inside: avoid;
    width: 100%;
  }

  .header-container * { visibility: visible; }

  .header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
    visibility: visible;
  }

  .hive-logo {
    height: 50px;
    width: auto;
    object-fit: contain;
    display: block;
    visibility: visible;
    position: static;
    margin-left: auto;
    float: right;
  }

  #download-pdf { display: none; }
}
