/* =========================================================
   智慧轉乘導航 & 獨立公車搜尋 - 液態玻璃樣式 (smart_trip.css)

   材質、顏色、緩動全部取自 style.css 的設計系統
   (--glass-* / --ink-* / --fill-* / --apple-* / --ease-*)，
   與天氣 HUD (weather_layer.js) 同一配方。請保持 style.css 先於本檔載入。
   ========================================================= */

/* 左上角浮動主面板 */
.smart-floating-panel {
    position: absolute;
    top: 12px;
    left: 58px;
    z-index: 1000;
    width: 306px;
    color: var(--ink);
    font-family: var(--font-sans);

    background: var(--glass-bg) !important;
    backdrop-filter: var(--glass-blur) !important;
    -webkit-backdrop-filter: var(--glass-blur) !important;

    border: var(--glass-border);
    border-radius: var(--radius-panel);
    box-shadow: var(--glass-shadow);

    padding: 14px;
    transition: transform 0.35s var(--ease-spring), max-height 0.3s var(--ease-out), box-shadow 0.25s ease;
    contain: layout style;
}

.smart-floating-panel:hover {
    box-shadow: var(--glass-shadow-hover);
}

.smart-mobile-toggle {
    display: none;
}

/* 面板內按鈕共用的鍵盤焦點外框 */
.smart-floating-panel button:focus-visible,
.smart-floating-panel a:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.9);
    outline-offset: 2px;
}

/* 頁籤內容切換進場動畫 */
#panel-view-trip,
#panel-view-bus {
    animation: panelFadeSlideIn 0.26s var(--ease-out) both;
}

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

/* 分段切換列 (Segmented Control)：與天氣 HUD 的模式列同款 */
.smart-tab-header {
    margin-bottom: 12px;
}

.smart-tab-bar {
    display: flex;
    gap: 3px;
    background: var(--fill-1);
    padding: 3px;
    border-radius: var(--radius-ctl);
    border: none;
    box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.16), inset 0 1px 3px rgba(0, 0, 0, 0.15);
}

.smart-tab-btn {
    flex: 1;
    padding: 6px 4px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 9px;
    background: transparent;
    color: var(--ink-3);
    border: none;
    box-shadow: none;
    cursor: pointer;
    transition: background-color 0.22s var(--ease-out), color 0.22s ease, transform 0.2s var(--ease-spring), box-shadow 0.22s ease;
}

.smart-tab-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--ink);
    filter: none;
}

.smart-tab-btn.active {
    background: var(--fill-3);
    color: #ffffff;
    box-shadow:
        inset 0 0.5px 0 rgba(255, 255, 255, 0.55),
        0 2px 6px rgba(0, 0, 0, 0.18);
}

.smart-section-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    text-align: left;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 4px;
    letter-spacing: 0.01em;
}

/* 地址與地標搜尋列 */
.smart-addr-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 10px;
}

.smart-addr-row {
    display: flex;
    gap: 6px;
}

.smart-input,
.smart-input-bus {
    flex: 1;
    min-width: 0;
    padding: 7px 11px;
    border: none;
    border-radius: var(--radius-field);
    background: var(--fill-1);
    box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.22), inset 0 1px 2px rgba(0, 0, 0, 0.12);
    color: var(--ink);
    font-size: 12px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.smart-input::placeholder,
.smart-input-bus::placeholder {
    color: var(--ink-3);
}

.smart-input:hover,
.smart-input-bus:hover {
    background: rgba(255, 255, 255, 0.20);
}

.smart-input:focus,
.smart-input-bus:focus {
    outline: none;
    background: var(--fill-2);
    box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.55), 0 0 0 3px rgba(10, 132, 255, 0.42);
}

/* 按鈕群：共用基底，確保不依賴全域 button 樣式 */
.smart-btn-a,
.smart-btn-b,
.smart-btn-full,
.smart-btn-danger,
.smart-btn-add-bus {
    font-weight: 600;
    color: #ffffff;
    border: none;
    cursor: pointer;
    user-select: none;
    box-shadow:
        inset 0 0.5px 0 rgba(255, 255, 255, 0.45),
        inset 0 0 0 0.5px rgba(255, 255, 255, 0.18),
        0 2px 5px rgba(0, 0, 0, 0.22);
    transition: transform 0.3s var(--ease-spring), filter 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.smart-btn-a:hover,
.smart-btn-b:hover,
.smart-btn-danger:hover,
.smart-btn-add-bus:hover {
    filter: brightness(1.12);
    box-shadow:
        inset 0 0.5px 0 rgba(255, 255, 255, 0.65),
        inset 0 0 0 0.5px rgba(255, 255, 255, 0.28),
        0 4px 10px rgba(0, 0, 0, 0.28);
}

.smart-btn-a:active,
.smart-btn-b:active,
.smart-btn-full:active,
.smart-btn-danger:active,
.smart-btn-add-bus:active {
    transform: scale(0.95);
}

.smart-btn-a {
    width: auto;
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-field);
    background: linear-gradient(180deg, #3d9bff 0%, var(--apple-blue) 100%);
}

.smart-btn-b {
    width: auto;
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-field);
    background: linear-gradient(180deg, var(--apple-red-hover) 0%, var(--apple-red) 100%);
}

.smart-btn-full {
    width: 100%;
    padding: 8px 12px;
    font-size: 12.5px;
    border-radius: 11px;
    background: var(--fill-2);
}
.smart-btn-full:hover {
    background: var(--fill-3);
}

.smart-btn-danger {
    width: 100%;
    padding: 8px 12px;
    font-size: 12.5px;
    border-radius: 11px;
    background: linear-gradient(180deg, var(--apple-red-hover) 0%, var(--apple-red) 100%);
    margin-top: 6px;
}

/* 規劃結果與模式比較卡片 */
.smart-result-box {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    padding-right: 4px;
    border-top: 0.5px solid var(--hairline);
    font-size: 12px;
    text-align: left;
    line-height: 1.55;
    max-height: 50vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
    animation: panelFadeSlideIn 0.3s var(--ease-out) both;
}

/* 攔截並修正 JS 寫在規劃結果裡的深色字體 (#1a252f, #666) */
.smart-result-box > div:first-child {
    color: var(--ink) !important;
    margin-bottom: 8px !important;
}
.smart-result-box > div:first-child > div {
    color: var(--ink-3) !important;
    margin-top: 2px;
}

.mode-card {
    cursor: pointer;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: var(--radius-ctl);
    border: none;
    color: var(--ink);
    box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.16), 0 2px 6px rgba(0, 0, 0, 0.12);
    transition: transform 0.28s var(--ease-spring), background-color 0.2s ease, box-shadow 0.25s ease;
}

.mode-card:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.40), 0 6px 14px rgba(0, 0, 0, 0.22);
}

.mode-card:active {
    transform: scale(0.98);
}

.mode-card-all {
    padding: 7px 10px;
    margin-bottom: 8px;
    background: var(--fill-2);
    color: var(--ink);
    font-weight: 600;
    text-align: center;
}
.mode-card-all:hover {
    background: var(--fill-3);
}

/* 三種交通方式維持各自的識別色（左側色條 + 同色系微光底 + 修正標題深色字） */
.mode-card-bus {
    border-left: 4px solid var(--apple-orange);
    background: linear-gradient(90deg, rgba(255, 159, 10, 0.22) 0%, rgba(255, 159, 10, 0.10) 100%);
}
.mode-card-bus:hover {
    background: linear-gradient(90deg, rgba(255, 159, 10, 0.32) 0%, rgba(255, 159, 10, 0.16) 100%);
}
.mode-card-bus .mode-card-header b:first-child {
    color: #ffb340 !important;
}

.mode-card-bike {
    border-left: 4px solid var(--apple-green);
    background: linear-gradient(90deg, rgba(48, 209, 88, 0.22) 0%, rgba(48, 209, 88, 0.10) 100%);
}
.mode-card-bike:hover {
    background: linear-gradient(90deg, rgba(48, 209, 88, 0.32) 0%, rgba(48, 209, 88, 0.16) 100%);
}
.mode-card-bike .mode-card-header b:first-child {
    color: var(--apple-green-hover) !important;
}

.mode-card-drive {
    border-left: 4px solid var(--apple-blue);
    background: linear-gradient(90deg, rgba(10, 132, 255, 0.25) 0%, rgba(10, 132, 255, 0.12) 100%);
    margin-bottom: 0;
}
.mode-card-drive:hover {
    background: linear-gradient(90deg, rgba(10, 132, 255, 0.35) 0%, rgba(10, 132, 255, 0.18) 100%);
}
.mode-card-drive .mode-card-header b:first-child {
    color: var(--apple-link) !important;
}

.mode-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}

.mode-card-detail {
    font-size: 11.5px;
    color: var(--ink-2);
    margin-top: 4px;
}

/* 攔截並提亮 JS 內寫死的 ETA 顏色 (#00897b, #d9534f) */
.mode-card-detail span[style*="color:#00897b"],
.mode-card-detail b[style*="color:#00897b"],
.leaflet-popup-content b[style*="color:#00897b"] {
    color: var(--apple-green-hover) !important;
}
.mode-card-detail b[style*="color:#d9534f"],
.leaflet-popup-content b[style*="color:#d9534f"] {
    color: var(--apple-red-hover) !important;
}

.mode-card-muted {
    font-size: 11.5px;
    color: var(--ink-3);
}

.smart-jump-link {
    display: inline-block;
    margin-top: 6px;
    color: var(--apple-link);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.15s ease, transform 0.2s var(--ease-out);
}
.smart-jump-link:hover {
    color: #98e2ff;
    text-decoration: underline;
    transform: translateX(2px);
}

/* A / B 可拖曳圓形圖釘 (加入懸停放大與呼吸陰影) */
.smart-pin-badge {
    color: #ffffff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2.5px solid #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    cursor: grab;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.38);
    transition: transform 0.25s var(--ease-spring), box-shadow 0.25s ease;
}
.smart-pin-badge:hover {
    transform: scale(1.14) translateY(-2px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.48);
}
.smart-pin-badge:active {
    cursor: grabbing;
    transform: scale(0.95);
}

/* 獨立公車搜尋面板與標籤 */
.smart-bus-view {
    display: none;
    text-align: left;
    font-size: 12px;
}

.smart-bus-search-row {
    display: flex;
    gap: 6px;
    margin-bottom: 9px;
}

.smart-btn-add-bus {
    width: auto;
    padding: 6px 14px;
    font-size: 12px;
    border-radius: var(--radius-field);
    background: linear-gradient(180deg, var(--apple-green-hover) 0%, var(--apple-green) 100%);
}

.smart-bus-tags {
    margin-bottom: 8px;
    min-height: 24px;
    color: var(--ink-2);
    font-size: 11.5px;
}

/* 攔截並修正 JS 寫在「已選路線」標題的 #333 深色字與 #888 提示字 */
.smart-bus-tags > div:first-child {
    color: var(--ink) !important;
    margin-bottom: 5px !important;
}
.smart-bus-tags span[style*="color:#888"] {
    color: var(--ink-3) !important;
}

.smart-tag-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.smart-route-chip {
    color: #ffffff;
    padding: 3.5px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.45), 0 2px 6px rgba(0, 0, 0, 0.24);
    animation: chipPopIn 0.25s var(--ease-spring) both;
    transition: transform 0.2s var(--ease-spring), filter 0.2s ease;
}

.smart-route-chip:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

@keyframes chipPopIn {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}

.smart-route-chip-close {
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.smart-route-chip-close:hover {
    opacity: 1;
    transform: scale(1.2);
}

.smart-history-chip {
    background: var(--fill-1);
    color: var(--ink-2);
    border: none;
    box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.22);
    padding: 3.5px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s var(--ease-spring);
}
.smart-history-chip:hover {
    background: var(--fill-2);
    color: var(--ink);
    transform: translateY(-1px);
}
.smart-history-chip:active {
    transform: scale(0.95);
}

.smart-bus-legend,
.smart-bus-status {
    display: none;
    margin-bottom: 8px;
    padding: 8px 11px;
    background: var(--fill-1);
    box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-field);
    font-size: 11.5px;
    line-height: 1.55;
    color: var(--ink);
    animation: panelFadeSlideIn 0.25s var(--ease-out) both;
}

/* 攔截並修復 JS 在 #locate-custom-bus-btn 寫死的深綠色 (#0f5132) 與深藍色 (#007bff) */
#locate-custom-bus-btn {
    color: var(--ink) !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}
#locate-custom-bus-btn span {
    color: var(--apple-link) !important;
    font-weight: 600;
    transition: color 0.15s ease;
}
#locate-custom-bus-btn:hover span {
    color: #98e2ff !important;
}

/* 具方向箭頭的公車動態標籤 (加上懸停放大與轉向平滑過渡) */
.smart-bus-marker-box {
    border-radius: 6px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.45), 0 3px 8px rgba(0, 0, 0, 0.38);
    display: inline-flex;
    align-items: center;
    gap: 3.5px;
    backface-visibility: hidden;
    transition: transform 0.25s var(--ease-spring), box-shadow 0.25s ease, opacity 0.3s ease;
}

.smart-bus-marker-box:hover {
    transform: scale(1.12) translateY(-1px);
    box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.70), 0 6px 14px rgba(0, 0, 0, 0.52);
}

.smart-bus-dir-badge {
    background: rgba(0, 0, 0, 0.32);
    padding: 0.5px 4px;
    border-radius: 3.5px;
    font-size: 10px;
}

/* 關鍵動畫：讓車頭方向箭頭在轉彎時平滑旋轉，不再瞬間跳格 */
.bus-heading-arrow {
    display: inline-block;
    font-size: 11px;
    line-height: 1;
    will-change: transform;
    backface-visibility: hidden;
    transition: transform 0.35s linear;
}

/* 靜態公車站牌 Popup 路線徽章（Popup 已是深色玻璃） */
.static-stop-route-badge {
    display: inline-block;
    background: var(--fill-2);
    color: var(--ink);
    padding: 2px 7px;
    margin: 2px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.25);
    transition: background-color 0.15s ease, transform 0.15s ease;
}
.static-stop-route-badge:hover {
    background: var(--fill-3);
    transform: translateY(-1px);
}

/* 減少動態效果：取消彈簧位移與縮放 */
@media (prefers-reduced-motion: reduce) {
    .smart-floating-panel,
    .smart-tab-btn,
    .smart-btn-a,
    .smart-btn-b,
    .smart-btn-full,
    .smart-btn-danger,
    .smart-btn-add-bus,
    .mode-card,
    .smart-route-chip,
    .smart-history-chip,
    .smart-bus-marker-box,
    .bus-heading-arrow,
    #panel-view-trip,
    #panel-view-bus,
    .smart-result-box {
        transition: none !important;
        animation: none !important;
    }
    .smart-btn-a:active,
    .smart-btn-b:active,
    .smart-btn-full:active,
    .smart-btn-danger:active,
    .smart-btn-add-bus:active,
    .mode-card:hover,
    .smart-bus-marker-box:hover {
        transform: none;
    }
}

/* =========================================================
   手機版 RWD 底部玻璃抽屜 (保留防重疊設計並強化滑動過渡)
   ========================================================= */
@media (max-width: 768px) {
    .smart-floating-panel {
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        border-radius: 24px 24px 0 0 !important;
        border: none !important;
        max-height: 60dvh;
        overflow-y: auto;
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
        background: var(--glass-bg-dense) !important;
        backdrop-filter: var(--glass-blur) !important;
        -webkit-backdrop-filter: var(--glass-blur) !important;
        box-shadow:
            inset 0 0.5px 0 rgba(255, 255, 255, 0.55),
            0 -8px 28px rgba(0, 0, 0, 0.26) !important;
        transition: max-height 0.35s var(--ease-out), padding 0.35s var(--ease-out);
    }

    .smart-floating-panel.minimized {
        max-height: calc(56px + env(safe-area-inset-bottom, 0px));
        overflow: hidden;
        padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    }

    .smart-mobile-toggle {
        display: block;
        float: right;
        background: var(--fill-2);
        color: var(--ink);
        border: none;
        border-radius: 8px;
        padding: 5px 14px;
        font-size: 12px;
        font-weight: 600;
        cursor: pointer;
        margin-left: 6px;
        box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.4);
        transition: background-color 0.2s ease, transform 0.2s var(--ease-spring);
    }
    .smart-mobile-toggle:active {
        transform: scale(0.94);
    }

    .leaflet-bottom.leaflet-left,
    .leaflet-bottom.leaflet-right {
        bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
        transition: bottom 0.3s var(--ease-out);
    }
}