/* ==== General Reset and Typography ==== */
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  box-sizing: border-box;
  font-family: Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

/* ==== Navigation Bar ==== */
nav {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 12px 0;
  background-color: #1e1e1e;
}

nav a {
  color: white;
  text-decoration: none;
  font-weight: bold;
  display: flex;
  align-items: center;
}

nav a:hover {
  text-decoration: underline;
}

.nav-icon {
  fill: white;
  display: none;
}

@media (max-width: 1000px) {
  .nav-icon {
    display: inline-block;
    margin-right: 6px;
    vertical-align: middle;
  }
}


/* Set all text color to white for uniform dark theme */
input,
table,
th,
td,
h1,
h2,
div,
span {
  color: white;
}

#page-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(135deg, #1e1e1e, #646464, #1e1e1e);
  background-size: 300% 300%;
  animation: moveDiagonalGradient 40s ease infinite;
}

@keyframes moveDiagonalGradient {
  0% {
    background-position: 0% 0%;
  }

  50% {
    background-position: 100% 100%;
  }

  100% {
    background-position: 0% 0%;
  }
}

/* ==== Layout Containers ==== */
#initial-view,
#results-view {
  margin-top: 20px;
  padding: 0 20px;
  max-width: 100%;
  box-sizing: border-box;
}

/* Centered splash layout for initial screen */
.centered-view.expanded {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  flex: 1;
  text-align: center;
}

/* To not break the mobile layout*/
@media (min-width: 1000px) {
  .centered-view.expanded {
    display: flex;
  }
}


/* Shrunk layout after table is loaded */
.centered-view.shrunk {
  height: auto;
  align-items: flex-start;
  padding-top: 20px;
  transition: all 0.5s ease;
}

.centered-view.expanded h1 {
  font-size: 3em;
  margin-bottom: 20px;
}

.centered-view.shrunk h1 {
  font-size: 1.5em;
  margin-bottom: 10px;
}

/* ==== Search and Import Section ==== */
.search-container {
  position: relative;
  width: 100%;
  max-width: 550px;
  min-width: 420px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-wrapper {
  position: relative;
  flex: 1;
  padding: 0;
  margin: 0;
}

#search {
  width: 100%;
  margin: 0;
}

/* Search suggestions dropdown styling */
#suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  max-height: 200px;
  overflow-y: auto;
  background: #2a2a2a;
  border: 1px solid #444;
  border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  z-index: 999;
  font-size: 14px;
  opacity: 0.95;
}

.suggestion-item {
  padding: 10px 14px;
  cursor: pointer;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  transition: background-color 0.2s ease;
}

.suggestion-item:hover {
  background-color: #3a3a3a;
}

.suggestion-item:focus {
  background-color: #3a3a3a;
  outline: none;
}

.search-container button {
  transform: translateY(-5px);
}

/* Hidden by default; mobile-only action buttons for run all and score settings */
.mobile-action-buttons {
  display: none;
}

/* ==== Watchlist Table ==== */
#watchlist {
  position: relative;
  height: min(70vh, 1200px);
  /* or tweak 800px based on what looks good */
  max-height: min(70vh, 1200px);
  width: 100%;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid #1e1e1e;
  border-radius: 8px;
  box-sizing: border-box;
}

#info-btn {
  display: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  font-weight: bold;
  align-items: center;
  justify-content: center;
}

#title-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

#title-bar #info-btn {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

.info-list {
  list-style: disc;
  padding-left: 20px;
}

.info-list li {
  margin: 8px 0;
  line-height: 1.4;
}

#watchlist-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-family: Arial, sans-serif;
}



/* Sticky table headers for scrollable table */
#watchlist-table thead th {
  position: sticky;
  top: 0;
  background-color: #1e1e1e;
  padding: 8px 12px;
  text-align: center;
  user-select: none;
  z-index: 10;
}

/* Table row backgrounds and hover effect */
tbody tr {
  background-color: rgba(255, 255, 255, 0.1);
  transition: background-color 0.3s ease;
}

tbody tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.05);
}

tbody tr:hover {
  background-color: rgba(26, 26, 26, 1);
}

td {
  padding: 10px 15px;
  text-align: center;
  border-right: 1px solid rgba(255, 255, 255, 0.15);
  vertical-align: middle;
}

td:last-child {
  border-right: none;
}

/* ==== Sortable Table Headers and Labels ==== */
.th-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 28px;
  margin-left: 10px;
}

.sort-arrows {
  visibility: hidden;
  display: inline-flex;
  flex-direction: column;
  margin-left: 4px;
  font-size: 0.75em;
  line-height: 0.75em;
  gap: 2px;
  cursor: pointer;
  margin-right: 8px;
}

th:hover .sort-arrows {
  visibility: visible;
}

.sort-arrows span {
  padding: 0 1px;
  user-select: none;
}

.sort-arrows span:hover {
  color: #ccc;
}

/* ==== Country sub-label ==== */
.country-sub {
  font-size: 0.8em;
  opacity: 0.8;
}

/* ==== Buttons ==== */
button,
td button {
  background: white;
  border: 2px solid #1e1e1e;
  color: #1e1e1e;
  padding: 6px 14px;
  font-weight: 600;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  outline: none;
  box-shadow: none;
}

td button {
  padding: 4px 10px;
  font-size: 13px;
  border-radius: 4px;
}

.ai-button,
.delete-button {
  width: 60px;
  font-size: 20px;
  background: none;
  border: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.ai-button:hover:not(:disabled),
.delete-button:hover:not(:disabled),
.ai-button:disabled,
.delete-button:disabled {
  background: none;
  border: none;
  color: #aaa;
}


.ai-button svg,
.ai-button img,
.delete-button svg {
  width: 30px;
  height: 30px;
  display: block;
  margin-right: 0;
}

/* Slightly smaller settings button and matching mobile gear */
#settings-btn,
#mobile-score-btn {
  padding: 6px 20px;
  font-size: 0.85em;
  line-height: 1;
  border-radius: 6px;
  z-index: 20;
}

/* Button hover, focus, and disabled states */
button:hover:not(:disabled):not(.delete-button):not(.ai-button):not(.weight-toggle),
td button:hover:not(:disabled):not(.delete-button):not(.ai-button):not(.weight-toggle) {
  background-color: #1e1e1e;
  color: white;
  border-color: #1e1e1e;
}

button:disabled {
  color: #aaa;
  border-color: #ccc;
  cursor: not-allowed;
  background: white;
  box-shadow: none;
}

button:focus-visible {
  box-shadow: 0 0 0 3px rgba(26, 26, 26, 1);
}

/* ==== Inputs (text/number) ==== */
input[type="text"],
input[type="number"],
#search {
  background: white;
  border: 2px solid #1e1e1e;
  color: #1e1e1e;
  padding: 6px 14px;
  font-weight: 600;
  font-size: 16px;
  border-radius: 6px;
  outline: none;
  transition: all 0.3s ease;
  box-sizing: border-box;
  user-select: text;
  flex: 1 1 auto;
  min-width: 0;
  background-clip: padding-box;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
#search:focus {
  border-color: #1e1e1e;
  box-shadow: 0 0 0 3px rgba(26, 26, 26, 1);
  background: white;
  color: #1e1e1e;
}

/* ==== Modals (AI, Weight, Overlay) ==== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
}

.modal-content {
  background: #ffffff;
  color: #1e1e1e !important;
  border-radius: 12px;
  padding: 25px 30px;
  width: 90%;
  box-shadow: 0 10px 40px rgba(26, 26, 26, 1);
  position: relative;
  font-family: Arial, sans-serif;
}

#weight-modal-content {
  max-width: 400px;
  padding-bottom: 10px;
}

#ai-modal-content {
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}

#weight-header-content {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  color: #1e1e1e;
}

#weight-header-content h3 {
  margin-top: 0px;
}

#weight-modal-content label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: #1e1e1e;
}

.weight-item {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
}

.weight-item label {
  flex: 1 1 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #1e1e1e !important;
}

.weight-item .metric-name {
  color: #1e1e1e !important;
  position: relative;
}

.weight-item .metric-name::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  background: #ff0000;
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.weight-item .metric-name.deleted::after {
  transform: scaleX(1);
  transform-origin: left;
}

.weight-item .metric-name.reverse::after {
  transform-origin: right;
}

.weight-toggle {
  font-size: 20px;
  background: none;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  margin-top: -12px;
}

#weight-modal-content input[type="number"] {
  padding: 6px 10px;
  text-align: right;
  width: 90px;
  flex: 0 0 auto;
  -moz-appearance: textfield;
}

#weight-modal-content input[type="number"]::-webkit-outer-spin-button,
#weight-modal-content input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.x-icon {
  display: inline-block;
  margin-top: -1px;
  font-size: 20px;
  line-height: 1;
}

.green-plus {
  color: green;
  font-size: 40px;
  font-weight: bold;
  line-height: 1;
}


/* Modal close button (X) */
.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: transparent;
  border: none;
  font-size: 22px;
  font-weight: bold;
  color: #1e1e1e;
  cursor: pointer;
  transition: color 0.2s ease;
}

.modal-close:hover {
  color: #001f3f;
}

/* Modal scrollbars */
#ai-modal-content::-webkit-scrollbar {
  width: 8px;
}

#ai-modal-content::-webkit-scrollbar-thumb {
  background-color: #1e1e1e;
  border-radius: 4px;
}

#modal-content,
#modal-content h3,
#modal-content p {
  color: #1e1e1e !important;
}

#modal-content h3 {
  margin-top: 0;
  font-size: 1.5rem;
  font-weight: bold;
}

#modal-content p {
  font-size: 1rem;
  line-height: 1.5;
  white-space: pre-wrap;
  margin-bottom: 0;
}

/* ==== Quote Section ==== */
#quote-container {
  transition: opacity 2s ease;
  margin-top: 20px;
  min-height: 80px;
  font-style: italic;
  font-size: 1.1em;
  color: white;
  max-width: 400px;
  text-align: center;
  user-select: none;
}

/* ==== Toast Notification ==== */
#toast {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e1e1e;
  color: #ffffff;
  padding: 14px 24px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  font-family: Arial, sans-serif;
  z-index: 5000;
  transition: top 0.5s ease;
  display: flex;
  gap: 12px;
  align-items: center;
}

#toast.show {
  top: 20px;
}

#toast button {
  background: none;
  border: none;
  color: #ffffff;
  cursor: pointer;
  font-size: 1.1em;
  padding: 0 4px;
  line-height: 1;
}

/* ==== Weight Donut (in weight modal) ==== */
#weight-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-top: 24px;
}

#weight-chart-container {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

/* Buttons next to donut chart */
#weight-buttons {
  display: flex;
  flex-direction: row;
  gap: 10px;
}

#weight-chart {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-left: -13px;
}

.weight-label {
  font-size: 1em;
  color: #1e1e1e;
  font-weight: bold;
  line-height: 1;
  padding-bottom: 10px;
}

#weight-chart svg {
  width: 80px;
  height: 80px;
  display: block;
}

/* Donut segments: background and progress */
#weight-chart circle {
  fill: none;
  stroke-width: 10;
}

#weight-chart circle.bg {
  stroke: #e0e0e0;
}

#weight-chart circle.progress {
  stroke: #000;
  stroke-dasharray: 157;
  /* 2 * pi * r for r=25 */
  stroke-dashoffset: 157;
  transition: stroke-dashoffset 0.4s ease;
}

#weight-chart circle.progress.green {
  stroke: #28a745;
}

#weight-chart circle.progress.red {
  stroke: red;
}

#weight-chart circle.progress.black {
  stroke: #000;
}

/* Donut center text */
#weight-chart text {
  font-size: 18px;
  fill: #1e1e1e;
  dominant-baseline: middle;
  text-anchor: middle;
}

#weight-chart text.green {
  fill: #28a745;
}

#weight-chart text.red {
  fill: red;
}

#weight-chart text.black {
  fill: #000;
}

/* Small donut used for score column */
.score-donut {
  display: flex;
  justify-content: center;
  align-items: center;
}

.score-donut svg {
  width: 40px;
  height: 40px;
  display: block;
}

.score-donut circle {
  fill: none;
  stroke-width: 6;
}

.score-donut circle.bg {
  stroke: #e0e0e0;
}

.score-donut circle.progress {
  stroke: #000;
  stroke-dasharray: 113;
  stroke-dashoffset: 113;
  transition: stroke-dashoffset 0.4s ease;
}

.score-donut text {
  font-size: 12px;
  fill: #1e1e1e;
  dominant-baseline: middle;
  text-anchor: middle;
}
/* ==== Mobile Layout Adjustments ==== */
@media (max-width: 600px) {

  html,
  body {
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }


  header {
    flex: 0 0 auto;
  }


  nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #1e1e1e;
    border-top: 1px solid #444;
    justify-content: space-around;
    padding: 12px 0;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    gap: 0;
  }

  nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 12px;
    flex: 1;
  }

  #initial-view,
  #results-view {
    padding: 0 10px;
  }

  .search-container {
    flex-direction: row;
    align-items: center;
    min-width: 0;
  }

  .search-container button {
    transform: none;
  }

  .mobile-action-buttons {
    /* hidden by default; revealed via showResults() */
    gap: 10px;
    margin-left: auto;
  }

  .mobile-action-buttons button {
    padding: 10px 14px;
  }

  #import-btn,
  #export-btn {
    display: none !important;
  }

  #watchlist {
    height: 450px;
  }


  #watchlist-table {
    height: auto;
    padding-bottom: 0;
  }

  #watchlist-table thead {
    display: none;
  }

  #watchlist-table tr {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(5, auto);
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 8px;
    height: 300px;
    box-sizing: border-box;
  }

  #watchlist-table td {
    display: block;
    text-align: left;
    border: none;
    padding: 4px 6px;
  }

  #watchlist-table td[data-label] {
    padding-top: 12px;
  }

  #watchlist-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 10px;
    opacity: 0.7;
    margin-bottom: 2px;
  }


  /* Custom layout for each cell */
  #watchlist-table td:nth-child(1) {
    grid-row: 1;
    grid-column: 1;
  }

  #watchlist-table td:nth-child(6) {
    grid-row: 1;
    grid-column: 2;
  }

  #watchlist-table td:nth-child(2) {
    grid-row: 2;
    grid-column: 1;
  }

  #watchlist-table td:nth-child(7) {
    grid-row: 2;
    grid-column: 2;
  }

  #watchlist-table td:nth-child(12) {
    grid-row: 2;
    grid-column: 3;
  }

  #watchlist-table td:nth-child(3) {
    grid-row: 3;
    grid-column: 1;
  }

  #watchlist-table td:nth-child(8) {
    grid-row: 3;
    grid-column: 2;
  }

  #watchlist-table td:nth-child(13) {
    grid-row: 3;
    grid-column: 3;
  }

  #watchlist-table td:nth-child(4) {
    grid-row: 4;
    grid-column: 1;
  }

  #watchlist-table td:nth-child(10) {
    grid-row: 4;
    grid-column: 2;
  }

  #watchlist-table td:nth-child(14) {
    grid-row: 4;
    grid-column: 3;
  }

  #watchlist-table td:nth-child(5) {
    grid-row: 5;
    grid-column: 1;
  }

  #watchlist-table td:nth-child(11) {
    grid-row: 5;
    grid-column: 2;
  }


  #watchlist-table td:nth-child(9) {
    display: none;
  }

  #watchlist-table tr {
    position: relative;
  }

  #watchlist-table td.delete-cell {
    position: absolute;
    top: 4px;
    right: 4px;
    grid-row: auto;
    grid-column: auto;
  }

  #watchlist-table td.col-score,
  #watchlist-table td.ai-cell {
    display: flex;
    justify-content: center;
  }

  #watchlist-table td.col-score {
    flex-direction: column;
    align-items: center;
  }

  #watchlist-table td.col-score::before {
    text-align: center;
    width: 100%;
  }

  #watchlist-table td.ai-cell {
    margin-top: 16px;
  }

  #watchlist-table th,
  #watchlist-table td {
    padding: 4px 6px;
    font-size: 12px;
  }
}


/* ==== About Page ==== */
.about-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px;
}

body.about-page #page-background {
  position: absolute;
  width: 100vw;
  min-height: 100vh;
  height: auto;
}

.photo-row {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 32px;
  /* space between photos */
  margin-bottom: 32px;
}

#skiing-photo {
  width: 480px;
  height: 360px;
}

#profile-photo {
  width: 385px;
  height: 504px;
}

#fishing-photo {
  width: 385px;
  height: 504px;
}

.about-container p {
  max-width: 600px;
  text-align: center;
  margin-bottom: 40px;
}

.resume-viewer {
  width: 100vw;
  min-width: 100vw;
  margin: 0;
  padding: 0;
  max-width: none;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.resume-viewer iframe {
  width: 50vw !important;
  min-width: 50vw !important;
  height: 1200px !important;
  min-height: 1200px !important;
  display: block;
  border: none;
  background: #fff;
}



/* ==== Tools Page ==== */
#tools-container {
  display: flex;
  justify-content: center;
  padding: 40px;
}

.tools-column {
  flex: 1;
  padding: 0 20px;
}

.tools-column+.tools-column {
  border-left: 2px solid #fff;
}

.tools-column h2 {
  text-align: center;
  margin-bottom: 20px;
}

.photo-row {
  flex-direction: column;
}

#skiing-photo,
#profile-photo,
#fishing-photo {
  width: 90vw;
  height: auto;
}

.resume-viewer iframe {
  width: 90vw !important;
  min-width: 90vw !important;
  height: 600px !important;
  min-height: 600px !important;
}

.about-container {
  padding-bottom: 100px;
}

#tools-container {
  flex-direction: column;
  padding: 20px;
  padding-bottom: 100px;
}

.tools-column+.tools-column {
  border-left: none;
  border-top: 2px solid #fff;
  margin-top: 20px;
}