/* ============================================================
   SEA Shell — layout, sidebar, nav, mobile bottom bar
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:        #2B4C7E;
  --brand-mid:    #3A6099;
  --brand-light:  #4A90D9;
  --accent:       #F5A623;
  --surface:      #F7F9FC;
  --card:         #FFFFFF;
  --border:       #DDE4EE;
  --text-primary: #1A2332;
  --text-secondary: #5B6B80;
  --text-muted:   #9BAABB;
  --sidebar-w:    220px;
  --bottom-nav-h: 60px;
  --radius:       12px;
  --shadow-sm:    0 1px 3px rgba(43,76,126,.10);
  --shadow-md:    0 4px 12px rgba(43,76,126,.12);
  --transition:   0.18s ease;
}

html, body {
  height: 100%;
  font-family: 'Poppins', sans-serif;
  background: var(--surface);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ── Shell chrome ─────────────────────────────────────────── */

#sea-shell {
  display: flex;
  min-height: 100dvh;
}

/* ── Sidebar ──────────────────────────────────────────────── */

#sea-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  padding: 20px 0 80px;
}

.sidebar-brand {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sidebar-brand a {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-brand .brand-icon {
  width: 32px;
  height: 32px;
  background: var(--brand);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
  font-weight: 800;
  flex-shrink: 0;
}

.sidebar-brand .brand-text {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.2;
}

.sidebar-brand .brand-sub {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Child switcher */

#sea-child-switcher {
  padding: 0 12px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.child-switcher-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 6px;
}

.child-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.child-pill:hover { background: var(--surface); }

.child-pill.active {
  background: #EBF2FB;
  color: var(--brand);
  font-weight: 700;
}

.child-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand-light);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.child-pill.active .child-avatar { background: var(--brand); }

.child-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.child-active-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-light);
  flex-shrink: 0;
}

/* Nav items */

#sea-nav {
  padding: 0 12px;
  flex: 1;
}

.nav-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 8px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-link:hover { background: var(--surface); color: var(--brand); }

.nav-link.active {
  background: #EBF2FB;
  color: var(--brand);
}

.nav-link .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: .6;
}

.nav-link.active .nav-icon { opacity: 1; }

/* Sidebar footer */

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
}

.sidebar-footer-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  width: 100%;
  transition: color var(--transition), background var(--transition);
}

.sidebar-footer-link:hover { background: #f0f4fa; color: #2B4C7E; }

/* ── Main content ─────────────────────────────────────────── */

#sea-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

#sea-view-container {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}

/* ── Loading / auth states ────────────────────────────────── */

.sea-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
  color: var(--text-muted);
}

.sea-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--brand-light);
  border-radius: 50%;
  animation: sea-spin .8s linear infinite;
}

@keyframes sea-spin { to { transform: rotate(360deg); } }

/* ── Mobile bottom nav ────────────────────────────────────── */

#sea-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-h);
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 200;
  align-items: center;
  justify-content: space-around;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 600;
  transition: color var(--transition);
  flex: 1;
  max-width: 80px;
}

.bottom-nav-btn svg { width: 22px; height: 22px; }

.bottom-nav-btn.active { color: var(--brand); }
.bottom-nav-btn.active svg path,
.bottom-nav-btn.active svg rect,
.bottom-nav-btn.active svg circle { fill: var(--brand); }

/* ── Toast / notification ─────────────────────────────────── */

#sea-toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 40px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
  z-index: 9999;
}

#sea-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive: tablet / mobile ─────────────────────────── */

@media (max-width: 768px) {
  #sea-sidebar { display: none; }
  #sea-main { margin-left: 0; padding-bottom: var(--bottom-nav-h); }
  #sea-view-container { padding: 16px 16px 24px; }
  #sea-bottom-nav { display: flex; }
}

/* ── View scaffold helpers (used by views) ────────────────── */

.sea-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 20px;
}

.sea-page-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--brand);
  margin-bottom: 4px;
}

.sea-page-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.sea-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 40px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: .04em;
}

.sea-badge-blue  { background: #EBF2FB; color: var(--brand); }
.sea-badge-green { background: #E6F9F1; color: #27AE60; }
.sea-badge-amber { background: #FEF6E4; color: #D4881A; }
.sea-badge-red   { background: #FEE8E8; color: #D0021B; }

/* ── Boot splash ──────────────────────────────────────────────
   While the shell initialises (Supabase SDK load + auth check), cover the
   static SEO fallback so signed-in users never see the "Sign in to start"
   flash. Driven by #sea-root[data-view], which the shell removes once mounted.
   Scoped to html.js so no-JS users still get the real static fallback. */
html.js #sea-root[data-view]{ position:relative; }
html.js #sea-root[data-view]::before{
  content:""; position:fixed; inset:0; z-index:9000; background:#f0f4fa;
}
html.js #sea-root[data-view]::after{
  content:""; position:fixed; left:50%; top:calc(50% - 15px); z-index:9001;
  width:30px; height:30px; margin-left:-15px;
  border:3px solid #d7e3f4; border-top-color:#2B4C7E; border-radius:50%;
  animation:sea-boot-spin .7s linear infinite;
}
@keyframes sea-boot-spin{ to{ transform:rotate(360deg); } }
