/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0d12;
  --surface: #111620;
  --surface2: #181e2c;
  --border: rgba(255,255,255,.07);
  --text-primary: #f0f4ff;
  --text-secondary: #8b95b0;
  --text-muted: #4e5872;
  --accent-green: #7AB420;
  --accent-green-glow: rgba(122,180,32,.25);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 40px rgba(0,0,0,.5);
  --font: 'Inter', system-ui, sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ── Background decorations ── */
.bg-grid {
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
}

.bg-glow {
  position: fixed; z-index: 0; border-radius: 50%;
  filter: blur(100px); pointer-events: none;
  animation: floatGlow 12s ease-in-out infinite alternate;
}
.glow-1 { width: 600px; height: 600px; top: -200px; left: -200px; background: rgba(122,180,32,.1); }
.glow-2 { width: 500px; height: 500px; bottom: -200px; right: -200px; background: rgba(122,180,32,.07); animation-delay: -6s; }

@keyframes floatGlow {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(40px, 40px) scale(1.1); }
}

/* ── Header ── */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10,13,18,.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1100px; margin: 0 auto;
  padding: 14px 24px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}

/* Brand */
.brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 180px; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 1rem; font-weight: 700; color: var(--text-primary); letter-spacing: -.3px; }
.brand-sub { font-size: .7rem; font-weight: 500; color: var(--accent-green); text-transform: uppercase; letter-spacing: 1px; }

/* Controls */
.header-controls {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}

.station-selector, .refresh-control {
  display: flex; align-items: center; gap: 8px;
}

.station-selector label,
.refresh-control label {
  font-size: .7rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px; white-space: nowrap;
}

select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: .85rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
  transition: border-color .2s;
}
select:focus { border-color: var(--accent-green); }
select:hover { border-color: rgba(122,180,32,.4); }

.btn-refresh {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .2s;
  flex-shrink: 0;
}
.btn-refresh:hover { border-color: var(--accent-green); color: var(--accent-green); background: rgba(122,180,32,.1); }
.btn-refresh.spinning #refreshIcon { animation: spin .6s linear infinite; }

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

/* Progress bar */
.progress-bar-wrapper {
  height: 2px; background: var(--border); position: relative;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-green), #a8e040);
  width: 100%;
  transform-origin: left;
  transition: transform linear;
  box-shadow: 0 0 8px var(--accent-green);
}

/* ── Main ── */
.main {
  position: relative; z-index: 1;
  max-width: 1100px; margin: 0 auto;
  padding: 28px 24px 60px;
}

/* ── Station Info ── */
.station-info {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.station-info::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent-green), #a8e040, var(--accent-green));
  background-size: 200% 100%;
  animation: shimmer 3s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.si-left { display: flex; align-items: center; gap: 16px; }

.station-badge {
  width: 64px; height: 64px;
  border-radius: 14px;
  background: var(--accent-green);
  color: #fff;
  font-size: 1.1rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: -.5px;
  box-shadow: 0 0 24px var(--accent-green-glow), 0 4px 16px rgba(0,0,0,.3);
  flex-shrink: 0;
  transition: background .4s;
}

.station-name-en {
  font-size: 1.4rem; font-weight: 700; line-height: 1.2;
  color: var(--text-primary);
}
.station-name-th {
  font-size: 1rem; color: var(--text-secondary); margin-top: 2px;
}

.si-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  border-radius: 40px;
  font-size: .78rem; font-weight: 600; letter-spacing: .3px;
  background: rgba(122,180,32,.12);
  border: 1px solid rgba(122,180,32,.25);
  color: var(--accent-green);
  transition: all .3s;
}
.status-pill.inactive {
  background: rgba(255,80,80,.1);
  border-color: rgba(255,80,80,.25);
  color: #ff6060;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .4; transform: scale(.8); }
}

.server-time {
  font-size: .78rem; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Error Banner ── */
.error-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  background: rgba(255,80,80,.08);
  border: 1px solid rgba(255,80,80,.2);
  border-radius: var(--radius-md);
  color: #ff8080;
  font-size: .85rem; margin-bottom: 20px;
}
.hidden { display: none !important; }

/* ── Platforms Grid ── */
.platforms-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ── Platform Card ── */
.platform-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: border-color .3s, transform .2s;
  animation: fadeUp .35s ease both;
}
.platform-card:hover { border-color: rgba(122,180,32,.3); transform: translateY(-2px); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.platform-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(255,255,255,.04), rgba(255,255,255,.01));
  border-bottom: 1px solid var(--border);
}

.platform-num-badge {
  display: flex; align-items: center; gap: 10px;
}
.p-num {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--accent-green);
  color: #fff;
  font-weight: 800; font-size: .95rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .4s;
}
.p-label {
  font-size: .68rem; color: var(--text-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
}
.p-direction {
  font-size: .9rem; font-weight: 600; color: var(--text-primary);
}

.train-count {
  font-size: .72rem; font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(122,180,32,.12);
  border: 1px solid rgba(122,180,32,.2);
  color: var(--accent-green);
}

/* ── Train Rows ── */
.train-list { padding: 8px 0; }

.train-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
  animation: fadeIn .3s ease both;
}
.train-row:last-child { border-bottom: none; }
.train-row:hover { background: rgba(255,255,255,.02); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.train-rank {
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(255,255,255,.05);
  color: var(--text-muted);
  font-size: .7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.train-rank.rank-1 { background: rgba(255,215,0,.1); color: #ffd700; }
.train-rank.rank-2 { background: rgba(192,192,192,.1); color: #c0c0c0; }
.train-rank.rank-3 { background: rgba(205,127,50,.1); color: #cd7f32; }

.train-info { flex: 1; min-width: 0; }
.train-no {
  font-size: .68rem; font-weight: 700; color: var(--accent-green);
  letter-spacing: .5px; text-transform: uppercase;
}
.train-dest {
  font-size: .88rem; font-weight: 500; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 1px;
}

.eta-box {
  flex-shrink: 0; text-align: right;
}
.eta-mins {
  font-size: 1.5rem; font-weight: 800;
  line-height: 1; font-variant-numeric: tabular-nums;
  transition: opacity .3s;
}
.eta-label { font-size: .65rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }

/* ETA color tiers */
.eta-now  { color: #ff6060; }
.eta-soon { color: #ffaa30; }
.eta-ok   { color: var(--accent-green); }

.arriving-badge {
  font-size: .68rem; font-weight: 700;
  color: #ff6060;
  border: 1px solid currentColor;
  border-radius: 20px;
  padding: 2px 8px;
  animation: blink .8s step-start infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── No service ── */
.no-service-card {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.no-service-icon {
  font-size: 4rem; margin-bottom: 16px; opacity: .4;
}
.no-service-card h2 { font-size: 1.4rem; margin-bottom: 8px; color: var(--text-secondary); }
.no-service-card p { color: var(--text-muted); }

/* ── Skeleton ── */
.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.skel {
  background: linear-gradient(90deg, var(--surface2) 25%, rgba(255,255,255,.04) 50%, var(--surface2) 75%);
  background-size: 300% 100%;
  border-radius: 8px;
  animation: skelAnim 1.4s infinite;
}
.skel-h  { height: 20px; margin-bottom: 20px; width: 60%; }
.skel-row { height: 56px; margin-bottom: 12px; }
@keyframes skelAnim {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ── Footer ── */
.footer {
  position: relative; z-index: 1;
  text-align: center;
  padding: 24px;
  font-size: .78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.footer a { color: var(--accent-green); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 700px) {
  .header-inner { padding: 12px 16px; }
  .main { padding: 20px 16px 50px; }
  .platforms-grid { grid-template-columns: 1fr; }
  .station-info { padding: 16px 20px; }
  .station-name-en { font-size: 1.15rem; }
  .station-badge { width: 52px; height: 52px; font-size: .9rem; }
  .train-dest { font-size: .82rem; }
  .eta-mins { font-size: 1.25rem; }
}
