/* 工作詳情抽屜與各對話框；共用元件見 /styles.css。 */

/* ---------- 抽屜 ---------- */
dialog.drawer { width: min(520px, 100vw); }
.drawer-body { padding: 0 0 32px; gap: 0; }
.drawer-body > .empty { padding: 64px 22px; }

/* 標題列：左側色條跟著工作狀態（.k-*） */
.dw-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 14px 22px;
  border-bottom: 1px solid var(--line); border-left: 5px solid var(--c);
  background: linear-gradient(90deg, color-mix(in srgb, var(--cs) 75%, transparent), transparent 65%) var(--card);
}
.dw-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.dw-case { align-self: flex-start; display: inline-flex; align-items: baseline; gap: 8px; max-width: 100%; border: 0; background: none; padding: 0; color: var(--ink); font-size: 13px; font-weight: 700; text-align: left; }
.dw-case span { color: var(--muted); font-weight: 500; }
.dw-case i { font-style: normal; color: var(--muted); }
.dw-case:hover, .dw-case:hover span, .dw-case:hover i { color: var(--accent-d); }
.dw-head h2 { margin: 0; font-family: 'Noto Serif TC', 'Songti TC', serif; font-size: 24px; font-weight: 700; letter-spacing: .03em; line-height: 1.3; overflow-wrap: anywhere; }
.dw-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dw-status { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; background: var(--cs); color: var(--c); font-size: 12px; font-weight: 700; white-space: nowrap; }
.dw-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

/* 基本資料 */
.dw-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; margin: 0; padding: 16px 22px; }
.dw-sec .dw-facts { padding: 0; }
.dw-facts .wide { grid-column: 1 / -1; }
.dw-facts dt { font-size: 11px; color: var(--muted); }
.dw-facts dd { margin: 2px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.dw-facts dd.dw-text { font-weight: 500; white-space: pre-wrap; }
.dw-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 22px 18px; }

/* 區塊 */
.dw-sec { border-top: 1px solid var(--line); padding: 16px 22px; display: flex; flex-direction: column; gap: 10px; }
.dw-sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 10px; flex-wrap: wrap; }
.dw-sec-head h3 { margin: 0; font-size: 15px; font-weight: 900; }
.dw-sec-head span { color: var(--muted); font-size: 12px; }
.dw-empty { margin: 0; color: var(--muted); font-size: 13px; }

/* 人員 */
.dw-lack { margin: 0; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--red-s); color: var(--red); font-weight: 700; font-size: 13px; }
.dw-lack::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex: 0 0 auto; }
.dw-group { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 10px; align-items: start; }
.dw-label { color: var(--muted); font-size: 13px; padding-top: 8px; }
.dw-people { display: flex; flex-direction: column; }
.dw-person { display: flex; align-items: center; justify-content: space-between; gap: 4px 10px; flex-wrap: wrap; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.dw-person:last-child { border-bottom: 0; }
.dw-who { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.dw-who .chip { white-space: normal; }
.dw-ops { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.dw-ops .button { white-space: nowrap; }

/* 實際出工 */
.dw-crew { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dw-crew li { display: flex; gap: 4px 8px; align-items: baseline; flex-wrap: wrap; font-size: 13px; padding: 7px 12px; background: var(--soft); border-radius: 9px; }
.dw-crew span { color: var(--muted); }
.dw-crew em { font-style: normal; margin-left: auto; font-weight: 700; }

/* 歷程：圓點顏色代表異動種類 */
.dw-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.dw-history li { position: relative; padding: 0 0 14px 22px; display: flex; flex-direction: column; gap: 1px; font-size: 13px; }
.dw-history li::before { content: ""; position: absolute; left: 1px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--hc, var(--muted)); box-shadow: 0 0 0 3px var(--card); }
.dw-history li::after { content: ""; position: absolute; left: 5px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.dw-history li:last-child { padding-bottom: 0; }
.dw-history li:last-child::after { display: none; }
.dw-history strong { font-weight: 700; overflow-wrap: anywhere; }
.dw-history span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.dw-history .h-assign { --hc: var(--accent); }
.dw-history .h-replace { --hc: var(--amber); }
.dw-history .h-remove, .dw-history .h-warn { --hc: var(--red); }
.dw-history .h-cancel { --hc: var(--grey); }
.dw-history .h-start { --hc: var(--blue); }
.dw-history .h-done { --hc: var(--done); }
.dw-history .h-edit, .dw-history .h-create { --hc: var(--line); }
.dw-history .h-edit::before, .dw-history .h-create::before { box-shadow: 0 0 0 3px var(--card), inset 0 0 0 2px var(--muted); background: var(--card); }

/* 人名小選單的分隔線（移除放在最下面） */
.chip-menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }

/* ---------- 對話框：標題與按鈕固定在上下，內容可捲動 ---------- */
dialog { scrollbar-width: thin; }
dialog form { --dlg-pad: 22px; padding: var(--dlg-pad); }
dialog form > .dialog-head {
  position: sticky; top: 0; z-index: 2; margin: calc(var(--dlg-pad) * -1) calc(var(--dlg-pad) * -1) 0;
  padding: 18px var(--dlg-pad) 14px; background: var(--card); border-bottom: 1px solid var(--line); align-items: center;
}
.dialog-head .eyebrow { overflow-wrap: anywhere; }
.dialog-head h2 { overflow-wrap: anywhere; }
dialog form > .dialog-actions {
  position: sticky; bottom: 0; z-index: 2; margin: 4px calc(var(--dlg-pad) * -1) calc(var(--dlg-pad) * -1);
  padding: 12px var(--dlg-pad); background: var(--card); border-top: 1px solid var(--line);
}
.dialog-actions .button { min-width: 88px; }
#replace-impact span { display: block; }
#replace-impact span + span { margin-top: 4px; }
.check-line { font-weight: 500; }
/* 欄位標籤後的補充說明：和標籤同一行的小字（label 是 grid，說明要包在 .label-main 裡才不會換行） */
.label-main small { margin-left: 6px; color: var(--muted); font-size: 11px; font-weight: 500; }

/* ---------- 窄螢幕：抽屜全寬，對話框從下方滑出 ---------- */
@media (max-width: 600px) {
  dialog.drawer { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border-left: 0; }
  .dw-head { padding: 14px 14px 12px 16px; }
  .dw-head h2 { font-size: 21px; }
  .dw-facts { padding: 14px 16px; gap: 10px 16px; }
  .dw-actions { padding: 0 16px 14px; }
  .dw-actions .button { flex: 1 1 auto; }
  .dw-sec { padding: 14px 16px; }
  .dw-person { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .dw-ops { justify-self: end; }
  dialog:not(.drawer) { width: 100vw; max-width: 100vw; margin: auto 0 0; max-height: 92dvh; border-radius: 16px 16px 0 0; border-bottom: 0; }
  dialog form { --dlg-pad: 16px; }
  #task-form .three-cols { grid-template-columns: 1fr 1fr; }
  #task-form .three-cols > :first-child { grid-column: 1 / -1; }
  .dialog-actions .button { flex: 1 1 0; }
}
