/* ---- APP SHELL ---- */
.app-body {
  background: var(--bg-alt);
  min-height: 100vh;
}

.app-nav {
  background: var(--white);
  border-bottom: 1px solid rgba(0,0,0,0.08);
  padding: 0 5vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.tm {
  font-size: 0.55em;
  vertical-align: super;
  line-height: 0;
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-link {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-muted);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.15s;
}

.nav-link:hover {
  background: var(--bg-alt);
  color: var(--fg);
}

.nav-link.active {
  background: var(--accent-light);
  color: var(--accent-dark);
}

.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 5vw 80px;
}

/* ---- PAGE HEADER ---- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 36px;
  gap: 16px;
}

.page-title {
  font-family: var(--serif);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 400;
  color: var(--fg);
  line-height: 1.1;
  margin-bottom: 4px;
}

.page-sub {
  font-size: 15px;
  color: var(--fg-muted);
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--accent-dark);
}

.btn-secondary {
  background: var(--fg);
  color: var(--white);
}

.btn-secondary:hover {
  opacity: 0.85;
}

.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
  border: 1.5px solid rgba(0,0,0,0.12);
}

.btn-ghost:hover {
  background: var(--bg-alt);
  color: var(--fg);
}

.btn-danger {
  background: #DC2626;
  color: white;
}

.btn-danger:hover {
  background: #B91C1C;
}

.btn-ai {
  background: linear-gradient(135deg, var(--accent-dark) 0%, var(--accent) 100%);
  color: white;
  font-size: 13px;
}

.btn-ai:hover {
  opacity: 0.9;
}

.btn-sm {
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 8px;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

/* ---- ALERTS ---- */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 24px;
}

.alert-error {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
}

.alert-success {
  background: #F0FDF4;
  color: #166534;
  border: 1px solid #BBF7D0;
}

/* ---- STATS GRID ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--white);
  border-radius: 14px;
  padding: 24px;
  border: 1px solid rgba(0,0,0,0.06);
  text-align: center;
}

.stat-value {
  font-family: var(--serif);
  font-size: 40px;
  color: var(--fg);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 13px;
  color: var(--fg-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ---- DASHBOARD COLS ---- */
.dashboard-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* ---- CARD ---- */
.card {
  background: var(--white);
  border-radius: 16px;
  padding: 28px;
  border: 1px solid rgba(0,0,0,0.06);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 20px;
}

.card-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 400;
  color: var(--fg);
}

.card-sub {
  font-size: 13px;
  color: var(--fg-muted);
}

.card-link {
  font-size: 13px;
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 600;
}

/* ---- ATTENTION LIST ---- */
.attention-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.attention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.attention-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.attention-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--fg);
  margin-bottom: 2px;
}

.attention-meta {
  font-size: 13px;
  color: var(--fg-muted);
}

.days-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  background: #FEF3C7;
  color: #92400E;
  font-size: 12px;
  font-weight: 600;
}

.days-badge.no-contact,
.days-badge.urgent-badge {
  background: #FEE2E2;
  color: #991B1B;
}

/* ---- ACTIVITY LIST ---- */
.activity-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.type-hospital_visit { background: #EF4444; }
.type-home_visit     { background: var(--accent); }
.type-counseling     { background: #8B5CF6; }
.type-phone_call     { background: #3B82F6; }
.type-other          { background: var(--fg-muted); }

.activity-info {
  flex: 1;
}

.activity-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--fg);
}

.activity-meta {
  font-size: 13px;
  color: var(--fg-muted);
  text-transform: capitalize;
}

.activity-notes {
  font-size: 13px;
  color: var(--fg-muted);
  margin-top: 4px;
  font-style: italic;
}

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

.empty-card {
  background: var(--white);
  border-radius: 16px;
  padding: 60px 40px;
  text-align: center;
  border: 1px solid rgba(0,0,0,0.06);
}

.empty-title {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--fg);
  margin-bottom: 12px;
}

.empty-sub {
  font-size: 15px;
  color: var(--fg-muted);
  margin-bottom: 24px;
}

/* ---- SEARCH ---- */
.search-form {
  display: flex;
  gap: 10px;
  margin-bottom: 28px;
}

.search-input {
  flex: 1;
  padding: 10px 16px;
  border: 1.5px solid rgba(0,0,0,0.12);
  border-radius: 10px;
  font-family: var(--sans);
  font-size: 15px;
  background: var(--white);
  color: var(--fg);
  outline: none;
  transition: border-color 0.15s;
}

.search-input:focus {
  border-color: var(--accent);
}

/* ---- MEMBER GRID ---- */
.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.member-card {
  background: var(--white);
  border-radius: 16px;
  padding: 24px;
  border: 1px solid rgba(0,0,0,0.06);
  display: flex;
  gap: 16px;
  align-items: flex-start;
  transition: transform 0.15s;
}

.member-card:hover {
  transform: translateY(-2px);
}

.member-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent-dark);
  font-family: var(--serif);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.member-info {
  flex: 1;
  min-width: 0;
}

.member-name {
  font-weight: 700;
  font-size: 16px;
  color: var(--fg);
  margin-bottom: 4px;
}

.member-meta {
  font-size: 13px;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

/* ---- FORMS ---- */
.form-card {
  background: var(--white);
  border-radius: 16px;
  padding: 36px;
  border: 1px solid rgba(0,0,0,0.06);
  max-width: 640px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.required {
  color: var(--accent);
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid rgba(0,0,0,0.12);
  border-radius: 10px;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--fg);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--accent);
  background: var(--white);
}

.form-textarea {
  resize: vertical;
  line-height: 1.6;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  padding-top: 20px;
  border-top: 1px solid rgba(0,0,0,0.06);
}

/* ---- CARE LOG LAYOUT ---- */
.care-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  align-items: start;
}

.log-form-card {
  position: sticky;
  top: 88px;
}

/* ---- CARE ENTRY ---- */
.care-entry {
  background: var(--white);
  border-radius: 14px;
  padding: 24px;
  border: 1px solid rgba(0,0,0,0.06);
  margin-bottom: 16px;
}

.care-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.care-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.care-type-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 3px 10px;
  border-radius: 20px;
}

.type-hospital_visit.care-type-badge { background: #FEE2E2; color: #991B1B; }
.type-home_visit.care-type-badge     { background: var(--accent-light); color: var(--accent-dark); }
.type-counseling.care-type-badge     { background: #EDE9FE; color: #5B21B6; }
.type-phone_call.care-type-badge     { background: #DBEAFE; color: #1D4ED8; }
.type-other.care-type-badge          { background: var(--bg-alt); color: var(--fg-muted); }

.care-date {
  font-size: 14px;
  color: var(--fg-muted);
  font-weight: 500;
}

.care-notes {
  font-size: 15px;
  color: var(--fg);
  line-height: 1.65;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--bg-alt);
  border-radius: 10px;
}

.btn-icon-delete {
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: all 0.15s;
}

.btn-icon-delete:hover {
  background: #FEE2E2;
  color: #991B1B;
}

/* ---- AI REMINDER ---- */
.reminder-section {
  margin-top: 12px;
}

.reminder-box {
  background: linear-gradient(135deg, #FBF7EF 0%, #F5EFE0 100%);
  border: 1px solid var(--accent-light);
  border-radius: 12px;
  padding: 16px 20px;
}

.reminder-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent-dark);
  margin-bottom: 8px;
}

.reminder-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--fg);
  margin-bottom: 12px;
}

.reminder-loading {
  font-size: 14px;
  color: var(--fg-muted);
  padding: 8px 0;
}

.loading-dots span {
  animation: blink 1.4s infinite both;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0; }
  40% { opacity: 1; }
}

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-cols { grid-template-columns: 1fr; }
  .care-layout { grid-template-columns: 1fr; }
  .log-form-card { position: static; }
}

@media (max-width: 640px) {
  .app-main { padding: 24px 5vw 60px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .member-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: stretch; }
  .form-card { padding: 24px; }
}

/* ---- NAV USER ---- */
.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-username {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-muted);
}

/* Church name badge next to the Parishly brand */
.nav-brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-church-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-dark);
  background: var(--accent-light);
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

/* form hint text */
.form-hint {
  display: block;
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: 4px;
}

/* Plan badge in nav */
.nav-plan-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 3px 10px;
  border-radius: 20px;
  text-decoration: none;
}
.nav-plan-pro {
  background: var(--accent-light);
  color: var(--accent-dark);
}
.nav-plan-church {
  background: var(--fg);
  color: var(--white);
}

/* Upgrade link in nav (free plan) */
.nav-upgrade-link {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-dark);
  text-decoration: none;
  border: 1.5px solid var(--accent);
  padding: 3px 10px;
  border-radius: 20px;
  transition: all 0.15s;
}
.nav-upgrade-link:hover {
  background: var(--accent);
  color: var(--white);
}
