@charset "UTF-8";

/* =========================================
   全域變數與基礎設定
   ========================================= */
:root {
  --primary-color: #2c3e50;
  --secondary-color: #3498db;
  --accent-color: #e74c3c;
  --background-color: #ecf0f1;
  --text-color: #333;
  --border-color: #ddd;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  margin: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

/* =========================================
   導覽列 (Navbar)
   ========================================= */
nav {
  background-color: var(--primary-color);
  width: 100%;
  padding: 10px 0;
  border-radius: 8px;
  margin-bottom: 30px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  max-width: 100%;
}

.nav-links {
  display: flex;
  flex-wrap: nowrap;
  overflow: hidden;
  align-items: center;
  justify-content: center;
}

nav a {
  color: white;
  text-decoration: none;
  font-size: 1.1rem;
  margin: 0 8px;
  padding: 8px 12px;
  border-radius: 4px;
  transition: background-color 0.3s;
  white-space: nowrap;
  flex-shrink: 0;
}

nav a:hover,
nav a.active {
  background-color: var(--secondary-color);
}

/* 「更多」下拉按鈕與選單 */
.nav-more {
  position: relative;
  flex-shrink: 0;
  margin-left: 4px;
}

.nav-more-btn {
  background-color: transparent;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 8px 14px;
  font-size: 1rem;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.3s;
  width: auto;
  margin-top: 0;
}

.nav-more-btn:hover {
  background-color: var(--secondary-color);
}

.nav-more-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background-color: var(--primary-color);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  min-width: 140px;
  z-index: 1000;
  overflow: hidden;
}

.nav-more-menu.show {
  display: block;
  animation: navMenuFadeIn 0.15s ease-out;
}

@keyframes navMenuFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.nav-more-menu a {
  display: block;
  color: white;
  text-decoration: none;
  padding: 10px 16px;
  font-size: 1rem;
  margin: 0;
  border-radius: 0;
  transition: background-color 0.2s;
  white-space: nowrap;
}

.nav-more-menu a:hover,
.nav-more-menu a.active {
  background-color: var(--secondary-color);
}

/* =========================================
   標題與文字
   ========================================= */
h1 {
  color: var(--primary-color);
  margin-bottom: 10px;
}

h2 {
  color: #7f8c8d;
  font-weight: 400;
  font-size: 1.2rem;
  margin-bottom: 30px;
}

.info-section {
  background-color: #fff;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  max-width: 600px;
  width: 90%;
  margin-bottom: 20px;
  line-height: 1.6;
}

#server-status {
  margin-bottom: 10px;
  font-weight: bold;
  color: var(--accent-color);
}

#loading-status,
#loading-routes-status,
#loading-stops-status {
  font-size: 1rem;
  color: var(--secondary-color);
  margin-top: 10px;
  font-weight: bold;
}

#error-message {
  color: var(--accent-color);
  margin-top: 15px;
  font-weight: bold;
}

.input-error {
  color: var(--accent-color);
  font-size: 0.85rem;
  font-weight: 500;
  margin-left: 6px;
  white-space: nowrap;
}

/* =========================================
   表單容器與輸入元件
   ========================================= */
.form-container {
  background-color: white;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  width: 90%;
  max-width: 800px;
  /* Increased to fit side-by-side inputs */
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: flex-end;
  /* Align bottom to match labels */
}

.form-group-item {
  flex: 1;
  min-width: 200px;
}

.form-group-item label {
  margin-bottom: 5px;
}

.form-group-item select {
  margin-bottom: 0;
}

label {
  font-size: 1.1rem;
  margin-bottom: 10px;
  display: block;
  font-weight: 500;
}

select,
input[type="number"] {
  width: 100%;
  padding: 10px;
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 1rem;
  box-sizing: border-box;
  /* 確保 padding 不會撐大寬度 */
}

button {
  background-color: var(--secondary-color);
  color: white;
  border: none;
  padding: 12px 20px;
  font-size: 1rem;
  border-radius: 4px;
  cursor: pointer;
  width: 100%;
  transition: background-color 0.3s;
  margin-top: 10px;
}

button:hover {
  background-color: #2980b9;
}

button[type="submit"] {
  background-color: #27ae60;
  font-weight: bold;
  margin-top: 20px;
}

button[type="submit"]:hover {
  background-color: #2ecc71;
}

/* 移除按鈕特定樣式 */
.remove-btn {
  background-color: var(--accent-color);
  width: auto;
  padding: 5px 10px;
  font-size: 0.9rem;
  margin-top: 0;
  margin-left: 10px;
  align-self: flex-start;
  /* 讓按鈕靠上對齊 */
}

.remove-btn:hover {
  background-color: #c0392b;
}

/* =========================================
   動態輸入介面 (inputline)
   ========================================= */
.line-item {
  background-color: #f8f9fa;
  padding: 15px;
  border-radius: 6px;
  margin-bottom: 15px;
  border: 1px solid #e9ecef;
  display: flex;
  flex-direction: column;
  /* 手機版垂直排列 */
}

@media (min-width: 600px) {
  .line-item {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .line-item select,
  .line-item input {
    margin-bottom: 0;
    margin-right: 10px;
  }

  .line-item select {
    flex: 2;
  }

  .line-item input {
    flex: 1;
    width: 60px;
  }

  .line-item label {
    margin-bottom: 0;
    margin-right: 5px;
    white-space: nowrap;
  }
}

.button-container {
  display: flex;
  gap: 10px;
}

.button-container button {
  flex: 1;
}

#reset-btn {
  background-color: #95a5a6;
}

#reset-btn:hover {
  background-color: #7f8c8d;
}

/* =========================================
   結果顯示
   ========================================= */
#result {
  margin-top: 20px;
  font-size: 1.2rem;
  color: var(--primary-color);
  text-align: center;
}

/* =========================================
   Footer
   ========================================= */
#footer {
  margin-top: 40px;
  color: #7f8c8d;
  font-size: 0.9rem;
  text-align: center;
}

#footer .disclaimer {
  color: var(--accent-color);
  font-weight: 500;
  margin-bottom: 8px;
}


/* =========================================
   查詢站牌頁面樣式
   ========================================= */
.stations-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 20px;
  justify-content: center;
  width: 95%;
  max-width: 1200px;
}

.station-column {
  flex: 1;
  min-width: 300px;
  max-width: 450px;
  /* 限制單欄最大寬度 */
  background-color: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  align-self: flex-start;
}

.station-column h3 {
  text-align: center;
  color: var(--primary-color);
  border-bottom: 2px solid var(--secondary-color);
  padding-bottom: 10px;
  margin-top: 0;
  margin-bottom: 15px;
}

.station-list {
  list-style: none;
  padding: 0;
  max-height: 600px;
  /* 設定最大高度 */
  overflow-y: auto;
  /* 超出則捲動 */
}

/* 自訂捲軸樣式 */
.station-list::-webkit-scrollbar {
  width: 8px;
}

.station-list::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.station-list::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

.station-list::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}


.station-item {
  display: flex;
  padding: 10px;
  border-bottom: 1px solid #eee;
  align-items: center;
  transition: background-color 0.2s;
}

.station-item:last-child {
  border-bottom: none;
}

.station-item:hover {
  background-color: #f0f8ff;
  /* 淺藍色 highlight */
}

.station-seq {
  background-color: var(--secondary-color);
  color: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: bold;
  margin-right: 12px;
  flex-shrink: 0;
}

.station-name {
  font-weight: 500;
  color: #333;
  font-size: 1rem;
}

/* CSS for segment info */
.station-segment {
  background-color: #f0f0f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

/* Warning Banner for Dual Terminal Routes */
.warning-banner {
  background-color: #fff3cd;
  color: #856404;
  padding: 10px;
  margin-bottom: 20px;
  border-radius: 5px;
  border: 1px solid #ffeeba;
  width: 90%;
  max-width: 500px;
  text-align: center;
  box-sizing: border-box;
}

/* Custom Searchable Select */
.searchable-select {
  position: relative;
  width: 100%;
}

.searchable-select input {
  margin-bottom: 0;
}

.dropdown-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 250px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  list-style: none;
  padding: 0;
  margin: 0;
  display: none;
}

.dropdown-list.show {
  display: block;
}

.dropdown-item {
  padding: 10px;
  cursor: pointer;
  border-bottom: 1px solid #f1f1f1;
  transition: background-color 0.2s;
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover,
.dropdown-item.active {
  background-color: #f0f8ff;
  color: var(--secondary-color);
}

.dropdown-item .match-highlight {
  color: var(--secondary-color);
  font-weight: bold;
}

/* Clear Button */
.clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1.2rem;
  color: #999;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  /* Flex to center content */
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-top: 0 !important;
  /* Override standard button margin */
}

.clear-btn:hover {
  background-color: #f1f1f1;
  color: #666;
}

/* Phantom Stop Styling (Virtual Stops) */
.phantom-stop {
  opacity: 0.5;
  background-color: #f9f9f9;
}

.phantom-stop:hover {
  background-color: #f0f0f0;
}

.phantom-stop .station-name,
.phantom-stop .station-seq,
.phantom-stop .station-segment {
  color: #aaa;
}

/* Ensure seqNo circle is also dim */
.phantom-stop .station-seq {
  background-color: #e0e0e0;
  color: #999;
  border: 1px solid #ccc;
}