/* ===================== Variables ===================== */
:root {
  --primary: #6C63FF;
  --primary-dark: #574fd6;
  --accent: #FF6B6B;
  --green: #22c55e;
  --red: #ef4444;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1e1e2e;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --transition: 0.2s ease;
}

/* ===================== Reset ===================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 18px; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; font-family: inherit; font-size: 1rem; }
input, select, textarea { font-family: inherit; font-size: 1rem; }

/* ===================== Utilities ===================== */
.hidden { display: none !important; }
.loading { padding: 2rem; text-align: center; color: var(--muted); font-size: 1.1rem; }
.text-muted { color: var(--muted); font-size: 1rem; }
.error-msg { color: var(--red); font-size: 1rem; padding: 0.6rem 0.9rem; background: #fef2f2; border-radius: 8px; border: 1px solid #fecaca; }
.success-msg { color: #15803d; font-size: 1rem; padding: 0.6rem 0.9rem; background: #dcfce7; border-radius: 8px; border: 1px solid #bbf7d0; }

/* ===================== Buttons ===================== */
.btn-primary {
  background: var(--primary); color: #fff;
  padding: 0.8rem 1.6rem; border-radius: 10px;
  font-weight: 700; font-size: 1.05rem; transition: background var(--transition);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline {
  background: transparent; color: var(--primary);
  padding: 0.75rem 1.4rem; border-radius: 10px;
  border: 2px solid var(--primary); font-weight: 700; font-size: 1.05rem;
  transition: all var(--transition);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-danger {
  background: #fee2e2; color: var(--red);
  padding: 0.5rem 0.9rem; border-radius: 8px;
  font-weight: 700; font-size: 0.95rem; border: 1px solid #fecaca;
}
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.95rem; }
.btn-lg { padding: 1.1rem 2.4rem; font-size: 1.2rem; width: 100%; }

/* ===================== Navbar ===================== */
.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 2.5rem; background: var(--card);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06); position: sticky; top: 0; z-index: 100;
}
.nav-brand { font-size: 1.5rem; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 0.5rem; }
.nav-right { display: flex; align-items: center; gap: 1.25rem; }
.nav-user { font-size: 1rem; color: var(--muted); }
.nav-user-btn {
  font-size: 1rem; color: var(--muted); background: none; border: none;
  padding: 0.35rem 0.75rem; border-radius: 8px; cursor: pointer;
  transition: all var(--transition); font-family: inherit;
}
.nav-user-btn:hover { background: rgba(108,99,255,0.1); color: var(--primary); }

/* ===================== Container ===================== */
.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ===================== Auth Page ===================== */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.auth-card {
  background: var(--card); border-radius: 20px;
  padding: 2.5rem 2rem; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.logo { text-align: center; margin-bottom: 2rem; }
.logo-icon { font-size: 3.5rem; }
.logo h1 { font-size: 2.2rem; color: var(--primary); font-weight: 800; }
.logo p { color: var(--muted); font-size: 1.05rem; margin-top: 0.3rem; }

/* ===================== Tabs ===================== */
.tabs, .admin-tabs {
  display: flex; gap: 0.4rem;
  background: var(--bg); border-radius: 10px;
  padding: 0.3rem; margin-bottom: 1.5rem;
}
.tab {
  flex: 1; padding: 0.7rem 1.2rem; border-radius: 8px;
  background: transparent; color: var(--muted);
  font-weight: 700; font-size: 1rem; transition: all var(--transition);
}
.tab.active { background: var(--card); color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

/* ===================== Forms ===================== */
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group label { font-size: 0.95rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.form-group input, .form-group select, .form-group textarea {
  padding: 0.8rem 1rem; border: 2px solid var(--border);
  border-radius: 10px; outline: none; transition: border var(--transition);
  background: var(--bg); color: var(--text); font-size: 1rem;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.75rem; }

/* ===================== Cards ===================== */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.25rem; }
.card { background: var(--card); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.child-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.child-avatar {
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #a78bfa);
  color: #fff; font-size: 1.6rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.child-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; justify-content: center; }

/* ===================== Page Header ===================== */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.75rem; }
.page-header h2 { font-size: 1.7rem; font-weight: 700; }

/* ===================== Badges ===================== */
.badge {
  display: inline-block; padding: 0.25rem 0.7rem;
  border-radius: 20px; font-size: 0.9rem; font-weight: 700;
  background: #ede9fe; color: var(--primary);
}
.badge.green { background: #dcfce7; color: var(--green); }
.badge.red { background: #fee2e2; color: var(--red); }
.role-admin { background: #fef9c3; color: #854d0e; }
.role-parent { background: #dbeafe; color: #1d4ed8; }
.role-student { background: #dcfce7; color: #15803d; }
.admin-badge { background: #fef9c3; color: #854d0e; font-size: 0.7rem; margin-left: 0.4rem; padding: 0.15rem 0.5rem; }

/* Pending question count badge on tab button */
.badge-count {
  display: inline-block; background: var(--red); color: #fff;
  border-radius: 20px; font-size: 0.75rem; font-weight: 700;
  padding: 0.1rem 0.5rem; margin-left: 0.35rem; vertical-align: middle;
}

/* Approval option cards */
.approve-option {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border: 2px solid var(--border);
  border-radius: 10px; cursor: pointer; transition: all var(--transition);
  background: var(--card); user-select: none;
}
.approve-option:hover { border-color: var(--primary); background: #f5f3ff; }
.approve-option.selected { border-color: var(--primary); background: #ede9fe; }
.approve-option .option-letter {
  font-weight: 800; color: var(--primary); min-width: 22px;
  font-size: 1.05rem;
}
.approve-option .option-text { flex: 1; line-height: 1.4; font-size: 1rem; }

/* ===================== Stats ===================== */
.stat-row { display: flex; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.stat-box {
  flex: 1; min-width: 100px; background: var(--bg);
  border-radius: 10px; padding: 1rem; text-align: center;
}
.stat-box.green { background: #dcfce7; }
.stat-box.red { background: #fee2e2; }
.stat-num { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat-box.green .stat-num { color: var(--green); }
.stat-box.red .stat-num { color: var(--red); }
.stat-label { font-size: 0.9rem; color: var(--muted); font-weight: 600; margin-top: 0.3rem; }

/* ===================== Tables ===================== */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 1rem; }
.data-table th { background: var(--bg); padding: 0.85rem 1.1rem; text-align: left; font-weight: 700; font-size: 0.9rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.data-table td { padding: 0.85rem 1.1rem; border-bottom: 1px solid var(--border); font-size: 1rem; }
.data-table tr:hover td { background: #fafbff; }
.question-cell { max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filter-row { display: flex; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.filter-row select { padding: 0.7rem 1rem; border: 2px solid var(--border); border-radius: 8px; background: var(--card); font-size: 1rem; }
.filter-row input[type="text"] { padding: 0.7rem 1rem; border: 2px solid var(--border); border-radius: 8px; background: var(--card); font-size: 1rem; }
.filter-row input[type="text"]:focus { outline: none; border-color: var(--primary); }

/* Difficulty toggle buttons */
.diff-filter { display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; }
.filter-label { color: var(--muted); font-size: 0.9rem; font-weight: 600; white-space: nowrap; margin-right: 0.2rem; }
.diff-btn {
  padding: 0.4rem 0.65rem; border: 2px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--muted); font-weight: 700; font-size: 0.95rem;
  transition: all var(--transition); line-height: 1;
}
.diff-btn:hover { border-color: var(--primary); color: var(--primary); }
.diff-btn.active { border-color: var(--primary); background: var(--primary); color: #fff; }

.data-table tr.row-blocked td { opacity: 0.55; }
.data-table tr.row-blocked:hover td { opacity: 0.7; }
.child-indent { color: var(--muted); margin-right: 4px; font-size: 0.9rem; }

/* Audit info cells in tables */
.audit-cell { white-space: nowrap; }
.audit-cell div:first-child { font-weight: 600; font-size: 0.9rem; }
.audit-date { color: var(--muted); font-size: 0.8rem; margin-top: 1px; }

/* Pagination */
.pagination-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.page-info { color: var(--muted); font-size: 0.95rem; }
.page-btns { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.page-btns button:disabled { opacity: 0.4; cursor: not-allowed; }
.page-ellipsis { padding: 0 0.3rem; color: var(--muted); line-height: 2; }

/* ===================== Modal ===================== */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.modal-content {
  position: relative; background: var(--card);
  border-radius: var(--radius); padding: 2rem;
  width: 100%; max-width: 500px; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-lg { max-width: 740px; }
.modal-content h3 { margin-bottom: 1.5rem; font-size: 1.4rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ===================== Quiz ===================== */
.quiz-setup-card {
  max-width: 500px; margin: 4rem auto; background: var(--card);
  border-radius: var(--radius); padding: 2.5rem; box-shadow: var(--shadow);
}
.quiz-setup-card h2 { margin-bottom: 0.5rem; }
.quiz-setup-card .text-muted { margin-bottom: 1.5rem; }
.quiz-header { margin-bottom: 1.75rem; }
.progress-info { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.85rem; }
.progress-bar { flex: 1; height: 12px; background: var(--border); border-radius: 6px; overflow: hidden; }
#progressFill { height: 100%; background: var(--primary); transition: width 0.4s ease; border-radius: 6px; }
.score-display { font-size: 1.3rem; font-weight: 700; color: var(--green); }
.question-card {
  background: var(--card); border-radius: var(--radius);
  padding: 2.5rem; box-shadow: var(--shadow); max-width: 820px; margin: 0 auto;
}
.question-text { font-size: 1.4rem; font-weight: 600; margin-bottom: 2rem; line-height: 1.7; }
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.option-btn {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.1rem 1.25rem; border-radius: 12px;
  border: 2px solid var(--border); background: var(--bg);
  text-align: left; transition: all var(--transition); font-size: 1.1rem;
}
.option-btn:hover:not(:disabled) { border-color: var(--primary); background: #ede9fe; }
.option-btn.correct { border-color: var(--green); background: #dcfce7; }
.option-btn.wrong { border-color: var(--red); background: #fee2e2; }
.option-btn:disabled { cursor: not-allowed; }
.option-key {
  min-width: 40px; height: 40px; border-radius: 10px;
  background: var(--primary); color: #fff;
  font-weight: 700; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.option-btn.correct .option-key { background: var(--green); }
.option-btn.wrong .option-key { background: var(--red); }
.option-text { flex: 1; line-height: 1.5; }

/* ===================== Result ===================== */
.result-card {
  max-width: 520px; margin: 4rem auto; background: var(--card);
  border-radius: var(--radius); padding: 3.5rem 3rem;
  box-shadow: var(--shadow); text-align: center;
}
.result-emoji { font-size: 5rem; margin-bottom: 1rem; }
.result-card h2 { font-size: 2rem; margin-bottom: 1.75rem; }
.result-stats { display: flex; gap: 1rem; justify-content: center; margin-bottom: 1.75rem; }
.result-message { color: var(--muted); margin-bottom: 2.5rem; line-height: 1.7; font-size: 1.1rem; }
.result-actions { display: flex; gap: 1rem; justify-content: center; }

/* ===================== Empty State ===================== */
.empty-state { text-align: center; padding: 3rem; color: var(--muted); }

/* ===================== Checkbox Grid ===================== */
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.5rem 0; }
.checkbox-item {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 0.8rem; border-radius: 8px;
  border: 2px solid var(--border); background: var(--bg);
  cursor: pointer; font-size: 0.9rem; transition: all var(--transition);
}
.checkbox-item:has(input:checked) { border-color: var(--primary); background: #ede9fe; color: var(--primary); font-weight: 600; }
.checkbox-item input { accent-color: var(--primary); }

/* ===================== Config Summary ===================== */
.config-summary { background: var(--bg); border-radius: 10px; padding: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.config-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.95rem; }
.config-row span:first-child { color: var(--muted); }
.config-row span:last-child { font-weight: 700; color: var(--primary); }

/* ===================== Responsive ===================== */
@media (max-width: 600px) {
  .options-grid { grid-template-columns: 1fr; }
  .navbar { padding: 0.75rem 1rem; }
  .container { padding: 1rem; }
  .auth-card { margin: 1rem; padding: 1.75rem 1.25rem; }
}
