/* ============================================================
   EchoBooks AI — Design System v2 (sidebar shell)
   Chiến lược màu 2 lớp:
   - SELLER UI: sidebar indigo đậm chuyên nghiệp + nền nội dung trung tính;
     pastel MyKidSpace chỉ xuất hiện ở tag/preview/biểu đồ.
   - KID UI (listen.css): full pastel MyKidSpace.
   ============================================================ */
:root {
  /* Bảng màu gốc học từ mykidspace.online */
  --ink:      #3D3580;
  --ink-deep: #2A2550;
  --ink-soft: #6B639E;
  --lavender: #A78BFA;
  --sky:      #BFE3F7;
  --mint:     #8BD8A0;
  --peach:    #F8CE8E;
  --pink:     #E8B8E0;
  --cream:    #FDF9F2;

  /* Seller UI tokens */
  --bg:       #F6F6FB;
  --card:     #FFFFFF;
  --text:     #2A2550;
  --muted:    #7A7594;
  --line:     #E8E6F2;
  --primary:  #5B4FC4;
  --primary-h:#4A3FB0;
  --success:  #3E8E5A;
  --danger:   #C4504F;
  --radius:   16px;
  --shadow:   0 4px 16px rgba(61, 53, 128, 0.08);
  --sidebar-w: 248px;
  font-size: 15px;
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
body {
  font-family: 'Nunito', 'Quicksand', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.55;
}
h1, h2, h3 { color: var(--ink); font-weight: 800; }
a { color: var(--primary); }

/* ---------- Shell: sidebar + content ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: linear-gradient(180deg, var(--ink-deep) 0%, #332B66 100%);
  color: #CFC9EE; display: flex; flex-direction: column;
  padding: 22px 14px; position: sticky; top: 0; height: 100vh;
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.22); border-radius: 999px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar .plan-card { flex-shrink: 0; }
.sidebar .logo {
  font-size: 21px; font-weight: 900; color: #fff; text-decoration: none;
  padding: 0 12px 18px; letter-spacing: .2px;
}
.sidebar .logo .dot { color: var(--lavender); }
.sidebar .section {
  font-size: 11px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase;
  color: #8F87BE; padding: 16px 12px 6px;
}
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  color: #CFC9EE; text-decoration: none; font-weight: 700; font-size: 14.5px;
  padding: 9px 12px; border-radius: 10px; margin: 1px 0;
}
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar nav a .ic { width: 20px; text-align: center; }
.sidebar nav a .badge {
  margin-left: auto; font-size: 10.5px; font-weight: 800; padding: 2px 8px;
  border-radius: 999px; background: var(--peach); color: var(--ink-deep);
}
.sidebar .spacer { flex: 1; }

.plan-card {
  background: rgba(255,255,255,.08); border-radius: 14px; padding: 14px; margin-top: 14px;
}
.plan-card .name { font-weight: 800; color: #fff; font-size: 13.5px; }
.plan-card .quota { font-size: 12px; color: #B4ACDE; margin: 6px 0 8px; }
.plan-card .meter { height: 7px; border-radius: 999px; background: rgba(255,255,255,.15); overflow: hidden; }
.plan-card .meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--lavender), var(--mint)); }
.plan-card .btn { width: 100%; text-align: center; margin-top: 10px; font-size: 13px; padding: 8px 10px; }

.content { flex: 1; min-width: 0; padding: 26px 32px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-size: 24px; }
.page-head .sub { color: var(--muted); font-weight: 700; font-size: 14px; }

/* ---------- Cards, stats ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.grid { display: grid; gap: 18px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.main-side { grid-template-columns: 2fr 1fr; align-items: start; }
@media (max-width: 900px) { .grid.cols-4, .grid.cols-3, .grid.cols-2, .grid.main-side { grid-template-columns: 1fr 1fr; } }
.stat .label { color: var(--muted); font-weight: 700; font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 900; color: var(--ink); }
.stat .trend { font-size: 13px; font-weight: 700; color: var(--success); }
.stat .trend.flat { color: var(--muted); }

/* Pastel tags */
.tag { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 800; color: var(--ink); }
.tag.lavender { background: color-mix(in srgb, var(--lavender) 30%, white); }
.tag.mint     { background: color-mix(in srgb, var(--mint) 35%, white); }
.tag.peach    { background: color-mix(in srgb, var(--peach) 45%, white); }
.tag.pink     { background: color-mix(in srgb, var(--pink) 40%, white); }
.tag.sky      { background: color-mix(in srgb, var(--sky) 55%, white); }
.tag.gray     { background: var(--line); color: var(--muted); }

/* Buttons */
.btn {
  display: inline-block; border: 0; cursor: pointer; text-decoration: none;
  font: inherit; font-weight: 800; border-radius: 12px; padding: 10px 22px;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-h); }
.btn.big { font-size: 16.5px; padding: 13px 28px; }
.btn.sm { font-size: 13px; padding: 6px 14px; }
.btn.ghost { background: var(--bg); color: var(--ink); }
.btn.ghost:hover { background: var(--line); }
.btn.outline { background: transparent; border: 2px solid var(--line); color: var(--ink); }

/* Tables */
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; color: var(--muted); font-size: 12.5px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
table.data td { padding: 12px; border-bottom: 1px solid var(--line); font-weight: 600; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: color-mix(in srgb, var(--bg) 55%, white); }

/* Mini bar sparkline trong bảng */
.scanbar { display: inline-flex; gap: 2px; align-items: flex-end; height: 26px; }
.scanbar i { width: 6px; background: var(--lavender); border-radius: 2px; display: block; }

/* Biểu đồ cột thuần CSS (dashboard/analytics) */
.chart { display: flex; gap: 8px; align-items: stretch; height: 160px; padding-top: 8px; }
.chart .col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; text-align: center; }
.chart .col i {
  display: block; border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, var(--lavender), color-mix(in srgb, var(--lavender) 55%, white));
}
.chart .col.hot i { background: linear-gradient(180deg, var(--primary), var(--lavender)); }
.chart .col .lb { font-size: 10.5px; font-weight: 700; color: var(--muted); }

/* Danh sách xếp hạng (top pages/books) */
.ranklist { display: flex; flex-direction: column; gap: 10px; }
.ranklist .row { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; }
.ranklist .row .bar { flex: 1; height: 9px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.ranklist .row .bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--mint), var(--sky)); }
.ranklist .row .n { color: var(--muted); font-size: 13px; min-width: 46px; text-align: right; }

/* Checklist onboarding */
.checklist { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.checklist li { display: flex; gap: 10px; align-items: center; font-weight: 700; font-size: 14px; }
.checklist li .st { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
.checklist li.done .st { background: color-mix(in srgb, var(--mint) 45%, white); }
.checklist li.todo .st { background: var(--line); }
.checklist li.todo { color: var(--muted); }

/* ---------- Wizard ---------- */
.steps { display: flex; gap: 8px; margin-bottom: 24px; }
.steps .step {
  flex: 1; text-align: center; font-weight: 800; font-size: 13px; color: var(--muted);
  padding: 10px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow);
}
.steps .step.on { background: var(--primary); color: #fff; }
.steps .step.done { background: color-mix(in srgb, var(--mint) 40%, white); color: var(--ink); }
.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 800px) { .choice-grid { grid-template-columns: 1fr; } }
.choice {
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 20px; cursor: pointer; transition: border-color .15s, transform .1s;
}
.choice:hover { transform: translateY(-2px); }
.choice.selected { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.choice .emoji { font-size: 34px; }
.choice h3 { margin: 8px 0 4px; font-size: 16px; }
.choice p { color: var(--muted); font-size: 13.5px; }
.choice.locked { opacity: .55; }
.field { margin: 14px 0; }
.field label { display: block; font-weight: 800; font-size: 13.5px; color: var(--ink); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 10px 14px; border: 2px solid var(--line); border-radius: 12px;
  font: inherit; background: var(--card); color: var(--text);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--lavender); }

.pagelist { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pagecard {
  background: var(--cream); border-radius: 14px; padding: 14px; text-align: center;
  border: 1.5px solid color-mix(in srgb, var(--peach) 40%, white);
}
.pagecard .w { font-size: 22px; font-weight: 900; color: var(--ink); }
.pagecard .a { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.pagecard button {
  margin-top: 8px; border: 0; background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 12px; font-weight: 800;
  cursor: pointer; box-shadow: var(--shadow);
}
.wizard-nav { display: flex; justify-content: space-between; margin-top: 26px; }
.wizard-nav .btn.primary { margin-left: auto; }

.genbox { text-align: center; padding: 40px 20px; }
.genbox .bar { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; max-width: 420px; margin: 18px auto; }
.genbox .bar i { display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--lavender), var(--mint)); transition: width .4s; }
.result-files { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }

/* Trang khóa (OTO) */
.locked-hero { text-align: center; padding: 34px 20px; }
.locked-hero .big-emoji { font-size: 52px; }
.locked-hero p { color: var(--muted); font-weight: 700; max-width: 520px; margin: 8px auto 18px; }

/* ---------- Plan system: paywall, modal, tiers ---------- */
.pw-wrap { position: relative; }
.pw-wrap > *:not(.pw-overlay) { filter: blur(6px); pointer-events: none; user-select: none; }
.pw-overlay {
  position: absolute; inset: 0; z-index: 5; border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center; padding: 20px;
  background: color-mix(in srgb, white 45%, transparent);
}
.pw-overlay .lock { font-size: 34px; }
.pw-overlay h3 { font-size: 17px; }
.pw-overlay p { color: var(--muted); font-weight: 700; font-size: 13.5px; max-width: 340px; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(42, 37, 80, .55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--card); border-radius: 20px; max-width: 470px; width: 100%;
  padding: 26px; box-shadow: 0 20px 60px rgba(42, 37, 80, .35); text-align: center;
}
.modal .m-emoji { font-size: 44px; }
.modal h2 { font-size: 20px; margin: 6px 0 4px; }
.modal .m-sub { color: var(--muted); font-weight: 700; font-size: 14px; margin-bottom: 12px; }
.modal .close { float: right; border: 0; background: var(--bg); border-radius: 50%; width: 30px; height: 30px; cursor: pointer; font-weight: 800; }

.stacklist { margin: 12px 0; }
.stackline { display: flex; justify-content: space-between; gap: 12px; font-weight: 700; font-size: 14px; border-bottom: 1px dashed var(--line); padding: 7px 2px; text-align: left; }
.stackline .v { color: var(--muted); white-space: nowrap; }
.stacktotal { display: flex; justify-content: space-between; font-weight: 900; padding: 10px 2px 0; color: var(--ink); }
.stacktotal .old { text-decoration: line-through; color: var(--muted); margin-right: 8px; }

.tier { border: 2px solid var(--line); position: relative; }
.tier.featured { border-color: var(--primary); }
.tier .flag {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 800;
  padding: 3px 12px; border-radius: 999px; white-space: nowrap;
}
.tier .price { font-size: 32px; font-weight: 900; color: var(--ink); }
.tier .price small { font-size: 14px; color: var(--muted); font-weight: 800; }
.tier .ds { font-size: 12.5px; color: var(--muted); font-weight: 700; margin-top: 6px; }
.tier .owned { background: color-mix(in srgb, var(--mint) 40%, white); color: var(--ink); border-radius: 10px; padding: 8px; font-weight: 800; margin-top: 10px; }

.upsell-banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px; margin-bottom: 18px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--lavender) 22%, white), color-mix(in srgb, var(--sky) 30%, white));
  border-radius: var(--radius); font-weight: 700; font-size: 14px;
}
.upsell-banner .btn { margin-left: auto; white-space: nowrap; }

.sidebar nav a .st-owned { margin-left: auto; font-size: 12px; }
.sidebar nav a .st-price { margin-left: auto; font-size: 11px; font-weight: 800; color: #B4ACDE; }
.plan-sim { margin-top: 10px; font-size: 11.5px; color: #8F87BE; font-weight: 700; }
.plan-sim select { width: 100%; margin-top: 4px; padding: 6px 8px; border-radius: 8px; border: 0; font: inherit; font-size: 12.5px; background: rgba(255,255,255,.12); color: #fff; }
.plan-sim select option { color: var(--ink); }

/* ---------- Full-page WYSIWYG preview (spec MASTERPLAN Phần 1) ---------- */
.pagelist.thumbs { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.thumb {
  position: relative; aspect-ratio: 8.5 / 11; background: #fff;
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
  padding: 9% 7% 6%; overflow: hidden; font-size: 8px; line-height: 1.35;
  display: flex; flex-direction: column; gap: 3px; color: var(--text);
}
.thumb .t-qr {
  position: absolute; top: 5%; right: 6%; width: 17%; aspect-ratio: 1;
  border: 1.5px solid var(--ink); border-radius: 3px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 11px; color: var(--ink);
}
.thumb .t-qr span { font-size: 4.5px; font-weight: 800; letter-spacing: .5px; }
.thumb .t-word { font-size: 16px; font-weight: 900; color: var(--ink); }
.thumb .t-head { font-size: 12px; font-weight: 900; color: var(--ink); }
.thumb .t-say { font-size: 6.5px; font-weight: 700; color: var(--muted); }
.thumb .t-sub { font-size: 6.5px; font-weight: 700; color: var(--muted); }
.thumb .t-label { font-size: 6px; font-weight: 800; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .4px; margin-top: 2px; }
.thumb .t-outline {
  font-size: 15px; font-weight: 900; color: transparent;
  -webkit-text-stroke: 0.8px var(--ink-soft); letter-spacing: 1px;
}
.thumb .t-trace {
  font-size: 10px; font-weight: 700; color: #C9C3E8; letter-spacing: 1px;
  border-bottom: 1px dashed #B8B0DC; padding-bottom: 1px; white-space: nowrap; overflow: hidden;
}
.thumb .t-line { border-bottom: 1px solid #B8B0DC; height: 9px; }
.thumb .t-find { font-size: 8px; font-weight: 700; color: var(--text); }
.thumb .t-blend { font-size: 10px; font-weight: 800; color: var(--ink); }
.thumb .t-imgbox {
  border: 1px dashed var(--ink-soft); border-radius: 4px; text-align: center;
  padding: 4px; font-size: 9px; color: var(--muted);
}
.thumb .t-dots { font-size: 9px; letter-spacing: 1px; }
.thumb .t-frame { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; width: 55%; }
.thumb .t-frame i { aspect-ratio: 1; border: 1px solid var(--ink-soft); display: block; }
.thumb .t-frame i.on { background: radial-gradient(circle, var(--ink) 38%, transparent 42%); }
.thumb .t-drawbox { border: 1px solid var(--ink-soft); border-radius: 3px; height: 14%; }
.thumb .t-star { font-size: 26px; text-align: center; }
.thumb .t-review { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 6px; font-size: 8px; font-weight: 700; }
.thumb .t-foot { margin-top: auto; font-size: 5.5px; color: var(--muted); font-weight: 700; text-align: center; }
.thumb.t-cert-page { padding: 8%; }
.thumb .t-cert { border: 2px solid var(--peach); border-radius: 6px; flex: 1; display: flex; align-items: center; justify-content: center; }
.thumb .t-cert-in { text-align: center; font-size: 7px; line-height: 1.6; }
.thumb .t-cert-in b { font-size: 9px; color: var(--ink); }
.thumb-meta { text-align: center; margin-top: 6px; }
.thumb-meta button {
  border: 0; background: var(--card); color: var(--ink); border-radius: 999px;
  padding: 4px 12px; font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; box-shadow: var(--shadow);
}
.thumb { font-family: 'Comic Neue', 'Nunito', sans-serif; }
.thumb .t-mas { font-size: 11px; }
.thumb .t-sentence { font-size: 9px; font-weight: 700; color: var(--ink); }
