:root {
  --ns-card-radius: 5px;
}

.timetable-container {
  max-width: 1200px;
  margin: 1rem auto;
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: -var(ns-card-radius);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.timetable-title {
  text-align: center;
  padding: 15px;
  background-color: #f0f0f0;
  border-bottom: 1px solid #ddd;
  margin-top: 0;
  border-top-left-radius: -var(ns-card-radius);
  border-top-right-radius: -var(ns-card-radius);
}

/* Default table styles for desktop */
table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border: 1px solid #ccc;
  padding: 12px 15px;
  text-align: left;
}

thead th {
  background-color: #e9e9e9;
  font-weight: bold;
  color: #333;
}

.day-header {
  background-color: #dcdcdc;
  vertical-align: top;
  text-align: center;
}

tbody tr:nth-child(odd) {
  background-color: #f9f9f9;
}

tbody tr:hover {
  background-color: #f1f1f1;
}

.timetable-key {
  position: sticky;
  margin-top: 1rem;
  top: 0;
  z-index: 100;
  background-color: #f7f9fc;
  padding: 0.5rem 1rem;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.timetable-key ul {
  list-style: none;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0;
}

.timetable-key li {
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer; /* Add a pointer cursor to indicate clickability */
  transition:
    transform 0.2s ease-in-out,
    box-shadow 0.2s ease-in-out; /* Smooth transitions */
  padding: 0.5rem 1rem;
  border-radius: 20px;
  background-color: #f0f0f0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.timetable-key li:hover {
  transform: translateY(-2px); /* Lifts the item slightly */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* Creates a more pronounced shadow */
}

.mobile-day-label {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--nsnavy);
}

@media (min-width: 768px) {
  table.timetable th:nth-child(2) {
    display: none;
  }
  table.timetable td:nth-child(2) {
    display: none;
  }
}

@media (max-width: 768px) {
  .timetable-container {
    overflow-x: hidden; /* Hide horizontal scroll if previously set */
    border: none; /* Remove container border for card view */
    box-shadow: none;
    padding: 0;
  }

  .timetable-title {
    border-radius: 0;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block; /* Make all table elements behave like block elements */
  }

  /* Hide the original table header on small screens */
  thead {
    display: none;
  }

  tr {
    margin-bottom: 15px; /* Space between "cards" */
    border: 1px solid var(--nsnavy);
    background-color: var(--nswhite);
    border-radius: var(--ns-card-radius);
    margin: 1rem;
    padding: 10px;
  }

  tr.day-row-separator {
    border: 0px;
    background-color: var(--nswhite);
  }

  td {
    border: none; /* Remove cell borders */
    position: relative;
    padding-left: 50%; /* Make space for the pseudo-element label */
    text-align: right; /* Align content to the right */
    font-size: 0.95em;
  }

  td:before {
    content: attr(data-label); /* Use data-label attribute for the label */
    position: absolute;
    left: 10px;
    width: 45%; /* Space for the label */
    padding-right: 10px;
    white-space: nowrap;
    text-align: left;
    font-weight: bold;
    color: var(--nsnavy);
  }

  /* Adjust the first td in each row (time) */
  tbody tr td:first-of-type {
    font-weight: bold;
    text-align: center;
    padding-left: 10px; /* Remove padding if no label needed */
    margin-bottom: 5px;
  }
  tbody tr td:first-of-type:before {
    content: none; /* No label for the first cell (time) */
  }
}
