/* Self-hosted IBM Plex Sans (variable font, weights 100-700) */
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

:root {
  --txdot-blue: #00338d;
  --txdot-blue-dark: #002060;
  --txdot-red: #da291c;
  --bg-color: #f4f7fa;
  --card-bg: #ffffff;
  --text-main: #333333;
  --text-muted: #666666;
  --border-color: #e0e0e0;
  --success-color: #28a745;
  --warning-color: #ffc107;
  --error-color: #dc3545;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --font-family: "IBM Plex Sans", sans-serif;
  --drop-zone-bg: #f8f9fa;
  --drop-zone-border: #cbd5e0;
  --table-header-bg: #f8f9fa;
  --table-hover-bg: #fafbfc;
}

[data-theme="dark"] {
  --bg-color: #121212;
  --card-bg: #1e1e1e;
  --text-main: #e0e0e0;
  --text-muted: #a0a0a0;
  --border-color: #333333;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.8);
  --drop-zone-bg: #2d2d2d;
  --drop-zone-border: #444444;
  --table-header-bg: #2d2d2d;
  --table-hover-bg: #252525;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  margin: 0;
  padding: 10px;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* Footer / Security Notice */
footer {
  margin-top: 30px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0.8;
}

footer svg {
  width: 16px;
  height: 16px;
  fill: var(--success-color);
}

.version-tag {
  position: fixed;
  bottom: 10px;
  right: 15px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
  font-family: var(--font-family);
  pointer-events: none;
}

@media print {
  .version-tag {
    display: none;
  }
}

/* Main Container */
.container {
  background-color: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 1200px;
  padding: 12px 15px;
  overflow: hidden;
  position: relative;
}

/* Header */
header {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 6px;
}

header img {
  height: 40px;
  margin-right: 15px;
}

header h1 {
  font-size: 20px;
  color: var(--txdot-blue);
  margin: 0;
  font-weight: 600;
}

/* Segmented Control / Tabs */
.tab-nav {
  display: flex;
  justify-content: center;
  background-color: #e9ecef;
  padding: 3px;
  border-radius: var(--radius-md);
  width: fit-content;
  margin: 0 auto 10px auto;
}

.tab-btn {
  background: none;
  border: none;
  padding: 5px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tab-btn.active {
  background-color: var(--card-bg);
  color: var(--txdot-blue);
  box-shadow: var(--shadow-sm);
}

.tab-btn:hover:not(.active) {
  color: var(--txdot-blue);
}

/* Search & Controls */
.controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 15px;
}

.search-flex-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  max-width: 500px;
}

.search-container {
  position: relative;
  flex: 1;
}

.search-input {
  width: 100%;
  padding: 8px 15px 8px 35px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 13px;
  transition: all 0.2s;
  outline: none;
}

.search-input:focus {
  border-color: var(--txdot-blue);
  box-shadow: 0 0 0 3px rgba(0, 84, 164, 0.1);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-btn {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-btn:hover {
  background: var(--table-hover-bg);
  border-color: var(--txdot-blue);
  color: var(--txdot-blue);
  box-shadow: var(--shadow-sm);
}

.btn-search {
  background: var(--txdot-blue);
  color: white;
  border-color: var(--txdot-blue);
}

.btn-search:hover {
  background: var(--txdot-blue-dark);
  color: white;
}

.table-container {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
}

/* Print Section */
.print-only {
  display: none;
}

@media print {
  @page {
    size: portrait;
    margin: 1.5cm;
  }
  body {
    background: white !important;
    color: black !important;
    font-family:
      "Segoe UI", Tahoma, Geneva, Verdana, sans-serif !important;
    font-size: 11pt !important;
  }
  .container {
    box-shadow: none !important;
    border: none !important;
    width: 100% !important;
    max-width: none !important;
    padding: 0 !important;
    background: white !important;
  }
  header {
    padding-bottom: 20px !important;
    margin-bottom: 30px !important;
    border-bottom: 3px solid var(--txdot-blue) !important;
  }
  header h1::after {
    content: " - Verification Audit Report";
    font-size: 14pt;
    color: #666;
    font-weight: 400;
    margin-left: 10px;
  }
  .tab-nav,
  .help-btn,
  .instructions,
  .drop-zone,
  .controls-row,
  footer,
  .progress-bar,
  button,
  .toggle-btn {
    display: none !important;
  }
  .view-section {
    display: none !important;
  }
  .view-section.active {
    display: block !important;
  }
  .metric-dashboard {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 0 !important;
    margin-bottom: 40px !important;
    border: 1px solid #ddd !important;
    border-radius: 0 !important;
  }
  .metric-card {
    box-shadow: none !important;
    border: none !important;
    border-right: 1px solid #eee !important;
    padding: 10px !important;
  }
  .metric-card:last-child {
    border-right: none !important;
  }
  .metric-value {
    font-size: 22pt !important;
    color: #333 !important;
  }
  .table-container {
    overflow: visible !important;
    border: 1px solid #ccc !important;
  }
  table {
    width: 100% !important;
    border-collapse: collapse !important;
    page-break-inside: auto;
  }
  th,
  td {
    border: 1px solid #eee !important;
    padding: 8px !important;
    font-size: 9pt !important;
  }
  th {
    background-color: #f1f1f1 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    color: #333 !important;
  }
  .badge {
    border: 1px solid #ccc !important;
    background: transparent !important;
    color: black !important;
    font-size: 8pt !important;
    padding: 1px 4px !important;
  }
  .hash-code {
    font-size: 8pt !important;
    color: #444 !important;
    word-break: break-all !important;
  }
  .print-only {
    display: block !important;
  }
  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }
  .no-print {
    display: none !important;
  }
}

/* Views */
.view-section {
  display: none;
  animation: fadeIn 0.4s ease-out;
}
.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.instructions {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-size: 14px;
}

/* Grouping Row Styles */
.group-row-hidden {
  display: none !important;
}

.hidden-by-search {
  display: none !important;
}

.toggle-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: #64748b;
  font-weight: bold;
  margin-right: 4px;
  transition: all 0.2s;
  font-size: 16px;
  user-select: none;
}

.toggle-btn:hover {
  background: #f1f5f9;
  color: var(--txdot-blue);
}

.toggle-btn.expanded {
  color: var(--txdot-blue);
  transform: rotate(90deg);
}

/* Metric Dashboard */
.metric-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 5px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: transform 0.2s;
  box-shadow: var(--shadow-sm);
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--txdot-blue);
  margin-bottom: 2px;
}

.metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.metric-card.error .metric-value {
  color: var(--error-color);
}
.metric-card.success .metric-value {
  color: var(--success-color);
}
.metric-card.warning .metric-value {
  color: var(--warning-color);
}

/* Drop Zones */
.drop-zone {
  border: 2px dashed var(--drop-zone-border);
  border-radius: var(--radius-lg);
  padding: 12px;
  text-align: center;
  background-color: var(--drop-zone-bg);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 10px;
  cursor: pointer;
}

.drop-zone:hover {
  border-color: var(--txdot-blue);
  background-color: var(--table-hover-bg);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.drop-zone:active {
  transform: translateY(0);
}

.drop-zone svg {
  transition: transform 0.3s ease;
}

.drop-zone:hover svg {
  transform: scale(1.1);
  color: var(--txdot-blue);
}

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  background-color: var(--table-header-bg);
  padding: 6px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}
td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  color: var(--text-main);
}

tr:hover td {
  background-color: var(--table-hover-bg);
}

.hash-code {
  font-family: "Courier New", monospace;
  font-size: 13px;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.2s;
  border: 1px solid transparent;
  padding: 2px 6px;
  border-radius: 4px;
}

.hash-code:hover {
  color: var(--txdot-blue);
  background-color: var(--table-hover-bg);
  border-color: var(--txdot-blue);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.hash-code::after {
  content: "📋";
  opacity: 0;
  transition: opacity 0.2s;
  font-size: 12px;
}

.hash-code:hover::after {
  opacity: 1;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  text-transform: uppercase;
}

.badge-pass {
  background-color: #d1e7dd;
  color: #0f5132;
}
.badge-fail {
  background-color: #f8d7da;
  color: #842029;
}
.badge-warn {
  background-color: #fff3cd;
  color: #664d03;
}
.badge-info {
  background-color: #cff4fc;
  color: #055160;
}
.badge-none {
  background-color: #e2e3e5;
  color: #41464b;
}

/* Help Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.3s;
  border: none;
  padding: 0;
  cursor: pointer;
  outline: none;
}

.modal-content {
  cursor: default;
  background-color: var(--card-bg);
  padding: 0;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: scaleIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes scaleIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-header {
  padding: 20px 30px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--drop-zone-bg);
}

.modal-header h2 {
  margin: 0;
  font-size: 24px;
  color: var(--txdot-blue);
}

.modal-body {
  padding: 30px;
  overflow-y: auto;
  line-height: 1.6;
}

.help-tabs {
  display: flex;
  border-bottom: 2px solid #e0e0e0;
  margin-bottom: 20px;
}

.help-tab {
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s;
}

.help-tab.active {
  color: var(--txdot-blue);
  border-bottom-color: var(--txdot-blue);
}

.help-section {
  display: none;
}
.help-section.active {
  display: block;
}

.faq-item {
  margin-bottom: 20px;
}
.faq-question {
  font-weight: 700;
  color: var(--txdot-blue);
  margin-bottom: 5px;
}

.help-btn {
  background: none;
  border: 2px solid var(--txdot-blue);
  color: var(--txdot-blue);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-weight: bold;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  transition: all 0.2s;
}

.help-btn:hover {
  background-color: var(--txdot-blue);
  color: white;
}

/* Wizard / Tour Overlay */
.wizard-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3000;
  display: none;
  pointer-events: none; /* Let clicks pass through, effectively handled by spotlight logic */
}

.wizard-spotlight {
  position: absolute;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.75);
  border-radius: 4px;
  pointer-events: none;
  transition: all 0.4s ease;
  z-index: 3001;
}

.wizard-tooltip {
  position: absolute;
  background: white;
  width: 300px;
  padding: 20px;
  border-radius: var(--radius-md);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  z-index: 3002;
  transition: all 0.4s ease;
}

.wizard-tooltip h3 {
  margin-top: 0;
  color: var(--txdot-blue);
  font-size: 18px;
}

.wizard-tooltip p {
  font-size: 14px;
  line-height: 1.5;
  color: #555;
  margin-bottom: 20px;
}

.wizard-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.wizard-btn {
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  font-size: 13px;
  border: none;
}

.wizard-skip {
  background: none;
  color: #777;
}

.wizard-next {
  background-color: var(--txdot-blue);
  color: white;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  min-width: 300px;
  padding: 15px 20px;
  border-radius: var(--radius-md);
  background: white;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
  border-left: 5px solid #333;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideIn 0.3s ease-out;
  font-size: 14px;
}

.toast.success {
  border-left-color: var(--success-color);
}
.toast.error {
  border-left-color: var(--error-color);
}
.toast.info {
  border-left-color: var(--txdot-blue);
}

.toast-close {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* SVG Icons */
.icon-svg {
  width: 50px;
  height: 50px;
  fill: var(--txdot-blue);
  margin-bottom: 10px;
}

/* Terms of Use Overlay */
/* Native <dialog>: hidden until showModal(); the element is a transparent
   full-viewport container and the opaque cover lives on ::backdrop */
#terms-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  background: transparent;
  overflow-y: auto;
  padding: 40px 16px;
}

#terms-overlay[open] {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

#terms-overlay::backdrop {
  background-color: #f4f7fa; /* fallback: light --bg-color */
  background-color: var(--bg-color);
}

#terms-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  max-width: 680px;
  width: 100%;
  overflow: hidden;
  margin: auto 0;
}

#terms-card .terms-header {
  background-color: var(--txdot-blue);
  color: #ffffff;
  padding: 28px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
}

#terms-card .terms-header img {
  height: 48px;
}

#terms-card .terms-header h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
  color: #ffffff;
}

#terms-card .terms-body {
  padding: 32px;
}

#terms-card .terms-body p {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-main);
  margin: 0 0 16px 0;
}

#terms-card .terms-body p:last-of-type {
  margin-bottom: 0;
}

#terms-card .terms-footer {
  padding: 20px 32px 32px;
  display: flex;
  justify-content: center;
  border-top: 1px solid var(--border-color);
}

#terms-accept-btn {
  background-color: var(--txdot-blue);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 32px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: background-color 0.2s;
}

#terms-accept-btn:hover {
  background-color: var(--txdot-blue-dark);
}

#terms-accept-btn:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 2px;
}

/* ==========================================
   Formerly-inline styles (CSP: style-src 'self')
   ========================================== */
.header-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}
.help-hr {
  border: 0;
  border-top: 1px solid #eee;
  margin: 15px 0;
}
.modal-close-x {
  font-size: 28px;
}
.cell-error {
  color: var(--error-color);
}
.hash-code-btn {
  all: unset;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
}

#tour-callout {
  background: #f0f7ff;
  padding: 15px;
  border-radius: 8px;
  border-left: 4px solid var(--txdot-blue);
  margin-bottom: 20px;
  display: none;
  align-items: center;
  justify-content: space-between;
}
#tour-callout .callout-title {
  margin: 0;
  font-weight: bold;
  color: var(--txdot-blue);
}
#tour-callout .callout-sub {
  margin: 0;
  font-size: 13px;
  color: #555;
}

#wizard-spotlight,
#wizard-tooltip {
  display: none;
}

/* Print report layout */
.print-report {
  margin-top: 50px;
}
.print-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}
.print-h {
  margin-bottom: 10px;
  color: #333;
}
.print-meta-line {
  font-size: 10pt;
  color: #666;
  margin: 4px 0;
}
.print-right {
  text-align: right;
}
.print-attest {
  font-size: 9pt;
  color: #777;
  font-style: italic;
}
.print-sign-row {
  display: flex;
  justify-content: space-between;
  gap: 50px;
}
.print-sign-box {
  flex: 1;
}
.print-sign-line {
  border-bottom: 1px solid #333;
  height: 40px;
  margin-bottom: 5px;
}
.print-sign-label {
  font-size: 9pt;
  font-weight: bold;
  color: #333;
}
