/* --- index.css (首頁專用樣式) --- */
/* 包含搜尋欄、分頁標籤、站點卡片列表、ETA 資訊、全域搜尋結果等僅在首頁使用的樣式 */

body.page-index {
    padding: 100px 0 60px 0;
}

.main-header,
.tabs {
    background-color: var(--dark-bg);
    position: fixed;
    left: 0;
    right: 0;
    z-index: 100;
}

.main-header {
    top: 0;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.search-bar {
    flex-grow: 1;
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    height: var(--header-element-height);
}

.search-icon {
    color: var(--secondary-text);
    margin-right: 8px;
    font-size: 16px;
}

#search-input {
    background: none;
    border: none;
    color: var(--primary-text);
    width: 100%;
    height: 100%;
    font-size: 16px;
    font-family: var(--monospace-font);
    outline: none;
}

#search-input::placeholder {
    color: var(--secondary-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.tabs {
    top: 55px;
    display: flex;
    padding: 0 15px;
    border-bottom: 1px solid var(--border-color);
}

.tab-item {
    font-family: inherit;
    font-size: 16px;
    background: none;
    border: none;
    color: var(--secondary-text);
    text-decoration: none;
    padding: 12px 5px;
    margin-right: 20px;
    font-weight: 500;
    position: relative;
    cursor: pointer;
}

.tab-item.active {
    color: var(--highlight-color);
}

.tab-item.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--highlight-color);
    border-radius: 1.5px;
}

.tab-item.hidden {
    display: none;
}


.sub-stops-container {
    padding: 0 15px 5px 15px;
}

#stops-container {
	padding: 10px;
}

/* --- 搜尋結果與站點卡片 --- */
#global-search-results-container {
    padding: 10px;
}

#global-search-results-container h3 {
    color: var(--primary-text);
    margin-top: 0;
    margin-bottom: 15px;
    padding-left: 5px;
}

.global-search-hint {
    background-color: var(--card-bg);
    color: var(--highlight-color);
    text-align: center;
    padding: 15px;
    margin: 15px 10px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.global-search-hint:hover {
    background-color: #3a3a3c;
    transform: translateY(-1px);
}

.global-search-hint:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.stop-group-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    margin-bottom: 15px;
    overflow: hidden;
    transition: background-color 0.2s ease;
}


.global-search-card.expanded {
    background-color: #38383a;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}


.global-search-card .sub-stops-container {
    max-height: 0;
    transition: max-height 0.4s ease-in-out;
    overflow: hidden;
	padding: 0; 
}

.global-search-card.expanded .sub-stops-container {
    max-height: 500px;
}

.stop-group-header {
    display: flex;
    align-items: center;
    /* 改動：移除垂直 padding，只保留水平 padding */
    padding: 0 15px;
    /* 新增：設定一個固定的高度，讓 flexbox 為您完美置中 */
    height: 60px; 
    cursor: pointer;
}

.favorite-star {
    font-size: 24px;
    color: var(--star-inactive-color);
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
}

.favorite-star.favorited {
    color: var(--highlight-color);
    transform: scale(1.2);
}

.group-star {
    margin-right: 12px;
}

.stop-group-name {
    font-weight: 600;
    font-size: 18px;
    margin: 0;
    flex-grow: 1;
}

.stop-group-distance {
    color: var(--secondary-text);
    font-size: 14px;
    margin-left: 10px;
}

.sub-stop-section {
    border-top: 1px solid var(--border-color);
    padding: 10px 0;
}

.sub-stop-section:first-child {
    border-top: none;
    padding-top: 0;
}

.sub-stop-header {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.sub-stop-star {
    font-size: 20px;
    margin-right: 10px;
}

.sub-stop-name {
    font-weight: 500;
    color: var(--secondary-text);
}

.sub-stop-lane {
    font-weight: 500;
    color: var(--secondary-text);
    margin-left: 8px;
    font-size: 14px;
}

.eta-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    font-size: 16px;
    text-decoration: none;
    color: var(--primary-text);
    border-bottom: 1px solid var(--border-color);
}

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

.eta-route-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
}

.eta-route {
    font-weight: bold;
    font-size: 18px;
}

.eta-dest {
    font-size: 14px;
    color: var(--secondary-text);
    margin-top: 2px;
}

.eta-time {
    font-weight: bold;
    font-size: 17px;
    color: var(--highlight-color);
    text-align: right;
    min-width: 80px;
}

.eta-item-no-data {
    color: var(--secondary-text);
    padding: 8px 0;
    font-size: 14px;
}

.order-controls {
    display: flex;
    flex-direction: column;
    margin-left: 10px;
}

.order-btn {
    background: none;
    border: 1px solid var(--secondary-text);
    color: var(--secondary-text);
    border-radius: 4px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    font-size: 12px;
}

.order-btn:first-child {
    margin-bottom: 4px;
}

.loading-etas {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    color: var(--secondary-text);
    font-size: 15px;
    gap: 10px;
}

.loading-etas::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--highlight-color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

mark {
    background-color: var(--highlight-color);
    color: var(--dark-bg);
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: bold;
}

/* 新增：為全域搜尋卡片內的子站點區塊補回左右內邊距 */
.global-search-card .sub-stop-section {
    padding-left: 15px;
    padding-right: 15px;
}

/* 
 * 新增：為容器內的最後一個子站點區塊補回底部的內邊距。
 * 原本 .sub-stop-section 有 10px 的 padding-top/bottom，
 * 我們這裡將 padding-bottom 增加到 15px，以還原原始設計中容器底部的 5px 間距。
 */
.global-search-card .sub-stops-container > .sub-stop-section:last-child {
    padding-bottom: 15px; 
}

/* 確保第一個子站點頂部沒有多餘的空間，還原原始設計 */
.global-search-card .sub-stops-container > .sub-stop-section:first-child {
    padding-top: 10px; /* 保持原有的 10px 上邊距 */
}

/* --- 新增：ETA 顯示模式 --- */
.eta-grid {
    display: grid;
    /* 響應式佈局，每項最小 70px，自動填充 */
    grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
    gap: 10px;
    padding: 10px 0;
}

/* ==================== 修改此區塊 ==================== */
.eta-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--primary-text);
    
    /* 新增樣式 */
    background-color: var(--dark-bg); /* 使用比卡片稍暗的背景以區分 */
    border: 1px solid var(--border-color); /* 添加 тонкий 邊框 */
    border-radius: 8px; /* 創建圓角矩形 */
    padding: 8px 4px;
    min-width: 50px; /* 確保一個最小寬度 */
    transition: background-color 0.2s ease; /* 為 hover 效果添加過渡 */
}

/* 新增 hover 效果，提升互動性 */
.eta-grid-item:hover {
    background-color: #3a3a3c;
}
/* ==================================================== */

.eta-grid-route {
    font-size: 18px;
    font-weight: bold;
    color: var(--highlight-color); /* 根據要求，路線文字為黃色 */
    margin-bottom: 4px;
}

.eta-grid-status {
    font-size: 16px;
    font-weight: 500;
}

.eta-grid-status.critical {
    color: #ff453a; /* 根據要求，特定狀態顯示為紅色 */
    font-weight: bold;
}
/* ==================== 在此區塊新增樣式 ==================== */
/* 新增：用於在網格中橫跨顯示詳細列表的容器 */
.eta-grid-list-expansion {
    grid-column: 1 / -1; /* 關鍵：讓此元素從第一欄橫跨到最後一欄 */
    padding: 5px 0;
}

/* 為了視覺統一，移除 expansion 內部 eta-item 的外邊框，
   因為 expansion 本身已經是一個視覺分組 */
.eta-grid-list-expansion .eta-item {
    border-bottom: 1px solid var(--border-color);
    padding-left: 0;
    padding-right: 0;
}

.eta-grid-list-expansion .eta-item:last-child {
    border-bottom: none;
}
/* ======================================================== */
/* 檢視模式切換邏輯 */
/* 預設情況下，顯示列表，隱藏網格 */
.eta-list { display: block; }
.eta-grid { display: none; }

/* 當 body 標籤有 view-mode-grid class 時，反轉顯示狀態 */
body.view-mode-grid .eta-list { display: none; }
body.view-mode-grid .eta-grid { display: grid; } /* 確保以 grid 形式顯示 */

/* 當處於網格模式時，微調 sub-stop 區塊的上下間距，使其更緊湊 */
body.view-mode-grid .sub-stop-section {
    padding-top: 5px;
    padding-bottom: 5px;
}

/* --- 在 style.css 或 index.css 中添加 --- */

.placeholder-action-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 25px 20px;
    margin: 20px 10px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.placeholder-action-card h3 {
    margin-top: 0;
    font-size: 18px;
}

.placeholder-action-card p {
    color: var(--secondary-text);
    font-size: 15px;
    line-height: 1.5;
}

.action-btn {
    background-color: var(--highlight-color);
    color: var(--dark-bg);
    border: none;
    border-radius: 8px;
    padding: 12px 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 15px;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.action-btn:hover {
    background-color: #f0c92e;
}

.action-btn:active {
    transform: scale(0.98);
}