/* ==========================================================================
   Máy thi chứng chỉ IT trong Study World (cert-terminal.mjs).
   Khung: màn hình máy tính phủ lên game. Bên trong dùng lại cert.css (cert-*, certcat-*)
   cho phần làm bài / kết quả để giống hệt trang /certs; phần danh mục dùng swt-*.
   ========================================================================== */

.sw-term { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(8, 14, 24, .55), rgba(8, 14, 24, .82)); animation: swt-in .22s ease-out; }
@keyframes swt-in { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }

.sw-term-desk { display: flex; flex-direction: column; align-items: center; width: min(1180px, 95vw); }
.sw-term-monitor { width: 100%; height: min(760px, 86vh); padding: 14px 14px 22px; border-radius: 18px;
  background: linear-gradient(180deg, #23272e, #15181d); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .08); position: relative; }
.sw-term-monitor::after { content: ''; position: absolute; left: 50%; bottom: 7px; width: 7px; height: 7px; margin-left: -3px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 6px #3ddc84; }
.sw-term-neck { width: 90px; height: 26px; background: linear-gradient(90deg, #1b1e23, #2b3038, #1b1e23); }
.sw-term-foot { width: 260px; height: 10px; border-radius: 10px 10px 4px 4px; background: #23272e; box-shadow: 0 8px 20px -6px rgba(0, 0, 0, .6); }

.sw-term-screen { position: relative; width: 100%; height: 100%; border-radius: 6px; overflow: hidden; display: flex; flex-direction: column;
  background: var(--cert-ground); color: var(--cert-ink); font-family: var(--cert-sans); font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
.sw-term-screen *, .sw-term-screen *::before, .sw-term-screen *::after { box-sizing: border-box; }

.sw-term-bar { flex: none; height: 38px; display: flex; align-items: center; gap: 10px; padding: 0 10px 0 14px;
  background: #0a1422; color: #cfe0f5; font-size: 12.5px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.sw-term-logo { color: #4da3ff; font-size: 14px; }
.sw-term-name { font-weight: 700; color: #fff; letter-spacing: .2px; }
.sw-term-crumb { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; padding-left: 10px; border-left: 1px solid rgba(255, 255, 255, .12); }
.sw-term-crumb button { background: none; border: 0; color: #9cc3ff; cursor: pointer; padding: 2px 4px; border-radius: 6px; font: inherit; }
.sw-term-crumb button:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sw-term-crumb span { opacity: .5; }
.sw-term-crumb b { color: #fff; overflow: hidden; text-overflow: ellipsis; }
.sw-term-clock { font-variant-numeric: tabular-nums; opacity: .8; }
.sw-term-btn { border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .06); color: #e6eefb; border-radius: 7px; padding: 3px 10px; font: inherit; cursor: pointer; }
.sw-term-btn:hover { background: rgba(255, 255, 255, .14); }
.sw-term-btn.is-stand { border-color: rgba(255, 120, 120, .35); color: #ffc2c2; }

.sw-term-body { flex: 1; min-height: 0; overflow-y: auto; position: relative; }
.sw-term-body.is-exam { overflow: hidden; }
.sw-term .cert-app { height: 100%; }
.sw-term .cert-modal { position: absolute; z-index: 30; }
.sw-term .cert-timer.is-low .val { color: #ff8a8a; }
.sw-term .cert-hd-exit { background: none; border: 0; cursor: pointer; font: inherit; }

/* ---------- danh mục ---------- */
.swt-page { max-width: 980px; margin: 0 auto; padding: 26px 30px 40px; }
.swt-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 20px; }
.swt-hero h2, .swt-certhero h2 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.2px; }
.swt-muted { color: var(--cert-ink-mute); margin: 4px 0 0; }
.swt-search { width: 300px; max-width: 100%; height: 40px; border-radius: 10px; border: 1px solid var(--cert-line); padding: 0 14px; font: inherit; background: #fff; outline: none; }
.swt-search:focus { border-color: var(--cert-accent); box-shadow: 0 0 0 3px var(--cert-accent-dim); }

.swt-vendors { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.swt-vendor { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 18px; border-radius: 14px; border: 1px solid var(--cert-line);
  background: #fff; cursor: pointer; text-align: left; font: inherit; color: inherit; position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s, border-color .15s; }
.swt-vendor::before { content: ''; position: absolute; inset: 0 0 auto; height: 4px; background: var(--v); }
.swt-vendor:hover { transform: translateY(-2px); border-color: var(--v); box-shadow: 0 12px 26px -16px rgba(12, 26, 46, .45); }
.swt-logo { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--v) 12%, #fff);
  color: var(--v); font-weight: 800; font-size: 13px; letter-spacing: .3px; overflow: hidden; }
.swt-logo img { max-width: 80%; max-height: 80%; object-fit: contain; }
.swt-logo.is-lg { width: 60px; height: 60px; font-size: 16px; }
.swt-vname { font-weight: 700; font-size: 15px; }
.swt-vmeta { color: var(--cert-ink-mute); font-size: 12.5px; }
.swt-vhead { display: flex; align-items: center; gap: 14px; }

.swt-list { display: flex; flex-direction: column; gap: 8px; }
.swt-cert { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--cert-line);
  background: #fff; cursor: pointer; text-align: left; font: inherit; color: inherit; border-left: 4px solid var(--v); transition: background .12s, box-shadow .12s; }
.swt-cert:hover { background: var(--cert-surface-alt); box-shadow: 0 8px 20px -14px rgba(12, 26, 46, .4); }
.swt-code { font-family: var(--cert-mono); font-weight: 700; font-size: 12.5px; padding: 3px 9px; border-radius: 7px; background: color-mix(in srgb, var(--v) 10%, #fff); color: var(--v); white-space: nowrap; }
.swt-cname { font-weight: 650; min-width: 0; }
.swt-cname small { display: block; color: var(--cert-ink-mute); font-weight: 500; font-size: 12px; }
.swt-pin { font-size: 10.5px; font-weight: 700; color: #92400E; background: var(--cert-mark-dim); padding: 1px 7px; border-radius: 999px; margin-left: 4px; }
.swt-go { color: var(--cert-ink-mute); font-size: 20px; }
.swt-empty { padding: 30px; text-align: center; color: var(--cert-ink-mute); background: #fff; border: 1px dashed var(--cert-line); border-radius: 12px; }

.swt-certhero { background: #fff; border: 1px solid var(--cert-line); border-radius: 16px; padding: 22px 24px; margin-bottom: 16px; border-top: 4px solid var(--v); }
.swt-certhero .certcat-code { display: inline-block; margin-bottom: 8px; }
.swt-facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.swt-facts span { background: var(--cert-surface-alt); border: 1px solid var(--cert-line); border-radius: 999px; padding: 4px 12px; font-size: 12.5px; color: var(--cert-ink-soft); }
.swt-owned { margin: 14px 0 0; color: #15803D; font-weight: 600; }
.swt-locknote { margin: 14px 0 0; font-size: 13px; color: var(--cert-ink-soft); background: var(--cert-mark-dim); border-radius: 10px; padding: 10px 12px; }
.swt-locknote a { color: var(--cert-accent-deep); font-weight: 600; }
.swt-exams { display: flex; flex-direction: column; gap: 8px; }
.swt-exam { display: grid; grid-template-columns: 1fr auto; grid-template-areas: 'nm act' 'info act'; gap: 2px 16px; align-items: center;
  background: #fff; border: 1px solid var(--cert-line); border-radius: 12px; padding: 12px 16px; }
.swt-exam .nm { grid-area: nm; font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.swt-exam .info { grid-area: info; font-size: 12.5px; color: var(--cert-ink-mute); }
.swt-exam .act { grid-area: act; display: flex; gap: 8px; align-items: center; }

.swt-result { padding-top: 24px; }
.swt-center { height: 100%; min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 30px; }
.swt-err { color: var(--cert-bad); font-weight: 600; }
.swt-spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--cert-line); border-top-color: var(--cert-accent); animation: swt-spin .8s linear infinite; }
@keyframes swt-spin { to { transform: rotate(360deg); } }

.swt-welcome { max-width: 620px; margin: 40px auto; background: #fff; border: 1px solid var(--cert-line); border-radius: 18px; padding: 30px 34px; text-align: center; }
.swt-welcome-ico { font-size: 40px; }
.swt-welcome h2 { margin: 6px 0 2px; font-size: 22px; font-weight: 800; }
.swt-steps { text-align: left; margin: 18px 0 22px; padding-left: 22px; color: var(--cert-ink-soft); }
.swt-steps li { margin: 6px 0; }

.swt-toast { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: #0a1422; color: #fff; padding: 8px 16px; border-radius: 10px; font-size: 13px; z-index: 40; }

/* ---------- ngồi / nằm: tuỳ chọn bên phải + trang web nhúng (seat-apps.mjs) ---------- */
.swa-list { position: absolute; right: 16px; top: 50%; translate: 0 -50%; /* không dùng transform: hiệu ứng sws-in ghi đè */ width: 236px; padding: 10px; display: flex; flex-direction: column; gap: 6px;
  pointer-events: auto; border-radius: 16px; }
.swa-list[hidden] { display: none; }
.swa-list { max-height: calc(100% - 140px); overflow-y: auto; }
.swa-hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11.5px; font-weight: 600; letter-spacing: .3px;
  color: rgba(232, 238, 247, .65); padding: 0 0 2px 6px; }
.swa-x { flex: none; width: 26px; height: 26px; border-radius: 8px; border: 0; background: rgba(255, 255, 255, .06); color: rgba(232, 238, 247, .75);
  font-size: 12px; cursor: pointer; }
.swa-x:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.swa-chev { flex: none; display: flex; color: rgba(232, 238, 247, .55); transition: transform .2s; }
.swa-item.is-expanded .swa-chev { transform: rotate(180deg); }
.swa-item[data-group="languages"] .swa-ic { background: rgba(61, 220, 132, .14); color: #7fe3a9; }
.swa-sub { display: flex; flex-direction: column; gap: 3px; margin: -2px 0 2px 18px; padding-left: 10px; border-left: 1px solid rgba(255, 255, 255, .1); }
.swa-sub[hidden] { display: none; }
.swa-subitem { display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px 8px; border-radius: 9px; border: 0; background: none; color: inherit;
  font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.swa-subitem:hover { background: rgba(61, 220, 132, .14); }
.swa-badge { flex: none; width: 26px; height: 22px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
  background: rgba(255, 255, 255, .08); color: #d9f7e6; }
.swa-sublabel { flex: 1; min-width: 0; }
.swa-subitem.is-open .swa-on { display: block; }
.swa-toggle { position: absolute; right: 16px; top: 50%; translate: 0 -50%; /* không dùng transform: hiệu ứng sws-in ghi đè */ width: 46px; height: 46px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; border: 1px solid rgba(255, 255, 255, .14); background: rgba(13, 20, 33, .88); color: #ffc477; cursor: pointer;
  pointer-events: auto; box-shadow: 0 10px 26px -10px rgba(0, 0, 0, .6); }
.swa-toggle:hover { background: rgba(13, 20, 33, .96); color: #fff; }
.swa-toggle[hidden] { display: none; }
.swa-toggle.is-open::after { content: ''; position: absolute; top: 4px; right: 4px; width: 9px; height: 9px; border-radius: 50%; background: #3ddc84; }
.swa-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .04); color: inherit; font: inherit; text-align: left; cursor: pointer; transition: background .15s, border-color .15s, transform .15s; }
.swa-item:hover { background: rgba(77, 163, 255, .16); border-color: rgba(77, 163, 255, .45); }
.swa-ic { flex: none; width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: rgba(77, 163, 255, .16); color: #8cc4ff; }
.swa-item[data-app="books"] .swa-ic { background: rgba(255, 184, 77, .16); color: #ffc477; }
.swa-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.swa-tx b { font-size: 14px; color: #fff; }
.swa-tx small { font-size: 11.5px; color: rgba(232, 238, 247, .6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swa-on { display: none; color: #3ddc84; font-size: 10px; }
.swa-item.is-open .swa-on { display: block; }
.swa-term[hidden] { display: none; }
.swa-term .sw-term-logo { display: flex; color: #8cc4ff; }
.swa-sp { flex: 1; }
.swa-load { font-size: 12px; opacity: .65; }
.swa-load[hidden] { display: none; }
.swa-body { overflow: hidden; background: #fff; }
.swa-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
@media (max-width: 760px), (max-height: 520px) {
  .swa-list { right: 10px; width: 200px; padding: 8px; }
  .swa-tx small { display: none; }
  .swa-ic { width: 30px; height: 30px; }
  .swa-toggle { right: 10px; width: 40px; height: 40px; }
  .swa-term .sw-term-desk { width: 100vw; }
  .swa-term .sw-term-monitor { height: 100vh; height: 100dvh; padding: 0; border-radius: 0; }
  .swa-term .sw-term-monitor::after, .swa-term .sw-term-neck, .swa-term .sw-term-foot { display: none; }
  .swa-term .sw-term-screen { border-radius: 0; }
}
/* Màn cảm ứng: góc dưới phải là cần điều khiển / nút nhảy → ô tuỳ chọn lên góc trên phải (dưới nút cài đặt) */
.sw-touch .swa-list, .sw-touch .swa-toggle { top: calc(62px + env(safe-area-inset-top, 0px)); translate: none; right: calc(10px + env(safe-area-inset-right, 0px)); }
.sw-touch .swa-list { max-height: calc(100% - 74px - env(safe-area-inset-top, 0px)); }

/* Khung chat đang mở (góc dưới phải, cao tới ~440px): ô tuỳ chọn khi ngồi né sang trái khung chat, màn hẹp thì ẩn */
.sw-chat-open .swa-list, .sw-chat-open .swa-toggle { right: calc(min(360px, 100vw - 32px) + 28px); }
@media (max-width: 760px) { .sw-chat-open .swa-list, .sw-chat-open .swa-toggle { display: none; } }
