/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --primary:   #6C63FF;
  --primary-dark: #5a52d5;
  --accent:    #FF6B6B;
  --accent-dark: #e55a5a;
  --green:     #4ECDC4;
  --green-dark:#3ab5ac;
  --yellow:    #FFE66D;
  --yellow-dark:#f0d44a;
  --bg:        #F7F7FF;
  --card:      #FFFFFF;
  --text:      #2D2D2D;
  --muted:     #888;
  --border:    #E0E0F0;
  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 4px 16px rgba(108,99,255,0.10);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.07);
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Typography ─────────────────────────────────────────────────────────────── */
h1 { font-size: 2rem; font-weight: 800; }
h2 { font-size: 1.4rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }
p  { line-height: 1.6; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.container { max-width: 900px; margin: 0 auto; padding: 0 1rem; }
/* Vertical only — using the `padding` shorthand here would wipe out the
   horizontal gutter set by `.container` on the shared content element. */
.page-content { padding-top: 1.5rem; padding-bottom: 6rem; }

/* ── Flash messages ─────────────────────────────────────────────────────────── */
.flash {
  background: var(--green);
  color: #fff;
  padding: .75rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.flash.error { background: var(--accent); }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .65rem 1.4rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
  min-height: 48px;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary  { background: var(--primary);  color: #fff; box-shadow: 0 3px 10px rgba(108,99,255,.35); }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-accent   { background: var(--accent);   color: #fff; box-shadow: 0 3px 10px rgba(255,107,107,.35); }
.btn-accent:hover   { background: var(--accent-dark); }
.btn-green    { background: var(--green);    color: #fff; box-shadow: 0 3px 10px rgba(78,205,196,.35); }
.btn-green:hover    { background: var(--green-dark); }
.btn-yellow   { background: var(--yellow);   color: var(--text); box-shadow: 0 3px 10px rgba(255,230,109,.35); }
.btn-yellow:hover   { background: var(--yellow-dark); }
.btn-ghost    { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-ghost:hover    { background: var(--primary); color: #fff; }
.btn-sm { padding: .4rem .9rem; font-size: .875rem; min-height: 36px; width: 130px; }
.btn-lg { padding: 1rem 2rem; font-size: 1.2rem; min-height: 60px; border-radius: var(--radius); }
.btn-block { width: 100%; }

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.card-title { font-size: 1.1rem; font-weight: 700; }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: .4rem; font-size: .95rem; }
.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .7rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  transition: border-color .15s;
  min-height: 48px;
}
.form-group input:not([type="checkbox"]):not([type="radio"]):focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-check { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.form-check input[type="checkbox"] { width: 20px; height: 20px; cursor: pointer; accent-color: var(--primary); }

/* ── Parent nav ─────────────────────────────────────────────────────────────── */
.top-nav {
  background: var(--card);
  border-bottom: 2px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}
.top-nav-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1rem;
  max-width: 900px;
  margin: 0 auto;
}
.nav-brand {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--primary);
  flex: 1;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.nav-links { display: flex; gap: .25rem; align-items: center; }
.nav-link {
  padding: .5rem .9rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--text);
  transition: background .15s;
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .95rem;
}
.nav-link:hover { background: var(--bg); text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }
.badge {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 800;
  padding: .1rem .45rem;
  min-width: 20px;
  text-align: center;
}

/* ── Kid bottom nav ──────────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 2px solid var(--border);
  display: flex;
  z-index: 100;
  box-shadow: 0 -4px 16px rgba(0,0,0,.08);
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: .6rem .25rem;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 600;
  transition: color .15s;
  min-height: 60px;
  cursor: pointer;
  text-decoration: none;
}
.bottom-nav-item .nav-icon { font-size: 1.5rem; line-height: 1; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item:hover { color: var(--primary); text-decoration: none; }

/* ── Kid hero balance ────────────────────────────────────────────────────────── */
.kid-hero {
  color: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.kid-hero .greeting { font-size: 1.1rem; opacity: .85; margin-bottom: .25rem; }
.kid-hero .kid-name { font-size: 2rem; font-weight: 900; }
.balance-row { display: flex; gap: 1rem; margin-top: 1rem; }
.balance-chip {
  background: rgba(255,255,255,.2);
  border-radius: var(--radius-sm);
  padding: .6rem 1rem;
  flex: 1;
  text-align: center;
}
.balance-chip .amount { font-size: 1.8rem; font-weight: 900; line-height: 1; }
.balance-chip .label { font-size: .8rem; opacity: .8; margin-top: .2rem; }

/* ── Task cards ──────────────────────────────────────────────────────────────── */
.task-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.25rem;
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-left: 5px solid var(--border);
  transition: box-shadow .15s;
}
.task-card:hover { box-shadow: var(--shadow); }
.task-card.status-approved { border-left-color: var(--green); }
.task-card.status-pending  { border-left-color: var(--yellow); }
.task-card.status-todo     { border-left-color: var(--primary); }
.task-card.status-todo.overdue { border-left-color: var(--accent); }
.task-card.status-rejected { border-left-color: var(--muted); }
.task-emoji { font-size: 2.2rem; flex-shrink: 0; width: 48px; text-align: center; }
.task-info  { flex: 1; min-width: 0; }
.task-title { font-weight: 700; font-size: 1.05rem; }
.task-meta  { color: var(--muted); font-size: .85rem; margin-top: .15rem; display: flex; gap: .75rem; flex-wrap: wrap; }
.task-actions { display: flex; gap: .5rem; flex-shrink: 0; flex-wrap: wrap; }
.points-badge {
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 800;
  padding: .2rem .6rem;
  white-space: nowrap;
}
.status-pill {
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  padding: .2rem .7rem;
  white-space: nowrap;
}
.pill-green  { background: #d4f5f3; color: var(--green-dark); }
.pill-yellow { background: #fff8d0; color: #a07000; }
.pill-red    { background: #ffe0e0; color: var(--accent-dark); }
.pill-grey   { background: #eee; color: var(--muted); }
.mandatory-tag { font-size: .75rem; color: var(--accent); font-weight: 700; }

/* ── Reward cards ────────────────────────────────────────────────────────────── */
.reward-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.reward-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  transition: transform .15s, box-shadow .15s;
}
.reward-card .reward-cost { margin-top: auto; }
.reward-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.reward-card.today-task { box-shadow: 0 0 0 2px var(--primary); }
.reward-emoji { font-size: 3rem; }
.reward-title { font-weight: 700; font-size: 1rem; }
.reward-desc  { color: var(--muted); font-size: .85rem; }
.reward-cost  { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }
.cost-chip {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 700;
  padding: .2rem .7rem;
}
.cost-chip.points { border-color: var(--primary); color: var(--primary); }
.cost-chip.cash   { border-color: var(--green);   color: var(--green-dark); }

/* ── Dashboard pending items ─────────────────────────────────────────────────── */
.pending-item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.25rem;
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.pending-info { flex: 1; min-width: 180px; }
.pending-actions { display: flex; gap: .5rem; align-items: flex-end; flex-direction: column; }
.pending-actions form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* ── Kid profile cards ───────────────────────────────────────────────────────── */
.kid-card {
  background: linear-gradient(135deg, var(--primary) 0%, #9c95ff 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.kid-avatar { font-size: 3.5rem; margin-bottom: .5rem; }
.kid-card-name { font-size: 1.5rem; font-weight: 900; }
.kids-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kid-actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }

/* ── Transaction history ─────────────────────────────────────────────────────── */
.txn-list { display: flex; flex-direction: column; gap: .5rem; }
.txn-item {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: .8rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}
.txn-icon { font-size: 1.5rem; flex-shrink: 0; }
.txn-info { flex: 1; }
.txn-desc  { font-weight: 600; }
.txn-date  { color: var(--muted); font-size: .8rem; }
.txn-amount { font-weight: 800; font-size: 1.1rem; white-space: nowrap; }
.txn-amount.positive { color: var(--green-dark); }
.txn-amount.negative { color: var(--accent); }

/* ── Tables (parent management) ─────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.data-table th { background: var(--primary); color: #fff; padding: .75rem 1rem; text-align: left; font-size: .9rem; }
.data-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }

/* ── Tabs ────────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: .25rem;
  flex-wrap: wrap;
  margin: 1.5rem 0 1.25rem;
  border-bottom: 2px solid var(--border);
}
.tab {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  padding: .6rem 1.1rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color .15s, border-color .15s, background .15s;
}
.tab:hover { color: var(--text); background: var(--bg); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Section headers ─────────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.section-title { font-size: 1.2rem; font-weight: 800; display: flex; align-items: center; gap: .4rem; }
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty-state .empty-emoji { font-size: 3rem; margin-bottom: .75rem; }

/* ── Login page ──────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
}
.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
}
.login-logo { text-align: center; font-size: 3rem; margin-bottom: .5rem; }
.login-title { text-align: center; font-size: 1.8rem; font-weight: 900; color: var(--primary); margin-bottom: .25rem; }
.login-sub { text-align: center; color: var(--muted); margin-bottom: 1.5rem; font-size: .95rem; }
.error-msg {
  background: #ffe0e0;
  color: var(--accent-dark);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  margin-bottom: 1rem;
  font-weight: 600;
  text-align: center;
}

/* ── Emoji picker ────────────────────────────────────────────────────────────── */
.emoji-picker { display: flex; flex-wrap: wrap; gap: .4rem; }
.emoji-option {
  font-size: 1.6rem;
  cursor: pointer;
  padding: .3rem .4rem;
  border-radius: 8px;
  border: 2px solid transparent;
  transition: border-color .1s, background .1s;
  line-height: 1;
}
.emoji-option:hover, .emoji-option.selected { border-color: var(--primary); background: rgba(108,99,255,.1); }
#emoji-hidden { display: none; }

/* ── Utility ─────────────────────────────────────────────────────────────────── */
.text-muted  { color: var(--muted); }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.mt-1  { margin-top: .5rem; }
.mt-2  { margin-top: 1rem; }
.mt-3  { margin-top: 1.5rem; }
.mb-1  { margin-bottom: .5rem; }
.mb-2  { margin-bottom: 1rem; }
.gap-1 { gap: .5rem; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.d-none { display: none; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  html { font-size: 15px; }
  .container { padding: 0 1.25rem; }
  .page-content { padding-top: 1rem; padding-bottom: 6rem; }
  h1 { font-size: 1.5rem; }

  /* Stack two-column form layouts */
  .form-row { grid-template-columns: 1fr; }

  /* Reward / task tiles two-up; tighter padding so content fits the card */
  .reward-grid { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
  .reward-card { padding: 1rem .85rem; }
  .reward-actions { flex-direction: column; }

  /* Keep kid balance tiles two-up even with the wider page gutters */
  .kids-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }

  /* Section headers wrap instead of squashing the title */
  .section-header { flex-wrap: wrap; gap: .5rem .75rem; }

  /* Parent top nav: icons only, tighter spacing */
  .top-nav-inner { gap: .4rem; padding: .6rem .75rem; }
  .nav-brand { font-size: 1.05rem; }
  .nav-links { gap: .15rem; }
  .nav-link { padding: .5rem .55rem; }
  .nav-links .nav-link span,
  .nav-links form .btn span { display: none; }
  .btn-sm { width: auto; }

  /* Task cards: action buttons drop to their own full-width row */
  .task-card { flex-wrap: wrap; }
  .task-actions { width: 100%; }
  .task-actions > .btn,
  .task-actions > form { flex: 1; }
  .task-actions > form .btn { width: 100%; }

  /* Dashboard approval forms: stack inputs full width */
  .pending-actions { width: 100%; align-items: stretch; }
  .pending-actions form { width: 100%; }
  .pending-actions form input,
  .pending-actions form select { width: 100% !important; flex: 1 1 100%; }
  .pending-actions .btn { width: 100%; }

  /* Kid profile penalty / password cards stack */
  .kid-actions-grid { grid-template-columns: 1fr; }
}
