:root {
  ---header-bg-color: #007bff;
  --header-bg-color: #9015e0;
  --header-text-color: #ffffff;
  --body-bg-color: #f4f4f4;
  ---tab-active-bg-color: #0056b3;
  --tab-active-bg-color: #4d0c75;
  ---button-bg-color: #007bff;
  --button-bg-color: #9015e0;
  --button-text-color: #ffffff;
  ---button-hover-bg-color: #0056b3;
  --button-hover-bg-color: #4d0c75;
  ---loading-spinner-color: #007bff;
  --loading-spinner-color: #9015e0;
  --table-bg-color: #ffffff;
  --table-border-color: #dddddd;
  --table-stripe-color: #f2f2f2;
  --modal-bg-color: #ffffff;
  ---info-link-color: #2979ff;
  --info-link-color: #9015e0;
  --text-color: #000000;
  --select-bg-color: #ffffff;
  --select-text-color: #000000;
  --select-border-color: #cccccc;
  --prediction-section-header-color: rgba(137, 168, 255, 0.9);
  ---link-color: #007bff;
  --link-color: #9015e0;
}

@media (prefers-color-scheme: dark) {
  :root {
    ---header-bg-color: #1a73e8; /* Slightly softer blue for dark mode */
    --header-bg-color: #9015e0;
    --header-text-color: #ffffff; /* White remains for readability */
    --body-bg-color: #222222; /* Dark background for dark mode */
    ---tab-active-bg-color: #0d47a1; /* Darker blue for active tabs */
    ----tab-active-bg-color: #6315e0;
    --tab-active-bg-color: #4d0c75;
    ---button-bg-color: #1a73e8; /* Matching header color */
    --button-bg-color: #9015e0;
    --button-text-color: #ffffff; /* White text for buttons */
    ---button-hover-bg-color: #0d47a1; /* Darker blue for button hover */
    --button-hover-bg-color: #4d0c75;
    ---loading-spinner-color: #1a73e8; /* Matching header color */
    --loading-spinner-color: #9015e0;
    --table-bg-color: #1e1e1e; /* Dark background for tables */
    --table-border-color: #333333; /* Darker border for tables */
    --table-stripe-color: #2a2a2a; /* Slightly lighter stripe for tables */
    --modal-bg-color: #1e1e1e; /* Dark background for modals */
    ---info-link-color: #82b1ff; /* Brighter blue for links in dark mode */
    --info-link-color: #9015e0;
    --text-color: #ffffff; /* White text for dark mode */
    --select-bg-color: #333333; /* Dark background for select elements */
    --select-text-color: #ffffff; /* White text for select elements */
    --select-border-color: #555555; /* Darker border for select elements */
  }
}

html {
  box-sizing: border-box;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

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

input,
button,
select {
  font-family: inherit;
  font-size: inherit;
}

body {
  margin: 0;
  font-family: Helvetica Neue, Roboto, sans-serif;
  color: var(--text-color);
  background-color: var(--body-bg-color);
  font-weight: 200;
}

.header-container {
  position: sticky;
  top: 0;
  background-color: var(--header-bg-color);
  color: #fff;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
}

header h1, header h2 {
  margin: 0;
  font-weight: light;
}

#header-initials-circle {
  border-radius: 50%;
  background-color: var(--tab-active-bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: medium;
  font-weight: normal;
  text-transform: uppercase;
  padding: 13px;
  cursor: pointer;
  min-width: 1px;
  min-height: 1px;
  aspect-ratio: 1 / 1;
}

.header-icon {
  width: 40px;
  height: 40px;
  margin-right: 10px;
}

h1 {
  margin: 0; 
}

nav {
  display: flex;
  justify-content: space-around;
}

.tab {
  flex: 1;
  padding: 10px;
  cursor: pointer;
  text-align: center;
  font-weight: 300;
}

.tab.active {
  border-bottom: 5px solid var(--tab-active-bg-color);
  font-weight: 800;
  font-size: larger;
}

#main-container {
  padding-bottom: 100px;
  overflow-y: auto;
  overflow-x: auto;
}

.section {
  padding: 20px;
  overflow: auto;
}

#auth-container {
  padding: 20px;
}

button {
  background-color: var(--button-bg-color);
  color: #fff;
  border: none;
  padding: 10px 20px;
  cursor: pointer;
  border-radius: 5px;
  margin-top: 10px;
}

button:hover {
  background-color: var(--button-hover-bg-color);
}

input {
  width: 100%;
  padding: 10px;
  margin: 10px 0;
  border-radius: 5px;
  border: 1px solid #ccc;
}

select {
  padding: 5px;
  border-radius: 5px;
  margin: 5px;
  width: 100%;
  background-color: var(--select-bg-color);
  color: var(--select-text-color);
  border: 1px solid var(--select-border-color);
}

select:disabled {
  opacity: 0.3;
}

.hidden {
  display: none !important;
}

.calendar-card {
  margin-bottom: 20px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 0px;
}

.calendar-card span {
  display: block;
  font-size: small;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: smaller;
}

.result-table th,
.result-table td {
  border: 1px solid #ddd;
  padding: 8px;
}

.result-table th {
  background-color: #f2f2f2;
  text-align: left;
}

#race-details span {
  display: block;
  font-size: small;
}

#race-details {
  margin-bottom: 20px;
  margin-left: 30px;
  margin-right: 30px;
  padding: 5px;
  border: 1px dashed #cccccc;
  text-align: center;
  border-radius: 5px;
}

#race-location {
  font-size: x-large;
  font-weight: bold;
}

#race-location-container {
  margin-bottom: 20px;
}

#loading-spinner,
#admin-loading-spinner {
  margin-top: 10px;
  color: var(--loading-spinner-color);
}

.loader {
  margin-top: 10px;
  border: 4px solid #f3f3f3;
  border-radius: 50%;
  /* border-top: 4px solid #3498db; */
  border-top: 4px solid var(--loading-spinner-color);
  width: 30px;
  height: 30px;
  -webkit-animation: spin 0.5s linear infinite; /* Safari */
  animation: spin 0.5s linear infinite;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black */
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1rem;
  border-bottom: 1px solid #dee2e6;
  font-size: x-large;
  font-weight: bold;
}

.modal-body {
  padding: 1rem 1rem;
}

.modal-content {
  background-color: white;
  border-radius: 5px;
  box-shadow: 0 0px 20px 10px rgba(0, 0, 0, 0.4);
  z-index: 1001;
  max-width: 500px;
  width: 90%;
  color: #000000;
  position: relative;
}

.modal-close {
  cursor: pointer;
  font-size: xx-large;
  font-weight: normal;
  color: #888;
}

#point-system-modal .modal-body {
  font-size: x-small;
  font-weight: normal;
}

#score-detail-table {
  width: 100%;
  border-collapse: collapse;
}

#score-detail-table th,
#score-detail-table td {
  text-align: left;
}

#score-detail-table tr {
  border-bottom: 1px solid rgba(137, 168, 255, .4);
}

#score-detail-modal-result-container {
  font-size: large;
  font-weight: bold;
  margin-top: 20px;
}

#scores-table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--table-bg-color);
}

#scores-table>thead {
  font-weight: bold;
}

#scores-table th,
#scores-table td {
  text-align: left;
  border: 1px solid var(--table-border-color);
  padding: 8px;
}

#scores-table>tbody th {
  font-weight: normal;
}

#scores-table > :not(:first-child) {
  border-top: 2px solid currentColor;
}

#scores-table > tbody > tr:nth-child(odd) {
  background-color: var(--table-stripe-color);
}

#scores-table > tbody > tr:nth-child(even) {
  background-color: var(--table-bg-color);
}

#error-modal-content,
#error-modal-content .modal-close {
  background-color: #cc3300;
  color: white;
}

#success-modal-content,
#success-modal-content .modal-close {
  background-color: #99cc33;
  color: black;
}

#auth-header h3 {
  margin: 10px;
}

#auth-header span {
  font-size: small;
}

.small-text {
  font-size: 0.7em;
}

.form-select {
  font-size: 0.8em;
}

.medium-text {
  font-size: 0.8em;
}

.legend {
  float: none;
  width: auto;
  margin: 0em;
  font-size: 0.9em;
  padding-left: 0.35em;
  padding-right: 0.35em;
  /* color: rgba(0,0,0, .55); */
  color: rgba(137, 168, 255, 0.9);
}

.prediction-table {
  width: 100%;
}

.prediction-table-row-title {
  width: 25%;
}

.prediction-table-row-selection {
  width: 50%;
  padding-right: 1em;
}

.prediction-table-row-result {
  max-width: 0;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.green {
  color: green;
}

.red {
  color: red;
}

.info-link {
  border: none;
  background: none;
  color: var(--info-link-color);
  text-decoration: none;
  cursor: pointer;
}

.info-link:hover {
  border: none;
  background: none;
}

.scores-table-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-border-bottom {
  border-bottom: 1px solid rgba(137, 168, 255, 0.4);
}

.center {
  display: flex;
  flex-direction: column;
  text-align: center;
  align-items: center;
}

.flex-container {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.full-width {
  width: 100%;
}

.divider {
  flex: 1;
  margin-left: 10px;
}

.clickable {
  cursor: pointer;
}

@media (max-width: 600px) {
  nav {
    overflow-x: auto;
  }

  .tab {
    flex: 1;
  }

  #race-details {
    margin-bottom: 20px;
    margin-left: 0px;
    margin-right: 0px;
    padding: 5px;
    border-top: 1px dashed #cccccc;
    border-bottom: 1px dashed #cccccc;
    text-align: left;
  }
}

/* Safari */
@-webkit-keyframes spin {
  0% { -webkit-transform: rotate(0deg); }
  100% { -webkit-transform: rotate(360deg); }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}