/* =========================================================
   Twelfth Street Baptist Church Directory
   Design tokens: deep ink navy + warm brass + soft parchment
   Signature: household entries styled as catalog/index cards
   ========================================================= */

:root {
  --navy: #1B2A4A;
  --navy-deep: #101a30;
  --brass: #B8863B;
  --brass-light: #D9AE6C;
  --burgundy: #7A2E2E;
  --parchment: #F6F4F0;
  --parchment-card: #FFFFFF;
  --ink: #2B2825;
  --ink-soft: #5C574F;
  --line: #E4DED2;
  --success: #3F6E4E;
  --danger: #A23B3B;

  --font-display: 'Lora', Georgia, 'Times New Roman', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-card: 0 1px 2px rgba(27,42,74,0.06), 0 4px 12px rgba(27,42,74,0.08);
  --shadow-raised: 0 2px 4px rgba(27,42,74,0.08), 0 12px 28px rgba(27,42,74,0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  padding-bottom: 72px;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  color: var(--navy);
  font-weight: 600;
  letter-spacing: -0.01em;
}

a { color: var(--navy); }

button {
  font-family: var(--font-body);
  cursor: pointer;
}

/* ---------- Top bar ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  padding: 18px 20px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow-card);
}

.topbar-inner {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 19px;
  color: #fff;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.topbar-title .rule {
  width: 3px;
  height: 16px;
  background: var(--brass);
  display: inline-block;
  border-radius: 2px;
}

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.topbar-actions button, .topbar-actions a.install-link {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 13px;
  position: relative;
}
.topbar-actions button:hover, .topbar-actions a.install-link:hover { background: rgba(255,255,255,0.1); }

/* ---------- Search ---------- */
.search-wrap {
  max-width: 880px;
  margin: 16px auto 0;
  padding: 0 20px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  width: 100%;
  padding: 13px 16px 13px 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--parchment-card);
  font-size: 16px;
  color: var(--ink);
  box-shadow: var(--shadow-card);
}

.search-box input:focus {
  outline: 2px solid var(--brass);
  outline-offset: 1px;
}

.search-box .icon {
  position: absolute;
  left: 15px;
  color: var(--ink-soft);
  font-size: 16px;
  pointer-events: none;
}

/* ---------- Filter chips ---------- */
.chip-row {
  max-width: 880px;
  margin: 12px auto 0;
  padding: 0 20px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--parchment-card);
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.chip.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.chip-subrow {
  max-width: 880px;
  margin: 6px auto 0;
  padding: 8px 20px 0 32px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  border-top: 1px dashed var(--line);
}
.chip-subrow::-webkit-scrollbar { display: none; }

.chip-sub {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--parchment);
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.chip-sub.active {
  background: var(--brass);
  border-color: var(--brass);
  color: #fff;
}

/* ---------- Content container ---------- */
.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 20px;
}

.section-label {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 24px 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
.section-label:first-child { margin-top: 0; }

/* ---------- Household card (signature element) ---------- */
.household-card {
  background: var(--parchment-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  position: relative;
}

.household-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  background: var(--brass);
}

.household-card.staff-card::before {
  background: var(--burgundy);
}

.household-card.calendar-today {
  background: #FFFBF0;
  border-color: var(--brass-light);
  box-shadow: 0 0 0 2px rgba(184,134,59,0.25), var(--shadow-card);
}

.household-card.calendar-today::before {
  background: var(--brass);
  width: 6px;
}

.today-badge {
  display: inline-block;
  background: var(--brass);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 4px;
}

.household-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 10px 20px;
  border-bottom: 1px solid var(--line);
}

.household-name {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--navy);
}

.household-meta {
  font-size: 12px;
  color: var(--ink-soft);
}

.member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 12px 20px;
  border-bottom: 1px solid var(--line);
}
.member-row:last-child { border-bottom: none; }

/* ---------- View toggle ---------- */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--parchment-card);
}

.view-toggle-btn {
  border: none;
  background: none;
  padding: 6px 12px;
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1;
}

.view-toggle-btn.active {
  background: var(--navy);
  color: #fff;
}

/* ---------- Grid view ---------- */
.member-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.member-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 18px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}

.member-tile:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.avatar-lg {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 8px;
  box-shadow: 0 0 0 2px var(--parchment-card), 0 0 0 3px var(--line);
}

.avatar-lg-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  color: #fff;
  font-family: var(--font-display);
  font-size: 24px;
}

.member-tile-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 15px;
  flex-shrink: 0;
  object-fit: cover;
  border: 2px solid var(--parchment-card);
  box-shadow: 0 0 0 1px var(--line);
}

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

.member-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.staff-badge {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--burgundy);
  color: #fff;
  padding: 2px 7px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 600;
}

.member-sub {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 2px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.member-sub a {
  color: var(--ink-soft);
  text-decoration: none;
}
.member-sub a:hover { color: var(--navy); text-decoration: underline; }

.tag-pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #EFEAE0;
  color: var(--ink-soft);
}

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

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--parchment-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--navy);
}
.icon-btn:hover { background: var(--parchment); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
}

.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-deep); }

.btn-brass { background: var(--brass); color: #fff; }
.btn-brass:hover { background: #a5762f; }

.btn-outline { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-outline:hover { background: var(--parchment); }

.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(162,59,59,0.3); }
.btn-danger:hover { background: rgba(162,59,59,0.06); }

.btn-block { width: 100%; }

.fab {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brass);
  color: #fff;
  border: none;
  font-size: 26px;
  box-shadow: var(--shadow-raised);
  z-index: 15;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16,26,48,0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}

@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
}

.modal {
  background: var(--parchment-card);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 22px 20px 28px;
}

@media (min-width: 640px) {
  .modal { border-radius: var(--radius); }
}

.modal-title {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--navy);
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title button {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--ink-soft);
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="tel"],
.field input[type="email"],
.field input[type="date"],
.field select,
.field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: #fff;
  color: var(--ink);
  font-family: var(--font-body);
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--brass);
  outline-offset: 1px;
}

.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  gap: 10px;
}

.toggle-row:last-child { border-bottom: none; }

.toggle-label { font-size: 14px; color: var(--ink); }
.toggle-sub { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute;
  inset: 0;
  background: var(--line);
  border-radius: 999px;
  transition: 0.15s;
}
.switch .track::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch input:checked + .track { background: var(--success); }
.switch input:checked + .track::before { transform: translateX(18px); }

.tag-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-option {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 13px;
  background: #fff;
  color: var(--ink-soft);
}

.tag-option.selected {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.photo-upload {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.photo-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--parchment);
  border: 1px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 22px;
  overflow: hidden;
  object-fit: cover;
  flex-shrink: 0;
}

.photo-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-buttons label {
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--navy);
  cursor: pointer;
}
.photo-buttons input[type="file"] { display: none; }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
}
.empty-state .display { font-size: 18px; margin-bottom: 6px; }

/* ---------- Login screen ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  padding: 20px;
}

.login-card {
  background: var(--parchment-card);
  border-radius: var(--radius);
  padding: 36px 28px;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-raised);
  text-align: center;
}

.login-card .rule-h {
  width: 32px;
  height: 3px;
  background: var(--brass);
  margin: 0 auto 18px;
  border-radius: 2px;
}

.login-card h1 {
  font-size: 22px;
  margin: 0 0 6px;
}

.login-card p {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 24px;
}

.login-card .field { text-align: left; }

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

/* ---------- Approval queue badge ---------- */
.badge-count {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--burgundy);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.pending-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.pending-item:last-child { border-bottom: none; }

.pending-text { font-size: 14px; }
.pending-sub { font-size: 12px; color: var(--ink-soft); }

.pending-actions { display: flex; gap: 6px; }
.pending-actions button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  font-size: 14px;
}
.approve-btn { background: var(--success); color: #fff; }
.reject-btn { background: var(--danger); color: #fff; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow-raised);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}

/* ---------- Loading ---------- */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--brass);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  * { transition: none !important; }
}

button:focus-visible, .chip:focus-visible, .tag-option:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.hidden { display: none !important; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--parchment-card);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 25;
  box-shadow: 0 -2px 10px rgba(27,42,74,0.06);
}

.nav-btn {
  flex: 1;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-weight: 600;
}

.nav-btn .nav-icon { font-size: 19px; }

.nav-btn.active { color: var(--navy); }
