:root {
  --primary: #5b3a8c;
  --primary-dark: #452a6e;
  --accent: #c9a227;
  --bg: #f6f4fa;
  --card: #ffffff;
  --text: #2b2438;
  --muted: #7a7290;
  --border: #e3ddf0;
  --danger: #c0392b;
  --success: #1e8e5a;
  --warning: #b7791f;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(43, 36, 56, 0.08);
}

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

body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-footer {
  margin-top: auto;
  text-align: center;
  padding: 12px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--card);
  border-top: 1px solid var(--border);
}

/* ---------- Top navigation ---------- */
.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--primary);
  color: #fff;
  padding: 0 20px;
  height: 58px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 1200;
}

.topnav .brand {
  font-size: 19px;
  font-weight: 700;
  margin-right: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
}

.topnav .brand .cross { color: var(--accent); font-size: 24px; }

.topnav a.nav-link {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14.5px;
  font-weight: 500;
  transition: background 0.15s;
}

.topnav a.nav-link:hover { background: rgba(255, 255, 255, 0.12); }
.topnav a.nav-link.active { background: var(--primary-dark); color: #fff; }
.topnav .spacer { flex: 1; }
.topnav .nav-user { font-size: 13px; opacity: 0.85; margin-right: 10px; }

/* ---------- Rotating Bible verse ---------- */
.verse-bar {
  background: #f7f1e3;
  color: #6b5a2e;
  border-bottom: 1px solid #eadfc3;
  text-align: center;
  padding: 7px 16px;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 13.5px;
  min-height: 32px;
  transition: opacity 0.5s;
}

.verse-bar.verse-fade { opacity: 0; }
.verse-bar .verse-ref { font-style: normal; font-size: 12px; opacity: 0.8; }

/* ---------- Layout ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
.page-wide { max-width: 1400px; }

h1.page-title { font-size: 26px; margin-bottom: 4px; }
p.page-sub { color: var(--muted); margin-bottom: 22px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}

.card h3 { margin-bottom: 8px; font-size: 17px; }
.card > p.muted { margin-bottom: 12px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; color: var(--text); }

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.inline-form input, .inline-form select { width: auto; flex: 1 1 140px; }
.inline-form textarea { flex: 1 1 100%; resize: vertical; }
.inline-form button { flex: 0 0 auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-secondary:hover { background: #f1ecfa; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #96281b; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #166e45; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-block { width: 100%; margin-top: 16px; }

/* ---------- Status badges & chips ---------- */
.badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.badge-pending { background: #fdf3df; color: var(--warning); }
.badge-approved { background: #e2f5eb; color: var(--success); }
.badge-rejected { background: #fbe4e1; color: var(--danger); }

.chip {
  display: inline-block;
  background: #ece6f7;
  color: var(--primary-dark);
  border-radius: 6px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 600;
  margin-right: 8px;
  min-width: 82px;
  text-align: center;
}

.chip-weekend { background: #f7ecd4; color: #8a6d1a; }

/* ---------- Lists ---------- */
.item-list { display: flex; flex-direction: column; gap: 6px; }

.item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  background: #faf8fd;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

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

/* ---------- Viewer: map + sidebar ---------- */
.viewer-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  flex: 1;
  min-height: 0;
}

@media (max-width: 800px) {
  .viewer-layout { grid-template-columns: 1fr; grid-template-rows: 45vh 1fr; }
  .viewer-sidebar { order: 2; }
}

.viewer-sidebar {
  background: var(--card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 18px;
}

.viewer-sidebar h2 { font-size: 17px; margin-bottom: 4px; }
.viewer-sidebar .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

.search-box { margin-bottom: 10px; }

.filter-row { display: flex; gap: 8px; margin-bottom: 10px; }
.filter-row select { flex: 1; }

.count-badge {
  background: #ece6f7;
  color: var(--primary-dark);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

.count-badge:empty { display: none; }

.dir-card {
  background: #faf8fd;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 18px;
}

.dir-card h2 { font-size: 15px; margin-bottom: 10px; }
.dir-card input[type="text"] { margin-bottom: 8px; }
.dir-card input[type="text"]:disabled { background: #efecf5; color: var(--muted); }

.check-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 8px;
  cursor: pointer;
}

.check-label input[type="checkbox"] { width: auto; accent-color: var(--primary); }

.dir-btns { display: flex; gap: 8px; margin-bottom: 8px; }
#route-result { font-size: 13.5px; line-height: 1.5; }

.popup-coords { color: var(--muted); font-size: 11.5px; font-family: monospace; }

.tel-link, .leaflet-container a.tel-link { color: var(--primary); font-weight: 600; text-decoration: none; }
.tel-link:hover, .leaflet-container a.tel-link:hover { text-decoration: underline; }

.coord-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.coord-inputs label { margin-top: 0; }

#map { height: 100%; width: 100%; }

.church-list-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.church-list-item:hover { border-color: var(--primary); background: #faf8fd; }
.church-list-item .name { font-weight: 600; font-size: 14.5px; }
.church-list-item .addr { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.church-list-item .dist { color: var(--primary); font-size: 12.5px; font-weight: 600; margin-top: 4px; }

/* ---------- Map popup ---------- */
.leaflet-popup-content { margin: 14px 16px; min-width: 260px; max-width: 320px; }
.leaflet-popup-content .popup-title { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.leaflet-popup-content .popup-addr { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }

.popup-section { margin-top: 10px; }
.popup-section h4 {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 3px;
  margin-bottom: 6px;
}

.popup-section.announce {
  background: #fdf9ec;
  border: 1px solid #f0e3b8;
  border-radius: 8px;
  padding: 8px 10px;
}

.popup-section.announce h4 { color: #8a6d1a; border-bottom-color: #f0e3b8; }
.announce-msg { font-size: 13px; margin-bottom: 4px; }

.timing-row { display: flex; gap: 8px; font-size: 13px; padding: 3px 0; }
.timing-day { font-weight: 600; min-width: 92px; flex-shrink: 0; }

/* Each mass time on its own line */
.timing-times { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.timing-time { line-height: 1.35; }

/* ---------- Auth box ---------- */
.auth-box { max-width: 420px; margin: 50px auto; }

.auth-tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 18px; }

.auth-tabs button {
  flex: 1;
  background: none;
  border: none;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}

.auth-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Tables (admin) ---------- */
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table th {
  text-align: left;
  padding: 10px 12px;
  background: #f1ecfa;
  color: var(--primary-dark);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
table.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:hover td { background: #faf8fd; }
.table-wrap { overflow-x: auto; }

/* ---------- Picker map ---------- */
.picker-map { height: 300px; border-radius: 8px; border: 1px solid var(--border); margin-top: 6px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: #fff;
  padding: 12px 22px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 3000;
  max-width: 90vw;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* ---------- Time View ---------- */
.tv-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.tv-controls label { margin: 0; }
.tv-controls select { width: auto; }

.tv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 22px;
  align-items: start;
}

@media (max-width: 600px) { .tv-grid { grid-template-columns: 1fr; } }

/* Time View accordion — styled after the diocesan reference design:
   sage-green time buttons, serif day headings, plain white panels */
.tv-col.tv-today {
  background: #f0f3ec;
  border-radius: var(--radius);
  padding: 12px;
  margin: -12px;
}

@media (max-width: 900px) { .tv-col.tv-today { margin: 0; } }

.tv-day {
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  font-size: 21px;
  letter-spacing: 0.3px;
  margin-bottom: 14px;
}

.tv-date {
  display: block;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 3px;
}

.tv-time {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #5c7a52;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 12px 16px;
  font-size: 14.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-top: 9px;
  transition: background 0.15s;
}

.tv-time:hover { background: #4b6543; }

.tv-count {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12px;
}

.tv-sign { margin-left: auto; font-size: 19px; line-height: 1; font-weight: 400; }

.tv-panel {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 10px 16px;
  margin-top: 5px;
}

.tv-church {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  font-size: 14px;
  color: #444;
  border-bottom: 1px solid #eee;
}

.tv-church:last-child { border-bottom: none; }

.tv-church[data-id] { cursor: pointer; }
.tv-church[data-id]:hover { background: #f4f7f1; }
.tv-church[data-id]:hover strong { color: #4b6543; text-decoration: underline; }

.tv-dist {
  color: #5c7a52;
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
}

.tv-fn-head {
  margin: 18px 0 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  color: #5c7a52;
  text-align: center;
}

.hidden { display: none !important; }

/* ---------- Priest rows ---------- */
.priest-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.priest-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

/* ---------- Consent checkbox ---------- */
.consent-label { margin-top: 14px; align-items: flex-start; }
.consent-label span { font-weight: 400; font-size: 13px; line-height: 1.4; }
.consent-label input { margin-top: 2px; }

/* ---------- Modal (Share dialog) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 36, 56, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}

.modal-box {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  padding: 22px;
  width: 100%;
  max-width: 440px;
}

.modal-box h3 { margin-bottom: 6px; }
.modal-box textarea { margin-top: 10px; resize: vertical; }

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
  .topnav { padding: 0 8px; height: 52px; }
  .topnav .brand { font-size: 15px; margin-right: 8px; }
  .topnav .brand .cross { font-size: 19px; }
  .topnav a.nav-link { padding: 7px 9px; font-size: 12.5px; }
  .topnav .nav-user { display: none; }

  .page { padding: 16px 12px 40px; }
  .card { padding: 14px; }

  /* Popup fits the phone screen */
  .leaflet-popup-content { min-width: 0; max-width: 76vw; margin: 12px 12px; }
  .timing-day { min-width: 74px; font-size: 12.5px; }
  .timing-row { font-size: 12.5px; }

  .viewer-sidebar { padding: 14px 12px; }
  .locate-btn { padding: 8px 12px; font-size: 12.5px; }
  .inline-form input, .inline-form select { flex: 1 1 110px; }
}

/* ---------- Hero banner (viewer) ---------- */
/* Rendered as a Leaflet control (bottom-left of the map) */
.locate-btn {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  box-shadow: var(--shadow);
}

.locate-btn:hover { background: #f1ecfa; }

/* Red cross church marker */
.church-marker {
  cursor: pointer;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

/* Church type chip (popup + sidebar) */
.type-tag {
  display: inline-block;
  background: #ece6f7;
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 1px 10px;
  font-size: 11.5px;
  font-weight: 600;
  margin: 2px 0 4px;
}
