:root {
  --bg: #F6F7FB;
  --surface: #FFFFFF;
  --surface-muted: #F0F1F8;
  --border: rgba(30, 34, 53, 0.09);
  --border-strong: rgba(30, 34, 53, 0.16);
  --text: #1E2235;
  --text-secondary: #5B5F76;
  --text-muted: #9397AC;

  --accent: #4C5FD5;
  --accent-hover: #3F50BE;
  --accent-bg: #EEF0FF;
  --accent-fg: #3745B0;

  --green: #2F9E52;
  --green-bg: #E7F7EC;
  --amber: #B9790F;
  --amber-bg: #FCF2DF;
  --red: #D9484A;
  --red-bg: #FDEBEC;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 1px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 6px 16px rgba(16, 24, 40, 0.08);
  --shadow-lift: 0 10px 24px rgba(16, 24, 40, 0.12);

  --font: "Nunito", "Segoe UI", Tahoma, Arial, sans-serif;
  --font-display: "Baloo 2", "Nunito", "Segoe UI", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
[v-cloak] { display: none; }
button, input, select, textarea { font-family: inherit; }

a, button { outline: none; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, tr:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-bg), 0 0 0 1px var(--accent);
  border-radius: var(--radius-sm);
}

#app { min-height: 100vh; }

/* ---------- Subject color palette (same hues as front-enfant, read-only swatches here) ---------- */
.swatch-blue { background: var(--accent); }
.swatch-orange { background: #FF7A45; }
.swatch-teal { background: #1C8C8C; }
.swatch-purple { background: #8B4FC7; }
.swatch-green { background: #2F9E52; }
.swatch-red { background: #E0524F; }
.swatch-amber { background: #D99A1B; }
.swatch-cyan { background: #2AA7C9; }
.swatch-brown { background: #9C6B4A; }
.swatch-pink { background: #D6548F; }

/* ================= Auth screens ================= */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lift); padding: 36px 32px; text-align: center;
}
.auth-logo { height: 72px; margin: 0 auto 18px; display: block; }
.auth-title { font-family: var(--font-display); font-size: 20px; font-weight: 800; margin: 0 0 4px; }
.auth-sub { font-size: 13.5px; color: var(--text-secondary); margin: 0 0 26px; }
.auth-form { text-align: start; }
.auth-error {
  background: var(--red-bg); color: var(--red); border-radius: var(--radius); padding: 10px 14px;
  font-size: 13px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}
.auth-locked-icon {
  width: 60px; height: 60px; border-radius: 50%; background: var(--red-bg); color: var(--red);
  display: flex; align-items: center; justify-content: center; font-size: 26px; margin: 0 auto 16px;
}
.auth-demo-links { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.auth-demo-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; font-weight: 700; letter-spacing: 0.03em; margin: 0 0 10px; }
.auth-demo-btn {
  display: block; width: 100%; text-align: start; background: var(--surface-muted); border: none;
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: 12.5px; font-weight: 700; color: var(--text-secondary);
  cursor: pointer; margin-bottom: 6px; transition: background 0.15s ease;
}
.auth-demo-btn:hover { background: var(--accent-bg); color: var(--accent-fg); }

/* ---------- Password strength checklist ---------- */
.pw-rules { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.pw-rules li { font-size: 12.5px; color: var(--text-muted); font-weight: 600; display: flex; align-items: center; gap: 7px; }
.pw-rules li.ok { color: var(--green); }
.pw-rules li i { font-size: 15px; }

/* ================= Admin shell ================= */
.admin-shell { display: flex; min-height: 100vh; align-items: stretch; }

.admin-sidebar {
  width: 250px; flex-shrink: 0; background: var(--surface); border-inline-end: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-logo { height: 54px; margin: 0 0 22px; cursor: pointer; transition: opacity 0.15s ease; }
.admin-logo:hover { opacity: 0.8; }

.admin-nav { display: flex; flex-direction: column; gap: 2px; }
.admin-nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  font-weight: 700; font-size: 14px; color: var(--text-secondary); cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.admin-nav-item i { font-size: 17px; width: 20px; text-align: center; }
.admin-nav-item:hover { background: var(--surface-muted); }
.admin-nav-item.active { background: var(--accent-bg); color: var(--accent-fg); }
.admin-nav-sep { height: 1px; background: var(--border); margin: 14px 4px; }

.admin-sidebar-footer { margin-top: auto; padding-top: 16px; }
.admin-user-card {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius);
  background: var(--surface-muted); cursor: pointer; transition: background 0.15s ease;
}
.admin-user-card:hover { background: var(--accent-bg); }
.admin-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; flex-shrink: 0;
}
.admin-user-info { min-width: 0; }
.admin-user-name { margin: 0; font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-user-role { margin: 1px 0 0; font-size: 11px; color: var(--text-muted); font-weight: 700; }
.admin-logout-btn {
  width: 100%; margin-top: 8px; background: none; border: none; color: var(--text-muted);
  font-size: 12.5px; font-weight: 700; padding: 7px; cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 6px; border-radius: var(--radius-sm); transition: background 0.15s ease, color 0.15s ease;
}
.admin-logout-btn:hover { background: var(--red-bg); color: var(--red); }

.admin-main { flex: 1; min-width: 0; padding: 32px 40px 60px; max-width: 1180px; }

.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.page-title { font-family: var(--font-display); font-size: 25px; font-weight: 800; margin: 0; }
.page-sub { font-size: 13.5px; color: var(--text-secondary); margin: 4px 0 0; }
.breadcrumb { font-size: 12.5px; color: var(--text-muted); font-weight: 700; margin: 0 0 6px; display: flex; align-items: center; gap: 6px; }
.breadcrumb a { color: var(--text-muted); cursor: pointer; text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: var(--radius); font-size: 13.5px; font-weight: 700; padding: 10px 16px; cursor: pointer;
  border: none; transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1.5px solid var(--border-strong); }
.btn-secondary:hover { background: var(--surface-muted); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: #FBD9DA; }
.btn-ghost { background: none; color: var(--text-secondary); padding: 8px 10px; }
.btn-ghost:hover { background: var(--surface-muted); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 30px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 20px; box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 14px;
}
.stat-icon {
  width: 44px; height: 44px; border-radius: 13px; background: var(--accent-bg); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
}
.stat-value { font-size: 24px; font-weight: 900; font-family: var(--font-display); line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 700; margin: 2px 0 0; }

.alert-banner {
  display: flex; align-items: center; gap: 12px; background: var(--red-bg); color: var(--red);
  border-radius: var(--radius-lg); padding: 14px 18px; margin-bottom: 24px; font-weight: 700; font-size: 13.5px;
}
.alert-banner i { font-size: 20px; flex-shrink: 0; }
.alert-banner a { color: var(--red); text-decoration: underline; cursor: pointer; }

/* ---------- Section card ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 22px 24px; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.card-header h3 { margin: 0; font-family: var(--font-display); font-size: 16px; font-weight: 800; }

/* ---------- Data table ---------- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: start; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted);
  font-weight: 800; padding: 12px 18px; background: var(--surface-muted);
}
.data-table td { padding: 13px 18px; border-top: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
.data-table tbody tr { transition: background 0.12s ease; }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr.clickable:hover td { background: var(--surface-muted); }
.table-empty { padding: 32px; text-align: center; color: var(--text-muted); font-size: 13.5px; }

.cell-name { font-weight: 800; }
.cell-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.cell-with-avatar { display: flex; align-items: center; gap: 10px; }
.row-avatar {
  width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 13px; flex-shrink: 0;
}

/* ---------- Pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.pill-active { background: var(--green-bg); color: var(--green); }
.pill-locked { background: var(--red-bg); color: var(--red); }
.pill-admin { background: var(--accent-bg); color: var(--accent-fg); }
.pill-parent { background: var(--surface-muted); color: var(--text-secondary); }
.pill-pending { background: var(--amber-bg); color: var(--amber); }

/* ---------- Subject grid (reused on child detail) ---------- */
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.subject-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 16px; background: var(--surface);
  cursor: pointer; box-shadow: var(--shadow-sm); transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-align: center;
}
.subject-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.subject-card-icon { width: 48px; height: 48px; margin: 0 auto 10px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff; }
.subject-card p { margin: 0; font-weight: 800; font-size: 14px; }
.subject-card .cell-sub { margin-top: 4px; }
.subject-card-add {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 20px 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; color: var(--text-muted); font-weight: 700; font-size: 13px; min-height: 108px;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.subject-card-add:hover { border-color: var(--accent); color: var(--accent); }
.subject-card-add i { font-size: 22px; }

/* ================= Subject detail (admin edit view) ================= */
.subject-detail-layout { display: flex; gap: 24px; align-items: flex-start; }
.subject-side {
  width: 280px; flex-shrink: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-sm);
}
.subject-side-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.subject-side-icon { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 18px; color: #fff; flex-shrink: 0; }
.subject-side-title { font-family: var(--font-display); font-weight: 800; font-size: 15.5px; margin: 0; }
.subject-side-lang { font-size: 11px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; }

.side-section-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted);
  margin: 18px 0 8px;
}
.side-add-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 15px; padding: 2px; border-radius: 6px; }
.side-add-btn:hover { background: var(--accent-bg); }

.side-chapter { margin-bottom: 4px; }
.side-chapter-head {
  display: flex; align-items: center; gap: 6px; padding: 7px 6px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 700; cursor: pointer; transition: background 0.15s ease;
}
.side-chapter-head:hover { background: var(--surface-muted); }
.side-chapter-head i.chevron { font-size: 13px; color: var(--text-muted); }
.chapter-reorder { display: flex; gap: 1px; }
.chapter-reorder .builder-remove:disabled { opacity: 0.3; cursor: not-allowed; }
.chapter-reorder .builder-remove:disabled:hover { background: none; color: var(--text-muted); }
.side-chapter-body { margin-inline-start: 14px; padding: 2px 0 6px; }
.side-leaf {
  display: flex; align-items: center; gap: 7px; padding: 6px 8px; border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--text-secondary); cursor: pointer; transition: background 0.15s ease, color 0.15s ease;
}
.side-leaf:hover { background: var(--surface-muted); }
.side-leaf.active { background: var(--accent-bg); color: var(--accent-fg); font-weight: 700; }
.side-leaf i.leaf-icon { font-size: 13px; flex-shrink: 0; }
.side-leaf-add { color: var(--accent); font-weight: 700; }
.side-empty { font-size: 11.5px; color: var(--text-muted); padding: 2px 8px 6px; }

.subject-content { flex: 1; min-width: 0; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }
.form-label { display: block; font-size: 12.5px; font-weight: 800; color: var(--text-secondary); margin-bottom: 6px; }
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border-strong); border-radius: var(--radius);
  font-size: 13.5px; background: var(--surface); color: var(--text); transition: border-color 0.15s ease;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); outline: none; }
.form-textarea { resize: vertical; min-height: 70px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }

.color-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.color-dot { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; transition: border-color 0.15s ease, transform 0.1s ease; }
.color-dot:hover { transform: scale(1.1); }
.color-dot.selected { border-color: var(--text); }

.icon-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-dot {
  width: 38px; height: 38px; border-radius: 11px; background: var(--surface-muted); color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center; font-size: 17px; cursor: pointer;
  border: 2px solid transparent; transition: all 0.15s ease;
}
.icon-dot:hover { background: var(--accent-bg); color: var(--accent); }
.icon-dot.selected { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }

.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; font-weight: 600; font-size: 13px; cursor: pointer; }
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- JSON import + read-only preview ---------- */
.json-textarea { min-height: 220px; font-family: "Courier New", monospace; font-size: 12.5px; line-height: 1.5; }
.preview-choice {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-secondary); margin-bottom: 4px;
}
.preview-choice i { font-size: 15px; color: var(--text-muted); }
.preview-choice.correct { background: var(--green-bg); color: var(--green); font-weight: 700; }
.preview-choice.correct i { color: var(--green); }

.tree-node-view { margin-inline-start: 0; }
.tree-view-text {
  display: inline-block; margin: 0 0 6px; padding: 6px 12px; border-radius: var(--radius-sm);
  background: var(--surface-muted); font-size: 13px; font-weight: 700;
}
.tree-node-view-children { margin-inline-start: 24px; display: flex; flex-direction: column; }

/* ---------- Builder rows (quiz / flashcards / exam / mind map) ---------- */
.builder-item {
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; margin-bottom: 14px; background: var(--surface);
}
.builder-item-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.builder-item-num { font-size: 12px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.builder-remove { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; padding: 4px; border-radius: 6px; }
.builder-remove:hover { background: var(--red-bg); color: var(--red); }
.choice-row-edit { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.choice-row-edit input[type="text"] { flex: 1; }
.choice-correct-toggle {
  width: 34px; height: 34px; border-radius: 9px; border: 1.5px solid var(--border-strong); background: var(--surface);
  color: var(--text-muted); cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s ease;
}
.choice-row-edit .choice-correct-toggle.on { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.add-row-btn {
  width: 100%; border: 1.5px dashed var(--border-strong); background: none; border-radius: var(--radius);
  padding: 10px; font-size: 13px; font-weight: 700; color: var(--text-muted); cursor: pointer;
  transition: all 0.15s ease;
}
.add-row-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Mind map tree editor ---------- */
/* ---------- Attempts table ---------- */
.attempts-section { margin-top: 24px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(17, 20, 32, 0.5); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-card {
  background: var(--surface); border-radius: var(--radius-xl); width: 100%; max-width: 580px;
  max-height: 88vh; overflow-y: auto; box-shadow: 0 24px 60px rgba(16, 24, 40, 0.35);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-family: var(--font-display); font-size: 17px; font-weight: 800; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; padding: 4px; border-radius: 8px; }
.modal-close:hover { background: var(--surface-muted); }
.modal-body { padding: 22px 24px; }

.placeholder-box { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.placeholder-box i { font-size: 34px; margin-bottom: 10px; display: block; }

/* ---------- Confirm popup (delete / block / unblock) -- sits above any open modal ---------- */
.confirm-backdrop { z-index: 300; background: rgba(17, 20, 32, 0.6); }
.confirm-card { max-width: 380px; }

.generated-password {
  font-family: "Courier New", monospace; font-size: 17px; font-weight: 800; letter-spacing: 0.04em;
  background: var(--surface-muted); border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  padding: 14px; margin-bottom: 18px; word-break: break-all; color: var(--text);
}

.toast-error {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--red); color: #fff; font-size: 13.5px; font-weight: 700;
  border-radius: var(--radius); padding: 12px 18px; box-shadow: var(--shadow-lift);
  display: flex; align-items: center; gap: 10px; z-index: 400; max-width: min(460px, 90vw);
}
.toast-error button { background: none; border: none; color: #fff; cursor: pointer; font-size: 16px; display: flex; flex-shrink: 0; }
.toast-success {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: var(--green); color: #fff; font-size: 13.5px; font-weight: 700;
  border-radius: var(--radius); padding: 12px 18px; box-shadow: var(--shadow-lift);
  display: flex; align-items: center; gap: 10px; z-index: 400; max-width: min(460px, 90vw);
}
.save-inline-btn { margin-top: 10px; }
.draft-indicator { margin-inline-start: auto; font-size: 13px; color: var(--amber); }

@media (max-width: 900px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; overflow-x: auto; }
  .admin-logo { height: 36px; margin: 0 16px 0 0; }
  .admin-nav { flex-direction: row; }
  .admin-nav-sep { display: none; }
  .admin-sidebar-footer { margin: 0 0 0 auto; }
  .admin-main { padding: 22px 18px 50px; }
  .subject-detail-layout { flex-direction: column; }
  .subject-side { width: 100%; }
}
