/*
 * stations_shared.css
 * Shared styles for all Thai Tracks station list pages.
 * Used by: stations_northern, stations_northeastern, stations_eastern,
 *           stations_maeklong, stations_southern
 */

:root {
  --srt-maroon: #800000;
  --srt-gold: #d4af37;
  --border: #e3e3ef;
  --shadow: 0 1px 4px rgba(0,0,0,.06);
  --shadow-md: 0 2px 12px rgba(0,0,0,.10);
  --ink: #1a1a1a;
}

html, body { margin: 0; padding: 0; background: #f0eeeb; color: var(--ink); font-family: 'Prompt', sans-serif; }

/* -- HEADER -- */
header {
  background: var(--srt-maroon);
  color: #fff;
  text-align: center;
  padding: 1.2rem 1.5rem 1rem;
  border-bottom: 4px solid var(--srt-gold);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent, transparent 60px, rgba(212,175,55,0.07) 60px, rgba(212,175,55,0.07) 61px);
  pointer-events: none;
}
.header-title-wrap { display: flex; flex-direction: column; align-items: center; position: relative; }
header h1 { margin: 0 0 2px; font-weight: 600; font-size: 1.7rem; letter-spacing: 0.08em; }
header h1 a { color: #fff; text-decoration: none; }
.header-tagline { font-size: 0.78rem; color: rgba(255,255,255,0.75); letter-spacing: 0.12em; text-transform: uppercase; margin: 0; }
.header-tagline span { display: inline-block; border-top: 1px solid rgba(212,175,55,0.4); padding-top: 4px; }

main { padding: 16px; }
.wrap { max-width: 1100px; margin: 0 auto; }
h2 { color: var(--srt-maroon); text-align: center; margin-top: 30px; }
h3 { color: var(--srt-maroon); border-bottom: 2px solid var(--srt-gold); padding-bottom: 5px; margin-top: 40px; }

/* -- DISTANCE CALCULATOR -- */
.calc-container {
  background: #fff; padding: 20px; border-radius: 8px; box-shadow: var(--shadow-md);
  margin-bottom: 20px; text-align: center; border: 1px solid var(--border);
}
.calc-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 15px; margin-top: 10px; }
.search-container { position: relative; text-align: left; }
input.search-input {
  padding: 10px 35px 10px 10px; border: 1px solid #ccc; border-radius: 6px;
  font-family: inherit; width: 100%; box-sizing: border-box; background-color: #fff; cursor: pointer;
}
.clear-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: #ccc; color: #fff; border: none; border-radius: 50%;
  width: 18px; height: 18px; font-size: 12px; line-height: 18px;
  cursor: pointer; display: none; text-align: center; padding: 0;
}
.options-list {
  position: absolute; top: 100%; left: 0; right: 0;
  background: #fff; border: 1px solid #ccc; border-radius: 0 0 6px 6px;
  max-height: 300px; overflow-y: auto; z-index: 1000; display: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.option-item { padding: 10px; cursor: pointer; font-size: 0.9rem; border-bottom: 1px solid #f0f0f0; }
.option-item:hover { background: #f8f8f8; color: var(--srt-maroon); }
.option-group-label { background: #f1f1f1; padding: 6px 10px; font-size: 0.75rem; font-weight: bold; color: #777; text-transform: uppercase; }
#distance-result { margin-top: 20px; font-weight: 600; color: var(--srt-maroon); font-size: 1.3rem; min-height: 1.5em; }

/* -- INFO CARD -- */
.info-card {
  background: #fff;
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--srt-gold);
  line-height: 1.6;
}
.info-card-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7a4a00;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* -- LINE NAV BUTTONS -- */
.line-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.line-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  border: 1.5px solid;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  cursor: pointer;
}
.line-btn-inactive { background: #f8f5f5; border-color: #e0d8d8; color: var(--srt-maroon); }
.line-btn-inactive:hover { background: var(--srt-maroon); border-color: var(--srt-maroon); color: #fff; }
.line-btn-active { background: var(--srt-maroon); border-color: var(--srt-maroon); color: #fff; cursor: default; }

/* -- LIVE SEARCH FILTER -- */
.filter-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.filter-input-wrap { position: relative; flex: 1; }
.filter-input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 36px 9px 36px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-family: 'Sarabun', 'Prompt', sans-serif;
  font-size: 0.95rem;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.filter-input:focus {
  outline: none;
  border-color: var(--srt-maroon);
  box-shadow: 0 0 0 3px rgba(128,0,0,0.1);
}
.filter-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #aaa;
  pointer-events: none;
}
.filter-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: #ccc;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  display: none;
  padding: 0;
}
.filter-count { font-size: 0.8rem; color: #888; white-space: nowrap; min-width: 70px; text-align: right; }

/* -- STATION TABLE -- */
.station-table-container {
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  overflow-x: auto;
  margin-bottom: 30px;
  border: 1px solid var(--border);
}
table { width: 100%; border-collapse: collapse; }
thead { position: sticky; top: 0; z-index: 10; }
th {
  background-color: var(--srt-maroon);
  color: white;
  text-align: left;
  padding: 10px 12px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th:hover { background-color: #6a0000; }
th .sort-arrow { margin-left: 5px; opacity: 0.5; font-style: normal; font-size: 0.7rem; }
th.sort-asc .sort-arrow::after { content: ' \25B2'; opacity: 1; }
th.sort-desc .sort-arrow::after { content: ' \25BC'; opacity: 1; }
th:not(.sort-asc):not(.sort-desc) .sort-arrow::after { content: ' \21C5'; }
td { padding: 6px 12px; border-bottom: 1px solid var(--border); line-height: 1.3; font-size: 0.9rem; }
td.thai-name { font-family: 'Sarabun', sans-serif; font-size: 1rem; line-height: 1.4; }
tbody tr:nth-child(even) { background: #faf8f8; }
tbody tr:hover { background: #f5eeee; }

/* -- JUNCTION ROW HIGHLIGHT -- */
tr.is-junction td { background: #fff0c0 !important; }
tr.is-junction:hover td { background: #ffe898 !important; }

/* -- PROVINCE DIVIDER ROW -- */
tr.province-row td {
  background: #f0eeeb !important;
  padding: 4px 12px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #888;
  border-bottom: 1px solid #ddd;
  border-top: 2px solid #ddd;
}
tr.province-row:hover td { background: #f0eeeb !important; }

.station-name-link { font-weight: 600; color: #1877f2; text-decoration: none; }
.station-name-link:hover { text-decoration: underline; }
.code-link { color: #1877f2; font-weight: 600; text-decoration: none; }

/* -- ANY QUESTIONS CARD -- */
.info-card-help {
  background: #fff;
  padding: 14px 18px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: 20px 0 30px;
  border: 1px solid var(--border);
  border-left: 4px solid #1a7a3c;
  line-height: 1.7;
  color: #444;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 0.92rem;
}
.info-card-help .card-icon { flex-shrink: 0; font-size: 1.25rem; margin-top: 1px; line-height: 1; }
.info-card-help a { color: #1877f2; font-weight: 600; text-decoration: none; }
.info-card-help a:hover { text-decoration: underline; }
.info-card-help p { margin: 8px 0 0; }
.info-card-help strong { color: var(--ink); }

/* -- STATS BAR -- */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--srt-maroon);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  border: 1px solid var(--srt-maroon);
  border-top: none;
  margin-bottom: 30px;
}
.stat-item { padding: 10px 16px; text-align: center; border-right: 1px solid rgba(255,255,255,0.1); }
.stat-item:last-child { border-right: none; }
.stat-label { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.09em; color: rgba(255,255,255,0.5); display: block; margin-bottom: 2px; }
.stat-value { font-size: 1rem; font-weight: 600; color: var(--srt-gold); }

/* -- BACK TO TOP BUTTON -- */
.back-to-top {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--srt-maroon);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  z-index: 999;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
}
.back-to-top:hover { background: #6a0000; transform: translateY(-2px); }
.back-to-top.visible { display: flex; }

/* -- FOOTER -- */
footer {
  background: #111;
  color: #fff;
  text-align: center;
  padding: 1.5rem;
  margin-top: 2rem;
  font-size: 0.9rem;
  line-height: 1.6;
}
footer a { color: var(--srt-gold); text-decoration: none; }
footer a:hover { text-decoration: underline; }

@media (max-width: 600px) { .calc-row { grid-template-columns: 1fr; } }
