/* =========================================
   TwinTraffic Editor - Style.css
   Based on Simulator Theme
   ========================================= */

:root {
    /* 色彩系統 (Slate & Blue Theme) */
    --bg-dark: #1e293b;
    /* Navbar */
    --bg-light: #ffffff;
    /* Toolbar/Panels */
    --bg-canvas: #e2e8f0;
    /* Canvas Background */
    --bg-panel: #f8fafc;
    /* Properties Panel Background */

    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #06b6d4;
    --success: #10b981;
    --danger: #ef4444;

    --text-main: #334155;
    --text-muted: #64748b;
    --text-inv: #f8fafc;

    --border: #cbd5e1;
    --border-light: #e2e8f0;

    /* 尺寸定義 */
    --h-nav: 50px;
    --h-toolbar: 70px;
    /* [修改] 稍微增加高度以容納文字 */
    --w-sidebar: 300px;

    --radius-sm: 4px;
    --radius-md: 6px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-canvas);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- 1. Navbar (Top) --- */
.app-navbar {
    height: var(--h-nav);
    background-color: var(--bg-dark);
    color: var(--text-inv);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 20;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 1.2rem;
    color: var(--accent);
}

.brand-text h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    display: inline;
}

.version-tag {
    background: #475569;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    margin-left: 6px;
}

.global-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.separator {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 5px;
}

/* Buttons & Inputs in Navbar */
.dropdown-dark {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-input {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-input.primary {
    background: var(--primary);
    color: white;
}

.btn-input.primary:hover {
    background: var(--primary-hover);
}

.btn-input.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #ddd;
}

.btn-input.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* --- Language Select Styling --- */
.language-select {
    height: 32px;
    /* 與按鈕高度一致 */
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-inv);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 0 8px;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

.language-select:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.language-select:focus {
    border-color: var(--primary);
    background-color: rgba(255, 255, 255, 0.15);
}

/* 修正下拉選單內的選項在某些瀏覽器如果是白底黑字的情況 */
.language-select option {
    background-color: var(--bg-dark);
    color: white;
}

/* --- 2. Toolbar (Sub-top) --- */
.app-toolbar {
    height: var(--h-toolbar);
    background-color: var(--bg-light);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 10px;
    gap: 5px;
    z-index: 10;
    flex-shrink: 0;
    overflow: visible;
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 4px;
}

.divider-v {
    width: 1px;
    height: 32px;
    background-color: var(--border);
    margin: 0 8px;
}

/* Tool Button Styling (Updated) */
.tool-btn {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-main);
    padding: 4px 8px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    /* Icon top, Text bottom */
    align-items: center;
    justify-content: center;
    min-width: 40px;
    /* 稍微加寬 */
    height: 52px;
    /* 固定高度 */
    transition: all 0.2s;
    gap: 4px;
}

/* Icon size */
.tool-btn i {
    font-size: 1.1rem;
    margin-bottom: 2px;
}

/* Text label styling */
.tool-btn .btn-text {
    font-size: 0.65rem;
    /* 小字體 */
    font-weight: 500;
    white-space: nowrap;
    line-height: 1;
    display: block;
    /* 預設顯示 */
}

.tool-btn:hover {
    background-color: #f1f5f9;
    color: var(--primary);
}

.tool-btn.active {
    background-color: #eff6ff;
    color: var(--primary);
    border-color: rgba(59, 130, 246, 0.2);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* --- 3. Main Layout --- */
#main-content {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    position: relative;
}

/* Right Sidebar (Properties) */
#properties-panel {
    width: var(--w-sidebar);
    background: var(--bg-panel);
    /* 修改：將右邊框改為左邊框 */
    border-left: 1px solid var(--border);
    border-right: none;

    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 5;
    /* 修改：陰影方向改為負值 (-2px) */
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.02);
}


.panel-header {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 600;
}

.live-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    color: white;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

/* --- Properties Panel Professional Styling --- */

/* 1. 區塊標題：用於分組 (如 GENERAL, GEOMETRY) */
.prop-section-header {
    font-size: 0.7rem;
    font-weight: 700;
    color: #94a3b8;
    /* Muted slate color */
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 16px 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-light);
}

/* 第一個標題不需要上方 margin */
.prop-section-header:first-child {
    margin-top: 0;
}

/* 2. 屬性列：左右佈局 (Label --- Input) */
.prop-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 10px;
}

/* 3. 標籤樣式 */
.prop-label {
    font-size: 0.85rem;
    color: var(--text-main);
    flex-shrink: 0;
    /* 防止標籤被壓縮 */
    max-width: 140px;
    user-select: none;
}

/* 4. 輸入框與 Select 通用樣式 */
/* 4. 輸入框與 Select 通用樣式 (保留原有的) */
.prop-input,
.prop-select {
    flex: 1;
    width: 100%;
    min-width: 0;
    padding: 6px 8px;
    font-size: 0.85rem;
    color: #1e293b;
    background-color: #ffffff;
    border: 1px solid var(--border);
    border-radius: 4px;
    transition: all 0.2s ease;

    /* 數值預設靠右，這樣金額、尺寸等數據比較好閱讀 */
    text-align: right;
}

/* [修正] 下拉選單文字強制靠左，便於閱讀選項*/
.prop-select {
    text-align: left;
}

/* [新增] 針對文字輸入框 (如 Name, ID) 強制靠左對齊 */
.prop-input[type="text"] {
    text-align: left;
}


.prop-input:focus,
.prop-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* 確保 disabled 的輸入框 (如 ID) 也是靠左比較自然 */
.prop-input:disabled {
    background-color: #f1f5f9;
    color: #94a3b8;
    border-color: transparent;
    cursor: default;
    text-align: left;
}

/* 5. 純文字數值顯示 (Read-only text) */
.prop-value-text {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* 6. 車道寬度網格佈局 (Lane Widths Grid) */
.prop-grid-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* 兩欄 */
    gap: 8px;
    margin-top: 4px;
}

.prop-grid-item {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 2px 4px;
}

.prop-grid-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-right: 6px;
    white-space: nowrap;
}

.prop-grid-input {
    border: none;
    background: transparent;
    width: 100%;
    text-align: right;
    font-size: 0.85rem;
    outline: none;
    padding: 4px 0;
}

.prop-grid-input:focus {
    color: var(--primary);
    font-weight: 600;
}

/* 7. 提示區塊 */
.prop-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: #f8fafc;
    padding: 8px;
    border-radius: 4px;
    margin-top: 10px;
    border: 1px dashed var(--border);
    line-height: 1.4;
}

/* Action Buttons in Panel */
#properties-content button.tool-btn,
#properties-content button.tool-btn-secondary {
    width: 100%;
    background: white;
    border: 1px solid var(--border);
    padding: 8px;
    margin-top: 5px;
    text-align: center;
    border-radius: var(--radius-sm);
    color: var(--text-main);
    /* 重置 tool-btn 在 toolbar 中的特定樣式 */
    display: block;
    height: auto;
    min-width: auto;
}

#properties-content button:hover {
    background: #f8fafc;
    border-color: var(--primary);
    color: var(--primary);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    margin-top: 40px;
}

.empty-state i {
    font-size: 2rem;
    margin-bottom: 10px;
    opacity: 0.3;
}

/* --- 4. Canvas Area --- */
#canvas-container {
    flex: 1;
    background-color: var(--bg-canvas);
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 20px 20px;
    position: relative;
    overflow: hidden;
}

#status-bar {
    position: absolute;
    bottom: 15px;
    left: 15px;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    pointer-events: none;
    z-index: 10;
}

/* 背景鎖定浮動按鈕 */
#bg-lock-float {
    position: absolute;
    bottom: 20px;
    /*稍微往上移，避免貼底*/
    right: 20px;
    /*稍微往左移*/
    background: white;
    padding: 8px 12px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    /* 加深陰影 */
    border: 1px solid var(--border);
    z-index: 100;
    /* [重要] 提高層級，確保在最上層 */
    font-size: 0.9rem;
    display: none;
    /* 預設隱藏，JS 會在新增背景後將其改為 block */
}

#bg-lock-float label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    color: var(--text-main);
    font-weight: 500;
}

#bg-lock-float input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* --- 5. Modals --- */
.modal {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1000;
}

.modal-content {
    background: white;
    margin: 5vh auto;
    width: 90%;
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal-content.large {
    max-width: 900px;
}

.modal-content.small {
    max-width: 320px;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-main);
}

.close-button {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-light);
    background: #f8fafc;
    text-align: right;
    border-radius: 0 0 8px 8px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 15px;
}

.tab-link {
    background: none;
    border: none;
    padding: 10px 15px;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.tab-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    text-align: left;
    background: #f1f5f9;
    padding: 8px;
    color: var(--text-muted);
    font-weight: 600;
}

td {
    padding: 8px;
    border-bottom: 1px solid var(--border-light);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.popover-style {
    position: absolute;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    margin: 0;
}

/* --- New Toolbar Toggle Button (Lock) --- */
.tool-check-label {
    border: 1px solid transparent;
    color: var(--text-main);
    padding: 4px 8px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    height: 52px;
    transition: all 0.2s;
    gap: 4px;
    user-select: none;
}

.tool-check-label input {
    display: none;
    /* 隱藏原始 Checkbox */
}

.tool-check-label i {
    font-size: 1.1rem;
    margin-bottom: 2px;
}

.tool-check-label .btn-text {
    font-size: 0.65rem;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1;
}

.tool-check-label:hover {
    background-color: #f1f5f9;
}

/* 當被鎖定 (Checked) 時的樣式：變紅 */
.tool-check-label:has(input:checked) {
    background-color: #fee2e2;
    /* 淺紅色背景 */
    color: #dc2626;
    /* 深紅色文字 */
    border-color: #fecaca;
}

/* --- Professional Modal Styling (Connection Settings) --- */

/* 1. Modal 內部佈局微調 */
.modal-content.popover-style {
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    overflow: hidden;
}

/* 2. Modal 標題列 */
.modal-header.compact {
    padding: 10px 15px;
    background: #f1f5f9;
    border-bottom: 1px solid var(--border);
}

.modal-header.compact h4 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* 3. Modal 內容格線系統 */
.modal-pro-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* 左右兩欄：來源 vs 目的 */
    gap: 15px;
    padding: 15px;
}

.modal-col-header {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 4. 輸入框群組 */
.modal-input-group {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.modal-input {
    width: 60px;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-main);
}

.modal-input:focus {
    border-color: var(--primary);
    outline: none;
}

/* 5. 底部按鈕區 */
.modal-footer.compact {
    padding: 10px 15px;
    background: #ffffff;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 0.8rem;
    border-radius: 4px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-cancel {
    background: transparent;
    color: #64748b;
    border: 1px solid transparent;
}

.btn-cancel:hover {
    color: #334155;
    background: #f1f5f9;
}

.btn-save {
    background: var(--primary);
    color: white;
    border: 1px solid var(--primary);
}

.btn-save:hover {
    background: var(--primary-hover);
}

/* 6. 屬性面板專用：刪除按鈕樣式 */
.btn-danger-outline {
    width: 100%;
    margin-top: 12px;
    padding: 8px;
    color: #ef4444;
    background: white;
    border: 1px solid #fecaca;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-danger-outline:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

.btn-group-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.btn-action {
    flex: 1;
    padding: 6px;
    font-size: 0.8rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: white;
    cursor: pointer;
}

.btn-action:hover {
    background: #f8fafc;
    border-color: var(--primary);
    color: var(--primary);
}

/* --- Traffic Light Editor Table Alignment --- */

/* 1. 表格整體設定 */
#tfl-schedule-table {
    width: 100%;
    border-collapse: separate;
    /* 使用 separate 以便設定圓角或間距 */
    border-spacing: 0;
}

/* 2. 表頭 (Group Name) - 垂直水平置中 */
#tfl-schedule-table th {
    text-align: center;
    /* 水平置中 */
    vertical-align: middle;
    /* 垂直置中 */
    padding: 10px 8px;
    /* 上下留白，讓標題不擁擠 */
    background: #f8fafc;
    /* 淺灰背景 */
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 2px solid var(--border);
    /* 加強表頭分隔線 */
    white-space: nowrap;
    /* 防止群組名稱換行 */
}

/* 3. 表格內容 (Color Blocks) - 垂直水平置中 */
#tfl-schedule-table td {
    text-align: center;
    /* 水平置中 */
    vertical-align: middle;
    /* 垂直置中 */
    padding: 8px 4px;
    border-bottom: 1px solid var(--border-light);
    height: 40px;
    /* 設定最小高度，確保列高一致 */
}

/* 4. 輸入框在表格內的微調 */
#tfl-schedule-table .prop-input {
    width: 100%;
    max-width: 80px;
    margin: 0 auto;
    /* 確保輸入框本身也置中 */
    text-align: center;
}

/* 5. 色塊在表格內的微調 (確保 inline-block 不受 line-height 影響偏位) */
.signal-block {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: transform 0.1s ease, box-shadow 0.2s ease;
    vertical-align: middle;
    /* 關鍵：讓色塊與單元格中心線對齊 */
    margin-top: -2px;
    /* 微調視覺重心 */
}

/* ... (保留原本的 hover 與 color class 設定) ... */
.signal-block:hover {
    transform: scale(1.1);
    border-color: rgba(0, 0, 0, 0.3);
}

.signal-red {
    background-color: #ef4444;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.signal-yellow {
    background-color: #f59e0b;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
}

.signal-green {
    background-color: #22c55e;
    box-shadow: 0 2px 4px rgba(34, 197, 94, 0.3);
}

/* --- Flow & Detector Professional Styling --- */

/* 1. 卡片式列表項目 (用於 Vehicle Mix) */
.prop-card {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

/* 2. 卡片內的列佈局 */
.prop-card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.prop-card-row:last-child {
    margin-bottom: 0;
}

/* 3. 緊湊型標籤 (用於卡片內) */
.prop-card-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* 4. 緊湊型輸入框 (用於權重輸入) */
.prop-card-input {
    width: 60px;
    padding: 2px 4px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    text-align: right;
}

/* 5. 迷你按鈕 (刪除/新增) */
.btn-mini {
    padding: 2px 6px;
    font-size: 0.75rem;
    border-radius: 3px;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn-mini-danger {
    background: #fee2e2;
    color: #dc2626;
}

.btn-mini-danger:hover {
    background: #fecaca;
}

.btn-full {
    width: 100%;
    margin-top: 4px;
    padding: 6px;
    font-size: 0.8rem;
    border: 1px dashed var(--border);
    background: #f8fafc;
    color: var(--primary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-full:hover {
    background: #eff6ff;
    border-color: var(--primary);
}

/* --- Vehicle Spawner Editor Professional Styling --- */

/* 1. 外層容器調整 */
#spawner-modal .modal-content {
    background-color: #f8fafc;
    /* 淺灰背景，區分卡片 */
    border: 1px solid var(--border);
}

/* 2. 時間週期卡片 (Time Period Card) */
.spawner-card {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    position: relative;
}

/* 3. 卡片標題列 */
.spawner-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.spawner-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 8px;
}

.spawner-card-title i {
    color: var(--primary);
}

/* 4. 輸入格線佈局 (用於 Duration/Count) */
.spawner-grid-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 16px;
}

.spawner-input-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
}

/* 5. 內部表格樣式 */
.spawner-sub-section {
    margin-top: 16px;
}

.spawner-sub-header {
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.spawner-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem;
    margin-bottom: 8px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    overflow: hidden;
}

.spawner-table th {
    background: #f1f5f9;
    color: var(--text-muted);
    font-weight: 600;
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.75rem;
}

.spawner-table td {
    background: #fff;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-light);
}

.spawner-table tr:last-child td {
    border-bottom: none;
}

/* 6. Profile 參數格線 (4欄) */
.profile-params-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    background: #f8fafc;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid var(--border-light);
}

/* 7. 按鈕微調 */
.btn-dashed {
    width: 100%;
    border: 1px dashed var(--border);
    background: transparent;
    color: var(--text-muted);
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-dashed:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #eff6ff;
}

.btn-icon-only {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 0.9rem;
    border-radius: 3px;
}

.btn-icon-only:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* --- Parking & Gate Specific Styling --- */

/* 狀態指示器 (用於 Gate 連接狀態) */
.prop-status-indicator {
    padding: 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    border: 1px solid transparent;
}

.prop-status-indicator.success {
    background-color: #f0fdf4;
    /* 淺綠 */
    color: #15803d;
    /* 深綠 */
    border-color: #bbf7d0;
}

.prop-status-indicator.error {
    background-color: #fef2f2;
    /* 淺紅 */
    color: #b91c1c;
    /* 深紅 */
    border-color: #fecaca;
}

/* --- Properties Panel Tabs --- */

/* 1. 分頁容器 */
.prop-tab-header {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
    background: #fff;
}

/* 2. 分頁按鈕 */
.prop-tab-btn {
    flex: 1;
    padding: 8px 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}

.prop-tab-btn:hover {
    color: var(--primary);
    background-color: #f8fafc;
}

/* 3. 激活狀態 */
.prop-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* 4. 分頁內容區塊 */
.prop-tab-content {
    display: none;
    /* 預設隱藏 */
    animation: fadeIn 0.2s ease-in-out;
}

.prop-tab-content.active {
    display: block;
    /* 激活時顯示 */
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(2px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Traffic Light Daily Plans UI --- */

/* 1. 視覺化時間軸 (Timeline Bar) */
.tfl-timeline-container {
    position: relative;
    width: 100%;
    height: 30px;
    background-color: #e2e8f0;
    border-radius: 6px;
    margin-bottom: 25px;
    /* 留空間給刻度 */
    display: flex;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
}

.tfl-timeline-segment {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid rgba(255, 255, 255, 0.3);
    transition: width 0.3s ease;
    /* 動畫過渡效果 */
}

.tfl-timeline-segment:last-child {
    border-right: none;
}

.seg-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.7rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 4px;
}

/* 時間軸刻度 */
.tfl-timeline-ticks {
    position: relative;
    width: 100%;
    height: 15px;
    margin-top: 4px;
}

.tfl-timeline-ticks span {
    position: absolute;
    font-size: 0.65rem;
    color: var(--text-muted);
    transform: translateX(-50%);
}

.tfl-timeline-ticks span::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    width: 1px;
    height: 4px;
    background-color: var(--border);
}

/* 2. 觸發點列表行 (Checkpoint Row) */
.tfl-checkpoint-row {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--border-light);
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    gap: 15px;
    transition: background 0.2s;
}

.tfl-checkpoint-row:hover {
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.cp-time {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
}

.cp-time-input {
    width: 100px;
    font-family: 'Roboto Mono', monospace;
    font-weight: 600;
}

.cp-action {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.cp-schedule {
    flex: 1;
}

.cp-delete {
    width: 30px;
    text-align: right;
}

/* ==========================================================================
   Traffic Light Editor - 膠囊分頁列與階層式時制庫樣式
   ========================================================================== */
.tfl-pill-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 12px;
}

.tfl-pill-bar-tier1 {
    background: #f5f3ff;
    border-color: #ddd6fe;
    margin-bottom: 8px;
}

.tfl-library-tier2-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 12px;
    margin-bottom: 12px;
}

.tfl-pill-bar-tier2 {
    background: transparent;
    border: none;
    padding: 0;
    margin-bottom: 0;
    flex: 1;
}

.tfl-timeshift-box {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-left: 10px;
    border-left: 1px solid #e2e8f0;
}

.tfl-pill-bar-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
    margin-right: 4px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.tfl-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #334155;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.tfl-pill:hover {
    border-color: #94a3b8;
    background: #f1f5f9;
}

.tfl-pill.active {
    background: #ede9fe;
    border-color: #8b5cf6;
    color: #5b21b6;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(139, 92, 246, 0.18);
}

.tfl-pill.tfl-pill-schedule.active {
    background: #dbeafe;
    border-color: #3b82f6;
    color: #1d4ed8;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(59, 130, 246, 0.18);
}

.tfl-pill-sub {
    font-size: 0.72rem;
    opacity: 0.75;
    font-weight: 400;
}

.tfl-pill-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.75);
    color: inherit;
    font-size: 0.7rem;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, color 0.15s, transform 0.1s;
}

.tfl-pill-icon-btn:hover {
    background: #ffffff;
    transform: scale(1.08);
}

.tfl-pill-icon-btn.danger:hover {
    background: #fee2e2;
    color: #ef4444;
}

.tfl-pill-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px dashed #94a3b8;
    background: rgba(255, 255, 255, 0.6);
    color: #475569;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tfl-pill-add-btn:hover {
    border-color: #6366f1;
    color: #4f46e5;
    background: #eef2ff;
}

.tfl-pill-inline-input {
    width: 125px;
    padding: 2px 6px;
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid #6366f1;
    border-radius: 4px;
    background: #ffffff;
    color: #0f172a;
    outline: none;
}


/* =========================================================
   Synchro Mode Toolbar & Visual Lane/Turn Diagram Picker
   ========================================================= */
.synchro-mode-btn {
    position: relative;
    border: 1.5px solid #cbd5e1 !important;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
    color: #334155 !important;
    transition: all 0.2s ease !important;
}

.synchro-mode-btn i {
    color: #f59e0b !important;
}

.synchro-mode-btn.synchro-active {
    border-color: #f59e0b !important;
    background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%) !important;
    color: #b45309 !important;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25), 0 2px 6px rgba(245, 158, 11, 0.2) !important;
}

.synchro-badge {
    font-size: 9px;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #64748b;
    letter-spacing: 0.4px;
    margin-top: 1px;
}

.synchro-mode-btn.synchro-active .synchro-badge {
    background: #f59e0b;
    color: #ffffff;
}

.synchro-panel-box {
    background: linear-gradient(180deg, #fffbeb 0%, #ffffff 100%);
    border: 1.5px solid #fcd34d;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.synchro-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #92400e;
}

.synchro-lane-count-bar {
    display: flex;
    align-items: center;
    gap: 4px;
}

.synchro-count-btn {
    padding: 2px 7px;
    font-size: 0.75rem;
    font-weight: 700;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #ffffff;
    color: #334155;
    cursor: pointer;
}

.synchro-count-btn.active {
    background: #f59e0b;
    color: #ffffff;
    border-color: #d97706;
}

.synchro-road-strip {
    display: flex;
    align-items: stretch;
    justify-content: center;
    background: #334155;
    border-left: 3px solid #facc15;
    border-right: 3px solid #e2e8f0;
    border-top: 4px solid #ffffff;
    border-radius: 6px;
    padding: 6px 4px;
    margin-bottom: 8px;
    gap: 4px;
}

.synchro-lane-col {
    flex: 1;
    min-width: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px 6px 4px;
    border-radius: 5px;
    border: 1.5px solid transparent;
    background: rgba(15, 23, 42, 0.35);
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
    position: relative;
}

.synchro-lane-col:hover {
    background: rgba(15, 23, 42, 0.65);
    border-color: rgba(147, 197, 253, 0.6);
}

.synchro-lane-col.selected {
    background: #1e293b;
    border-color: #38bdf8;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.synchro-lane-arrow-big {
    font-size: 1.35rem;
    font-weight: 900;
    color: #ffffff;
    line-height: 1.1;
    letter-spacing: -1px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    margin-bottom: 4px;
}

.synchro-lane-col.selected .synchro-lane-arrow-big {
    color: #38bdf8;
}

.synchro-lane-label {
    font-size: 0.68rem;
    color: #cbd5e1;
    font-weight: 600;
    margin-bottom: 2px;
}

.synchro-lane-code-badge {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #94a3b8;
}

.synchro-lane-col.selected .synchro-lane-code-badge {
    background: rgba(56, 189, 248, 0.2);
    color: #7dd3fc;
}

/* 下方共用單排大尺寸轉向選擇器 */
.synchro-shared-turn-bar {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 7px 8px;
}

.synchro-shared-turn-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.74rem;
    color: #334155;
    margin-bottom: 6px;
}

.synchro-turn-pills {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

.synchro-turn-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px 2px;
    border-radius: 5px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s ease;
    gap: 1px;
}

.synchro-turn-pill .pill-arrow {
    font-size: 0.95rem;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -1px;
}

.synchro-turn-pill .pill-code {
    font-size: 0.58rem;
    font-weight: 700;
    opacity: 0.7;
}

.synchro-turn-pill:hover {
    border-color: #3b82f6;
    background: #eff6ff;
    color: #1d4ed8;
}

.synchro-turn-pill.active {
    background: #2563eb;
    border-color: #1d4ed8;
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}

.synchro-turn-pill {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 1px 3.5px;
    border-radius: 3px;
    border: 1px solid #64748b;
    background: #1e293b;
    color: #cbd5e1;
    cursor: pointer;
    line-height: 1.2;
}

.synchro-turn-pill:hover {
    border-color: #93c5fd;
    color: #ffffff;
}

.synchro-turn-pill.active {
    background: #3b82f6;
    border-color: #60a5fa;
    color: #ffffff;
}

.synchro-preset-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-top: 6px;
}

.synchro-preset-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px 4px;
    background: #1e293b;
    border: 1.5px solid #475569;
    border-top: 3px solid #f8fafc;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s ease;
    color: #f8fafc;
}

.synchro-preset-card:hover {
    border-color: #f59e0b;
    transform: translateY(-1px);
}

.synchro-preset-card.active {
    border-color: #f59e0b;
    background: #0f172a;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
}

.synchro-preset-lanes {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.synchro-preset-lane-cell {
    flex: 1;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 800;
    color: #ffffff;
    border-right: 1px dashed rgba(255, 255, 255, 0.4);
    padding: 1px 2px;
    letter-spacing: -1px;
}

.synchro-preset-lane-cell:last-child {
    border-right: none;
}

.synchro-preset-caption {
    font-size: 0.62rem;
    color: #94a3b8;
    margin-top: 2px;
    font-weight: 600;
}

.synchro-approach-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 9px;
    margin-bottom: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.synchro-approach-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #f1f5f9;
}

.synchro-compass-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

/* =========================================================
   UI Optimization Patch - Right Properties Panel Redesign
   ========================================================= */

/* 1. 適度加寬右側面板，解決雙欄與車道圖擁擠問題 */
:root {
    --w-sidebar: 400px;
}

#properties-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 2. 置頂物件識別卡 (取代原本的 <h4> 與重複的 ID 輸入框) */
.prop-object-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    box-shadow: var(--shadow-sm);
}

.prop-object-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.prop-object-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #eff6ff;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.prop-object-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.prop-object-type {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

.prop-object-id {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-header-delete {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.btn-header-delete:hover {
    background: #fef2f2;
    color: var(--danger);
    border-color: #fecaca;
}

/* 3. 唯讀數據儀表板 (取代 disabled input) */
.prop-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.prop-stat-grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.prop-stat-box {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.prop-stat-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.prop-stat-value {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.88rem;
    font-weight: 700;
    color: #0f172a;
}

/* 4. 手風琴摺疊區塊 (<details> & <summary>) */
details.prop-accordion {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

details.prop-accordion>summary {
    list-style: none;
    padding: 9px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);
    background: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: background 0.15s;
}

details.prop-accordion>summary::-webkit-details-marker {
    display: none;
}

details.prop-accordion>summary:hover {
    background: #f8fafc;
}

details.prop-accordion[open]>summary {
    border-bottom: 1px solid var(--border-light);
    background: #f8fafc;
}

.prop-accordion-arrow {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

details.prop-accordion[open] .prop-accordion-arrow {
    transform: rotate(180deg);
}

.prop-accordion-body {
    padding: 10px 12px;
}

.prop-accordion-badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #475569;
    margin-left: auto;
    margin-right: 8px;
}

/* 5. 分段控制器 (Segmented Control - 取代凌亂的 Radio 清單) */
.segmented-control {
    display: flex;
    background: #e2e8f0;
    padding: 3px;
    border-radius: 7px;
    gap: 2px;
    margin-bottom: 8px;
}

.segmented-option {
    flex: 1;
    text-align: center;
    position: relative;
}

.segmented-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.segmented-option span {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s;
}

.segmented-option input[type="radio"]:checked+span {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* 6. 緊湊型車道列與車種膠囊 (Compact Lane Row & Vehicle Chips) */
.lane-compact-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    background: #f8fafc;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    margin-bottom: 6px;
    gap: 6px;
    transition: border-color 0.15s;
}

.lane-compact-row:hover {
    border-color: var(--primary);
    background: #eff6ff;
}

.veh-chip-group {
    display: flex;
    gap: 3px;
}

.veh-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #94a3b8;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s;
}

.veh-chip input {
    display: none;
}

.veh-chip:has(input:checked) {
    background: #dbeafe;
    border-color: #60a5fa;
    color: #1d4ed8;
}

/* 7. 路口方向切換分頁 (用於 Node -> Synchro 分頁，避免 4 個方向垂直塞爆) */
.approach-switcher {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 6px;
}

.approach-tab-btn {
    flex: 1;
    padding: 5px 4px;
    font-size: 0.72rem;
    font-weight: 700;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: #475569;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}

.approach-tab-btn.active {
    background: #ffffff;
    color: #1d4ed8;
    border-color: #bfdbfe;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* 8. 低干擾次要按鈕 (取代原本五顏六色的按鈕) */
.btn-soft {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 7px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #334155;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-soft:hover {
    background: #f8fafc;
    border-color: var(--primary);
    color: var(--primary);
}

/* 1. 確保工具列允許下拉選單浮出 */
.app-toolbar {
    overflow: visible !important;
}

/* 2. 工具列收納式下拉選單 (Split/Dropdown Tool Group) */
.tool-dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.tool-dropdown-toggle {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-main);
    padding: 4px 8px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    height: 52px;
    transition: all 0.2s;
    gap: 4px;
}

.tool-dropdown-toggle i.group-icon {
    font-size: 1.1rem;
    margin-bottom: 2px;
}

.tool-dropdown-toggle .btn-text {
    font-size: 0.65rem;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 3px;
}

.tool-dropdown-toggle .caret-icon {
    font-size: 0.6rem;
    opacity: 0.65;
}

.tool-dropdown-toggle:hover {
    background-color: #f1f5f9;
    color: var(--primary);
}

.tool-dropdown.active .tool-dropdown-toggle {
    background-color: #eff6ff;
    color: var(--primary);
    border-color: rgba(59, 130, 246, 0.25);
}

.tool-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    min-width: 170px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.14);
    padding: 4px;
    z-index: 250;
    flex-direction: column;
    gap: 2px;
}

.tool-dropdown.open .tool-dropdown-menu {
    display: flex;
}

/* 選單內的工具改為水平列表排列，好讀好點 */
.tool-dropdown-menu .tool-btn {
    flex-direction: row;
    justify-content: flex-start;
    width: 100%;
    height: 36px;
    padding: 6px 10px;
    gap: 10px;
}

.tool-dropdown-menu .tool-btn i {
    font-size: 0.95rem;
    margin-bottom: 0;
    width: 18px;
    text-align: center;
}

.tool-dropdown-menu .tool-btn .btn-text {
    font-size: 0.78rem;
    font-weight: 500;
}