/* Adapted from the cc-pastor-dir app's theme/layout — same look and feel,
   trimmed to what a single-purpose member directory needs (no tab bar,
   no AMA/admin/support views), plus form styles for self-service editing. */

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a5276;
  --primary-dark: #154360;
  --primary-light: #d6eaf8;
  --accent: #2980b9;
  --text: #1a1a2e;
  --text-sub: #5d6d7e;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dce3ea;
  --red: #c0392b;
  --green: #27ae60;
  --header-height: 56px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  background: var(--surface);
  box-shadow: 0 0 20px rgba(0,0,0,0.08);
  padding-top: env(safe-area-inset-top);
}

#app.hidden { display: none; }
.hidden { display: none; }

#app-header {
  height: var(--header-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--primary);
  color: white;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.header-link {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

#main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

/* ── List Header (sticky search) ────────────────────────────────────────── */
.list-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
}

.search-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

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

.church-filter {
  margin-top: 8px;
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text-sub);
  -webkit-appearance: none;
}

/* ── Item List ───────────────────────────────────────────────────────────── */
.list-item {
  min-height: 56px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  -webkit-tap-highlight-color: transparent;
}

.list-item:active { background: var(--primary-light); }

.item-name { font-size: 16px; font-weight: 500; color: var(--text); line-height: 1.3; }
.item-sub  { font-size: 13px; color: var(--text-sub); line-height: 1.3; }

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-sub);
  font-size: 15px;
}

/* ── Detail View ─────────────────────────────────────────────────────────── */
.detail-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--primary);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.back-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.back-btn:active { background: rgba(255,255,255,0.35); }

.edit-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.detail-body { padding: 20px 16px 120px; }

.detail-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 20px;
  line-height: 1.2;
}

.detail-section { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.detail-section:last-child { border-bottom: none; }

.detail-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-sub);
  margin-bottom: 4px;
}

.detail-value { font-size: 15px; color: var(--text); line-height: 1.5; }

.phone-link, .email-link { color: var(--accent); text-decoration: none; }

/* ── Action Bar ──────────────────────────────────────────────────────────── */
.action-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 600px;
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 20;
}

.action-btn {
  flex: 1;
  display: block;
  padding: 11px 4px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}

.action-btn:active { opacity: 0.75; }

.action-call    { background: var(--green);  color: white; }
.action-text    { background: #8e44ad;       color: white; }
.action-email   { background: var(--accent); color: white; }
.action-contact { background: var(--primary); color: white; }

/* ── Edit Form ───────────────────────────────────────────────────────────── */
.edit-field { margin-bottom: 14px; }

.edit-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-sub);
  margin-bottom: 4px;
}

.edit-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
}

.edit-field input:focus { border-color: var(--primary); }

.field-timestamp { font-size: 11px; color: var(--text-sub); margin-top: 3px; }

.save-btn {
  width: 100%;
  padding: 13px;
  border-radius: 10px;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}

.save-btn:disabled { opacity: 0.6; }

.save-status { font-size: 13px; margin-top: 8px; text-align: center; }
.save-status.success { color: var(--green); }
.save-status.error   { color: var(--red); }

/* ── Login Screen ────────────────────────────────────────────────────────── */
#login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

#login-screen.hidden { display: none; }

.login-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 40px 28px 36px;
  max-width: 340px;
  width: 100%;
  box-shadow: 0 4px 32px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.login-title { font-size: 26px; font-weight: 700; color: var(--primary); margin: 0; }
.login-subtitle { font-size: 14px; color: var(--text-sub); margin: 0 0 12px; }

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 13px 16px;
  border-radius: 10px;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
