/* Prototype Playground — nạp sau assets/css/global.css của website (header, menu, footer, token dùng chung), giao diện tối. */
:root {
  --primary: #4C5FFF;
  --primary-dark: #00084A;
  --accent: #019770;
  --error: #F04438;
  --bg: #0A0D1A;
  --surface: #111528;
  --surface-2: #171B33;
  --surface-3: #1E2340;
  --border: #262B4D;
  --border-light: #333962;
  --text: #F5F6FA;
  --text-2: #A7ACC7;
  --text-3: #7D82A3;
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-full: 999px;
  --shadow-3: 0 16px 40px rgba(0,8,74,0.48), 0 6px 16px rgba(0,8,74,0.32);
  --side-w: 300px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 400 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- playground ---------- */
/* playground ghim vào khung nhìn, dưới header website: không cuộn trang */
.pg-player { display: grid; grid-template-columns: var(--side-w) 1fr; position: fixed; top: var(--header-h); left: 0; right: 0; bottom: 0; }
body.is-player { overflow: hidden; }
/* thu gọn sidebar có hiệu ứng: cột co lại, nội dung trượt + mờ; khung xem co giãn theo (ResizeObserver trong JS) */
.pg-player { transition: grid-template-columns .3s cubic-bezier(.4, 0, .2, 1); }
.pg-side { overflow: hidden; transition: opacity .22s ease, transform .3s cubic-bezier(.4, 0, .2, 1), visibility 0s; }
.pg-player.side-collapsed { grid-template-columns: 0 1fr; }
.pg-player.side-collapsed .pg-side { opacity: 0; transform: translateX(-24px); visibility: hidden; border: 0; transition: opacity .18s ease, transform .3s cubic-bezier(.4, 0, .2, 1), visibility 0s .3s; }
.pg-side__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pg-collapse { width: 30px; height: 30px; }
#sideToggle svg { transition: transform .3s; }
.pg-player.side-collapsed #sideToggle { color: var(--text); background: var(--surface-2); border-color: var(--border-light); }
@media (prefers-reduced-motion: reduce) { .pg-player, .pg-side { transition: none; } }
.pg-noanim .pg-player, .pg-noanim .pg-side { transition: none !important; }
body.is-player .site-footer { display: none; } /* playground chiếm trọn màn hình, footer chỉ ở trang tổng */
.pg-side { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--border); }
.pg-side__top { padding: 14px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--border); }
.pg-back { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); font-size: 13px; font-weight: 500; margin: -2px 0 0 -4px; }
.pg-back svg { width: 16px; height: 16px; }
.pg-back:hover { color: var(--text); }
.pg-prod { display: flex; align-items: center; gap: 10px; }
.pg-prod i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.pg-prod div { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.pg-prod span { color: var(--text-3); font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.pg-prod span a:hover { color: var(--text); text-decoration: underline; }
.pg-prod h1 { margin: 2px 0 0; font-size: 15px; line-height: 1.3; font-weight: 700; }
.pg-prod small { color: var(--text-3); font-size: 12px; }
.pg-prod i { align-self: flex-start; margin-top: 5px; }
.pg-search input { width: 100%; height: 38px; border-radius: var(--radius-sm); border: 1px solid var(--border-light); background: var(--surface-2); color: var(--text); font: inherit; }
.pg-search { position: relative; display: block; }
.pg-search svg { position: absolute; left: 10px; top: 10px; color: var(--text-3); }
.pg-search input { padding: 0 10px 0 34px; }
.pg-search input::placeholder { color: var(--text-3); }
.pg-side__meta { color: var(--text-3); font-size: 12px; display: flex; justify-content: space-between; gap: 8px; }
.pg-side__meta button { border: 0; background: none; padding: 0; color: var(--text-2); font-size: 12px; text-decoration: underline; text-underline-offset: 2px; }
.pg-side__meta button:hover { color: var(--text); }
.pg-list { overflow-y: auto; padding: 8px 8px 24px; flex: 1; overscroll-behavior: contain; }
.pg-group > summary { list-style: none; display: flex; align-items: center; gap: 6px; padding: 8px 8px 6px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); cursor: pointer; user-select: none; }
.pg-group > summary::-webkit-details-marker { display: none; }
.pg-group > summary svg { width: 14px; height: 14px; transition: transform .15s; }
.pg-group[open] > summary svg { transform: rotate(90deg); }
.pg-group > summary span { margin-left: auto; font-weight: 600; }
.pg-item { text-decoration: none; display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: none; padding: 6px 10px; font-size: 13.5px; border-radius: var(--radius-sm); color: var(--text-2); }
.pg-item:hover { background: var(--surface-2); color: var(--text); }
.pg-item.is-active { background: rgba(76,95,255,.16); color: var(--text); box-shadow: inset 2px 0 0 var(--primary); }
.pg-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-item i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; opacity: .8; }
.pg-empty { color: var(--text-3); padding: 24px 12px; text-align: center; }

.pg-stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.pg-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--surface); }
.pg-crumb { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.pg-crumb span { color: var(--text-3); font-size: 12px; }
.pg-crumb b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.pg-toolbar__group { display: flex; align-items: center; gap: 4px; }
.pg-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-sm); border: 1px solid transparent; background: none; color: var(--text-2); }
.pg-icon:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.pg-icon:disabled { opacity: .35; pointer-events: none; }
.pg-seg { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; }
.pg-seg button { border: 0; background: none; height: 28px; min-width: 34px; padding: 0 10px; border-radius: 6px; color: var(--text-3); font-size: 13px; font-weight: 600; display: inline-grid; place-items: center; }
.pg-seg button:hover { color: var(--text); }
.pg-seg button.is-active { background: var(--surface-3); color: var(--text); box-shadow: 0 0 0 1px var(--border-light); }
.pg-seg button:disabled { opacity: .35; pointer-events: none; }

.pg-viewport { position: relative; flex: 1; min-height: 0; overflow: hidden; background: radial-gradient(circle at 50% 0, #171B33, var(--bg) 70%); }
.pg-device { position: absolute; top: 16px; left: 50%; transform-origin: top center; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-3), 0 0 0 1px var(--border-light); }
.pg-device iframe { display: block; border: 0; width: 100%; height: 100%; background: #fff; }
.pg-loading { position: absolute; top: 0; left: 0; right: 0; height: 2px; overflow: hidden; opacity: 0; transition: opacity .2s; pointer-events: none; }
.pg-loading.is-on { opacity: 1; }
.pg-loading span { position: absolute; inset: 0; width: 40%; background: var(--primary); animation: pg-load 1s ease-in-out infinite; }
@keyframes pg-load { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

.pg-toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); font-weight: 600; padding: 10px 16px; border-radius: var(--radius-sm); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 50; }
.pg-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.pg-scrim { display: none; }

/* ---------- màn hẹp ---------- */
@media (max-width: 960px) {
  .pg-player { grid-template-columns: 1fr; }
  .pg-side { position: fixed; z-index: 40; top: var(--header-h); bottom: 0; left: 0; width: min(86vw, 340px); transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-3); }
  .pg-player.side-open .pg-side { transform: none; }
  .pg-player.side-open .pg-scrim { display: block; position: fixed; inset: var(--header-h) 0 0; z-index: 35; background: rgba(0,0,0,.5); }
  .pg-crumb { order: -1; flex-basis: calc(100% - 44px); }
}
@media (max-width: 600px) {
  .pg-toolbar { padding: 8px 10px; gap: 6px; }
  #devices { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* icon lĩnh vực (KTP.domainIcon trong assets/js/global.js) */
.domain-icon { width: 14px; height: 14px; flex: none; vertical-align: -2px; margin-right: 6px; }
.pg-prod span .domain-icon { width: 12px; height: 12px; margin-right: 4px; }
@media (max-width: 960px) { .pg-player.side-collapsed { grid-template-columns: 1fr; } .pg-player.side-collapsed .pg-side { visibility: visible; opacity: 1; } .pg-collapse { display: none; } }

/* chuyển màn: góc phải dưới khung xem, nổi bật */
.pg-pager { position: absolute; right: 16px; bottom: 14px; z-index: 3; display: flex; align-items: center; gap: 6px; padding: 6px; background: var(--surface-2); border: 1px solid var(--border-light); border-radius: var(--radius-full); box-shadow: var(--shadow-3); }
.pg-pager__btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; min-width: 40px; padding: 0 10px; border: 0; border-radius: var(--radius-full); background: var(--surface-3); color: var(--text); font-weight: 600; }
.pg-pager__btn:hover { background: var(--border-light); }
.pg-pager__btn--next { padding: 0 14px 0 18px; background: var(--primary); color: #fff; }
.pg-pager__btn--next:hover { background: #3141C0; }
.pg-pager__btn:disabled { opacity: .35; pointer-events: none; }
.pg-pager__pos { min-width: 84px; text-align: center; font-weight: 700; font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; }

/* Light theme của website (<html data-theme="light">): token nền / viền lấy từ global.css, ở đây chỉ map token chữ riêng của playground */
:root[data-theme="light"] { --text: #12142A; --text-2: #434765; --text-3: #5C6180; }
:root[data-theme="light"] .pg-viewport { background: radial-gradient(circle at 50% 0, #E3E6F1, var(--bg) 70%); }
