/* ══════════════════════════════════════════════════
   iTracker Design System — 表單（欄位、輸入框、搜尋框、下拉、日期選擇、helper text）
   正本：design-system/components/form.css（tracker 建置複製到 wwwroot/css/ds/，勿手改產物）。
   v1.0 自 wwwroot/css/site.css 原樣搬入（規則與原相對順序不變）。
   ══════════════════════════════════════════════════ */
/* 工具列搜尋（DS v2 定案）：平時只是一顆放大鏡圖示鈕（工具列高 --ctl-h、圖示 16）；
   點擊 → .is-open 原地展開成搜尋框並聚焦；空值且失焦 → 收回；有字保持展開（原生 × 一鍵清除）；Esc 清空並收回。
   行為由 site-core.js initSearchBoxes() 統一掛載，頁面只需輸出：
   <div class="search-box"><button type="button" class="search-box-btn" aria-label="搜尋">svg</button><input type="search" …></div> */
.search-box {
  display: flex; align-items: center; gap: var(--space-1);
  background: transparent; border: 1px solid transparent;
  border-radius: var(--r-sm); height: var(--ctl-h); width: var(--ctl-h); flex: none;
  box-sizing: border-box; overflow: hidden;
  transition: background-color .12s, width .16s cubic-bezier(.16, 1, .3, 1);
}
.search-box-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: calc(var(--ctl-h) - 2px); height: calc(var(--ctl-h) - 2px); padding: 0;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-secondary); cursor: pointer;
}
.search-box-btn svg { width: 16px; height: 16px; }
.search-box:not(.is-open) .search-box-btn:hover { background-color: var(--bg-hover); color: var(--text-primary); }
.search-box-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.search-box input {
  flex: 1; min-width: 0; width: 0; padding: 0 var(--space-2) 0 0; visibility: hidden;
  border: none; outline: none; font-size: var(--fs-body); color: var(--text-primary); font-family: inherit; background: transparent;
}
.search-box.is-open { width: 240px; background-color: var(--bg-input); border-color: var(--border-input); }
.search-box.is-open:focus-within { border-color: var(--focus-border); box-shadow: var(--focus-ring); }
.search-box.is-open .search-box-btn { cursor: default; color: var(--text-tertiary); }
.search-box.is-open input { visibility: visible; }
/* 常駐搜尋框（v2.4，add-qa-helper）：面板頂端一直展開的搜尋（例：問答小幫手）＝ .search-box.is-open.is-static，
   寬度填滿容器；放大鏡鈕當送出鈕（type="submit"）。initSearchBoxes 不掛收合行為。 */
.search-box.is-static { width: 100%; }
.search-box.is-static .search-box-btn { cursor: pointer; color: var(--text-secondary); }
.search-box.is-static .search-box-btn:hover { color: var(--text-primary); }
.fg       { display: flex; flex-direction: column; gap: var(--space-1); }
.fg.full  { grid-column: 1 / -1; }
/* label 用 Body (CLAUDE.md spec：form input & label = Body 14/primary) */
.fg label { font-size: var(--fs-body); color: var(--text-primary); }
/* 必填星號：全域套用（原僅 `.fg label .req` 範圍過窄，未包 `.fg` 的表單如 RoleEdit 星號未變色）*/
.req { color: var(--accent-text); margin-left: var(--space-0_5); }
/* form-stack：modal 內表單容器，每個欄位等距，不再用 inline margin-bottom */
.form-stack    { display: flex; flex-direction: column; gap: var(--space-4); }
.form-section  { display: flex; flex-direction: column; gap: var(--space-2); }
/* ── 輸入框（全站單一元件，兩階高度；v2.0）──────────────────
   .input           表單階：表單／設定頁／modal 內（高 --ctl-h-lg 32），同列按鈕也用 32
   .input.input-sm  工具列階：工具列／清單列內／表格格內／浮層內（高 --ctl-h 28）
   .fg 欄位內未加 class 的 input／select／textarea 自動套表單階（同一份宣告，不是另一套）。
   寬度、對齊等版面屬性由頁面另加 layout class；外觀（框／底／字／focus）一律不得覆寫。 */
.input, .fg input:not([type="checkbox"]):not([type="radio"]), .fg select, .fg textarea, .ms-trigger {
  width: 100%; height: var(--ctl-h-lg); padding: 0 var(--space-3);
  border: 1px solid var(--border-input); border-radius: var(--r-sm);
  font-size: var(--fs-body); color: var(--text-primary);
  font-family: inherit; outline: none; box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
  background-color: var(--bg-input); line-height: 1;
}
.input-sm { width: auto; height: var(--ctl-h); padding: 0 var(--space-2); }   /* 工具列／格內：寬度依內容或頁面 layout class */
.input:hover:not(:focus):not(:disabled):not([readonly]),
.fg input:not([type="checkbox"]):not([type="radio"]):hover:not(:focus):not(:disabled):not([readonly]),
.fg select:hover:not(:focus):not(:disabled),
.fg textarea:hover:not(:focus):not(:disabled):not([readonly]) { border-color: var(--border-hover); }
/* 原生 <select> 統一視覺：移除瀏覽器預設箭頭 + 套 DS 自訂箭頭（token 日夜自適應）。
   保留原生 picker 行為（鍵盤／行動裝置 native picker），只改外觀。 */
select.input, .fg select {
  padding-right: var(--space-8); cursor: pointer;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
}
select.input-sm { padding-right: var(--space-6); background-position: right var(--space-2) center; }
textarea.input, .fg textarea {
  height: auto; min-height: 90px; padding: var(--space-2) var(--space-3);
  line-height: 1.65; resize: vertical;
}
/* 數字欄不顯示上下箭頭（報價時數、工時格）*/
input.input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input.input[type="number"]::-webkit-outer-spin-button,
input.input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
/* focus：框變色＋2px 實線環 */
.input:focus, .fg input:not([type="checkbox"]):not([type="radio"]):focus, .fg select:focus, .fg textarea:focus,
.ms-trigger:focus, .ms-trigger.open {
  border-color: var(--focus-border);
  box-shadow: var(--focus-ring);
}
.input[aria-invalid="true"],
.fg input:not([type="checkbox"]):not([type="radio"])[aria-invalid="true"],
.fg select[aria-invalid="true"],
.fg textarea[aria-invalid="true"] { border-color: var(--danger-text); }
/* placeholder 統一走 text-tertiary（過 AA），避免瀏覽器預設灰在深底不可讀 */
.input::placeholder, .fg input:not([type="checkbox"]):not([type="radio"])::placeholder, .fg textarea::placeholder { color: var(--text-tertiary); opacity: 1; }
/* 凍結態（純展示）：攤平到 --bg-frozen；click-to-edit 態（JS 加 inline style="cursor:pointer"）維持輸入框外觀 */
.input[readonly]:not([style*="cursor:pointer"]),
.fg input:not([type="checkbox"]):not([type="radio"])[readonly]:not([style*="cursor:pointer"]),
.fg textarea[readonly]:not([style*="cursor:pointer"]) {
  background-color: var(--bg-frozen);
  color: var(--text-tertiary);
  border-color: var(--border-faint);
  cursor: default;
}
.input[readonly]:focus,
.fg input:not([type="checkbox"]):not([type="radio"])[readonly]:focus,
.fg textarea[readonly]:focus {
  border-color: var(--border-faint);
  box-shadow: none;
}
/* 停用態：攤平＋不可互動 */
.input:disabled, .fg input:not([type="checkbox"]):not([type="radio"]):disabled, .fg textarea:disabled, .fg select:disabled {
  background-color: var(--bg-frozen);
  color: var(--text-tertiary);
  border-color: var(--border-faint);
  opacity: .7;
  cursor: not-allowed;
}
/* ── 勾選框（全站單一外觀；v2.0）：小圓角方框，選中＝靛藍實心＋白勾；夜間不出現原生亮白框。
   單選鈕沿用原生（html accent-color＝靛藍）。開關請用 .mx-switch。頁面只可調 margin，不覆寫外觀。 */
input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; margin: 0;
  width: 16px; height: 16px; flex-shrink: 0;
  display: inline-grid; place-content: center; vertical-align: -3px;
  border: 1px solid var(--border-hover); border-radius: var(--r-xs);
  background-color: var(--bg-input); cursor: pointer;
  transition: background-color .12s, border-color .12s;
}
input[type="checkbox"]::before {
  content: ''; width: 10px; height: 10px; transform: scale(0); transition: transform .1s;
  background-color: var(--text-on-accent);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
input[type="checkbox"]:hover:not(:disabled) { border-color: var(--text-tertiary); }
input[type="checkbox"]:checked,
input[type="checkbox"]:indeterminate { background-color: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::before { transform: scale(1); }
input[type="checkbox"]:indeterminate::before { transform: scale(1); height: 2px; clip-path: none; }
input[type="checkbox"]:focus-visible { outline: none; box-shadow: var(--focus-ring); }
input[type="checkbox"]:disabled { opacity: .5; cursor: not-allowed; }
/* Multi-Select */
.ms-wrap    { position: relative; }
/* 觸發鈕外觀＝.input 表單階（見上方群組宣告），這裡只放版面 */
.ms-trigger { cursor: pointer; text-align: left; display: flex; align-items: center; justify-content: space-between; }
.ms-arrow { transition: transform .15s; flex-shrink: 0; color: var(--text-tertiary); }
.ms-trigger.open .ms-arrow { transform: rotate(180deg); }
.ms-menu {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg-elevated); border-radius: var(--r-md);
  padding: var(--space-1); z-index: 50; box-shadow: var(--shadow-pop);
}
.ms-menu.show { display: block; }
.ms-item {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-2); border-radius: var(--r-xs);
  font-size: var(--fs-body); color: var(--text-primary);
  cursor: pointer; user-select: none;
}
.ms-item:hover                       { background: var(--bg-muted); }
.ms-item input[type="checkbox"]      { flex-shrink: 0; }
/* 行內下拉（狀態／類型／指派／優先／協作者）：外框 .inline-popup ＋ 標題 .inline-popup-label ＋ 選項 .inline-opt。
   掛 body、position:fixed 由呼叫端定位；v2.0 自 site.css 搬入（值不變）。 */
.inline-popup {
  position: fixed;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  padding: var(--space-1);
  z-index: 500;
  box-shadow: var(--shadow-pop);
}
.inline-popup--type   { min-width: 120px; }
.inline-popup--prio   { min-width: 120px; }
.inline-popup--assign { min-width: 160px; max-height: 240px; overflow-y: auto; }
.inline-popup--status { min-width: 180px; }
.inline-popup-label {
  font-size: var(--fs-caption); color: var(--text-tertiary);
  padding: var(--space-1) var(--space-2) var(--space-1);
  text-transform: uppercase; letter-spacing: .05em;
}
.inline-opt {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); font-size: var(--fs-body);
  cursor: pointer; border-radius: var(--r-xs); color: var(--text-primary);
  white-space: nowrap; transition: background .1s;
}
.inline-opt:hover  { background: var(--bg-muted); }
.inline-opt.active { background: var(--accent-soft); color: var(--accent-text); }   /* UAT：選中指示改 accent 紫 */
/* 選單項做成 <button>（鍵盤可達）時的重設；停用＝淡字、不可點；目前項（.is-current）維持主文字＋勾 */
button.inline-opt { width: 100%; border: 0; background: transparent; font-family: inherit; text-align: left; }
button.inline-opt:focus-visible { outline: none; background: var(--bg-muted); }
.inline-opt:disabled { cursor: default; background: transparent; color: var(--text-tertiary); }
.inline-opt:disabled:not(.is-current) .inline-opt-icon { opacity: .5; }
.inline-opt.is-current { color: var(--text-primary); }
.inline-opt-icon  { display: inline-flex; flex: none; }
.inline-opt-check { flex: none; color: var(--text-secondary); }
.inline-opt--danger { color: var(--danger-text); }   /* 危險動作（刪除）選項；確認視窗另開 */
.inline-popup--more { min-width: 140px; }
/* 唯讀資訊浮層（內放 .info-row；如任務詳情「回報環境」）*/
.inline-popup--info { width: 260px; max-width: calc(100vw - 2 * var(--space-2)); }
.inline-popup--info .info-row { padding: var(--space-1) var(--space-2); }
.inline-popup--info:focus { outline: none; }
.inline-opt-key   { margin-left: auto; padding-left: var(--space-3); font-size: var(--fs-caption); color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
/* form label 後的小字 hint（紅 *  右邊的「2-8 字…」說明）*/
.label-hint { font-size: var(--fs-caption); color: var(--text-tertiary); font-weight: 400; margin-left: var(--space-1); }
.form-row { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-3); }
/* ── 通用日曆 Date Picker（B-6；JS＝site-daterange.js，2026-07-17 通用化）──
   全站唯一日曆元件（range 雙月選起訖／single 單月選一天），取代原生 <input type=date>＝樣式統一。
   masked 觸發欄 .drp-field（顯示 yyyy/mm/dd 樣板、只打數字自動補分隔）＋ body 掛載彈窗 .drp-pop。
   值真實來源＝隱藏原 input（type=hidden、id/value 不變）→ 呼叫端讀值零改動。全 token 化、dark-aware。
   用在：建立任務／ticket 排程卡／群組期間（range）、里程碑（single）；未來任何日曆一律用此、勿再用原生 date。 */
.drp { display: block; }
.drp-field-wrap { position: relative; display: flex; align-items: center; }
.drp-field { width: 100%; padding-right: 34px; cursor: text; }
.drp-field::placeholder { color: var(--text-tertiary); }
.drp-ico { position: absolute; right: 10px; width: 16px; height: 16px; color: var(--text-tertiary); pointer-events: none; }
.drp-clear {
  position: absolute; right: 30px; width: 18px; height: 18px; line-height: 16px; text-align: center;
  border: none; background: none; color: var(--text-tertiary); font-size: var(--fs-title); cursor: pointer; border-radius: var(--r-xs);
}
.drp-clear:hover { color: var(--text-primary); background: var(--bg-muted); }
.drp-pop {
  position: fixed; z-index: 1250; background: var(--bg-elevated);
  border: 1px solid var(--border-card); border-radius: var(--r-md); box-shadow: var(--shadow-pop); padding: var(--space-3);
}
.drp-cals { display: flex; gap: var(--space-4); }
.drp-cal { width: 224px; }
.drp-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-1); padding: 0 2px; }
.drp-ttl { font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--text-primary); }
.drp-nav, .drp-nav-sp { width: 22px; height: 22px; flex: none; }
.drp-nav {
  display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-input);
  background: var(--bg-control); color: var(--text-secondary); border-radius: var(--r-xs); cursor: pointer; font-size: var(--fs-body);
}
.drp-nav:hover { background: var(--bg-muted); color: var(--text-primary); }
.drp-dow, .drp-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.drp-dow span { text-align: center; font-size: var(--fs-caption); color: var(--text-tertiary); padding: 3px 0; }
.drp-d {
  height: 28px; display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-caption); color: var(--text-primary); border-radius: var(--r-sm); cursor: pointer; user-select: none;
}
.drp-d.mut { color: var(--text-tertiary); opacity: .5; cursor: default; }
.drp-d.we { color: var(--text-tertiary); }
.drp-d:hover:not(.mut):not(.ep) { background: var(--bg-hover); }
.drp-d.hv, .drp-d.in { background: var(--accent-soft); border-radius: 0; }
.drp-d.ep { background: var(--accent); color: var(--text-on-accent); font-weight: var(--fw-bold); border-radius: var(--r-sm); }
.drp-d.today:not(.ep) { box-shadow: inset 0 0 0 1px var(--accent-text); }
.drp-ft { display: flex; align-items: center; justify-content: space-between; margin-top: var(--space-2); padding-top: var(--space-2); border-top: 1px solid var(--divider); }
.drp-legend { font-size: var(--fs-caption); color: var(--text-tertiary); display: flex; align-items: center; gap: 4px; }
.drp-lg-ep, .drp-lg-in, .drp-lg-today { width: 10px; height: 10px; border-radius: 3px; display: inline-block; vertical-align: -1px; }
.drp-lg-ep { background: var(--accent); }
.drp-lg-in { background: var(--accent-soft); }
.drp-lg-today { box-shadow: inset 0 0 0 1px var(--accent-text); }
.drp-ft-clear { border: none; background: none; color: var(--accent-text); font-size: var(--fs-caption); cursor: pointer; }
.drp-ft-clear:hover { text-decoration: underline; }
/* toggle switch（.mx-switch）：共用開關控制元件（2026-06-17 自 Issues 頁 @section Styles 上收）*/
.mx-switch { position: relative; width: 32px; height: 18px; flex-shrink: 0; }
.mx-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.mx-switch-slider {
  position: absolute; inset: 0; background: var(--bg-elevated);
  border: 1px solid var(--border-input);   /* off 狀態軌道在日間會與 panel 底色融合，加邊框讓凹槽可見（雙模） */
  border-radius: var(--r-pill); cursor: pointer; transition: background .15s, border-color .15s;
}
.mx-switch-slider::before {
  content: ''; position: absolute;
  width: 12px; height: 12px; left: 3px; top: 2px;   /* top=2：18px 軌內含 1px 邊，圓鈕垂直置中（上下各留 3px 外緣）；原 3px 使鈕偏低 1px */
  background: var(--text-tertiary); border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,.35);   /* 2026-06-23：knob 加陰影，避免 dark「on」態白滑塊在淺石墨軌（--accent 翻淺）上糊掉 */
  transition: transform .15s, background .15s;
}
/* 2026-07-21 DS 對齊：開啟軌道＝實心填滿→用 --accent（實心底語意 token），非 --accent-text（文字/邊框語意）。
   使全站開關「開」與 btn-primary、內部留言 --note-accent 日夜同紫；連帶清單/時間板夜間由亮紫轉品牌深紫（白鈕 5.4:1 過標準）。 */
.mx-switch input:checked + .mx-switch-slider { background: var(--accent); border-color: var(--accent); }
.mx-switch input:checked + .mx-switch-slider::before { transform: translateX(14px); background: #fff; }
/* asp-validation-for 錯誤訊息（沿用 .hint 字級，但用 danger 色）*/
.hint.err, span.field-validation-error {
  color: var(--danger-text);
  font-size: var(--fs-caption);
  line-height: 1.5;
}
.hint.err:empty { display: none; }

/* ── 複合輸入框（3.4.0 自 site.css 收入；任務簡述、留言共用）────────────
   .reply-input-box ＞ textarea ＋（選填）縮圖區 ＋ .reply-input-footer（框內動作鈕）。
   外框管 focus／錯誤／拖放／唯讀視覺，內層 textarea 不畫框。支援點擊／拖放／Ctrl+V 加圖由頁面 JS 處理。 */
.reply-input-box {
  border: 1px solid var(--border-input); border-radius: var(--r-md);
  overflow: hidden; background: var(--bg-input);
  transition: border .15s, box-shadow .15s, background .15s;
}
.reply-input-box:focus-within { border-color: var(--accent-text); box-shadow: var(--focus-ring); }
/* 錯誤態：內層 textarea 標 aria-invalid → 外框變紅（與 .fg 輸入框同一套語意） */
.reply-input-box:has(textarea[aria-invalid="true"]) { border-color: var(--danger-text); }
.reply-input-box.drag {
  border-color: var(--success); border-style: dashed;
  background: color-mix(in srgb, var(--success) 6%, var(--bg-input));
}
.reply-input-box textarea {
  width: 100%; padding: var(--space-3) var(--space-3);
  border: none; outline: none;
  font-size: var(--fs-body); font-family: inherit;
  resize: none; min-height: 80px;
  color: var(--text-primary); line-height: 1.65;
  background: transparent;        /* 顯式設透明，避免瀏覽器 dark 模式預設白底 */
}
/* 表單把 .reply-input-box 包進 .fg 時，.fg textarea:focus 會在內層 textarea 再疊一圈 focus-ring →
   視覺像「框中框」。內層 textarea 不自己畫 focus 框，focus 視覺一律交給外層 .reply-input-box:focus-within。 */
.reply-input-box textarea:focus { box-shadow: none; }
.reply-input-footer {
  padding: var(--space-2) var(--space-3); border-top: 1px solid var(--divider);
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; row-gap: var(--space-2);   /* 詳情左欄變窄（右欄屬性面板）時，送出鈕整組換行而非把文字擠成逐字 */
}
.reply-input-footer > .flex-center.gap-2 { margin-left: auto; }
/* 窄容器（modal 或第三欄 inspector 抽屜）改直式堆疊，避免送出鈕溢出、文字被擠成逐字換行；
   容器＝.modal-bd／.ip-body 的 container-type，兩種宿主一致生效 */
@container (max-width: 600px) {
  .reply-input-footer {
    flex-wrap: wrap;
    row-gap: var(--space-2);
  }
  .reply-input-footer > .flex-center.gap-4 { width: 100%; }
  .reply-input-footer > .flex-center.gap-2 { width: 100%; justify-content: flex-end; }
}

/* 唯讀兩種視覺分流：凍結態（純展示）攤平到 --bg-frozen；click-to-edit 態（JS 加 inline style="cursor:pointer"）維持輸入框外觀 */
.reply-input-box textarea[readonly] { cursor: default; }
.reply-input-box:has(> textarea[readonly]:not([style*="cursor:pointer"])) {
  background: var(--bg-frozen);
  border-color: var(--border-faint);
}
.reply-input-box:has(textarea[readonly]:focus) {
  border-color: var(--border-faint);
  box-shadow: none;
}

/* ── 底部儲存列（3.6.0；長表單用，unify-save-bar-and-tooltip）──────────────
   有欄位與打開時不同才出現（JS 拿掉 [hidden]），黏在捲動容器底部；左「有未儲存的變更」、右「捨棄變更」＋「儲存」。
   放在頁面捲動容器（tracker：#content）的最後一個子元素；手機底部導覽列蓋住的高度由 tracker site.css 補 bottom。 */
.save-bar {
  position: sticky; bottom: 0; z-index: 4;
  display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background-color: var(--bg-section);
  border-top: 1px solid var(--border-card);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-body);
}
.save-bar[hidden] { display: none; }
.save-bar-msg { margin-right: auto; display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-secondary); min-width: 0; }
.save-bar-dot { width: 8px; height: 8px; border-radius: 50%; background-color: var(--warn); flex: none; }
@media (prefers-reduced-motion: no-preference) {
  .save-bar:not([hidden]) { animation: save-bar-in .16s ease-out; }
  @keyframes save-bar-in { from { transform: translateY(100%); } }
}
