/* =========================================================
   CHILDCARE APP  –  CSS
   Theme: Warm, friendly, professional
   Fonts: Nunito (headings) + DM Sans (body)
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=DM+Sans:wght@400;500;600&display=swap');

/* ── RESET & ROOT ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f0f4ff;
  --surface:   #ffffff;
  --surface2:  #f8faff;
  --border:    #e2e8f8;
  --primary:   #6366f1;
  --primary-d: #4f46e5;
  --primary-l: #eef2ff;
  --secondary: #f59e0b;
  --success:   #10b981;
  --danger:    #ef4444;
  --warning:   #f97316;
  --info:      #3b82f6;
  --text:      #1e2a4a;
  --text-2:    #64748b;
  --text-3:    #94a3b8;

  --radius:    14px;
  --radius-sm: 8px;
  --radius-lg: 22px;
  --shadow:    0 2px 12px rgba(99,102,241,.10);
  --shadow-md: 0 8px 32px rgba(99,102,241,.15);
  --transition: all .2s cubic-bezier(.4,0,.2,1);

  --nav-h: 64px;
  --tab-h: 68px;
  --font-h: 'Nunito', sans-serif;
  --font-b: 'DM Sans', sans-serif;
}

html { -webkit-tap-highlight-color: transparent; scroll-behavior: smooth; }
body {
  font-family: var(--font-b);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ── TYPOGRAPHY ─────────────────────────────────────────── */
h1,h2,h3,h4 { font-family: var(--font-h); font-weight: 800; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

/* ── LAYOUT ──────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; min-height: 100dvh; }

/* Top nav */
.top-nav {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.25rem;
  box-shadow: var(--shadow);
}
.top-nav .brand {
  font-family: var(--font-h); font-weight: 900; font-size: 1.2rem;
  color: var(--primary);
  display: flex; align-items: center; gap: .5rem;
}
.top-nav .brand span { font-size: 1.5rem; }
.nav-actions { display: flex; align-items: center; gap: .75rem; }
.avatar-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary-l); color: var(--primary);
  border: 2px solid var(--primary);
  font-family: var(--font-h); font-weight: 800; font-size: .9rem;
  cursor: pointer; display: grid; place-items: center; transition: var(--transition);
}
.avatar-btn:hover { background: var(--primary); color: #fff; }
.notif-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  cursor: pointer; display: grid; place-items: center;
  font-size: 1.2rem; position: relative; transition: var(--transition);
}
.notif-btn .badge {
  position: absolute; top: 2px; right: 2px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger); border: 2px solid #fff;
  display: none;
}
.notif-btn .badge.visible { display: block; }

/* Page content */
.page-content {
  flex: 1;
  padding: 1.25rem;
  padding-bottom: calc(var(--tab-h) + 1.25rem);
  max-width: 768px;
  margin: 0 auto;
  width: 100%;
}

/* Bottom tab bar */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--tab-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  box-shadow: 0 -4px 20px rgba(99,102,241,.08);
}
.tab-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  cursor: pointer; border: none; background: none;
  color: var(--text-3); font-family: var(--font-b);
  font-size: .7rem; font-weight: 500;
  transition: var(--transition); position: relative;
}
.tab-item svg { width: 22px; height: 22px; stroke-width: 2; }
.tab-item.active { color: var(--primary); }
.tab-item.active::before {
  content: ''; position: absolute; top: -1px; left: 20%; right: 20%;
  height: 3px; border-radius: 0 0 4px 4px;
  background: var(--primary);
}
.tab-badge {
  position: absolute; top: 8px; right: calc(50% - 18px);
  min-width: 18px; height: 18px; border-radius: 9px;
  background: var(--danger); color: #fff;
  font-size: .65rem; font-weight: 700; padding: 0 4px;
  display: grid; place-items: center; border: 2px solid #fff;
}

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

/* Child card */
.child-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 1rem;
  display: flex; align-items: center; gap: 1rem;
  cursor: pointer; transition: var(--transition); margin-bottom: .75rem;
  box-shadow: var(--shadow);
}
.child-card:hover, .child-card:active { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.child-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-l), #ddd4fe);
  display: grid; place-items: center;
  font-family: var(--font-h); font-weight: 900; font-size: 1.1rem;
  color: var(--primary); flex-shrink: 0;
}
.child-info { flex: 1; min-width: 0; }
.child-name { font-family: var(--font-h); font-weight: 800; font-size: 1rem; }
.child-meta { font-size: .8rem; color: var(--text-2); margin-top: 2px; }
.child-status { display: flex; align-items: center; gap: .4rem; font-size: .75rem; font-weight: 600; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-in  .status-dot { background: var(--success); }
.status-out .status-dot { background: var(--text-3); }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .65rem 1.25rem; border-radius: var(--radius-sm);
  border: none; cursor: pointer; font-family: var(--font-b);
  font-size: .9rem; font-weight: 600; transition: var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.9); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.9); }
.btn-warning { background: var(--secondary); color: #fff; }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-l); }
.btn-outline { background: transparent; border: 2px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: .4rem .85rem; font-size: .8rem; }
.btn-lg { padding: .9rem 1.75rem; font-size: 1rem; border-radius: var(--radius); }
.btn-full { width: 100%; }
.btn-icon { padding: .5rem; border-radius: var(--radius-sm); background: var(--surface2); border: 1px solid var(--border); cursor: pointer; display: grid; place-items: center; transition: var(--transition); }
.btn-icon:hover { background: var(--primary-l); border-color: var(--primary); }

/* ── ACTION GRID ─────────────────────────────────────────── */
.action-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: 1rem;
}
.action-btn {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem .9rem;
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  cursor: pointer; transition: var(--transition); box-shadow: var(--shadow);
  font-family: var(--font-b); font-size: .85rem; font-weight: 600; color: var(--text);
}
.action-btn:hover, .action-btn:active { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.action-btn .emoji { font-size: 1.8rem; }
.action-btn.feeding  { border-top: 3px solid #f59e0b; }
.action-btn.nap      { border-top: 3px solid #8b5cf6; }
.action-btn.diaper   { border-top: 3px solid #06b6d4; }
.action-btn.checkout { border-top: 3px solid var(--success); }
.action-btn.checkin  { border-top: 3px solid var(--primary); }

/* ── ACTIVITY LOG ────────────────────────────────────────── */
.activity-log { list-style: none; }
.activity-item {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .75rem 0; border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1rem; flex-shrink: 0;
}
.activity-icon.feeding  { background: #fef3c7; }
.activity-icon.nap      { background: #ede9fe; }
.activity-icon.diaper   { background: #cffafe; }
.activity-icon.checkin  { background: #d1fae5; }
.activity-icon.checkout { background: #fee2e2; }
.activity-body { flex: 1; min-width: 0; }
.activity-text { font-size: .88rem; font-weight: 600; }
.activity-meta { font-size: .75rem; color: var(--text-2); margin-top: 2px; }

/* ── FORMS ───────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .4rem; color: var(--text); }
.form-control {
  width: 100%; padding: .7rem 1rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface);
  font-family: var(--font-b); font-size: .9rem; color: var(--text);
  transition: var(--transition); outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── MODALS ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px); z-index: 500;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%; max-width: 520px; max-height: 92dvh;
  overflow-y: auto; padding: 1.5rem;
  transform: translateY(100%); transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.modal-title { font-size: 1.15rem; font-weight: 800; font-family: var(--font-h); }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-2); line-height: 1; }

/* ── MESSAGES ────────────────────────────────────────────── */
.conv-list { list-style: none; }
.conv-item {
  display: flex; align-items: center; gap: .9rem;
  padding: .9rem; border-radius: var(--radius);
  cursor: pointer; transition: var(--transition); margin-bottom: .5rem;
}
.conv-item:hover, .conv-item.active { background: var(--primary-l); }
.conv-avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: grid; place-items: center; color: #fff;
  font-family: var(--font-h); font-weight: 800; font-size: 1rem; flex-shrink: 0;
}
.conv-info { flex: 1; min-width: 0; }
.conv-name { font-weight: 700; font-size: .92rem; }
.conv-preview { font-size: .78rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-meta { text-align: right; flex-shrink: 0; }
.conv-time { font-size: .72rem; color: var(--text-3); }
.conv-unread {
  min-width: 20px; height: 20px; border-radius: 10px;
  background: var(--primary); color: #fff;
  font-size: .7rem; font-weight: 700; padding: 0 5px;
  display: grid; place-items: center; margin-top: 4px; margin-left: auto;
}

/* Chat view */
.chat-view { display: flex; flex-direction: column; height: calc(100dvh - var(--nav-h) - var(--tab-h)); }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: .6rem;
}
.msg-bubble {
  max-width: 75%; padding: .65rem 1rem; border-radius: 18px;
  font-size: .88rem; line-height: 1.5; word-break: break-word;
  animation: bubbleIn .15s ease;
}
@keyframes bubbleIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg-bubble.mine {
  background: var(--primary); color: #fff;
  align-self: flex-end; border-bottom-right-radius: 4px;
}
.msg-bubble.theirs {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  align-self: flex-start; border-bottom-left-radius: 4px;
}
.msg-meta { font-size: .7rem; opacity: .7; margin-top: 3px; }
.msg-sender { font-weight: 700; font-size: .72rem; color: var(--primary); margin-bottom: 2px; }
.chat-input-bar {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: .75rem 1rem; display: flex; gap: .75rem; align-items: flex-end;
}
.chat-input {
  flex: 1; border: 1.5px solid var(--border); border-radius: 22px;
  padding: .6rem 1rem; font-family: var(--font-b); font-size: .9rem;
  outline: none; resize: none; max-height: 120px; overflow-y: auto;
  transition: var(--transition);
}
.chat-input:focus { border-color: var(--primary); }
.chat-send-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--primary); border: none; cursor: pointer;
  display: grid; place-items: center; color: #fff;
  transition: var(--transition); flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--primary-d); }

/* ── BADGES & PILLS ──────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem; border-radius: 100px;
  font-size: .72rem; font-weight: 700;
}
.pill-admin   { background: #fee2e2; color: #dc2626; }
.pill-teacher { background: #d1fae5; color: #065f46; }
.pill-parent  { background: #dbeafe; color: #1d4ed8; }
.pill-success { background: #d1fae5; color: #065f46; }
.pill-warn    { background: #fef3c7; color: #92400e; }
.pill-info    { background: #dbeafe; color: #1d4ed8; }

/* ── STATS ROW ───────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-bottom: 1rem; }
.stat-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: .9rem .75rem;
  text-align: center; box-shadow: var(--shadow);
}
.stat-value { font-family: var(--font-h); font-size: 1.6rem; font-weight: 900; color: var(--primary); }
.stat-label { font-size: .72rem; color: var(--text-2); margin-top: 2px; font-weight: 600; }

/* ── SECTIONS & DIVIDERS ─────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 1.25rem 0 .75rem;
}
.section-title { font-family: var(--font-h); font-weight: 800; font-size: .95rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; }
.divider { height: 1px; background: var(--border); margin: 1rem 0; }

/* ── LOGIN PAGE ──────────────────────────────────────────── */
.login-page {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 1.5rem; background: linear-gradient(135deg, #eef2ff 0%, #f0fdf4 100%);
}
.login-card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 2.5rem 2rem; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-md); border: 1px solid var(--border);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo .emoji { font-size: 3.5rem; display: block; margin-bottom: .5rem; }
.login-logo h1 { font-size: 1.5rem; color: var(--primary); }
.login-logo p { font-size: .85rem; color: var(--text-2); margin-top: .25rem; }

/* ── TABS (inline) ───────────────────────────────────────── */
.inline-tabs { display: flex; background: var(--surface2); border-radius: var(--radius-sm); padding: 3px; margin-bottom: 1rem; gap: 3px; }
.inline-tab {
  flex: 1; padding: .5rem; border-radius: 6px; border: none;
  background: none; font-family: var(--font-b); font-size: .82rem;
  font-weight: 600; color: var(--text-2); cursor: pointer; transition: var(--transition);
}
.inline-tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

/* ── UPDATE BANNER ───────────────────────────────────────── */
.update-banner {
  position: fixed; top: var(--nav-h); left: 0; right: 0; z-index: 200;
  background: var(--primary); color: #fff;
  padding: .75rem 1.25rem; display: flex; align-items: center; justify-content: space-between;
  transform: translateY(-100%); transition: transform .3s;
  box-shadow: var(--shadow-md);
}
.update-banner.visible { transform: translateY(0); }
.update-banner p { font-size: .88rem; font-weight: 600; }

/* ── TOAST ───────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: calc(var(--tab-h) + 1rem); left: 50%;
  transform: translateX(-50%); z-index: 1000;
  display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none;
}
.toast {
  background: #1e2a4a; color: #fff;
  padding: .6rem 1.2rem; border-radius: 100px;
  font-size: .85rem; font-weight: 600;
  animation: toastIn .25s ease; box-shadow: var(--shadow-md);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-2); }
.empty-state .emoji { font-size: 3rem; display: block; margin-bottom: .75rem; }
.empty-state p { font-size: .9rem; }

/* ── LOADING ─────────────────────────────────────────────── */
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── SCROLLBAR ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (min-width: 640px) {
  .page-content { padding: 1.5rem; }
  .modal { border-radius: var(--radius-lg); margin-bottom: 2rem; }
  .modal-overlay { align-items: center; }
}
