/* =========================================================
   THEME VARIABLES
   ========================================================= */

:root {
  --darkblue: #081f37;
  --mediumblue: #132b45;
  --cardbg: #1e3a5f;
  --darkerblue: #061526;
  --blue: #2563eb;
  --lightblue: #38bdf8;
  --lightblue-hover: #7dd3fc;
  --white: #ffffff;
  --black: #000000;
  --onTime: #22c55e;
  --lateSmall: #eab308;
  --lateBig: #ef4444;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Screen reader utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* =========================================================
   GLOBAL BASE
   ========================================================= */

* {
  box-sizing: border-box;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0 1rem;
  background: var(--darkblue);
  color: var(--white);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 720px;
  margin: auto;
  padding: 1.5rem 0 3rem 0;
}

/* SVG icons */
.icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}


/* =========================================================
   HEADER ROW
   ========================================================= */

.headerRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(19, 43, 69, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Alert bell button */
.alertBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.alertBtn:hover {
  background: rgba(239, 68, 68, 0.35);
  transform: scale(1.05);
}

.alertBtn .icon {
  width: 22px;
  height: 22px;
}

/* Left pill */
#nextTrain {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: var(--mediumblue);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--lightblue);
}

/* Clock on right */
#liveClock {
  font-family: "JetBrains Mono", monospace;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.colon {
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0.2; }
}


/* =========================================================
   STATION SELECTORS
   ========================================================= */

.stationSelect {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.selectWrapper {
  position: relative;
  width: 100%;
}

.selectWrapper::after {
  content: "▾";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--lightblue);
  pointer-events: none;
  font-size: 0.85rem;
}

.stationSelect select {
  width: 100%;
  padding: 0.85rem 2rem 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--mediumblue);
  color: var(--white);
  font-size: 0.95rem;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.stationSelect select:focus {
  outline: none;
  border-color: var(--lightblue);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.swapBtn {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--lightblue);
  color: var(--darkblue);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.swapBtn:hover {
  background: var(--lightblue-hover);
  transform: scale(1.05);
}

.swapBtn:active {
  transform: scale(0.95);
}


/* =========================================================
   REFRESH BUTTON
   ========================================================= */

.refresh {
  width: 100%;
  margin-bottom: 1.5rem;
  padding: 0.85rem 1.2rem;
  border: none;
  border-radius: var(--radius-md);
  background: var(--lightblue);
  color: var(--darkblue);
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.refresh:hover {
  background: var(--lightblue-hover);
}

.refresh:active {
  transform: scale(0.99);
}

.refresh.is-loading .spinOnRefresh {
  animation: spin 0.8s linear infinite;
}


/* =========================================================
   STATUS NOTICE BANNER
   ========================================================= */

.statusNotice {
  padding: 1rem 1.2rem;
  border-radius: var(--radius-md);
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-weight: 500;
}

.statusNotice button {
  background: var(--lightblue);
  color: var(--darkblue);
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}


/* =========================================================
   TRAIN LIST
   ========================================================= */

#trainList {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.emptyNotice {
  text-align: center;
  padding: 3rem 1rem;
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.1rem;
  background: rgba(19, 43, 69, 0.4);
  border-radius: var(--radius-md);
  border: 1px dashed rgba(255, 255, 255, 0.1);
}


/* =========================================================
   TRAIN CARD (MOBILE FIRST)
   ========================================================= */

.trainCard {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--cardbg);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.trainCard:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.trainCard.lateSmall {
  background: linear-gradient(
    135deg,
    rgba(234, 179, 8, 0.25),
    var(--cardbg) 70%
  );
  border-color: rgba(234, 179, 8, 0.3);
}

.trainCard.lateBig {
  background: linear-gradient(
    135deg,
    rgba(239, 68, 68, 0.3),
    var(--cardbg) 70%
  );
  border-color: rgba(239, 68, 68, 0.4);
}

.trainCard.canceled {
  background: linear-gradient(
    135deg,
    rgba(239, 68, 68, 0.35),
    rgba(30, 58, 95, 0.9) 70%
  );
  border-color: rgba(239, 68, 68, 0.6);
  opacity: 0.9;
}


/* =========================================================
   LEFT & RIGHT COLUMNS
   ========================================================= */

.leftCol {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.leftCol h2 {
  font-family: "JetBrains Mono", monospace;
  font-size: 2.2rem;
  font-weight: 700;
  margin: 0;
  line-height: 1;
  color: var(--white);
}

.leftCol h2.strikethrough {
  text-decoration: line-through;
  opacity: 0.6;
}

.platform {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--lightblue);
}

.platform.changed {
  color: #f97316;
  font-weight: 700;
}

.platform.changed::after {
  content: " (Gewijzigd)";
  font-size: 0.8rem;
  text-transform: uppercase;
}

.rightCol {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  gap: 0.3rem;
}

.rightCol p {
  margin: 0;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.9);
}

.trainType {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--white);
}

.trainDirection {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metaBadges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
  margin-top: 0.2rem;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.85);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.canceledBadge {
  background: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.5);
  font-weight: 700;
}


/* =========================================================
   DELAY ROW
   ========================================================= */

.delay {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.onTime .dot    { background: var(--onTime); box-shadow: 0 0 6px var(--onTime); }
.lateSmall .dot { background: var(--lateSmall); box-shadow: 0 0 6px var(--lateSmall); }
.lateBig .dot   { background: var(--lateBig); box-shadow: 0 0 6px var(--lateBig); }
.canceled .dot  { background: #ef4444; box-shadow: 0 0 6px #ef4444; }

.onTime { color: var(--onTime); }
.lateSmall { color: var(--lateSmall); }
.lateBig { color: var(--lateBig); }
.canceled { color: #f87171; }



/* =========================================================
   DESKTOP REFINEMENT
   ========================================================= */

@media (min-width: 600px) {
  .leftCol h2 {
    font-size: 2.5rem;
  }
}


/* =========================================================
   LOADING OVERLAY
   ========================================================= */

#loadingScreen {
  position: fixed;
  inset: 0;
  background: rgba(8, 31, 55, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  transition: opacity 0.2s ease;
}

.loader {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--lightblue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* =========================================================
   MODAL OVERLAY & CONTENT
   ========================================================= */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  z-index: 2000;
}

.modal.show {
  display: flex;
}

body.modalOpen {
  overflow: hidden;
}

.modalContent {
  background: var(--darkerblue);
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.modalContent h2 {
  margin: 0;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 1.3rem;
}

#alertList {
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.alertItem {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--lateBig);
}

.alertItem h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.05rem;
  color: var(--white);
}

.alertItem p {
  margin: 0;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.4;
}

#closeModal {
  border: none;
  background: var(--lightblue);
  color: var(--darkblue);
  padding: 1rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease;
}

#closeModal:hover {
  background: var(--lightblue-hover);
}
