:root {
  --f1-red: #e10600;
  --f1-dark: #15151e;
  --f1-darker: #0c0c12;
  --f1-gray: #1f1f2b;
  --f1-light-gray: #2d2d3d;
  --f1-text: #ffffff;
  --f1-text-secondary: #9090a0;

  font-size: clamp(13px, 1.1vw, 17px); /* Responsive root font size */
  margin: 0;
  padding: 0;
  overflow-x: auto; /* Allow horizontal scroll when content overflows */
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Exo 2', sans-serif;
  background-color: var(--f1-darker);
  color: var(--f1-text);
  line-height: 1.5;
  min-height: 100vh;
}

.dashboard-container {
  width: 100%;
  padding: 1rem;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 1rem;
  height: 100vh;
}

.dashboard-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 2rem;
  align-items: center;
  background-color: var(--f1-dark);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--f1-light-gray);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.settings-button {
  background: none;
  border: none;
  color: var(--f1-text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.75rem;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.settings-button:hover {
  color: var(--f1-red);
}

.port-badge {
  background: #0e639c;
  color: #ffffff;
  font-family: 'Exo 2', sans-serif;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  padding: 4px 8px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
}

.track-info {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.track-name {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--f1-red);
  margin: 0;
}

.telemetry-splash-wrapper {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  border: 1px solid var(--f1-light-gray);

  display: flex;
  justify-content: center; /* Center horizontally */
  align-items: center; /* Center vertically */
  gap: 10px; /* Space between dot and text */
  text-align: center;
}

.status-wrapper {
  display: flex;
  align-items: center; /* Ensures dot and text are aligned */
  gap: 8px; /* Space between dot and text */
}

/* Change the styles for the first child paragraph tag */
.status-wrapper > p:nth-child(2) {
  margin-bottom: 3px;
}

.blinking-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  animation: blink 1.5s infinite alternate;
  flex-shrink: 0; /* Prevents shrinking */
}

.blinking-dot.red {
  background-color: red;
}

.blinking-dot.green {
  background-color: green;
}

@keyframes blink {
  0% { opacity: 1; }
  100% { opacity: 0.2; }
}

.telemetry-time-trial-wrapper {
  overflow-y: auto;
  max-height: calc(100vh - 200px);
  width: 100%;
  height: 100%;
  border-radius: 8px;
  border: 2px solid var(--f1-light-gray);
}

/* Specific wrapper for tt-data view */
.time-trial-tt-data {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Section containers */
.time-trial-tt-data-section {
  flex: 1 1 0;
  min-height: 0;
  max-height: 33.333%;
  width: 100%;
  overflow: auto;
}

/* Table specific styles */
.time-trial-tt-data-table {
  table-layout: fixed;
  margin-bottom: 0;
  width: 100%;
}

.time-trial-tt-data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background-color: inherit;
  width: 20%;
}

/* Optional: Add some spacing between tables in the same section */
.time-trial-tt-data-table + .time-trial-tt-data-table {
  margin-top: 0.5rem;
}

.telemetry-table-wrapper {
  overflow-y: auto;
  max-height: calc(100vh - 200px);
  background-color: var(--f1-dark);
  border-radius: 8px;
  border: 1px solid var(--f1-light-gray);
}

.telemetry-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed; /* Ensures consistent column widths */
}

.telemetry-table th,
.telemetry-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--f1-light-gray);
  overflow: hidden; /* Prevent content overflow */
  text-overflow: ellipsis;
  white-space: nowrap; /* Keeps content in one line */
}

.telemetry-table th {
  background-color: var(--f1-gray);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--f1-text-secondary);
  position: sticky;
  top: 0;
  z-index: 10;
}

.telemetry-table .best-lap,
.telemetry-table .curr-lap,
.telemetry-table .last-lap {
  width: 10%; /* Equal width for "Best Lap", "Current Lap" and "Last Lap" */
}

.telemetry-table th:nth-child(1) { width: 4%; } /* POS */
.telemetry-table th:nth-child(2) { width: 12%; } /* DRIVER */
.telemetry-table th:nth-child(3) { width: 7%; } /* DELTA */
.telemetry-table th:nth-child(4) { width: 8%; } /* ERS */
.telemetry-table th:nth-child(5) { width: 10%; } /* WARNS/PENS */
.telemetry-table th:nth-child(9) { width: 9%; } /* TYRE INFO */
.telemetry-table th:nth-child(10) { width: 8%; } /* WEAR PREDICTION */
.telemetry-table th:nth-child(11) { width: 6%; } /* DAMAGE */
.telemetry-table th:nth-child(12) { width: 6%; } /* FUEL */

.player-row td {
  color: inherit; /* Inherit color for non-DRS rows */
}

.drs-row td {
  color: #10e71b; /* Set font color to green */
}

.dnf-row td {
  color: #e60505; /* Set font color to green */
}

.player-row.drs-row td {
  color: #10e71b; /* Set font color to green */
}

.ot-row td {
  color: #41bff3;
}

.player-row.ot-row td {
  color: #41bff3;
}

.player-row.dnf-row td {
  color: #e60505; /* Set font color to green */
}

.player-row td:first-child {
  border-left: 1px solid #f7f5ef; /* Left border (white) */
}

.player-row td:last-child {
  border-right: 1px solid #f7f5ef; /* Right border (white) */
}

.player-row td {
  border-top: 1px solid #f7f5ef !important; /* Top border (white) */
  border-bottom: 1px solid #f7f5ef !important; /* Bottom border (white) */
}

.drs-row td:first-child {
  color: #10e71b; /* Set font color to green */
}

.drs-row td:last-child {
  color: #10e71b; /* Set font color to green */
}

.drs-row td {
  color: #10e71b; /* Set font color to green */
}

.ot-row td:first-child {
  color: #41bff3;
}

.ot-row td:last-child {
  color: #41bff3;
}

.ot-row td {
  color: #41bff3;
}

.driver-name {
  cursor: pointer;
  color: var(--f1-text);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

.tyre-compound {
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  text-align: center;
  display: inline-block;
  min-width: 80px;
}

.tyre-soft { background-color: #ff1e00; }
.tyre-medium { background-color: #ffd700; color: #000000; }
.tyre-hard { background-color: #ffffff; color: #000000; }

.delta-positive { color: #ff4444; }
.delta-negative { color: #44ff44; }

.fastest-lap {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
}

.fastest-lap-label {
  color: var(--f1-text-secondary);
  font-weight: 600;
}

.fastest-lap-time {
  color: var(--f1-red);
  font-weight: 700;
  font-size: 1.25rem;
}

.fastest-lap-driver {
  color: var(--f1-text);
  font-weight: 600;
}

.stat-value {
  font-weight: 700;
  font-size: 1.125rem;
}

.stat-unit {
  font-size: 0.875rem;
  color: var(--f1-text-secondary);
  margin-left: 0.25rem;
}

/* Modal Styles */
.modal-content {
  background-color: var(--f1-dark);
  color: var(--f1-text);
  border: 1px solid var(--f1-light-gray);
}

.modal-header {
  border-bottom-color: var(--f1-light-gray);
}

.modal-footer {
  border-top-color: var(--f1-light-gray);
}

.inactive .nav-link {
  color: var(--f1-text-secondary);
}

.btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

.form-control {
  background-color: var(--f1-gray);
  border-color: var(--f1-light-gray);
  color: var(--f1-text);
}

.form-control:focus {
  background-color: var(--f1-gray);
  border-color: var(--f1-red);
  color: var(--f1-text);
  box-shadow: 0 0 0 0.25rem rgba(225, 6, 0, 0.25);
}

.form-label {
  color: var(--f1-text);
}

.btn-primary {
  background-color: var(--f1-red);
  border-color: var(--f1-red);
}

.btn-primary:hover {
  background-color: #c30500;
  border-color: #c30500;
}

.btn-secondary {
  background-color: var(--f1-gray);
  border-color: var(--f1-light-gray);
}

.btn-secondary:hover {
  background-color: var(--f1-light-gray);
  border-color: var(--f1-light-gray);
}

/* Ensure toast container is positioned correctly */
.toast-container {
  z-index: 1055;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 200px;
  background-color: #333; /* Dark background */
  color: #fff; /* White text */
  border-radius: 20px; /* Rounded corners */
  padding: 10px 20px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4); /* Subtle shadow for better visibility */
}

.toast-body {
  font-size: 16px; /* Standard font size */
  text-align: center; /* Centered text */
}

a {
  text-decoration: none; /* Removes the underline */
  color: inherit; /* Inherits the color from the parent element */
}

.ers-bar {
  display: flex;
  width: 100%;
  height: .33em;
  background-color: #222;
  border-radius: .25rem;
  overflow: hidden;
}

.ers-bar__fill {
  transition: width .2s ease-in-out;
  border-radius: .25rem 0 0 .25rem;
}

.ers-bar__fill--normal {
  background-color: #00e676;
}

.ers-bar__fill--low {
  background-color: #ff1744;
}

/* For purple sector */
.bg-purple {
    background-color: #800080;
}

/* Accessibility: respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .blinking-dot {
        animation: none;
        opacity: 1;
    }
}
