/* =========================
   SAFETY: prevent stuck overlays/backdrops from blocking clicks
   ========================= */

/* TEMP KILL: remove any debug red border/outline around main wrappers */
.page-container,
.childadd-wrap,
.children-wrap,
body,
html {
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
}



/* Only kill pseudo-overlays when a loading class is active */
body.is-loading::before,
body.is-loading::after,
html.is-loading::before,
html.is-loading::after,
.page-container.is-loading::before,
.page-container.is-loading::after {
  content: none !important;
  display: none !important;
  pointer-events: none !important;
}

/* Backdrop/overlay nodes should never block clicks */
.modal-backdrop,
.backdrop,
.overlay,
.dark-overlay,
#page-overlay,
#loading-overlay,
.page-overlay,
.loading-overlay,
.spinner-overlay,
.screen-cover,
.screen-overlay {
  pointer-events: none !important;
}

/* Ensure clickability */
body,
.page-container {
  pointer-events: auto !important;
}

/* =========================
   Layout (base.html uses .page-container)
   ========================= */

html, body {
  background: #fff;
}

body{
  font-family: sans-serif;
  margin: 0;
  padding: 0;
}

.page-container{
  max-width: 980px;      /* global site width */
  margin: 2rem auto;     /* global page spacing */
  padding: 0 1rem;
}

/* Generic header spacing */
header {
  margin-bottom: 2rem;
}

/* Status row (text + quick login) */
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.status-text {
  font-size: 0.9rem;
  white-space: nowrap;
}

/* Auth strip */
.auth-panel {
  display: flex;
  justify-content: flex-end;
  flex: 1;
}
.auth-form-inline {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  font-size: 0.8rem;
}
.auth-title {
  font-weight: 600;
  white-space: nowrap;
  margin-right: 0.25rem;
}
.auth-field-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.auth-field-inline label {
  font-size: 0.8rem;
  margin: 0;
  white-space: nowrap;
}
.auth-field-inline input[type="text"],
.auth-field-inline input[type="password"] {
  width: 8rem;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  border: 1px solid #d1d5db;
  font-size: 0.8rem;
}
.auth-form-inline .btn,
.auth-form-inline .btn-secondary {
  padding: 0.25rem 0.7rem;
  font-size: 0.8rem;
}
.auth-hint {
  font-size: 0.75rem;
  opacity: 0.75;
  white-space: nowrap;
}


.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, max-content));
  justify-content: start; /* or center */
  gap: 1rem;
}

.skill-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.skill-card h2 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}
.skill-code {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.5rem;
}
.skill-desc {
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}
.skill-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
  align-items: center;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid #2563eb;
  background: #2563eb;
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
}
.btn:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}
.btn-exam {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid #b91c1c;
  background: #b91c1c;
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
}
.btn-exam:hover {
  background: #991b1b;
  border-color: #991b1b;
}
.btn-secondary {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid #4b5563;
  background: #fff;
  color: #111827;
  text-decoration: none;
  font-size: 0.85rem;
}
.btn-secondary:hover {
  background: #f3f4f6;
}

/* Footer */
.footer-note {
  margin-top: 2rem;
  font-size: 0.8rem;
  color: #777;
}

/* Tools sections */
.tools-section {
  margin-bottom: 2rem;
  padding: 1rem 1.25rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
}
.tools-section h2 {
  margin-top: 0;
  font-size: 1rem;
  margin-bottom: 0.75rem;
}
.tools-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.tools-actions form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.tools-actions input[type="file"] {
  font-size: 0.85rem;
}
.exam-note {
  font-size: 0.8rem;
  color: #666;
}

/* Search */
.search-row {
  margin: 0.5rem 0 1.5rem;
}
.search-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.search-form input[type="search"] {
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  font-size: 0.85rem;
  min-width: 180px;
}
.search-form button {
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border: 1px solid #4b5563;
  background: #fff;
  font-size: 0.8rem;
  cursor: pointer;
}
.search-form button:hover {
  background: #f3f4f6;
}
.search-meta {
  font-size: 0.8rem;
  color: #555;
  margin-top: 0.4rem;
}

/* Responsive tweaks */
@media (max-width: 600px) {
  .status-row {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .status-text {
    white-space: normal;
  }
  .auth-form-inline {
    border-radius: 8px;
    align-items: flex-start;
  }
}

/* Narrow page layout for start-session page */
.narrow-page {
  max-width: 700px;
  margin: 0 auto;
}

/* Meta text under heading */
.meta {
  font-size: 0.9rem;
  color: #4b5563;
  margin-bottom: 1rem;
}

/* Start-session form */
.session-start-form {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
}
.session-start-form label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
}
.session-start-form select {
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  border: 1px solid #d1d5db;
  min-width: 180px;
  margin-bottom: 0.75rem;
}

/* Primary button (for starting session) */
.btn-primary {
  display: inline-block;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  border: 1px solid #2563eb;
  background: #2563eb;
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn-primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

/* Back link under the form */
.back-link {
  margin-top: 1rem;
  font-size: 0.9rem;
}
.back-link a {
  color: #2563eb;
  text-decoration: none;
}
.back-link a:hover {
  text-decoration: underline;
}

/* ---------- Question page layout ---------- */

.question-page {
  max-width: 800px;
  margin: 0 auto;
}

/* Full-screen exam feel */
.question-page.exam-mode {
  max-width: none;
  margin: 0;
  padding: 0;
}

.question-page.exam-mode .question-card {
  border-radius: 0;
  border: none;
  max-width: 960px;
  margin: 0 auto;
  min-height: 100vh;
  box-sizing: border-box;
}

/* Question card + content */
.question-card {
  border: 1px solid #ccc;
  padding: 1.5rem;
  border-radius: 8px;
}

.options { margin-top: 1rem; }
.option-item { margin: 0.25rem 0; }

/* Code block display */
.code-block {
  background: #f5f5f5;
  padding: 1rem;
  border-radius: 6px;
  white-space: pre-wrap;
  font-family: Consolas, monospace;
}

/* Feedback banner */
.feedback {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 6px;
}
.feedback.correct {
  background: #e6ffed;
  border: 1px solid #34a853;
}
.feedback.incorrect {
  background: #ffecec;
  border: 1px solid #ea4335;
}

/* Exam timer */
.exam-timer {
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  background: #fef3c7;
  font-size: 0.9rem;
}

/* ---------- Drag & drop code-fill ---------- */

.dragdrop-layout {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.code-area { flex: 2 1 260px; }
.options-area {
  flex: 1 1 220px;
  border-left: 1px solid #ddd;
  padding-left: 1rem;
}

.drag-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.drag-item {
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  border: 1px solid #2563eb;
  cursor: grab;
  font-size: 0.85rem;
  background: #e0ecff;
}
.drag-item.used { opacity: 0.5; }

.dropzone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  min-height: 20px;
  border-radius: 4px;
  border: 2px dashed #ccc;
  background: #fff;
  padding: 0.1rem 0.3rem;
  font-family: Consolas, monospace;
  font-size: 0.85rem;
}
.dropzone.filled {
  border-style: solid;
  border-color: #2563eb;
  background: #eef3ff;
}
.dropzone.drag-over {
  border-color: #1d4ed8;
  background: #e0ecff;
}
.dropzone-text { color: #888; }
.drag-help-text {
  font-size: 0.85rem;
  color: #555;
  margin-top: 0.25rem;
}

/* ---------- Order-steps drag & drop ---------- */

.order-list {
  list-style: none;
  padding-left: 0;
  margin-top: 0.5rem;
}

.order-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  margin-bottom: 0.35rem;
  border-radius: 4px;
  border: 1px solid #ddd;
  background: #fafafa;
  cursor: grab;
}
.order-item.drag-over {
  border-color: #2563eb;
  background: #eef3ff;
}
.order-item .handle {
  font-size: 0.9rem;
  opacity: 0.6;
  user-select: none;
}

/* ---------- Session summary / completion page ---------- */

.summary-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1rem;
}

.summary-page h1 { margin-bottom: 0.5rem; }

.overall {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: #f3f4f6;
}
.overall strong { font-size: 1.05rem; }

.summary-table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 1rem;
}
.summary-table th,
.summary-table td {
  border: 1px solid #e5e7eb;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.9rem;
}
.summary-table th { background: #f9fafb; }
.summary-row-weak { background: #fef2f2; }

.footer-links { margin-top: 1.5rem; }
.footer-links a { color: #2563eb; text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }

.last-result {
  font-size: 0.9rem;
  color: #4b5563;
  margin-bottom: 0.5rem;
}

/* Clickable table rows */
.clickable-row {
  cursor: pointer;
  transition: background 0.1s ease;
}
.clickable-row:hover { background: #eff6ff; }

/* ---------- Subtopic review page ---------- */

.review-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem;
}

.review-page h1 { margin-bottom: 0.5rem; }

.review-meta {
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.review-page .question-card {
  border: 1px solid #e5e7eb;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  background: #fafafa;
}

.result-correct { color: #16a34a; font-weight: 600; }
.result-incorrect { color: #dc2626; font-weight: 600; }

.nav-links { margin-top: 1.5rem; }
.nav-links a { color: #2563eb; text-decoration: none; }
.nav-links a:hover { text-decoration: underline; }

/* ---------- "My Progress" / stats page ---------- */

.stats-page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1rem;
}

.stats-page h1 { margin-bottom: 1rem; }
.stats-intro-link { margin-bottom: 1.5rem; }

/* KPI cards row */
.cards {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

.card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  background: #f9fafb;
  min-width: 180px;
}

.stats-table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 1rem;
}
.stats-table th,
.stats-table td {
  border: 1px solid #e5e7eb;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.9rem;
}
.stats-table th { background: #f3f4f6; }

/* ---------- My Trends page ---------- */

.trends-page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1rem;
}

.trends-page h1 { margin-bottom: 0.5rem; }

.trends-subtitle {
  font-size: 0.9rem;
  color: #6b7280;
  margin-bottom: 1.5rem;
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.controls-row form { margin: 0; }
.controls-row label { font-size: 0.9rem; margin-right: 0.25rem; }
.controls-row select { padding: 0.2rem 0.4rem; font-size: 0.9rem; }

.trend-skill-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  background: #f9fafb;
}
.trend-skill-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.trend-skill-name { font-size: 1.05rem; font-weight: 600; }
.trend-skill-code { font-size: 0.8rem; color: #6b7280; }

.chart-wrapper {
  width: 100%;
  max-width: 100%;
  height: 150px;
  margin-bottom: 0.75rem;
}
.chart-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.trends-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
}
.trends-table th,
.trends-table td {
  border: 1px solid #e5e7eb;
  padding: 0.35rem 0.6rem;
  text-align: left;
}
.trends-table th { background: #f3f4f6; }

.no-data {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fee2e2;
  color: #b91c1c;
  margin-top: 1rem;
}

.trends-back-links { margin-top: 2rem; font-size: 0.9rem; }

/* ---------- Auth pages (login / signup) ---------- */

.auth-page {
  max-width: 500px;
  margin: 0 auto;
  padding: 0 1rem;
}

.auth-page h1 { margin-bottom: 1rem; }

.auth-form-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.25rem;
  background: #f9fafb;
}

.auth-field { margin-bottom: 0.9rem; }

.auth-field label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.2rem;
}

.auth-field input[type="text"],
.auth-field input[type="password"] {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  border: 1px solid #d1d5db;
  font-size: 0.9rem;
}

.auth-errorlist {
  margin: 0 0 0.8rem;
  padding-left: 1rem;
  color: #b91c1c;
  font-size: 0.8rem;
}

.auth-primary-btn {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid #2563eb;
  background: #2563eb;
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
}
.auth-primary-btn:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.auth-back-link {
  margin-top: 1rem;
  font-size: 0.85rem;
}
.auth-back-link a {
  color: #2563eb;
  text-decoration: none;
}
.auth-back-link a:hover { text-decoration: underline; }

/* =========================
   Add Child page
   ========================= */

.childadd-wrap{
  max-width: 820px;
  margin: 0 auto;
  color:#111827;
}

.childadd-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:1rem;
  flex-wrap:wrap;
}

.childadd-header h1{ margin:0 0 .25rem 0; }
.childadd-sub{ margin:0; color:#6b7280; }

.childadd-wrap .btn-light{
  text-decoration:none;
  border:1px solid #e5e7eb;
  background:#fff;
  color:#111827;
  padding:.55rem .8rem;
  border-radius:10px;
  display:inline-block;
}
.childadd-wrap .btn-dark{
  border:none;
  background:#111827;
  color:#fff;
  padding:.75rem 1.05rem;
  border-radius:12px;
  font-weight:900;
  cursor:pointer;
}

.childadd-wrap .msg{
  margin:1rem 0 0 0;
  padding:.75rem;
  border:1px solid #e5e7eb;
  background:#f9fafb;
  border-radius:12px;
}

.childadd-wrap .card{
  margin-top:1rem;
  border:1px solid #e5e7eb;
  border-radius:14px;
  padding:1rem;
  background:#fff;
}
.childadd-wrap .card h3{ margin:0 0 .75rem 0; }

.childadd-wrap .errbox{
  margin-bottom:.75rem;
  padding:.75rem;
  border:1px solid #fecaca;
  background:#fef2f2;
  border-radius:12px;
}
.childadd-wrap .errtext{ color:#991b1b; }

.childadd-wrap .field{ margin-bottom:.9rem; }
.childadd-wrap .field label{
  display:block;
  font-weight:800;
  margin-bottom:.25rem;
}
.childadd-wrap .req{ color:#b00020; }

.childadd-wrap .field input,
.childadd-wrap .field select,
.childadd-wrap .field textarea{
  width:100%;
  box-sizing:border-box;
  border:1px solid #e5e7eb;
  border-radius:12px;
  padding:.65rem .75rem;
  font:inherit;
  background:#fff;
}

.childadd-wrap .help{
  margin-top:.25rem;
  font-size:.9rem;
  color:#6b7280;
}

.childadd-wrap .actions{
  display:flex;
  gap:.75rem;
  align-items:center;
  flex-wrap:wrap;
  margin-top:.75rem;
}

.childadd-wrap .how{
  margin-top:1rem;
  padding:.9rem;
  border:1px dashed #e5e7eb;
  border-radius:14px;
  color:#4b5563;
  background:#fff;
}
.childadd-wrap .how .title{
  font-weight:900;
  margin-bottom:.25rem;
  color:#111827;
}

/* =========================
   My Children page
   ========================= */

.children-wrap{
  max-width: 980px;
  margin: 0 auto;
  color:#111827;
}

.children-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:1rem;
  flex-wrap:wrap;
}
.children-header h1{ margin:0 0 .25rem 0; }
.children-sub{ margin:0; color:#6b7280; }

.children-actions{
  display:flex;
  gap:.6rem;
  flex-wrap:wrap;
  align-items:center;
}

.children-wrap .btn-dark{
  text-decoration:none;
  border:1px solid #111827;
  background:#111827;
  color:#fff;
  padding:.6rem .9rem;
  border-radius:12px;
  font-weight:800;
  display:inline-block;
}
.children-wrap .btn-light{
  text-decoration:none;
  border:1px solid #e5e7eb;
  background:#fff;
  color:#111827;
  padding:.6rem .9rem;
  border-radius:12px;
  display:inline-block;
}

.children-wrap .msg{
  margin:1rem 0 0 0;
  padding:.75rem;
  border:1px solid #e5e7eb;
  background:#f9fafb;
  border-radius:12px;
}

.children-wrap .table-card{
  margin-top:1rem;
  border:1px solid #e5e7eb;
  border-radius:14px;
  overflow:hidden;
  background:#fff;
}
.children-wrap .table-scroll{
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}
.children-wrap table{
  width:100%;
  border-collapse:collapse;
  min-width:760px;
}
.children-wrap thead tr{
  background:#f9fafb;
  text-align:left;
}
.children-wrap th,
.children-wrap td{
  padding:.75rem;
  border-bottom:1px solid #e5e7eb;
  vertical-align:top;
}
.children-wrap tbody tr:hover{ background:#fafafa; }

.children-wrap code.kid{
  font-weight:800;
  background:#f3f4f6;
  padding:.2rem .45rem;
  border-radius:8px;
  display:inline-block;
}

.children-wrap .pill-green{
  display:inline-block;
  padding:.2rem .55rem;
  border-radius:999px;
  border:1px solid #b7f3cb;
  background:#e8fff1;
  color:#065f46;
  font-size:.85rem;
  font-weight:800;
}
.children-wrap .pill-red{
  display:inline-block;
  padding:.2rem .55rem;
  border-radius:999px;
  border:1px solid #fecaca;
  background:#fef2f2;
  color:#991b1b;
  font-size:.85rem;
  font-weight:800;
}

.children-wrap .hint{
  margin-top:.9rem;
  color:#6b7280;
  font-size:.95rem;
}

/* helpers used by children/add-child templates */
.field-errbox { margin-top: .35rem; }
.muted-note { color:#6b7280; font-size:.92rem; }
.how-list { margin:.25rem 0 0 1.2rem; }
.kid-name { font-weight:900; }
.kid-meta { margin-top:.35rem; font-size:.85rem; color:#6b7280; }
.btn-compact { padding:.45rem .7rem; border-radius:10px; display:inline-block; }
.empty-card { padding:1rem; border-style:dashed; }
.empty-title { font-weight:900; margin-bottom:.25rem; }
.empty-sub { color:#6b7280; margin-bottom:.75rem; }


/* Mobile-safe defaults */
*, *::before, *::after { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }

/* Your wrapper */
.page-container{
  width: 100%;
  max-width: 980px;   /* adjust if you want */
  margin: 0 auto;
  padding: 12px;
}

/* On phones, give a bit more breathing room */
@media (max-width: 600px){
  .page-container{ padding: 10px; }
}




