@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,wght@0,400;0,500;1,400&family=Nunito:wght@400;500;600&display=swap');

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

:root {
  --sage:        #7BAF8E;
  --sage-light:  #EAF4EE;
  --sage-dark:   #4A7A5C;
  --peach:       #F2A97E;
  --peach-light: #FDF0E8;
  --peach-dark:  #C4703A;
  --lavender:    #A992C9;
  --lav-light:   #F0EAF9;
  --lav-dark:    #6B4F99;
  --sky:         #7BB8D4;
  --sky-light:   #E8F4FA;
  --sky-dark:    #3A7A9C;
  --gold:        #D4A853;
  --gold-light:  #FBF3E0;
  --gold-dark:   #8C6520;
  --bg:          #FBF8F4;
  --surface:     #FFFFFF;
  --border:      rgba(0,0,0,0.08);
  --text:        #2D2A26;
  --text-muted:  #7A7570;
  --text-hint:   #B0ABA5;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-xl:   24px;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* --- SCREENS --- */
.screen { display: none; }
.screen.active { display: block; }

/* --- LOGIN --- */
.login-wrap {
  max-width: 420px;
  margin: 0 auto;
  padding: 3rem 1rem 2rem;
}
.login-logo {
  font-family: 'Fraunces', serif;
  font-size: 32px;
  font-weight: 500;
  text-align: center;
  color: var(--sage-dark);
  margin-bottom: 4px;
}
.login-sub {
  font-size: 15px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 2rem;
}
.forgot-link {
  font-size: 13px;
  color: var(--sky-dark);
  text-align: center;
  margin-top: 12px;
  cursor: pointer;
}
.forgot-link:hover { text-decoration: underline; }
.login-error {
  font-size: 13px;
  color: #C4703A;
  margin-bottom: 10px;
  display: none;
  background: var(--peach-light);
  padding: 8px 12px;
  border-radius: var(--radius-md);
}
.login-error.visible { display: block; }

/* --- TOPBAR --- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-logo {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 500;
  color: var(--sage-dark);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-name {
  font-size: 13px;
  color: var(--text-muted);
}
.role-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 99px;
}
.family-badge { background: var(--sage-light); color: var(--sage-dark); }
.staff-badge  { background: var(--lav-light);  color: var(--lav-dark); }
.logout-btn {
  font-family: 'Nunito', sans-serif;
  font-size: 12px;
  color: var(--text-hint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
}
.logout-btn:hover { color: var(--text); }

/* --- CONTAINER --- */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

/* --- CARD --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}
.card-title {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 1.25rem;
}

/* --- FIELDS --- */
.field { margin-bottom: 14px; }
.field label, .field > label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
input[type="email"],
input[type="password"],
input[type="text"],
select,
textarea {
  width: 100%;
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--sage);
  background: #fff;
}
textarea { resize: vertical; min-height: 90px; }

/* --- BUTTONS --- */
.btn-primary {
  width: 100%;
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  font-weight: 600;
  padding: 12px;
  border-radius: var(--radius-lg);
  border: none;
  background: var(--sage-dark);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  margin-top: 4px;
}
.btn-primary:hover { background: #3A6649; }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 20px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--sage);
  background: var(--sage-light);
  color: var(--sage-dark);
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.15s;
}
.btn-secondary:hover { background: #D4EBD9; }

/* --- PILLS --- */
.pill-group { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.pill:hover { border-color: var(--sage); color: var(--sage-dark); }
.pill.active-wellness   { background: var(--sage-light);  border-color: var(--sage);     color: var(--sage-dark); }
.pill.active-activities { background: var(--sky-light);   border-color: var(--sky);      color: var(--sky-dark); }
.pill.active-nutrition  { background: var(--gold-light);  border-color: var(--gold);     color: var(--gold-dark); }
.pill.active-social     { background: var(--lav-light);   border-color: var(--lavender); color: var(--lav-dark); }
.pill.active-medical    { background: var(--peach-light); border-color: var(--peach);    color: var(--peach-dark); }

/* --- METRICS --- */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 1.5rem;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.metric-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 6px; }
.metric-value { font-family: 'Fraunces', serif; font-size: 32px; font-weight: 500; color: var(--sage-dark); }

/* --- PAGE HEADING --- */
.page-heading { margin-bottom: 1.25rem; }

/* --- UPDATE CARDS --- */
.update-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
  transition: box-shadow 0.2s;
}
.update-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.08); }
.update-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cat-label-text { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.update-body { font-size: 15px; line-height: 1.75; color: var(--text); }
.mood-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; background: var(--bg); padding: 8px 12px; border-radius: var(--radius-md); }
.mood-pip { width: 8px; height: 8px; border-radius: 50%; }
.mood-txt { font-size: 13px; font-weight: 600; }
.update-date { font-size: 11px; color: var(--text-hint); margin-top: 10px; }

/* --- MESSAGE SECTION --- */
.message-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  margin-top: 1.5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}
.section-label {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 10px;
}

/* --- RECENT POSTS --- */
.post-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.post-item:last-child { border-bottom: none; }
.post-av {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.post-name { font-size: 14px; font-weight: 600; color: var(--text); }
.post-preview { font-size: 13px; color: var(--text-muted); margin-top: 2px; line-height: 1.5; }
.post-meta { font-size: 11px; color: var(--text-hint); margin-top: 4px; }

/* --- SUCCESS MSG --- */
.success-msg { font-size: 13px; font-weight: 600; color: var(--sage-dark); margin-top: 10px; display: none; background: var(--sage-light); padding: 8px 14px; border-radius: var(--radius-md); }
.success-msg.visible { display: block; }

/* --- EMPTY STATE --- */
.empty-state { font-size: 14px; color: var(--text-muted); padding: 2.5rem 0; text-align: center; }

/* --- RESIDENT PHOTO LIST --- */
.resident-photo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.resident-photo-item:last-child { border-bottom: none; }

/* --- WELCOME BANNER --- */
.welcome-banner {
  background: linear-gradient(135deg, var(--sage-light) 0%, var(--sky-light) 100%);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(123,175,142,0.2);
}

/* --- RESPONSIVE --- */
@media (max-width: 500px) {
  .metrics-row { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 0 1rem; }
  .user-name { display: none; }
  .card { padding: 1.25rem; border-radius: var(--radius-lg); }
  .update-card { border-radius: var(--radius-lg); }
}

/* --- ADD RESIDENT --- */
.btn-add-resident {
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 99px;
  border: 1.5px solid var(--sage);
  background: var(--sage-light);
  color: var(--sage-dark);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-add-resident:hover { background: #D4EBD9; }
.add-resident-inner {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-top: 1rem;
  border: 1px solid var(--border);
}
.btn-cancel {
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.btn-cancel:hover { background: var(--bg); }
.error-msg {
  font-size: 13px;
  font-weight: 600;
  color: var(--peach-dark);
  margin-top: 8px;
  background: var(--peach-light);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  display: none;
}
.error-msg.visible { display: block; }
.resident-staff-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.resident-staff-item:last-child { border-bottom: none; }
.res-info { flex: 1; }
.res-name-staff { font-size: 14px; font-weight: 600; color: var(--text); }
.res-meta-staff { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* --- MESSAGES INBOX --- */
.unread-badge {
  font-size: 11px;
  font-weight: 700;
  background: var(--peach);
  color: #fff;
  padding: 3px 10px;
  border-radius: 99px;
}
.message-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.message-item:last-child { border-bottom: none; }
.message-item.unread { background: var(--sage-light); margin: 0 -1.75rem; padding: 14px 1.75rem; border-radius: var(--radius-md); }
.msg-from { font-size: 13px; font-weight: 700; color: var(--text); }
.msg-resident { font-size: 11px; color: var(--text-muted); margin-left: 6px; font-weight: 400; }
.msg-date { font-size: 11px; color: var(--text-hint); float: right; }
.msg-body { font-size: 14px; color: var(--text); margin: 6px 0; line-height: 1.6; }
.msg-reply-preview { font-size: 13px; color: var(--sage-dark); background: var(--sage-light); padding: 6px 10px; border-radius: var(--radius-md); margin-top: 6px; }
.msg-reply-preview::before { content: 'Your reply: '; font-weight: 700; }
.btn-reply {
  font-family: 'Nunito', sans-serif;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 99px;
  border: 1.5px solid var(--sage);
  background: transparent;
  color: var(--sage-dark);
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.15s;
}
.btn-reply:hover { background: var(--sage-light); }

/* --- COMMENTS --- */
.comment-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.comment-item {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.comment-author {
  font-size: 12px;
  font-weight: 700;
  color: var(--sage-dark);
  margin-bottom: 3px;
}
.comment-date {
  font-weight: 400;
  color: var(--text-hint);
  margin-left: 6px;
}
.comment-body {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}
.comment-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 8px;
}
.comment-input {
  flex: 1;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  resize: none;
  min-height: 44px;
  max-height: 100px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
}
.comment-input:focus { border-color: var(--sage); background: #fff; }
.btn-comment {
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--sage-dark);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  height: 44px;
}
.btn-comment:hover { background: #3A6649; }
