/* Parents Portal — warm Montessori styling.
   Always uses the light, website-matching palette. */

:root {
  color-scheme: light;
  --bg: #faf6ec;
  --surface: #fffdf6;
  --surface-alt: #eef2e4;
  --text: #22301f;
  --dim: #5f6d58;
  --border: #8f876c;
  --accent: #2e5a3c;
  --accent-contrast: #ffffff;
  --accent-2: #9e4f1f;
  --accent-2-soft: #fbeadd;
  --danger: #b3352b;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.serif { font-family: Georgia, "Iowan Old Style", "Times New Roman", serif; }
.dim { color: var(--dim); }
.small { font-size: 0.875rem; }
.tiny { font-size: 0.75rem; }
.accent { color: var(--accent); }
.pre-wrap { white-space: pre-wrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Skip link: hidden until keyboard focus, then pinned top-left. */
.skip-link {
  position: absolute; left: 0.75rem; top: -4rem; z-index: 100;
  background: var(--accent); color: var(--accent-contrast);
  padding: 0.5rem 1rem; border-radius: 0.5rem;
  font-weight: 600; text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus-visible { top: 0.75rem; }

.wrap { max-width: 48rem; margin: 0 auto; padding: 0 1rem; }
.wrap-narrow { max-width: 28rem; }

main.wrap { padding-top: 1.25rem; padding-bottom: 2.5rem; }

/* ---------- app shell + sidebar nav ---------- */

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.sidenav { background: var(--surface); border-bottom: 1px solid var(--border); }

.sidenav-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; padding: 0.75rem 1rem;
}

.sidenav-nav { display: flex; gap: 0.25rem; overflow-x: auto; padding: 0 1rem 0.75rem; }

.sidenav-nav .tab { white-space: nowrap; flex-shrink: 0; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-main main.wrap { flex: 1; width: 100%; }

@media (min-width: 960px) {
  .app-shell { flex-direction: row; }
  .sidenav {
    width: 15rem; flex-shrink: 0;
    position: sticky; top: 0; height: 100vh;
    border-bottom: 0; border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
  }
  .sidenav-top { flex-direction: column; align-items: flex-start; }
  .sidenav-nav { flex-direction: column; overflow-y: auto; overflow-x: visible; padding: 0.5rem; flex: 1; }
  .sidenav-nav .tab { display: block; text-align: left; }
}

.brand-name { margin: 0; font-size: 1.125rem; line-height: 1.25; }
.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-logo-link { display: block; flex: 0 0 auto; }
.brand-logo { display: block; height: 44px; width: auto; }
.brand .tiny { margin: 0.125rem 0 0; }

.tabs { display: flex; gap: 0.25rem; padding-bottom: 0.5rem; flex-wrap: wrap; }

.tab {
  border-radius: 999px; padding: 0.375rem 0.875rem;
  font-size: 0.875rem; font-weight: 500;
  color: var(--dim); text-decoration: none;
}
.tab.active { background: var(--accent); color: var(--accent-contrast); }

/* ---------- footer ---------- */

footer.site {
  margin-top: 2.5rem; border-top: 1px solid var(--border);
  padding: 1rem 0 2.5rem; text-align: center;
}
footer.site p { margin: 0; }

/* ---------- buttons & links ---------- */

.btn {
  display: inline-block; border-radius: 0.5rem;
  padding: 0.625rem 1rem; font-size: 1rem; font-weight: 500;
  text-decoration: none; cursor: pointer; border: 1px solid transparent;
  font-family: inherit; line-height: 1.5;
}
.btn-sm { padding: 0.5rem 0.75rem; font-size: 0.875rem; }
.btn-block { width: 100%; text-align: center; }
.btn[disabled] { opacity: 0.6; cursor: default; }

.btn-primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-accent2 { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }

.btn-row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline; margin: 0; }

.link-accent {
  color: var(--accent); font-weight: 500; text-decoration: underline;
  display: inline-block; margin-top: 0.5rem;
}

.row-between {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  justify-content: space-between; gap: 0.75rem;
}

/* ---------- forms ---------- */

.form-grid { display: grid; gap: 0.75rem; margin-top: 1rem; }
.grid-2 { display: grid; gap: 0.75rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.form-actions { margin-top: 1.5rem; }

.label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.25rem; }

.input {
  width: 100%; border-radius: 0.5rem;
  border: 1px solid var(--border); background: var(--surface);
  padding: 0.625rem 0.75rem; font-size: 1rem; color: var(--text);
  font-family: inherit;
}
.input::placeholder { color: var(--dim); }
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea.input { resize: vertical; }

.editor-group { margin: 1.25rem 0 0; padding: 0; border: 0; }
.editor-legend { font-size: 1.125rem; padding: 0; margin-bottom: 0.5rem; }

/* ---------- flash messages ---------- */

.flash {
  border-radius: 0.5rem; padding: 0.5rem 0.75rem;
  font-size: 0.875rem; margin: 0 0 1rem;
}
.flash-error { border: 1px solid var(--danger); background: var(--surface); color: var(--danger); }
.flash-success { border: 1px solid var(--accent); background: var(--surface); color: var(--accent); }

/* ---------- auth screen ---------- */

.auth { padding-top: 2rem; padding-bottom: 2.5rem; }

.signin-art {
  aspect-ratio: 16 / 9; width: 100%; object-fit: cover;
  border-radius: 1rem; border: 1px solid var(--border); display: block;
}

.auth-logo-link { display: block; }
.auth-logo {
  display: block; width: min(300px, 78%); height: auto;
  margin: 0.25rem auto 0;
}

.auth-title { font-size: 1.875rem; line-height: 1.2; margin: 1.5rem 0 0; }
.auth > p.dim { margin: 0.5rem 0 0; }

.auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border); background: var(--surface-alt);
  border-radius: 0.5rem; padding: 0.25rem; margin-top: 1.5rem;
}
.auth-tab {
  border-radius: 0.375rem; padding: 0.5rem 0.75rem;
  font-size: 0.875rem; font-weight: 500; text-align: center;
  color: var(--dim); text-decoration: none;
}
.auth-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

.auth .small.dim { margin-top: 1rem; }

/* ---------- cards & sections ---------- */

.section-title { font-size: 1.5rem; margin: 0; font-weight: 600; }
.row-between .small.dim { margin: 0.25rem 0 0; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 0.75rem; padding: 1rem; margin-top: 1.25rem;
}

.today-card { border: 2px solid var(--accent-2); }

.kicker {
  font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--accent-2); margin: 0;
}

.today-grid { display: grid; gap: 0.75rem; margin: 0.75rem 0 0; padding: 0; }
@media (min-width: 640px) { .today-grid { grid-template-columns: 1fr 1fr; } }
.today-grid dt { margin: 0; }
.today-grid dd { margin: 0.125rem 0 0; font-size: 1rem; }

.empty-note {
  margin-top: 1.5rem; border: 1px solid var(--border);
  background: var(--surface); border-radius: 0.75rem;
  padding: 1.5rem 1rem; text-align: center;
}
.empty-note p { margin: 0 0 1rem; }
.empty-note .btn { margin-top: 0.25rem; }

.footnote { margin-top: 1rem; }
.admin-actions { margin-top: 1.25rem; }
.admin-actions .tiny { margin-top: 0.5rem; }

/* ---------- menu tables ---------- */

.menu-caption { font-size: 1.125rem; margin: 1.5rem 0 0; }

.table-scroll { overflow-x: auto; margin-top: 0.5rem; }

table.menu {
  width: 100%; min-width: 34rem; table-layout: fixed;
  border-collapse: collapse; font-size: 0.875rem;
  border-radius: 0.75rem; overflow: hidden;
}
table.menu thead tr { background: var(--surface-alt); }
table.menu th, table.menu td {
  padding: 0.5rem; text-align: left; vertical-align: top;
  overflow-wrap: break-word;
}
table.menu tbody tr { border-top: 1px solid var(--border); background: var(--surface); }
table.menu tbody tr.today-row { background: var(--accent-2-soft); }
table.menu th.today-col { color: var(--accent-2); }
table.menu td.today-col { font-weight: 500; }
table.menu th.week-col, table.menu td.week-col { width: 3.5rem; }
.today-tag {
  display: block; font-size: 0.625rem; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase;
}
.sack { font-weight: 600; letter-spacing: 0.02em; color: var(--accent-2); }

/* ---------- lesson plan ---------- */

.theme-line { font-size: 1.25rem; margin: 1.25rem 0 0; }
.theme-line .accent { color: var(--accent); }

.day-list { list-style: none; margin: 1.25rem 0 0; padding: 0; display: grid; gap: 0.75rem; }
.day-card { margin-top: 0; }
.day-card.today { border-color: var(--accent-2); box-shadow: 0 0 0 1px var(--accent-2); }
.day-head { margin: 0; font-size: 0.875rem; font-weight: 600; }
.day-head .kicker { margin-left: 0.5rem; }
.day-focus { margin: 0.25rem 0 0; font-weight: 500; }
.day-card .small { margin: 0.25rem 0 0; }

/* ---------- events ---------- */

.event-list { list-style: none; margin: 1.25rem 0 0; padding: 0; display: grid; gap: 0.75rem; }
.event { display: flex; gap: 0.75rem; margin-top: 0; }
.event.muted { opacity: 0.7; }

.date-badge { width: 3.5rem; flex-shrink: 0; text-align: center; }
.date-badge .kicker { margin: 0; }
.date-day { font-size: 1.125rem; line-height: 1.25; margin: 0; }

.event-body { min-width: 0; flex: 1; }
.event-title { margin: 0; font-weight: 500; }
.event-body .small { margin: 0.25rem 0 0; }
.event-admin { margin-top: 0.75rem; }

/* ---------- families ---------- */

.account-list { list-style: none; margin: 1.25rem 0 0; padding: 0; display: grid; gap: 0.5rem; }
.account {
  margin-top: 0; display: flex; flex-wrap: wrap;
  align-items: center; justify-content: space-between; gap: 0.5rem;
}
.account-name { margin: 0; font-weight: 500; }
.account-id { min-width: 0; }
.account-id .small { margin: 0; }
.account-meta { text-align: right; }
.account-meta .tiny { margin: 0.25rem 0 0; }

.role-badge {
  display: inline-block; border-radius: 999px;
  padding: 0.25rem 0.625rem; font-size: 0.75rem; font-weight: 600;
  background: var(--surface-alt); color: var(--text);
}
.role-badge.role-admin { background: var(--accent); color: var(--accent-contrast); }

/* ---------- enrollment nudge ---------- */

.enroll-nudge {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin: 0 0 1.25rem; padding: 1rem 1.25rem;
  background: var(--surface-alt); border: 1px solid var(--border);
  border-left: 4px solid var(--accent); border-radius: 0.75rem;
}
.enroll-nudge-title { margin: 0 0 0.25rem; font-weight: 700; font-size: 1rem; }
.enroll-nudge .tiny { margin: 0; }
.enroll-nudge .btn { flex: 0 0 auto; }

/* ---------- preview: check-in/out + daily feed ---------- */

.badge {
  display: inline-block; font-size: 0.6875rem; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--accent-2-soft); color: var(--accent-2);
  border: 1px solid var(--accent-2); border-radius: 999px;
  padding: 0.1rem 0.5rem; margin-left: 0.35rem; vertical-align: middle;
}
.preview-note { margin: 0 0 1rem; }
.child-list { display: grid; gap: 0.75rem; margin-bottom: 1.25rem; }
.child-card { margin: 0; }
.child-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem;
}
.child-name { font-size: 1.125rem; margin: 0; }
.child-head .tiny { margin: 0.15rem 0 0; }
.child-status { margin: 0; text-align: right; }
.status-in { color: var(--accent); font-weight: 600; }
.status-absent { color: #a16207; font-weight: 600; }
.checkin-form { display: grid; gap: 0.6rem; }
.stack { display: grid; gap: 0.75rem; }
.feed { display: grid; gap: 0.9rem; }
.feed-item { margin: 0; overflow: hidden; padding: 0; }
.feed-photo { width: 100%; height: auto; display: block; aspect-ratio: 4 / 3; object-fit: cover; }
.feed-body { padding: 0.9rem 1rem 1rem; }
.feed-body p { margin: 0 0 0.4rem; }
.feed-body p:last-child { margin-bottom: 0; }
.feed-meta { margin-bottom: 0.35rem; }
.push-card { margin-bottom: 1rem; }
.push-card .card-title { margin-top: 0; }
.card-title { font-size: 1.05rem; margin: 0 0 0.5rem; }

/* ---------- preview: classroom daycare features ---------- */

.section-title { font-size: 1.25rem; margin: 1.5rem 0 0.75rem; }
.input-sm { width: auto; min-width: 0; padding: 0.4rem 0.6rem; font-size: 0.875rem; }
.pickup-list { list-style: none; margin: 0.4rem 0 0.75rem; padding: 0; display: grid; gap: 0.4rem; }
.pickup-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
  background: var(--surface-alt); border-radius: 0.5rem; padding: 0.4rem 0.6rem;
}
.pickup-form { margin-top: 0.5rem; }
.badge-kind { background: var(--surface-alt); border-color: var(--border); color: var(--text); }
.badge-ok { background: #e6f2e4; border-color: var(--accent); color: var(--accent); }
.log-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.log-item {
  margin: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem;
}
.log-item p { margin: 0 0 0.25rem; }
.log-item p:last-child { margin-bottom: 0; }
.log-meta { margin-bottom: 0.2rem; }
.thread-row {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  margin: 0 0 0.6rem; text-decoration: none; color: inherit;
}
.thread-row:hover { border-color: var(--accent); }
.thread-row p { margin: 0; }
.thread { display: grid; gap: 0.6rem; margin-bottom: 1rem; }
.msg {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.6rem 0.8rem; max-width: 85%;
}
.msg p { margin: 0; }
.msg-meta { margin-bottom: 0.25rem; }
.msg-mine { justify-self: end; background: var(--surface-alt); }
.sig-list { list-style: none; margin: 0.6rem 0 0; padding: 0; display: grid; gap: 0.5rem; }
.sig-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  background: var(--surface-alt); border-radius: 0.5rem; padding: 0.4rem 0.6rem;
}
.kid-list { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.3rem; }
.kid-list li { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.kid-list .inline-form { margin-left: auto; }

/* ---------- parent autocomplete popup ---------- */
.ac-wrap { position: relative; }
.ac-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 60;
  list-style: none; margin: 0.25rem 0 0; padding: 0.25rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 0.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); max-height: 14rem; overflow-y: auto;
}
.ac-item { padding: 0.5rem 0.625rem; border-radius: 0.375rem; cursor: pointer; font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-item:hover, .ac-item.ac-active { background: var(--surface-alt); }
.ac-item strong { font-weight: 600; }
.ac-item .dim { font-size: 0.75rem; }
@media (max-width: 560px) {
  .enroll-nudge { flex-direction: column; align-items: stretch; text-align: left; }
}

/* ---------- two-column split (families) ---------- */
.split { display: grid; gap: 1.25rem; margin-top: 1rem; }
.split-col { min-width: 0; }
.split-col .card-title { margin: 0 0 0.5rem; }
@media (max-width: 899px) {
  /* On phones the actionable list (children without parents) comes first. */
  .split-col:last-child { order: -1; }
}
@media (min-width: 900px) {
  .split { grid-template-columns: 1fr 1fr; align-items: start; }
  /* Actionable list (children without parents) on the left. */
  .split-col:first-child { order: 2; }
  .split-col:last-child { order: 1; }
}

/* ---------- check-in tabs ---------- */
.checkin-tabs { display: flex; gap: 0.25rem; margin: 1.25rem 0 1rem; }
.checkin-panel { margin-top: 0.75rem; margin-bottom: 1rem; }

.tab-danger { background: var(--danger); color: #fff; }
.tab-danger.active { background: var(--danger); color: #fff; }

.welcome-banner {
  max-width: 48rem;
  margin: 1rem auto 0;
  padding: 0.9rem 1.25rem;
  font-size: 1.15rem;
  text-align: center;
  color: #fffdf6;
  background: #2e5a3c;
  border-radius: 12px;
}
.welcome-star {
  color: #e8b84b;
  margin-right: 0.5rem;
}
.teacher-banner {
  display: inline-block;
  margin: 0.5rem 0 0;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fffdf6;
  background: #2e5a3c;
  border-radius: 12px;
}
.child-summary { cursor: pointer; list-style: none; padding: 0; margin: 0.25rem 0; }
.child-summary::-webkit-details-marker { display: none; }
.child-summary .child-name { display: inline-block; font-size: 1rem; font-weight: 600; color: #fffdf6;
  background: #2e5a3c; border-radius: 12px; padding: 0.7rem 1.5rem; }
.child-summary:hover .child-name { background: #24492f; }
details.child-card[open] .child-summary .child-name, details[data-class-section][open] > .child-summary .child-name { background: #24492f; }
.child-summary.class-btn .child-name { display: block; text-align: center; }
.child-summary.class-btn .child-count { display: block; text-align: center; font-size: 0.8rem; font-weight: 400; opacity: 0.85; margin-top: 0.15rem; }
.class-toggle[aria-expanded="true"] { background: var(--accent-2); border-color: var(--accent-2); }
.class-btn-row { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.25rem; -webkit-overflow-scrolling: touch; }
.class-btn-row .class-toggle { flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 600px) {
  .class-btn-row .class-toggle { font-size: 0.9rem; padding: 0.6rem 1rem; }
}
.class-btn-row .class-toggle { display: inline-block; font-size: 1rem; font-weight: 600; color: #fffdf6;
  background: #2e5a3c; border-radius: 12px; padding: 0.7rem 1.5rem; text-align: center; }
.class-btn-row .class-toggle:hover { background: #24492f; }
.class-btn-row .class-toggle.active-class { background: var(--accent-2); border-color: var(--accent-2); }
.ptr-indicator { position: fixed; top: 0; left: 0; right: 0; text-align: center; padding: 0.5rem;
  background: var(--accent); color: #fff; font-size: 0.85rem; font-weight: 600;
  transform: translateY(-100%); transition: transform 0.2s; z-index: 1000; }
.ptr-indicator.visible { transform: translateY(0); }
@media (min-width: 1024px) {
  .push-card-mobile-only { display: none; }
}
