/* Form gửi bug 5 phần + dải tiến độ, trình khoanh lỗi, phiếu bug (xem trước, trang phiếu, bản in). */

/* ---------- dải tiến độ 5 phần (dính đầu form khi cuộn) ---------- */
.form-strip {
  position: sticky; top: 56px; z-index: 5; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
  padding: 8px; margin: 0 0 14px; background: rgba(223, 226, 228, 0.92); backdrop-filter: blur(6px);
  border-radius: var(--radius);
}
@media (max-width: 639px) { .form-strip { top: 0; margin-left: -6px; margin-right: -6px; } }
.form-strip button {
  display: grid; gap: 4px; justify-items: start; min-height: 48px; padding: 6px 8px 8px; border: 0; border-radius: 6px;
  background: var(--tag); color: var(--ink-2); font: inherit; font-size: 0.74rem; font-weight: 700; cursor: pointer; text-align: left;
  position: relative; overflow: hidden; line-height: 1.2;
}
.form-strip button::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--rule-2);
  transform-origin: left; transition: background-color 0.3s var(--ease-out);
}
.form-strip .fs-no { font-size: 0.95rem; color: var(--ink); }
/* phần đã đủ: tô kín mực (liếc là thấy khác phần còn trống) */
.form-strip button.done { background: var(--ink); color: #d9dde1; animation: strip-fill 0.35s var(--ease-out); }
.form-strip button.done .fs-no { color: #fff; }
.form-strip button.done::after { background: var(--s-closed); }
.form-strip button.optional.done { background: var(--ink-2); }
.form-strip button.current:not(.done) { box-shadow: inset 0 0 0 2px var(--ink); }
.form-strip button.done.current { box-shadow: inset 0 0 0 2px var(--tag), inset 0 0 0 4px var(--ink); }
@keyframes strip-fill { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) { .form-strip button.done { animation: none; } }
/* điện thoại: tần suất 4 ô 1 hàng */
@media (max-width: 639px) {
  #frequency-seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #frequency-seg .seg-btn { min-width: 0; }
}
@media (max-width: 420px) { .form-strip .fs-label { display: none; } .form-strip button { justify-items: center; } }

/* ---------- form 5 phần ---------- */
.form-step { padding-top: 16px; scroll-margin-top: 130px; }
.step-title { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; margin: 0 0 14px; }
.step-badge {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex: none;
  border-radius: 6px; background: var(--ink); color: #fff; font-weight: 700; font-size: 0.95rem;
}
.mt-8 { margin-top: 8px; }
.step-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.step-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.step-no {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
  border-radius: 6px; background: var(--tag-2); box-shadow: inset 0 0 0 1px var(--rule); color: var(--ink); font-weight: 700; font-size: 0.9rem;
}
.step-del {
  min-width: 44px; min-height: 44px; border: 1px solid var(--rule); border-radius: var(--radius-ctl); background: var(--field);
  color: var(--ink-2); font: inherit; cursor: pointer;
}
.step-del:hover { border-color: var(--danger); color: var(--danger); }
.field.invalid .step-input { border-color: var(--danger); background: var(--danger-soft); }
.ev-mark {
  position: absolute; left: 4px; bottom: 26px; /* nằm trên dòng "Đã tải lên / Lỗi tải lên" ở đáy, không đè nút Xóa */
  min-height: 32px; padding: 4px 10px; border-radius: 6px; border: 0;
  background: #e61414; color: #fff; font: inherit; font-size: 0.8rem; font-weight: 700; cursor: pointer;
}
.ev-item.is-marked { outline: 3px solid #e61414; outline-offset: -3px; }
.hint-list { margin: 6px 0 0; padding-left: 20px; }
.preview-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
details.more { border-top: 1px solid var(--rule-2); padding-top: 6px; }

/* ---------- trình khoanh lỗi ---------- */
body.no-scroll { overflow: hidden; }
.markup-overlay { position: fixed; inset: 0; z-index: var(--z-overlay); background: rgba(14, 16, 19, 0.88); display: flex; align-items: center; justify-content: center; padding: 12px; }
.markup-box { background: var(--tag); border-radius: var(--radius); padding: 14px; width: min(100%, 1100px); max-height: 100%; overflow: auto; }
.markup-help { margin: 0 0 10px; font-weight: 700; }
.markup-stage { width: 100%; display: flex; justify-content: center; }
.markup-stage canvas { max-width: 100%; touch-action: none; cursor: crosshair; border-radius: 6px; }
.markup-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 12px; }

/* ---------- phiếu bug: 1 thẻ lớn ---------- */
.ticket {
  position: relative; background: var(--tag); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 18px 0; margin-bottom: 14px; overflow: hidden;
}
.ticket::before {
  content: ''; position: absolute; top: 24px; left: 18px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--desk); box-shadow: inset 0 1.5px 3px rgba(0, 0, 0, 0.28);
}
.t-title { font-size: 1.25rem; margin: 0 0 14px; padding-left: 30px; line-height: 1.35; display: grid; gap: 8px; }
.t-code {
  display: inline-block; justify-self: start; font-size: 2.1rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1;
  color: var(--ink); padding-bottom: 6px; border-bottom: 3px solid var(--ink);
}
/* dải trạng thái ngay dưới tiêu đề: màu theo trạng thái */
.t-strip {
  display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 0 -18px 16px; padding: 10px 18px 8px;
  background:
    radial-gradient(circle at 5px 0, var(--tag) 2.2px, transparent 2.8px) repeat-x 0 0 / 10px 5px,
    var(--b, var(--s-muted));
  color: var(--bt, #fff); font-weight: 700;
}
.t-strip .t-strip-sev { font-weight: 500; opacity: 0.92; }
.t-info { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin-bottom: 8px; table-layout: fixed; }
.t-info th, .t-info td { border-bottom: 1px solid var(--rule-2); padding: 7px 8px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.t-info th { width: 17%; font-size: 0.78rem; font-weight: 700; color: var(--ink-2); background: var(--tag-2); }
.t-sec { font-size: 1rem; margin: 18px 0 6px; display: flex; align-items: center; gap: 8px; }
.t-sec::before { content: ''; width: 8px; height: 18px; border-radius: 2px; background: var(--ink); flex: none; }
.t-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; max-width: 72ch; }
.t-steps { margin: 0; padding-left: 24px; }
.t-steps li { margin: 3px 0; padding-left: 2px; }
.t-steps li::marker { font-weight: 700; }
.t-fig { margin: 10px 0 14px; }
.t-fig img, .t-fig video { display: block; max-width: 100%; border-radius: 6px; box-shadow: 0 0 0 1px var(--rule); }
.t-fig figcaption { font-size: 0.82rem; color: var(--ink-2); margin-top: 5px; font-weight: 700; }
.t-history { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 0.92rem; }
.ticket > :last-child { margin-bottom: 20px; }
.ticket-toolbar { display: flex; gap: 8px; justify-content: space-between; margin-bottom: 14px; }
.ticket-toolbar[hidden] { display: none; } /* chưa tải / không tìm thấy phiếu: không hiện nút In */
@media (max-width: 520px) {
  .t-info, .t-info tbody, .t-info tr { display: block; }
  .t-info tr { display: grid; grid-template-columns: 34% 66%; }
  .t-info th, .t-info td { width: auto; }
  .t-code { font-size: 1.8rem; }
}

/* ---------- bản in: chỉ phiếu, mỗi phiếu 1 trang ---------- */
@media print {
  .no-print, .topbar, .nav, .form-strip { display: none !important; }
  body { background: #fff; padding-bottom: 0; }
  .page { max-width: none; padding: 0; }
  .ticket { box-shadow: none; padding: 0; }
  .ticket::before { display: none; }
  .t-title { padding-left: 0; }
  .t-strip { margin: 0 0 12px; }
  .t-fig { break-inside: avoid; }
  .t-fig img { max-height: 11cm; }
  .t-code, .t-strip, .t-info th, .t-sec::before { -webkit-print-color-adjust: exact; print-color-adjust: exact; } /* giữ nền khi in */
}
