/* ---------- Base Styles ---------- */
body {
  font-family: 'Segoe UI', sans-serif;
  background: #f6f9fc;
  margin: 0;
  padding: 15px;
  color: #333;
}

h1 {
  text-align: center;
  color: #0078d4;
  margin-bottom: 10px;
}

/* ---------- Tabs ---------- */
.tab-buttons {
  text-align: center;
  margin: 0 16px 20px 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
}

.tab-buttons button {
  background: #e1ecf9;
  border: none;
  padding: 8px 16px;
  margin: 0;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.3s;
  white-space: nowrap;
}

.tab-buttons button.active,
.tab-buttons button:hover {
  background: #0078d4;
  color: #fff;
}

/* ---------- Cards ---------- */
.card-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  margin: 8px auto;
  padding: 0;
  max-width: 900px;
  width: 95%;
  transition: transform 0.2s;
}

.card-header {
  padding: 10px 14px;
  font-weight: bold;
  font-size: 16px;
  background: linear-gradient(180deg, #004d4d 0%, #003838 100%);
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.card-content {
  padding: 10px 12px;
  /* prevent accidental inner scrollbars reserving space */
  overflow: visible;
}

/* ---------- Car Park Summary Table ---------- */
.car-card.summary {
  max-width: 900px;
  width: 95%;
  margin: 0 auto 20px auto;
}

.car-summary-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.car-summary-table th,
.car-summary-table td {
  padding: 6px 8px;
  font-size: 15px;
  border-bottom: 1px solid #eee;
  word-wrap: break-word;
}

.car-summary-table th {
  background-color: #f2f2f2;
  color: #333;
}

.car-summary-table th:nth-child(1),
.car-summary-table td:nth-child(1) {
  width: 60%;
}

.car-summary-table th:nth-child(2),
.car-summary-table td:nth-child(2) {
  width: 40%;
  text-align: right;
}

.car-address {
  font-size: 13px;
  color: #555;
}

/* ---------- Free Spots Bar ---------- */
.spots-bar {
  position: relative;
  height: 10px;
  width: 100%;
  max-width: 180px;
  background-color: #f8d7da;
  border-radius: 5px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
}

.spots-bar .available {
  background-color: #28a745;
  height: 100%;
  float: left;
}

.spots-bar .filled {
  background-color: #dc3545;
  height: 100%;
  float: left;
}

.spots-text {
  display: block;
  font-size: 0.85em;
  color: #333;
  margin-top: 4px;
  text-align: left;
  line-height: 1.2em;
}

@media (max-width: 600px) {
  .spots-text {
    font-size: 0.8em;
    margin-top: 3px;
  }
}

/* ---------- Header Bar ---------- */
.header-bar {
  max-width: 900px;
  margin: 0 auto 8px auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 10px;
}

.left-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.suburb-btn {
  background-color: #004d4d;
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
}

.suburb-btn:hover {
  background-color: #007272;
}

.fuel-type-label {
  font-weight: 500;
  color: #333;
}

#fuelTypeSelect {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 14px;
}

.last-updated {
  font-style: italic;
  font-size: 0.9em;
  color: #444;
  text-align: right;
}

/* ---------- Fuel Section ---------- */
#fuelHeader {
  display: none;
}

.fuel-card.summary {
  max-width: 900px;
  width: 95%;
  margin: 0 auto 20px auto;
}

.fuel-card.summary table {
  width: 100%;
  border-collapse: collapse;
}

.fuel-card.summary th,
.fuel-card.summary td {
  padding: 6px 0;
  font-size: 15px;
  border-bottom: 1px solid #eee;
}

/* ---------- Modal ---------- */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 10px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  animation: fadeIn 0.3s ease;
}

.modal-actions {
  margin-top: 15px;
  text-align: right;
}

.btn-primary,
.btn-secondary {
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s;
}

.btn-primary {
  background: #004d4d;
  color: white;
}

.btn-primary:hover {
  background: #007a7a;
}

.btn-secondary {
  background: #ccc;
  color: black;
}

.btn-secondary:hover {
  background: #aaa;
}

/* ---------- Footer ---------- */
.footer {
  max-width: 900px;
  margin: 10px auto;
  background-color: #2f2f2f;
  color: white;
  text-align: center;
  padding: 6px 0;
  border-top: 2px solid #006d77;
  border-radius: 0 0 8px 8px;
  font-size: 0.9em;
  animation: fadeIn 1.5s ease;
}

.footer p {
  margin: 3px 0;
}

.footer a {
  color: #00bfa6;
  text-decoration: none;
  font-weight: 600;
}

.footer a:hover {
  text-decoration: underline;
}

/* ---------- Disclaimer Tooltip (Footer) ---------- */
.disclaimer {
  position: relative;
  cursor: pointer;
  color: #00d1b2;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.info-icon {
  width: 14px;
  height: 14px;
  color: #00d1b2;
  flex-shrink: 0;
  vertical-align: middle;
  transition: transform 0.2s ease;
}

.disclaimer:hover .info-icon {
  transform: scale(1.1);
}

.disclaimer-text {
  visibility: hidden;
  opacity: 0;
  width: 260px;
  background-color: #222;
  color: #fff;
  text-align: left;
  border-radius: 6px;
  padding: 8px 10px;
  position: absolute;
  bottom: 140%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85em;
  line-height: 1.3em;
  transition: opacity 0.3s ease;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.disclaimer-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: #222 transparent transparent transparent;
}

background-color: #004d4d;
color: white;
border: none;
padding: 6px 14px;
border-radius: 6px;
font-weight: 500;
cursor: pointer;
transition: background 0.2s ease;
}

.suburb-btn:hover {
  background-color: #007272;
}

.fuel-type-label {
  font-weight: 500;
  color: #333;
}

#fuelTypeSelect {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 14px;
}

.last-updated {
  font-style: italic;
  font-size: 0.9em;
  color: #444;
  text-align: right;
}

/* ---------- Fuel Section ---------- */
#fuelHeader {
  display: none;
}

.fuel-card.summary {
  max-width: 900px;
  width: 95%;
  margin: 0 auto 20px auto;
}

.fuel-card.summary table {
  width: 100%;
  border-collapse: collapse;
}

.fuel-card.summary th,
.fuel-card.summary td {
  padding: 6px 0;
  font-size: 15px;
  border-bottom: 1px solid #eee;
}

/* ---------- Modal ---------- */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 10px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  animation: fadeIn 0.3s ease;
}

.modal-actions {
  margin-top: 15px;
  text-align: right;
}

.btn-primary,
.btn-secondary {
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s;
}

.btn-primary {
  background: #004d4d;
  color: white;
}

.btn-primary:hover {
  background: #007a7a;
}

.btn-secondary {
  background: #ccc;
  color: black;
}

.btn-secondary:hover {
  background: #aaa;
}

/* ---------- Footer ---------- */
.footer {
  max-width: 900px;
  margin: 10px auto;
  background-color: #2f2f2f;
  color: white;
  text-align: center;
  padding: 6px 0;
  border-top: 2px solid #006d77;
  border-radius: 0 0 8px 8px;
  font-size: 0.9em;
  animation: fadeIn 1.5s ease;
}

.footer p {
  margin: 3px 0;
}

.footer a {
  color: #00bfa6;
  text-decoration: none;
  font-weight: 600;
}

.footer a:hover {
  text-decoration: underline;
}

/* ---------- Disclaimer Tooltip (Footer) ---------- */
.disclaimer {
  position: relative;
  cursor: pointer;
  color: #00d1b2;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.info-icon {
  width: 14px;
  height: 14px;
  color: #00d1b2;
  flex-shrink: 0;
  vertical-align: middle;
  transition: transform 0.2s ease;
}

.disclaimer:hover .info-icon {
  transform: scale(1.1);
}

.disclaimer-text {
  visibility: hidden;
  opacity: 0;
  width: 260px;
  background-color: #222;
  color: #fff;
  text-align: left;
  border-radius: 6px;
  padding: 8px 10px;
  position: absolute;
  bottom: 140%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85em;
  line-height: 1.3em;
  transition: opacity 0.3s ease;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.disclaimer-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: #222 transparent transparent transparent;
}

.disclaimer:hover .disclaimer-text {
  visibility: visible;
  opacity: 1;
}

/* ---------- Train Info Tooltip ---------- */
.tooltip {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

/* Tooltip text - Hidden by default */
.tooltip .tooltiptext {
  visibility: hidden;
  width: 250px;
  background-color: #333;
  color: #fff;
  text-align: left;
  border-radius: 6px;
  padding: 10px;

  /* Position absolute */
  position: absolute;
  z-index: 1000;
  top: -10px;
  /* Align top with icon */
  left: 120%;
  /* Show to the right of the icon */

  opacity: 0;
  transition: opacity 0.3s;
  font-size: 0.85em;
  font-weight: normal;
  box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

/* Tooltip arrow */
.tooltip .tooltiptext::after {
  content: "";
  position: absolute;
  top: 15px;
  right: 100%;
  /* Arrow on the left side of tooltip */
  margin-top: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: transparent #333 transparent transparent;
}

/* Show on hover */
.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .header-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 0 6px;
  }

  .last-updated {
    width: 100%;
    text-align: left;
  }

  /* Trains table: tighter spacing and safe horizontal scroll */
  .train-card.summary table {
    font-size: 14px;
    margin-bottom: 0;
    /* avoid extra gap under table */
  }

  .train-card.summary .card-content {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .train-card.summary th,
  .train-card.summary td {
    padding: 6px;
    white-space: nowrap;
  }
}

/* Sticky header for train table on all screens */
.train-card.summary table thead th {
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, #004d4d 0%, #003838 100%);
  color: #fff;
  z-index: 2;
}

/* Desktop table row status color coding */
.train-card.summary table tbody tr.status-on-time {
  background: linear-gradient(135deg, #f0fbf0 0%, #ffffff 100%) !important;
}

.train-card.summary table tbody tr.status-delayed {
  background: linear-gradient(135deg, #fffdf0 0%, #ffffff 100%) !important;
}

.train-card.summary table tbody tr.status-cancelled {
  background: linear-gradient(135deg, #fff5f5 0%, #ffffff 100%) !important;
}

/* Desktop destination + minutes */
.train-desktop-leaving {
  font-size: 12px;
  color: #666;
  margin-left: 8px;
  font-weight: 400;
  white-space: nowrap;
}

.train-desktop-destination-text {
  white-space: nowrap;
}

/* Mobile card view - hidden on desktop */
.train-mobile-cards {
  display: none;
}

/* Mobile card styles */
@media (max-width: 768px) {

  /* Hide table on mobile */
  .train-table-desktop {
    display: none !important;
  }

  /* Show card view on mobile */
  .train-mobile-cards {
    display: block;
    padding: 0;
  }

  .train-mobile-card {
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 8px 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
  }

  .train-mobile-card.status-on-time {
    background: linear-gradient(135deg, #f0fbf0 0%, #ffffff 100%);
  }

  .train-mobile-card.status-delayed {
    background: linear-gradient(135deg, #fffdf0 0%, #ffffff 100%);
  }

  .train-mobile-card.status-cancelled {
    background: linear-gradient(135deg, #fff5f5 0%, #ffffff 100%);
  }

  .train-mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-right: 30px;
  }

  .train-mobile-line {
    font-size: 18px;
    font-weight: bold;
    color: #004d4d;
  }

  .train-mobile-status {
    font-size: 14px;
    font-weight: bold;
  }

  .train-mobile-destination {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    display: flex;
    align-items: baseline;
    gap: 8px;
    white-space: nowrap;
  }

  .train-mobile-leaving {
    font-size: 12px;
    color: #666;
    font-weight: 400;
    white-space: nowrap;
  }

  .train-mobile-destination-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .train-mobile-times {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
    /* keep everything on one line */
    overflow-x: auto;
    /* allow horizontal scroll on very small screens */
    -webkit-overflow-scrolling: touch;
  }

  .train-mobile-time-item {
    display: inline-flex;
    flex-direction: row;
    align-items: baseline;
    gap: 3px;
    /* tighter gap between label and value */
    white-space: nowrap;
    flex: 0 0 auto;
    /* prevent shrinking/wrapping */
  }

  .train-mobile-label {
    font-size: 12px;
    color: #666;
    text-transform: none;
    /* camel case */
    margin-right: 1px;
  }

  .train-mobile-value {
    font-size: 15px;
    font-weight: 600;
    color: #004d4d;
  }

  .train-mobile-info {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 18px;
    cursor: pointer;
    z-index: 10;
  }

  .train-mobile-info .train-mobile-info-icon {
    display: inline-block;
  }

  .train-mobile-info .train-mobile-info-text {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    right: 0;
    top: 30px;
    width: 280px;
    background: #333;
    color: #fff;
    padding: 10px;
    border-radius: 6px;
    font-size: 13px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: opacity 0.3s ease;
    text-align: left;
    line-height: 1.4;
  }

  .train-mobile-info .train-mobile-info-text::before {
    content: "";
    position: absolute;
    top: -8px;
    right: 10px;
    border-width: 0 8px 8px 8px;
    border-style: solid;
    border-color: transparent transparent #333 transparent;
  }

  .train-mobile-info:hover .train-mobile-info-text {
    visibility: visible;
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}