/* Thẻ phân loại: mỗi bug / case / việc là 1 thẻ bìa trắng có lỗ xỏ dây góc trên trái, dải xé ở mép dưới
   in tên trạng thái. Nhãn trạng thái trong DOM (.badge.st-* / .badge.r-*) được đặt xuống mép thẻ làm chính dải xé,
   nên JS chỉ cần in nhãn như cũ (Lead đổi trạng thái -> nhãn đổi -> dải đổi). */

/* ---------- thẻ ---------- */
.card, .bug-card, .todo-item {
  background: var(--tag); border-radius: var(--radius); box-shadow: var(--shadow);
}
.card { padding: 18px; margin-bottom: 14px; }
.card.narrow { max-width: 460px; margin: 28px auto; }

.bug-card, .todo-item { position: relative; overflow: hidden; min-width: 0; }
.bug-card { padding: 16px 16px 46px; }
/* Lỗ xỏ dây chỉ còn trên phiếu bug (bug-ticket-styles.css): 2 QA mới đọc nó thành ô radio / ô tick trên các thẻ
   có nút bấm (phản biện ngày đầu 30/09), nên thẻ danh sách không vẽ lỗ. */
/* dải xé nền (thẻ không có nhãn trạng thái, và màu dải cũ khi đang xé) */
.bug-card::after, .todo-item::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 12px;
  background:
    radial-gradient(circle at 5px 0, var(--tag) 2.2px, transparent 2.8px) repeat-x 0 0 / 10px 5px,
    var(--strip-prev, var(--strip, var(--rule-2)));
}

/* ---------- dải trạng thái có tên: nhãn trạng thái của thẻ nằm ở mép dưới ---------- */
.bug-head > .badge[class*="st-"], .case-meta > .badge[class*="r-"] {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; display: flex; align-items: center;
  min-height: 30px; padding: 7px 16px 5px; border-radius: 0; font-size: 0.82rem; font-weight: 700; letter-spacing: 0.01em;
  background:
    radial-gradient(circle at 5px 0, var(--tag) 2.2px, transparent 2.8px) repeat-x 0 0 / 10px 5px,
    var(--b);
  color: var(--bt, #fff);
}
.badge.r-todo[class] { --b: var(--rule-2); --bt: var(--ink-2); box-shadow: none; }

/* nhãn nhỏ còn lại trong đầu thẻ: viền mảnh, chữ mực, ô màu nhỏ (không lặp màu cả khối) */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.76rem; font-weight: 700; line-height: 1.3;
  padding: 2px 8px; border-radius: 3px; background: transparent; color: var(--ink); white-space: nowrap;
  box-shadow: inset 0 0 0 1px var(--rule);
}
.badge[class*="st-"]::before, .badge[class*="r-"]::before { content: ''; width: 7px; height: 12px; border-radius: 1px; background: var(--b); flex: none; }
.bug-head > .badge[class*="st-"]::before, .case-meta > .badge[class*="r-"]::before { display: none; }
.st-new { --b: var(--s-new); }
.st-info { --b: var(--s-info); --bt: var(--ink); }
.st-ok { --b: var(--s-open); }
.st-progress { --b: var(--s-progress); }
.st-fixed { --b: var(--s-fixed); --bt: var(--ink); }
.st-reopen { --b: var(--s-reopen); }
.st-closed { --b: var(--s-closed); }
.st-dup, .st-no { --b: var(--s-muted); }
/* kết quả case */
.r-Pass { --b: var(--s-closed); }
.r-Fail { --b: var(--s-reopen); }
.r-Blocked { --b: var(--s-info); --bt: var(--ink); }
.r-NA { --b: var(--s-muted); }
.r-todo { --b: var(--rule); }
/* "Mở lại xN", "Cần chạy lại": cảnh báo đi kèm */
.badge.reopen { color: var(--danger); box-shadow: inset 0 0 0 1.5px var(--s-reopen); }

/* đầu thẻ: số thẻ lớn */
.bug-head, .case-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 0 0 8px; }
.bug-code { font-weight: 700; font-size: 1.3rem; letter-spacing: -0.01em; line-height: 1.1; margin-right: 2px; }
.bug-screen { font-weight: 700; margin: 0 0 4px; }
.bug-actual { margin: 0 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2); }

/* nhãn phụ (ưu tiên, build, kiểu lỗi, số ngày): viền mảnh, chữ mực */
.tag {
  display: inline-flex; align-items: center; font-size: 0.76rem; font-weight: 700; line-height: 1.3;
  padding: 2px 7px; border-radius: 3px; color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--rule); background: transparent;
}
.tag.soft { color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink-3); }
.tag.age-stale { color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--s-reopen); }

/* ghi chú Lead: mẩu giấy kẹp trên thẻ */
.lead-feedback {
  background: #fff4cf; color: var(--ink); border-radius: 6px; padding: 10px 12px; margin: 0 0 10px;
  white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 1px 0 rgba(125, 82, 0, 0.12);
}

/* ô đếm theo trạng thái (Lead) */
.sum-chip {
  display: inline-flex; align-items: center; gap: 8px; background: var(--tag); border: 1px solid var(--rule); border-radius: 6px;
  padding: 6px 12px 6px 8px; min-height: 42px; font: inherit; font-size: 0.88rem; font-weight: 500; cursor: pointer; color: var(--ink);
  text-decoration: none; transition: border-color 0.2s var(--ease-out), transform 0.12s var(--ease-out);
}
.sum-chip::before { content: ''; width: 8px; height: 20px; border-radius: 2px; background: var(--b, var(--ink)); flex: none; }
.sum-chip b { font-size: 1.02rem; font-weight: 700; }
.sum-chip:hover { border-color: var(--ink); }
.sum-chip:active { transform: translateY(1px); }

/* ---------- Lead: danh sách hàng gọn + ngăn chi tiết (kiểu issue list / issue view của Jira) ---------- */
.bug-list:has(> .issue-row) { gap: 6px; }
.issue-row {
  display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; width: 100%;
  padding: 10px 12px; border: 0; border-radius: var(--radius-ctl); background: var(--tag); color: var(--ink);
  box-shadow: 0 0 0 1px var(--rule-2); font: inherit; text-align: left; cursor: pointer;
  transition: box-shadow 0.15s var(--ease-out), background-color 0.15s var(--ease-out);
}
.issue-row:hover { box-shadow: 0 0 0 1px var(--ink-3); }
.issue-row.is-selected { background: var(--tag-2); box-shadow: 0 0 0 2px var(--ink); }
.ir-code { font-weight: 700; }
.ir-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ir-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.ir-stale { color: var(--danger); }
/* hàng "Bug của tôi": là link mở phiếu; dòng 2 = bước tiếp theo + phản hồi Lead */
a.issue-row { text-decoration: none; }
.my-row .ir-next, .my-row .ir-lead { grid-column: 2 / -1; }
.my-row .ir-next { color: var(--ink-2); }
.my-row .ir-lead { background: #fff4cf; border-radius: 6px; padding: 4px 8px; justify-self: start; }
@media (max-width: 639px) { .my-row .ir-next, .my-row .ir-lead { grid-column: 1 / -1; } }
/* bộ lọc nhanh (nút bật / tắt, không có ô màu trạng thái) */
.sum-chip[data-quick]::before { display: none; }
.sum-chip[data-quick] { padding-left: 12px; }
.sum-chip[aria-pressed=true] { background: var(--ink); color: #fff; border-color: var(--ink); }
/* Lead: ô đếm trạng thái = hàng bộ lọc nhanh 1 dòng cuộn ngang (kiểu quick filters của Jira), danh sách lên sát trên */
body.wide #status-summary { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
body.wide #status-summary .sum-chip { flex: none; min-height: 38px; padding: 4px 10px 4px 7px; font-size: 0.84rem; }
@media (min-width: 900px) {
  body.wide .filters { flex-wrap: nowrap; }
  body.wide .filters .field { margin-bottom: 8px; }
}
@media (max-width: 639px) {
  .issue-row { grid-template-columns: auto minmax(0, 1fr); }
  .ir-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .ir-meta { grid-column: 1 / -1; justify-content: flex-start; }
}
.issue-drawer {
  position: fixed; top: 56px; right: 0; bottom: 0; width: min(580px, 100vw); z-index: 30;
  display: flex; flex-direction: column; background: var(--desk); box-shadow: -18px 0 36px -24px rgba(0, 0, 0, 0.55);
}
.issue-drawer[hidden] { display: none; }
.drawer-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; background: var(--tag); border-bottom: 1px solid var(--rule-2); }
.drawer-head .btn { min-height: 40px; padding: 6px 12px; }
.drawer-hint { flex: 1 1 auto; }
.drawer-body { overflow: auto; padding: 12px; overscroll-behavior: contain; }
.issue-drawer .lead-card { grid-template-columns: 1fr; }
@media (min-width: 1100px) { body.drawer-open .page { margin-right: 590px; margin-left: 16px; } }
@media (max-width: 639px) {
  .issue-drawer { top: 0; width: 100vw; }
  .drawer-hint { display: none; }
}

/* trống */
.empty { text-align: center; color: var(--ink-2); }
.empty.card { background: transparent; box-shadow: none; border: 2px dashed var(--rule); padding: 30px 16px; }

/* ---------- xé dải khi đổi trạng thái: dải cũ rơi xuống, dải mới lướt vào (320 ms) ---------- */
.strip-changed::after { animation: strip-fall 0.32s var(--ease-out) both; }
.strip-changed .bug-head > .badge[class*="st-"], .strip-changed .case-meta > .badge[class*="r-"] { animation: strip-wipe 0.32s var(--ease-out) both; }
@keyframes strip-fall { from { transform: none; } to { transform: translateY(14px) rotate(1.5deg); opacity: 0; } }
@keyframes strip-wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) {
  .strip-changed::after, .strip-changed .badge { animation: none !important; }
}
