/* Giao diện dùng chung cho checklist.html và config-builder.html.
   Nền trắng, viền/nhấn màu xanh dương nhạt (--accent). --gold giữ riêng cho
   nút hành động chính (Tải thư mục .zip / Xuất Word) để nổi bật, không dùng
   ở chỗ khác. */

:root {
  --accent: #2f6fbe;
  --accent-soft: rgba(47, 111, 190, .5);
  --gold: #cda45e;
  --rule: rgba(59, 130, 246, .32);
  --rule-soft: rgba(59, 130, 246, .14);
  --bg: #ffffff;
  --panel: #f5f9fd;
  --panel-2: #eaf2fb;
  --text: #1b2733;
  --muted: #64748b;
  --ok: #1f8a45;
  --warn: #b3730a;
  --err: #c53434;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  padding-bottom: 80px;
}

code {
  background: var(--panel-2);
  border: 1px solid var(--rule-soft);
  border-radius: 4px;
  padding: 1px 5px;
  font: 12.5px/1.4 "Cascadia Code", Consolas, "SF Mono", monospace;
  color: var(--accent);
  word-break: break-word;
}
strong { color: var(--text); }

/* --- thanh trên cùng ----------------------------------------------------- */

header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  padding: 14px 24px;
}
header .wrap, header .in { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
header .wrap { max-width: 900px; gap: 16px; }
h1 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: .2px; }
h1 span { color: var(--accent); }
header .sp { flex: 1; }

.bar { flex: 1 1 200px; height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; min-width: 120px; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-soft), var(--accent)); transition: width .25s ease; }
.count { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.saved { font-size: 12px; color: var(--ok); opacity: 0; transition: opacity .2s; }
.saved.on { opacity: 1; }

/* --- nút ----------------------------------------------------------------- */

button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 7px 13px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
button:hover { border-color: var(--accent-soft); color: var(--text); }
button.primary { background: var(--gold); color: var(--text); border-color: var(--gold); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.primary:disabled, button:disabled { opacity: .4; cursor: not-allowed; filter: none; }

button.icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 7px 9px; }
button.icon-btn:hover { color: var(--accent); }

/* --- hộp chú thích (i) --------------------------------------------------- */

.lbl {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}
.lbl > .info { margin-left: auto; }        /* luôn dạt sang phải ngoài cùng */
.lbl b { color: var(--err); font-weight: 400; }

.info {
  flex: 0 0 auto;
  display: inline-block;   /* để width/height ăn cả khi nằm ngoài flex (vd trong h1) */
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--panel-2);
  color: var(--muted);
  font: 600 11px/14px "Segoe UI", sans-serif;
  font-style: normal;
  text-align: center;
  cursor: help;
  position: relative;
  user-select: none;
}
.info:hover, .info:focus-visible { border-color: var(--accent); color: var(--accent); outline: none; }

.info::after {
  content: attr(data-tip);
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: max-content;
  max-width: 280px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 9px 11px;
  font: 400 12px/1.5 -apple-system, "Segoe UI", Roboto, sans-serif;
  text-align: left;
  white-space: normal;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(3px);
  transition: opacity .14s, transform .14s, visibility .14s;
  z-index: 50;
  pointer-events: none;
}
.info:hover::after, .info:focus-visible::after { opacity: 1; visibility: visible; transform: translateY(0); }

/* --- checklist ----------------------------------------------------------- */

main { max-width: 900px; margin: 0 auto; padding: 24px; }

.meta {
  background: var(--panel);
  border: 1px solid var(--rule-soft);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 28px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px 16px;
}
.meta input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--rule-soft);
  border-radius: 6px;
  padding: 7px 9px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.meta input:focus { outline: none; border-color: var(--accent-soft); }
.hint { grid-column: 1 / -1; font-size: 12px; color: var(--muted); margin: 0; }

section { margin-bottom: 34px; }
h2 {
  font-size: 15px;
  color: var(--accent);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 8px;
  margin: 0 0 14px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
h2 em { font-style: normal; font-size: 12px; color: var(--muted); font-weight: 400; }
.sub { font-size: 13px; color: var(--muted); margin: 18px 0 8px; }
.sub:first-of-type { margin-top: 0; }

.item { display: flex; gap: 10px; padding: 5px 0; align-items: flex-start; }
.item.child { margin-left: 30px; }
.item input[type=checkbox] {
  appearance: none;
  flex: 0 0 auto;
  width: 17px; height: 17px;
  margin: 3px 0 0;
  border: 1.5px solid var(--rule);
  border-radius: 4px;
  background: var(--bg);
  cursor: pointer;
  position: relative;
}
.item input[type=checkbox]:hover { border-color: var(--accent-soft); }
.item input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
.item input[type=checkbox]:checked::after {
  content: "";
  position: absolute;
  left: 5px; top: 1px;
  width: 4px; height: 9px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.item .body { flex: 1; min-width: 0; }
.item .txt { cursor: pointer; display: block; }
.item.done .txt { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--rule); }
.item.done .txt strong { color: var(--muted); }

.note-in {
  display: block;
  width: 100%;
  margin-top: 5px;
  background: transparent;
  border: 0;
  border-bottom: 1px dashed var(--rule-soft);
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  padding: 2px 0;
}
.note-in::placeholder { color: var(--muted); }
.note-in:focus { outline: none; border-bottom-color: var(--accent-soft); }

select.note-in.yesno {
  display: inline-block;
  width: auto;
  min-width: 130px;
  cursor: pointer;
  background: var(--panel-2);
  border: 1px solid var(--rule-soft);
  border-radius: 5px;
  padding: 3px 7px;
}

textarea.note-in.wide {
  resize: vertical;
  min-height: 54px;
  border: 1px solid var(--rule-soft);
  border-radius: 6px;
  background: var(--bg);
  padding: 6px 8px;
  margin-top: 6px;
}

.note-rows { display: flex; flex-direction: column; gap: 4px; margin-top: 5px; }
.note-row { display: flex; align-items: center; gap: 8px; }
.note-row .note-in { margin-top: 0; flex: 1; }
.note-rm {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  padding: 0;
  border-radius: 5px;
  font-size: 13px;
  line-height: 1;
  color: var(--muted);
}
.note-rm:hover { color: var(--err); border-color: var(--err); }

.note-add {
  margin-top: 6px;
  padding: 3px 9px;
  font-size: 12px;
  color: var(--muted);
  background: transparent;
}
.note-add:hover { color: var(--accent); border-color: var(--accent-soft); }

.note {
  font-size: 13px;
  color: var(--muted);
  border-left: 2px solid var(--rule);
  padding: 4px 0 4px 12px;
  margin: 6px 0 6px 30px;
}
.tail { font-size: 13px; color: var(--muted); margin-top: 10px; }

ul.plain { padding-left: 18px; font-size: 14px; color: var(--muted); }
ul.plain li { margin: 6px 0; }

/* --- form config-builder ------------------------------------------------- */

/* 3 cột: [checklist kiểm tra] [form] [kết quả].
   Hẹp dần thì checklist tách lên thành hàng riêng, rồi mới xếp chồng hết. */
.layout {
  max-width: 1560px;
  margin: 0 auto;
  padding: 22px 24px 90px;
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr) minmax(0, 440px);
  grid-template-areas: "checks form out";
  gap: 24px;
  align-items: start;
}
.checks-col {
  grid-area: checks;
  position: sticky;
  top: 78px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 110px);
  overflow: auto;
}
#form { grid-area: form; }
.out { grid-area: out; position: sticky; top: 78px; }

@media (max-width: 1320px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
    grid-template-areas: "checks checks" "form out";
  }
  .checks-col { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 940px) {
  .layout { grid-template-columns: 1fr; grid-template-areas: "checks" "form" "out"; }
  .out { position: static; }
}

/* Cột form là flex column để đổi chỗ các mục bằng `order` — mục đã đánh dấu
   xong bị đẩy xuống đáy mà DOM không hề bị di chuyển. */
#form { display: flex; flex-direction: column; }

#form > details.done { opacity: .55; }
#form > details.done:hover { opacity: 1; }
#form > details.done > summary { color: var(--ok); }
#form > details.done > summary em { opacity: .5; }

.done-btn {
  flex: 0 0 auto;
  margin-left: 10px;
  width: 22px;
  height: 17px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
}
.done-btn:hover { border-color: var(--ok); color: var(--ok); }
.done-btn.on { background: var(--ok); border-color: var(--ok); color: var(--bg); }

details {
  background: var(--panel);
  border: 1px solid var(--rule-soft);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: visible;
}
details[open] { border-color: var(--rule); }
summary {
  cursor: pointer;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "▾"; color: var(--muted); font-size: 12px; }
details[open] summary::after { content: "▴"; }
/* Chú thích tên field của nhóm (vd nkConfig) — đỏ, nghiêng, nằm ngay sau
   tiêu đề nhóm cách 10px. Phải nằm TRONG .s-title, nếu không justify-content
   của summary sẽ đẩy nó văng sang mép phải. */
summary em {
  font-style: italic;
  font-weight: 400;
  font-size: 12px;
  color: var(--err);
  margin-left: 10px;
}
summary .s-title { flex: 1; min-width: 0; }
summary .info { margin-right: 2px; }   /* nằm ngay trước mũi tên đóng/mở */

/* Chú thích gắn trên h1: tooltip xổ xuống vì phía trên đã hết chỗ. */
h1 .info { margin-left: 2px; vertical-align: middle; }
h1 .info::after, .info.below::after { bottom: auto; top: calc(100% + 8px); transform: translateY(-3px); }
h1 .info:hover::after, .info.below:hover::after,
h1 .info:focus-visible::after, .info.below:focus-visible::after { transform: translateY(0); }

.fields {
  padding: 4px 16px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px 14px;
}
.fields .full { grid-column: 1 / -1; }

/* Tiêu đề nhóm con trong một mục (vd "WiFi" nằm trong nkConfig) — kẻ ngang
   hết chiều rộng để tách khối, không tạo thêm cấp <details> lồng nhau. */
.grp {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 -2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
}
.grp::after { content: ""; flex: 1; height: 1px; background: var(--rule-soft); }
.fields > .grp:first-child, .toggles > .grp:first-child { margin-top: 2px; }

label.f { display: block; }
input[type=text], input[type=url], input[type=email], input[type=number], input[type=date], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--rule-soft);
  border-radius: 6px;
  padding: 7px 9px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
select { cursor: pointer; }
input:disabled { opacity: .45; cursor: not-allowed; }

/* Ô nhập nội dung đa ngôn ngữ: mặc định cao đúng 1 dòng như <input>, bấm nút
   ⤢ ở góc phải nhãn thì giãn ra để nhìn hết câu dài. */
textarea.ml {
  height: 34px;
  min-height: 34px;
  line-height: 1.4;
  overflow: hidden;
  resize: none;
  white-space: pre-wrap;
  transition: height .15s ease;
}
textarea.ml.open { height: 116px; overflow: auto; resize: vertical; }

.exp {
  margin-left: auto;
  flex: 0 0 auto;
  width: 20px;
  height: 16px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
}
.exp:hover { border-color: var(--accent); color: var(--accent); }
.exp.on { background: var(--accent); border-color: var(--accent); color: var(--bg); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-soft); }

.toggles { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 7px 14px; }
.tg { display: flex; align-items: center; gap: 9px; font-size: 13.5px; padding: 3px 0; }
.tg input {
  appearance: none;
  width: 34px; height: 19px;
  border-radius: 99px;
  background: var(--panel-2);
  border: 1px solid var(--rule-soft);
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background .15s;
}
.tg input::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--muted);
  transition: .15s;
}
.tg input:checked { background: var(--accent); border-color: var(--accent); }
.tg input:checked::after { left: 17px; background: var(--bg); }

.rows { grid-column: 1 / -1; }
.row { display: grid; grid-template-columns: 1fr 132px 1.4fr 32px; gap: 8px; margin-bottom: 8px; align-items: start; }
.row button { padding: 0; height: 33px; }
/* Ô icon: dropdown, và chỉ khi chọn "ảnh riêng…" mới hiện thêm ô nhập đường
   dẫn ngay bên dưới — không chiếm thêm cột của lưới. */
.p-icon-cell { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.p-icon-custom[hidden] { display: none; }

.note-line { grid-column: 1 / -1; font-size: 12px; color: var(--muted); margin: 0; }

/* Khối hướng dẫn thao tác nhiều bước — khác tooltip (i) ở chỗ luôn hiện, dùng
   cho việc người triển khai phải làm ở hệ thống KHÁC rồi mới quay lại điền. */
.guide {
  border: 1px solid var(--rule-soft);
  border-left: 2px solid var(--accent-soft);
  border-radius: 8px;
  background: var(--bg);
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted);
}
.guide h4 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
}
.guide ol { margin: 0; padding-left: 18px; }
.guide li { margin: 5px 0; }
.guide p { margin: 9px 0 0; }
.guide strong { color: var(--text); }
.guide em { font-style: italic; color: var(--text); }
.guide code { font-size: 11.5px; word-break: break-all; }

/* --- vùng thả file ------------------------------------------------------- */

.drop {
  /* <label> mặc định là inline — nằm trực tiếp trong .fields thì được grid
     blockify hộ, nhưng khi bọc trong <div> thì phải tự khai báo, nếu không
     border/padding tràn ra ngoài. */
  display: block;
  grid-column: 1 / -1;
  border: 1.5px dashed var(--rule);
  border-radius: 10px;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--panel-2); }
.drop b { display: block; color: var(--text); font-weight: 600; font-size: 14px; margin-bottom: 3px; }
.drop span { font-size: 12px; color: var(--muted); }
.drop input[type=file] { display: none; }

.files { grid-column: 1 / -1; margin: 0; padding: 0; list-style: none; }
.files li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--rule-soft);
  border-radius: 8px;
  margin-top: 8px;
  background: var(--bg);
  font-size: 13px;
}
.files .thumb {
  width: 34px; height: 34px;
  flex: 0 0 auto;
  border-radius: 5px;
  border: 1px solid var(--rule-soft);
  object-fit: contain;
  background: var(--panel-2);
}
.files .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .nm em { font-style: normal; display: block; font-size: 11.5px; color: var(--muted); }
.files .sz { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --- cột kết quả --------------------------------------------------------- */

/* Trong cột kết quả, pre/tree nằm sẵn trong khung <details> nên bỏ viền riêng
   của chúng đi, tránh viền lồng viền. */
.out details .box-body { padding: 0 14px 14px; }
.out details pre, .out details .tree {
  border: 0;
  background: var(--bg);
  border-radius: 8px;
  margin: 0;
}

.tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs button.on { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }
pre {
  background: var(--panel);
  border: 1px solid var(--rule-soft);
  border-radius: 10px;
  padding: 14px;
  margin: 0;
  max-height: 46vh;
  overflow: auto;
  font: 12.5px/1.55 "Cascadia Code", Consolas, monospace;
  white-space: pre;
  color: var(--text);
}
.acts { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

.tree {
  margin-top: 12px;
  background: var(--panel);
  border: 1px solid var(--rule-soft);
  border-radius: 10px;
  padding: 12px 14px;
  font: 12.5px/1.7 "Cascadia Code", Consolas, monospace;
  color: var(--muted);
  white-space: pre;
  overflow-x: auto;
}
.tree b { color: var(--accent); font-weight: 400; }

.checks { border: 1px solid var(--rule-soft); border-radius: 10px; background: var(--panel); padding: 12px 14px; flex: none; }
.checks h3, .cmds h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.checks ul { margin: 0; padding-left: 18px; font-size: 13px; }
.checks li { margin: 5px 0; }
li.e { color: var(--err); }
li.w { color: var(--warn); }
li.i { color: var(--accent); }   /* thông tin thuần, không phải vấn đề */
li.o { color: var(--ok); list-style: none; margin-left: -18px; }

.cmds { border: 1px solid var(--rule-soft); border-radius: 10px; background: var(--panel); padding: 12px 14px; flex: none; }
.cmds h3 button { font-size: 11px; padding: 2px 8px; }
.cmds pre {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
}
.cmds pre .cmt { color: var(--muted); font-style: italic; }

/* --- hộp thoại ----------------------------------------------------------- */

dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 0;
  max-width: 800px;
  width: 92vw;
}
dialog::backdrop { background: rgba(0, 0, 0, .65); }
dialog .head { padding: 14px 18px; border-bottom: 1px solid var(--rule-soft); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
dialog .head strong { font-size: 14px; }
dialog textarea {
  width: 100%;
  height: 55vh;
  background: var(--bg);
  color: var(--text);
  border: 0;
  border-radius: 0;
  padding: 14px 18px;
  font: 13px/1.55 "Cascadia Code", Consolas, monospace;
  resize: vertical;
}
dialog .foot { padding: 12px 18px; border-top: 1px solid var(--rule-soft); display: flex; gap: 8px; justify-content: flex-end; }
