/* ===== Admin JLPT N5 ===== */
* { box-sizing: border-box; }
body {
  margin: 0; font-family: "Plus Jakarta Sans", "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  background: #eef1f6; color: #1f2733; font-size: 15px;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 18px; }
code { background:#eceff5; padding:1px 6px; border-radius:5px; font-size:.9em; }
a { color:#2456c6; }

/* ===== Thanh quản trị: 2 tầng (thương hiệu + tài khoản / tab điều hướng) ===== */
.adm-top { background:#1c2740; color:#fff; box-shadow:0 2px 12px rgba(15,23,42,.14); position:sticky; top:0; z-index:50; }
/* Tầng 1: thương hiệu + tài khoản */
.adm-top-bar { background:linear-gradient(180deg,#26355a,#1e2b49); border-bottom:1px solid rgba(255,255,255,.07); }
.adm-top-bar-in { display:flex; align-items:center; gap:14px; min-height:56px; flex-wrap:wrap; }
.adm-top .brand { color:#fff; text-decoration:none; display:inline-flex; align-items:center; gap:9px; font-size:1.05rem; font-weight:700; white-space:nowrap; }
.adm-top .brand .brand-logo { width:34px; height:34px; border-radius:50%; object-fit:cover; background:#fff; box-shadow:0 2px 6px rgba(0,0,0,.3); flex:none; }
.adm-top .brand b { font-weight:800; letter-spacing:.2px; }
.adm-account { margin-left:auto; display:flex; align-items:center; gap:9px; }
.adm-top .who { display:inline-flex; align-items:center; gap:8px; color:#e2e9f8; font-size:.9rem; font-weight:600; }
.who-av { width:30px; height:30px; border-radius:50%; background:linear-gradient(135deg,#3b82f6,#2456c6); display:inline-flex; align-items:center; justify-content:center; font-weight:800; font-size:.82rem; color:#fff; box-shadow:0 2px 6px rgba(0,0,0,.28); flex:none; }
.btn-out { display:inline-flex; align-items:center; gap:6px; color:#2c3a5c; background:#fff; border:1px solid #c3ccdd; padding:7px 13px; border-radius:9px; text-decoration:none; font-size:.86rem; font-weight:600; transition:.14s; cursor:pointer; }
.btn-out:hover { background:#eef1f6; border-color:#9fabc6; }
.bo-ic { font-size:.95rem; line-height:1; }
/* Nút trong thanh header nền tối */
.adm-top .btn-out { color:#e2e9f8; background:rgba(255,255,255,.07); border-color:rgba(255,255,255,.18); }
.adm-top .btn-out:hover { background:rgba(255,255,255,.15); border-color:rgba(255,255,255,.34); color:#fff; }
.adm-top .btn-out.danger:hover { background:#d64545; border-color:#d64545; color:#fff; }
/* Tầng 2: tab điều hướng */
.adm-nav { background:#161f33; }
.adm-nav-in { display:flex; flex-wrap:wrap; align-items:stretch; gap:1px 0; overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:none; }
.adm-nav-in::-webkit-scrollbar { height:0; display:none; }
.adm-tab { flex:0 0 auto; display:inline-flex; align-items:center; gap:8px; color:#aab6d6; text-decoration:none; font-size:.92rem; font-weight:600; padding:13px 16px; white-space:nowrap; border-bottom:3px solid transparent; transition:color .14s, background .14s, border-color .14s; }
.adm-tab .tab-ic { font-size:1.05rem; line-height:1; }
.adm-tab:hover { color:#fff; background:rgba(255,255,255,.06); }
.adm-tab.active { color:#fff; background:rgba(74,139,255,.14); border-bottom-color:#4b8bff; }
.adm-tab.ext { color:#8ea0c6; }   /* các tab mở tab mới (Đề đào tạo ↗, Xem web ↗) — nối tiếp, tự xuống dòng khi hết chỗ */
.adm-tab.ext:hover { color:#fff; }
@media (max-width:760px) {
  .adm-top-bar-in { min-height:52px; gap:10px; }
  .adm-top .brand { font-size:1rem; }
  .btn-out .bo-lbl { display:none; }        /* mobile: nút tài khoản chỉ còn icon cho gọn */
  .adm-top .btn-out { padding:7px 10px; }
  .who-name { max-width:34vw; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .adm-tab.ext { margin-left:0; }            /* trong cuộn ngang: 'Xem web' chạy cuối tự nhiên */
}

.adm-main { padding: 22px 18px 60px; }
.adm-foot { display:flex; align-items:center; justify-content:center; gap:13px; flex-wrap:wrap; text-align:left; color:#8892a6; font-size:.82rem; padding:24px 18px 36px; line-height:1.6; }
.adm-foot-logo { width:42px; height:42px; border-radius:50%; object-fit:cover; background:#fff; box-shadow:0 1px 5px rgba(20,30,60,.14); flex:none; }
.adm-foot-txt b { color:#3f4a63; }

/* Flash */
.flash { padding:11px 15px; border-radius:9px; margin:0 0 16px; font-weight:500; }
.flash.ok  { background:#e2f7ec; color:#0f7a54; border:1px solid #b6e8cf; }
.flash.err { background:#fdeaea; color:#b62222; border:1px solid #f3c2c2; }

/* Headings & cards */
.page-head { display:flex; align-items:center; justify-content:space-between; margin:0 0 18px; }
.page-head h1, h1 { font-size:1.5rem; margin:0; }
.card { background:#fff; border:1px solid #e0e5ee; border-radius:14px; padding:18px; margin:0 0 18px; box-shadow:0 1px 2px rgba(20,30,60,.04); }
.card h2 { margin:0 0 14px; font-size:1.15rem; }
.card h3 { margin:0 0 12px; font-size:1.02rem; }
.sec-h { font-size:1.2rem; margin:24px 0 12px; }
.crumb { color:#6a7488; font-size:.9rem; margin:0 0 14px; }
.crumb a { color:#2456c6; text-decoration:none; }
.crumb a:hover { text-decoration:underline; }

/* Nhảy tới phần/nhóm từ breadcrumb: chừa khoảng & làm nổi mục vừa tới */
.section-card, .group-block { scroll-margin-top:72px; }
:target.section-card, :target.group-block { animation:crumb-flash 2s ease-out 1; }
@keyframes crumb-flash {
  0%   { box-shadow:0 0 0 3px #f2c94c; background:#fffaf0; }
  100% { box-shadow:0 0 0 0 rgba(242,201,76,0); }
}
.muted { color:#8892a6; font-size:.88rem; }
.hint { color:#6a7488; font-size:.85rem; margin:12px 0 0; }

/* Forms */
label { display:block; font-size:.9rem; color:#3a4256; font-weight:500; margin:0 0 10px; }
input[type=text], input[type=number], input[type=password], select, textarea {
  width:100%; margin-top:5px; padding:9px 11px; border:1px solid #ccd3e0; border-radius:9px;
  font:inherit; background:#fff; color:#1f2733;
}
textarea { resize:vertical; line-height:1.55; }
input:focus, select:focus, textarea:focus { outline:2px solid #9db6f0; border-color:#6f93e0; }
.row { display:flex; gap:14px; flex-wrap:wrap; align-items:flex-end; }
.row > label { flex:1 1 180px; margin-bottom:0; }
.form-foot { display:flex; gap:10px; align-items:stretch; margin-top:16px; }
.form-foot .btn-out { display:inline-flex; align-items:center; padding:0 16px; font-size:inherit; font-weight:600; border-radius:9px; }
.fs { border:1px solid #e0e5ee; border-radius:11px; padding:14px; margin:14px 0; }
.fs legend { font-weight:600; padding:0 8px; color:#2a3550; }
details.adv { margin:10px 0; }
details.adv summary { cursor:pointer; color:#2456c6; font-size:.9rem; }
.pw-wrap { max-width:460px; margin:24px auto 0; }
.pw-wrap .page-head { justify-content:center; }
.form-narrow { max-width:460px; margin:0 auto; }
.form-narrow label small { color:#8892a6; font-weight:400; }

/* Buttons */
.btn-primary { background:#2456c6; color:#fff; border:0; padding:10px 18px; border-radius:9px; font:inherit; font-weight:600; cursor:pointer; }
.btn-primary:hover { background:#1c47a6; }
.btn-sm { display:inline-block; background:#eef1f8; color:#2a3550; border:1px solid #d3dae8; padding:5px 11px; border-radius:8px; font-size:.85rem; text-decoration:none; cursor:pointer; }
.btn-sm:hover { background:#e2e7f3; }
.btn-sm.danger, .btn-xs.danger { background:#fdeded; color:#c22; border-color:#f3c9c9; }
.btn-xs { display:inline-block; background:#eef1f8; color:#2a3550; border:1px solid #d3dae8; padding:3px 8px; border-radius:7px; font-size:.78rem; text-decoration:none; cursor:pointer; }
.btn-xs:hover { background:#e2e7f3; }

/* Tables */
.tbl { width:100%; border-collapse:collapse; background:#fff; border:1px solid #e0e5ee; border-radius:12px; overflow:hidden; }
.tbl th, .tbl td { padding:10px 12px; text-align:left; border-bottom:1px solid #eef1f6; font-size:.92rem; vertical-align:middle; }
.tbl th { background:#f6f8fc; font-size:.82rem; text-transform:uppercase; letter-spacing:.03em; color:#6a7488; }
.tbl tr:last-child td { border-bottom:0; }
.tbl .lnk { font-weight:600; text-decoration:none; }
.tbl.mini { margin:8px 0 0; }
.tbl.mini th, .tbl.mini td { padding:6px 9px; font-size:.86rem; }
.stem-cell { font-family:"Noto Sans JP", sans-serif; }
.actions { white-space:nowrap; text-align:right; }
.empty { text-align:center; color:#8892a6; padding:26px; }
.empty-sm { padding:8px 0; }

/* Pills */
.pill { display:inline-block; padding:2px 9px; border-radius:20px; font-size:.78rem; font-weight:600; border:0; cursor:default; }
.pill.ok   { background:#e2f7ec; color:#0f7a54; }
.pill.warn { background:#fff3d6; color:#a5730a; }
.pill.off  { background:#eceff5; color:#6a7488; }
button.pill { cursor:pointer; }

/* Sections in exam page */
.section-card { padding:16px 18px; }
.section-top { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; }
.section-actions { display:flex; gap:7px; align-items:center; }
.skey { display:inline-block; background:#1f2a44; color:#fff; font-size:.72rem; padding:2px 8px; border-radius:6px; margin-right:6px; text-transform:uppercase; }
.sec-edit { display:none; margin:14px 0 4px; padding:14px; background:#f7f9fc; border-radius:10px; }
.sec-edit.open { display:block; }
.group-block { border-top:1px dashed #e0e5ee; margin-top:14px; padding-top:12px; }
.group-top { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.group-top .sp { flex:1; }
.new-exam { display:none; }
.new-exam.open { display:block; }

/* Option editor */
.opt-row { display:flex; align-items:center; gap:10px; margin:0 0 8px; }
.opt-idx { width:24px; height:24px; flex:none; display:flex; align-items:center; justify-content:center; background:#eef1f8; border-radius:6px; font-size:.82rem; font-weight:600; color:#3a4256; }
.opt-row input[type=text] { margin-top:0; }
.opt-correct { flex:none; margin:0; display:flex; align-items:center; gap:5px; font-weight:600; color:#0f7a54; white-space:nowrap; }
.opt-tools { display:flex; align-items:center; gap:16px; margin-top:8px; }
.opt-none { margin:0; display:flex; align-items:center; gap:6px; color:#a5730a; font-weight:600; }
.cur-fig { display:flex; align-items:center; gap:12px; margin-bottom:10px; }
.cur-fig img { max-height:90px; border:1px solid #d3dae8; border-radius:8px; }
.pick-fig { display:flex; align-items:center; gap:12px; margin:8px 0 4px; }
.pick-fig img { max-height:120px; max-width:100%; border:1px solid #c3ccdd; border-radius:8px; }
.pick-fig .pick-note { font-size:.85rem; color:#0f7a54; }
.pick-thumb { position:relative; display:inline-block; line-height:0; }
.pick-thumb .pick-clear { position:absolute; top:-8px; right:-8px; width:22px; height:22px; padding:0;
  display:flex; align-items:center; justify-content:center; background:#e23b3b; color:#fff;
  border:2px solid #fff; border-radius:50%; font-size:.72rem; line-height:1; cursor:pointer;
  box-shadow:0 1px 3px rgba(0,0,0,.25); }
.pick-thumb .pick-clear:hover { background:#c22; }
.chk { margin:0; display:flex; align-items:center; gap:6px; font-weight:500; }

/* ===== Thanh công cụ soạn tiếng Nhật + xem trước ===== */
.jp-toolbar { display:flex; flex-wrap:wrap; gap:6px; align-items:center; padding:10px 12px; background:#f0f4fb; border:1px solid #d7deea; border-radius:11px 11px 0 0; }
.jp-tb-hint { font-size:.82rem; color:#6a7488; margin-right:4px; }
.jp-tb-btn { background:#fff; border:1px solid #ccd6e6; border-radius:8px; padding:6px 10px; font-size:.85rem; cursor:pointer; color:#25324e; font-family:"Noto Sans JP",sans-serif; }
.jp-tb-btn:hover { background:#2456c6; color:#fff; border-color:#2456c6; }
.jp-preview-box { border:1px solid #d7deea; border-top:0; border-radius:0 0 11px 11px; background:#fff; padding:0 0 4px; margin:0 0 16px; }
.jp-prev-label { font-size:.72rem; text-transform:uppercase; letter-spacing:.04em; color:#8892a6; padding:7px 12px 4px; }
.jp-preview { padding:10px 14px 14px; font-family:"Noto Sans JP","Be Vietnam Pro",sans-serif; font-size:1.12rem; line-height:2; color:#1f2733; }
.jp-prev-empty, .qprev-empty { color:#aab2c4; font-size:.86rem; font-style:italic; font-weight:400; }

/* Bản dựng cả câu hỏi — mô phỏng trang thi */
.qprev-card { border:1px solid #e3e8f2; border-radius:12px; padding:14px 16px; background:#fbfcfe; }
.qprev-qtop { display:flex; gap:12px; align-items:flex-start; }
.qprev-no { flex:none; width:30px; height:30px; display:flex; align-items:center; justify-content:center;
  background:#2456c6; color:#fff; border-radius:8px; font-size:.95rem; font-weight:700; }
.qprev-stem { flex:1; line-height:1.95; padding:2px 4px; border-radius:8px; }
.qprev-stem.is-focus { background:#fff6da; box-shadow:0 0 0 2px #f2c94c inset; }
.qprev-fig { margin:10px 0 2px; }
.qprev-fig img { display:block; max-width:100%; max-height:260px; border:1px solid #d3dae8; border-radius:8px; }
.qprev-cap { margin-top:5px; font-size:.85rem; color:#6a7488; }
.qprev-options { margin:12px 0 0; display:grid; gap:8px; }
.qprev-opt { display:flex; gap:10px; align-items:flex-start; border:1.6px solid #dfe5f0; border-radius:11px;
  padding:8px 12px; background:#fff; position:relative; }
.qprev-opt .qprev-mark { flex:none; width:26px; height:26px; display:flex; align-items:center; justify-content:center;
  border:1.6px solid #cdd6e6; border-radius:50%; font-size:.85rem; font-weight:700; color:#3a4256; }
.qprev-opt .qprev-otext { flex:1; line-height:1.75; }
.qprev-opt.is-correct { border-color:#22a06b; background:#eefaf3; }
.qprev-opt.is-correct .qprev-mark { background:#22a06b; border-color:#22a06b; color:#fff; }
.qprev-opt.is-focus { box-shadow:0 0 0 2px #f2c94c inset; border-color:#f2c94c; }
.qprev-badge { flex:none; align-self:center; font-size:.72rem; font-weight:700; color:#0f7a54;
  background:#d6f2e4; border-radius:20px; padding:2px 9px; }
/* ký hiệu render trong preview — khớp web thi */
.jp-preview ruby rt { font-size:.56em; font-weight:400; color:#6b76a0; }
.jp-preview .ul { text-decoration:underline; text-decoration-color:#2456c6; text-underline-offset:3px; text-decoration-thickness:2px; font-weight:600; }
.jp-preview .star { color:#e04b5a; font-weight:800; padding:0 .12em; }
.jp-preview .blank-num { display:inline-block; min-width:2em; text-align:center; border:1.5px solid #2a3550; border-radius:7px; padding:0 .3em; font-weight:700; color:#25324e; background:#eef3ff; margin:0 .14em; }
.jp-field:focus { outline:2px solid #2456c6; }

/* Login */
.login-body { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:20px; min-height:100vh; background:linear-gradient(160deg,#26355a,#1a2440); }
.login-card { background:#fff; padding:32px 30px; border-radius:16px; width:340px; box-shadow:0 20px 50px rgba(0,0,0,.3); }
.login-logo { display:block; width:66px; height:66px; border-radius:50%; object-fit:cover; background:#fff; margin:0 auto 14px; box-shadow:0 4px 16px rgba(0,0,0,.22); }
.login-cr { margin:0; text-align:center; color:#c1cdea; font-size:.8rem; line-height:1.5; }
.login-cr b { color:#fff; }
.login-card h1 { font-size:1.25rem; margin:0 0 4px; text-align:center; }
.login-card .sub { text-align:center; color:#8892a6; margin:0 0 20px; font-size:.9rem; }
.login-card label { margin-bottom:14px; }
.login-card .btn-primary { width:100%; margin-top:6px; }

/* ================= Responsive / Mobile ================= */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .wrap { padding: 0 12px; }
  .adm-main { padding: 16px 12px 48px; }
  h1, .page-head h1 { font-size: 1.28rem; }

  /* Tiêu đề trang: nút xuống hàng gọn gàng */
  .page-head { flex-wrap:wrap; gap:10px; }
  .page-head > div { display:flex; gap:8px; flex-wrap:wrap; }

  /* Form: mỗi ô một dòng cho dễ nhập */
  .row > label { flex-basis:100%; }

  /* Bảng -> thẻ xếp dọc, mỗi dòng một thẻ, có nhãn cột */
  .tbl { border:0; background:transparent; }
  .tbl thead { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0 0 0 0); border:0; }
  .tbl tr { display:block; border:1px solid #e0e5ee; border-radius:12px; background:#fff; margin:0 0 12px; padding:2px 2px; box-shadow:0 1px 2px rgba(20,30,60,.04); }
  .tbl td { display:flex; justify-content:space-between; align-items:center; gap:14px;
    padding:9px 14px; border-bottom:1px solid #f2f4f9; font-size:.92rem; text-align:right; }
  .tbl tr td:last-child { border-bottom:0; }
  .tbl td::before { content:attr(data-label); font-weight:600; color:#6a7488; font-size:.8rem; text-align:left; flex:none; }
  .tbl td[data-label=""]::before { content:none; }
  .tbl td.col-title, .tbl td.stem-cell { display:block; text-align:left; }
  .tbl td.col-title::before, .tbl td.stem-cell::before { display:block; margin-bottom:3px; }
  .tbl td.col-title .lnk { font-size:1.05rem; }
  .tbl .actions { justify-content:flex-start; white-space:normal; flex-wrap:wrap; gap:8px; }
  .tbl td.empty { display:block; text-align:center; }
  .tbl td.empty::before { content:none; }

  /* Vùng chạm lớn hơn cho ngón tay */
  .btn-xs { padding:8px 13px; font-size:.82rem; }
  .btn-sm { padding:8px 14px; font-size:.86rem; }
  .btn-primary { padding:11px 18px; }
  .actions .btn-xs, .actions .btn-sm { margin:0; }
  .jp-tb-btn { padding:8px 11px; }

  /* Trang đề: hành động phần/nhóm xuống hàng thoáng */
  .section-actions { flex-wrap:wrap; }
  .group-top { gap:8px 10px; }

  /* Card đăng nhập vừa màn nhỏ */
  .login-body { padding:16px; }
  .login-card { width:100%; max-width:360px; }

  /* Ô lựa chọn đáp án khi hẹp */
  .opt-row { flex-wrap:wrap; }
  .opt-row input[type=text] { flex:1 1 100%; order:3; }
  .opt-correct { order:2; margin-left:auto; }
}

@media (max-width: 400px) {
  .adm-top .brand { font-size:.98rem; }
  .jp-tb-hint { flex-basis:100%; }
}

/* ===== Chủ đề: bộ chọn đề (topics.php) ===== */
.topic-toolbar { display:flex; align-items:center; gap:10px 14px; flex-wrap:wrap; margin:0 0 12px; }
.topic-search { flex:1 1 260px; min-width:180px; padding:9px 12px; border:1px solid #d3dae8; border-radius:9px; font:inherit; }
.topic-search:focus { outline:none; border-color:#2456c6; box-shadow:0 0 0 3px rgba(36,86,198,.15); }
.picker-count { color:#2456c6; }
.exam-picker { max-height:460px; overflow:auto; border:1px solid #e0e5ee; border-radius:12px; background:#fff; }
.exam-picker .pk-row { display:flex; align-items:center; gap:12px; padding:9px 14px; border-bottom:1px solid #eef1f6; cursor:pointer; margin:0; }
.exam-picker .pk-row:last-child { border-bottom:0; }
.exam-picker .pk-row:hover { background:#f6f8fc; }
.exam-picker .pk-row input[type=checkbox] { width:18px; height:18px; flex:none; cursor:pointer; }
.exam-picker .pk-main { flex:1 1 auto; min-width:0; }
.exam-picker .pk-title { font-weight:600; color:#243049; }
.exam-picker .pk-sub { color:#8892a6; font-size:.82rem; margin-top:1px; }
.exam-picker .pk-sub code { background:#f1f4fa; padding:1px 5px; border-radius:5px; }
.exam-picker .pk-none { padding:18px; text-align:center; color:#8892a6; }
.pill.cat-jlpt  { background:#e7edff; color:#2f4bad; }
.pill.cat-train { background:#e2f7ec; color:#0f7a54; }
.pill.cat-other { background:#eceff5; color:#6a7488; }
.topic-desc-cell { color:#8892a6; font-size:.86rem; margin-top:2px; }
.actions button[disabled] { opacity:.35; cursor:not-allowed; }

/* ===== Thanh phân trang (dùng chung — inc.php render_pager) ===== */
.pager { display:flex; flex-wrap:wrap; align-items:center; gap:10px 14px; margin:16px 0 4px; font-size:.9rem; color:#4a5568; }
.pager-info b { color:#1f2733; }
.pager-nav { display:inline-flex; flex-wrap:wrap; gap:4px; }
.pager .pg-btn { display:inline-flex; align-items:center; justify-content:center; min-width:34px; height:34px;
  padding:0 9px; border:1px solid #d3dae8; border-radius:8px; background:#fff; color:#2a3550;
  text-decoration:none; font-size:.9rem; font-weight:600; cursor:pointer; }
.pager .pg-btn:hover { background:#eef1f8; border-color:#9fabc6; }
.pager .pg-btn.cur { background:#2456c6; border-color:#2456c6; color:#fff; cursor:default; }
.pager .pg-btn.disabled { color:#c3ccdd; background:#f6f8fc; cursor:not-allowed; }
.pager .pg-gap { padding:0 4px; color:#8892a6; align-self:center; }
.pager-per { margin-left:auto; display:inline-flex; align-items:center; gap:7px; color:#6a7488; white-space:nowrap; }
.pager-per select { width:auto; margin-top:0; padding:6px 9px; border-radius:8px; }
@media (max-width:760px) {
  .pager { gap:10px; }
  .pager-per { margin-left:0; width:100%; }
}
