/* ===== Base / reset ===== */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f8fafc;
  color: #1e293b;
}
a {
  color: inherit;
}

/* ===== Nav bar ===== */
.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 30px;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  position: sticky;
  top: 0;
  z-index: 100;
  font-size: 70px;
  justify-content: space-between;
  align-items: center;
}
.nav .logo {
  font-weight: 800;
  font-size: 70px;
  color: #3b82f6;
  letter-spacing: 0.5px;
}
.nav div:last-child a {
  text-decoration: none;
  color: #475569;
  font-weight: 500;
  font-size: 40px;
  justify-content: space-evenly;
}
.nav div:last-child a:hover {
  color: #3b82f6;
}

/* ===== Home hero ===== */
.hero {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: white;
  padding: 70px 20px;
  text-align: center;
}
.hero-inner {
  max-width: 700px;
  margin: 0 auto;
}
.hero h1 {
  font-size: 42px;
  margin: 0 0 14px 0;
}
.hero p {
  font-size: 18px;
  opacity: 0.9;
  margin: 0 0 24px 0;
}
.cta {
  display: inline-block;
  background: white;
  color: #3b82f6;
  padding: 12px 26px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0,0,0,0.15);
}

/* ===== Stats cards (home) ===== */
.stats {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: -30px;
  padding: 0 20px;
}
.card {
  background: white;
  padding: 24px 32px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.06);
  text-align: center;
  min-width: 160px;
}
.card h2 {
  margin: 0 0 6px 0;
  color: #3b82f6;
  font-size: 30px;
}
.card p {
  margin: 0;
  color: #777;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== Content section ===== */
.content {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 60px 20px;
}
.content h2 {
  font-size: 26px;
  margin-bottom: 16px;
  color: #1e293b;
}
.description-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.04);
  margin-bottom: 30px;
  line-height: 1.6;
  color: #475569;
}

/* ===== Feature cards ===== */
.features {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 40px;
}
.feature {
  background: white;
  border-radius: 12px;
  padding: 24px;
  flex: 1 1 220px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.04);
}
.feature h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
}
.feature p {
  margin: 0;
  color: #64748b;
  font-size: 14px;
  line-height: 1.5;
}

/* ===== Preview / supplementary blocks ===== */
.preview-block,
.supplementary-block {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.04);
  margin-bottom: 30px;
}
.caption {
  color: #475569;
  line-height: 1.6;
  font-size: 14px;
  margin-bottom: 20px;
}
.chart-wrapper {
  position: relative;
  width: 100%;
  min-height: 400px;
}
.supplementary-image-wrapper {
  width: 100%;
  overflow: hidden;
  border-radius: 8px;
}
.supplementary-image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 30px 20px;
  color: #94a3b8;
  font-size: 13px;
}

/* ===== Species page overrides ===== */
.profile-header {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: white;
  padding: 60px 20px;
  text-align: center;
}
.profile-header h1 {
  font-size: 40px;
  margin: 0 0 10px 0;
  font-style: italic;
}
.profile-header p {
  font-size: 18px;
  opacity: 0.9;
  margin: 0;
}
.metrics-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin-top: -30px;
  margin-bottom: 40px;
}
.metric-card {
  background: white;
  padding: 20px 30px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  text-align: center;
}
.metric-card h2 {
  margin: 0 0 5px 0;
  color: #3b82f6;
  font-size: 28px;
}
.metric-card p {
  margin: 0;
  color: #777;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.source-tag {
  display: inline-block;
  background: #e2e8f0;
  color: #475569;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 14px;
  margin: 4px;
}
.graph-container {
  background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.04);
  margin-top: 30px;
  text-align: center;
}
.graph-container img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}
#sources {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

/* ===== Search page overrides ===== */
.search-hero {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: white;
  padding: 60px 20px;
  text-align: center;
}
.search-container {
  max-width: 700px;
  margin: -30px auto 40px auto;
  padding: 0 20px;
}
.search-box-wrapper {
  background: white;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}
.search-box-wrapper i {
  color: #94a3b8;
  font-size: 18px;
  margin-left: 10px;
}
.search-box-wrapper input {
  border: none;
  outline: none;
  width: 100%;
  font-size: 16px;
  color: #333;
}
.table-container {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 15px;
}
th {
  background-color: #f1f5f9;
  color: #475569;
  font-weight: 600;
  padding: 14px 18px;
  border-bottom: 2px solid #e2e8f0;
}
td {
  padding: 12px 18px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}
tr:hover td {
  background-color: #f8fafc;
}
table a {
  color: #3b82f6;
  text-decoration: none;
  font-weight: 500;
}
table a:hover {
  text-decoration: underline;
}
.action-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 15px;
}
.btn-download {
  background: #3b82f6;
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s ease;
}
.btn-download:hover {
  background: #2563eb;
}

/* ===== Page-routing helper ===== */
.page { display: none; }
.page.active { display: block; }
.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: #111;
  color: white;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  transform: translateY(10px);
  z-index: 9999;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.phylogeny-scroll {
  overflow-x: auto;
  white-space: nowrap;
  max-width: 100%;
  display: block;
}

/* Common_name column */
td:nth-child(5),
th:nth-child(5) {
  width: 220px;
  max-width: 220px;
}

#page-search .content {
  max-width: 3000px;
}


#myTable {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

#myTable td:first-child,
#myTable th:first-child {
  width: 200px;
  max-width: 140px;
  padding-right: 300px;
  white-space: nowrap;
}

#myTable th,
#myTable td {
  white-space: nowrap;
}

.col0-scroll {
  display: block;
  width: 100%;
  width: 300px;
  overflow-x: auto;
  white-space: nowrap;
  margin-top: 4px;
  padding: 2px 0 6px 0;
}

#myTable td.frozen-col,
#myTable th.frozen-col {
  position: sticky;
  z-index: 2;
  background: #fff; /* match your row background */
}

#myTable th.frozen-col {
  z-index: 3; /* header stays above frozen body cells */
  background: #f8fafc; /* match your existing header background */
}

#myTable td.frozen-col-last,
#myTable th.frozen-col-last {
  border-right: 1px solid #e2e8f0; /* visual seam where frozen area ends */
}

.nav div:last-child a {
  margin-left: 18px;
}


/* =====================================================
   SEARCH TABLE HORIZONTAL SCROLLING
   ===================================================== */

#page-search .content {
  width: 100%;
  max-width: 3000px;
  min-width: 0;
}

#page-search .table-container {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: scroll !important;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Force the table to be wider than the visible area */
#page-search #myTable {
  display: table;
  width: max-content !important;
  min-width: 1800px;
  table-layout: auto;
  border-collapse: collapse;
}

/* Prevent cells from wrapping */
#page-search #myTable th,
#page-search #myTable td {
  white-space: nowrap;
  min-width: 150px;
}

/* First column (Lineage) */
#page-search #myTable th:first-child,
#page-search #myTable td:first-child {
  width: 320px;
  min-width: 320px;
  max-width: none;
  padding-right: 18px;
}

/* Common_name column */
#page-search #myTable th:nth-child(5),
#page-search #myTable td:nth-child(5) {
  width: 220px;
  min-width: 220px;
}

/* Species column */
#page-search #myTable th:nth-child(2),
#page-search #myTable td:nth-child(2) {
  width: 220px;
  min-width: 220px;
}

/* TaxID column */
#page-search #myTable th:nth-child(3),
#page-search #myTable td:nth-child(3) {
  width: 130px;
  min-width: 130px;
}

/* Long values in the first column (Lineage / Notes) */
#page-search .col0-scroll {
  display: block;
  width: 300px;
  max-width: 300px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  margin-top: 4px;
  padding: 2px 0 6px 0;
}

/* Preserve frozen-column styling */
#page-search #myTable td.frozen-col,
#page-search #myTable th.frozen-col {
  position: sticky;
  z-index: 2;
  background: white;
}

#page-search #myTable th.frozen-col {
  z-index: 3;
  background: #f8fafc;
}

#page-search #myTable td.frozen-col-last,
#page-search #myTable th.frozen-col-last {
  border-right: 1px solid #e2e8f0;
}
