/* entry.css —— ②新增單 + ①分類設定,疊在 base.css 的工業標籤語言上。 */

/* ---------- 錯誤提示 ---------- */
.alert-err {
  border: var(--bw) solid var(--danger);
  border-left-width: 8px;
  border-radius: var(--radius);
  background: #fdf1f1;
  box-shadow: var(--shadow-sm);
  padding: 12px 16px;
  margin: 12px 0;
  color: #8c1c1c;
}
.alert-err ul { margin: 6px 0 0; padding-left: 20px; }

/* ============================================================
   ② 新增單表單:相機優先、單手可完成
   ============================================================ */
.form-title { margin-bottom: 12px; }
.form-title p { margin: 0; font-size: 14px; }
.case-form { margin-top: 4px; padding: 18px 18px 4px; }

/* 拍照區:最大目標,黃底虛線 = 現場「往這裡放」的語言 */
.photo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 104px;
  border: 2px dashed var(--ink);
  border-radius: var(--radius);
  background: var(--hazard-tint);
  color: var(--ink);
  cursor: pointer;
  transition: background .12s, transform .08s;
}
.photo-btn:hover { background: var(--hazard); }
.photo-btn:active { transform: translate(1px, 1px); }
.photo-btn-icon { font-size: 34px; line-height: 1; }
.photo-btn-text { display: flex; flex-direction: column; font-size: 18px; font-weight: 800; line-height: 1.3; }
.photo-btn-text i { font-style: normal; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
/* 連拍(button 元素)= 主打動作:實心安全黃 + 實線框,一眼鎖定 */
button.photo-btn {
  font: inherit;
  background: var(--hazard);
  border-style: solid;
  box-shadow: var(--shadow-sm);
}
button.photo-btn:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow); }

.photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.photo-preview .thumb {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: var(--radius);
  overflow: hidden;
  border: var(--bw) solid var(--line);
  background: #fff;
  box-shadow: 2px 2px 0 rgba(23, 20, 16, .85);
}
.photo-preview .thumb img { width: 100%; height: 100%; object-fit: cover; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.check-row input[type=checkbox] { width: 24px; height: 24px; min-height: 24px; accent-color: var(--ink); }
.check-row label { font-weight: 700; font-size: 14px; color: var(--ink); }

.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.submit-bar { padding: 4px 0 14px; }

@media (max-width: 520px) {
  .field-row { flex-direction: column; gap: 0; }
  .case-form { padding: 14px 12px 4px; }
  /* 手機:送出列貼底,單手捲到哪都按得到 */
  .submit-bar {
    position: sticky;
    bottom: 0;
    padding: 12px 0 14px;
    background: linear-gradient(to top, var(--surface) 65%, transparent);
  }
}

/* ============================================================
   ① 分類設定
   ============================================================ */
.cat-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.cat-head p { margin: 0; font-size: 13px; }

.cat-add-form { margin-bottom: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.cat-table { overflow: hidden; }

.cat-row {
  display: grid;
  grid-template-columns: 36px 1.4fr 2fr 1.6fr 72px 88px;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  transition: background .12s;
}
.cat-row:last-child { border-bottom: none; }
.cat-row:hover { background: var(--hazard-tint); }
.cat-row-head {
  background: var(--ink);
  color: rgba(255, 255, 255, .85);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
}
.cat-row-head:hover { background: var(--ink); }
.cat-row.is-off { opacity: .45; }
.cat-row.dragging { background: var(--hazard-tint); opacity: .7; }
.cat-row.drop-target { box-shadow: inset 0 3px 0 var(--hazard); }

.col-handle { cursor: grab; color: var(--ink-faint); font-size: 18px; text-align: center; user-select: none; }
.col-handle:active { cursor: grabbing; }

/* 上/下移按鈕:桌機藏(有拖曳),手機顯示(HTML5 拖曳不支援觸控) */
.col-move { display: none; }
.col-move .mv {
  display: block;
  width: 34px; height: 30px;
  border: var(--bw) solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12px;
  cursor: pointer;
  margin: 2px 0;
}
.col-move .mv:active { background: var(--hazard); }
.col-name { font-weight: 800; }
.col-desc, .col-method { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 啟用開關:信號燈 */
.toggle-btn {
  min-width: 52px;
  min-height: 32px;
  border-radius: var(--radius);
  border: var(--bw) solid var(--line);
  background: var(--paper);
  color: var(--ink-faint);
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(23, 20, 16, .85);
  transition: transform .08s, box-shadow .08s;
}
.toggle-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.toggle-btn.on { background: var(--ok); color: #fff; }

.btn-edit {
  min-height: 36px;
  padding: 4px 12px;
  font-size: 14px;
}

/* inline 編輯 / 佔整行 */
.cat-edit-form { grid-column: 1 / -1; margin-top: 10px; padding-top: 12px; border-top: 2px dashed var(--line-soft); }

@media (max-width: 720px) {
  .cat-row-head { display: none; }
  .cat-row {
    grid-template-columns: 40px 1fr 72px 72px;
    grid-template-areas:
      "move name active op"
      "move desc desc desc"
      "move method method method";
    row-gap: 4px;
  }
  .col-handle { display: none; }       /* 觸控拖不動,換上下移鈕 */
  .col-move { display: block; grid-area: move; }
  .col-name { grid-area: name; }
  .col-desc { grid-area: desc; white-space: normal; }
  .col-method { grid-area: method; white-space: normal; }
  .col-active { grid-area: active; }
  .col-op { grid-area: op; }
  .cat-edit-form { grid-area: auto; grid-column: 1 / -1; }
}

/* ---------- 拍照/相簿雙按鈕 + 累積縮圖(可單張移除) ---------- */
.photo-btn-row { display: flex; gap: 10px; }
.photo-btn-row .photo-btn {
  flex: 1; min-width: 0;
  flex-direction: column; gap: 6px;
  min-height: 96px; padding: 12px 6px;
  text-align: center;
}
.photo-btn-row .photo-btn-icon { font-size: 28px; }
.photo-btn-row .photo-btn-text { font-size: 15px; align-items: center; }
.photo-preview .thumb-rm {
  position: absolute; top: 0; right: 0;
  width: 22px; height: 22px; padding: 0; border: 0;
  background: var(--ink); color: var(--hazard);
  font-size: 12px; line-height: 22px; cursor: pointer;
}
.photo-preview .thumb-busy {
  display: flex; align-items: center; justify-content: center;
  width: 84px; height: 84px;
  border: 2px dashed var(--line);
  font-size: 12px; color: var(--ink-faint); background: var(--paper);
}
