/*
 * Roehos design system — hand-authored, no build step (spec §4: no Node
 * build required in production). Original palette/typography/components;
 * not derived from any competitor's visual design.
 */

:root {
  color-scheme: light;

  /* Brand: deep indigo (trust, calm authority) + warm amber (warmth, without
     being a cliché "church gold"). Neutral slate scale for structure. */
  --ink-900: #1b1730;
  --ink-800: #241f3d;
  --ink-700: #322b52;
  --violet-600: #4f3bd6;
  --violet-500: #6353e8;
  --violet-100: #ecebfd;
  --amber-500: #e5972f;
  --amber-100: #fdf1de;
  --green-600: #1f8a5f;
  --green-100: #e3f6ec;
  --red-600: #c8402e;
  --red-100: #fbe8e5;

  --slate-50: #f7f7fb;
  --slate-100: #eef0f5;
  --slate-200: #dfe1ea;
  --slate-300: #c3c6d4;
  --slate-500: #6d7186;
  --slate-600: #565a70;
  --slate-700: #3f4256;

  --bg: var(--slate-50);
  --surface: #ffffff;
  --text: var(--ink-900);
  --text-muted: var(--slate-500);
  --border: var(--slate-200);
  --primary: var(--violet-600);
  --primary-hover: var(--violet-500);
  --accent: var(--amber-500);
  --danger: var(--red-600);
  --success: var(--green-600);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(27, 23, 48, 0.06);
  --shadow: 0 4px 16px rgba(27, 23, 48, 0.08);
  --shadow-lg: 0 16px 40px rgba(27, 23, 48, 0.14);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0 0 0.4em; font-weight: 650; letter-spacing: -0.01em; color: var(--ink-900); }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .text-sm { font-size: 0.85rem; }
.text-muted { color: var(--text-muted); }

/* Phase 13 (Hardening, WCAG 2.4.1 "Bypass Blocks"): a keyboard/screen-reader
   user shouldn't have to tab through 30+ sidebar links to reach the page
   content. Off-screen until focused, then a real visible link. */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--primary); color: #fff; padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0; font-weight: 600;
}
.skip-link:focus { left: 0; text-decoration: none; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
  width: 248px; flex-shrink: 0; background: var(--ink-900); color: #e8e6f8;
  display: flex; flex-direction: column; padding: 20px 14px;
  /* Pinned to the viewport so only .app-nav scrolls on a tall page — the
     sidebar used to be a plain flex item with no height of its own, so it
     scrolled away with the page on any dashboard taller than one screen. */
  position: sticky; top: 0; height: 100vh; overflow: hidden;
}
.app-sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 6px 6px 22px 10px; }
.app-sidebar .brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--violet-500), var(--amber-500));
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; font-size: 15px;
  flex-shrink: 0;
}
.app-sidebar .brand-name { font-weight: 700; font-size: 1.05rem; color: #fff; flex: 1; white-space: nowrap; overflow: hidden; }
.sidebar-collapse-toggle {
  background: none; border: none; color: #a7a2cf; cursor: pointer; padding: 6px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.85rem;
}
.sidebar-collapse-toggle:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-collapse-toggle .icon-collapse { display: inline; }
.sidebar-collapse-toggle .icon-expand { display: none; }

.app-nav {
  display: flex; flex-direction: column; gap: 2px; flex: 1;
  /* min-height:0 is the classic flexbox fix that lets a flex child actually
     shrink below its content size — without it overflow-y:auto never kicks
     in and the nav just keeps growing the (sticky, fixed-height) sidebar. */
  min-height: 0; overflow-y: auto; overflow-x: hidden; padding-right: 2px; margin-right: -2px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.app-nav::-webkit-scrollbar { width: 6px; }
.app-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 3px; }
.app-nav > a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: #c7c3e6; font-size: 0.92rem; font-weight: 500;
}
.app-nav > a:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.app-nav > a.active { background: rgba(255,255,255,0.12); color: #fff; }

/* ---------- Collapsible nav groups ---------- */
.nav-group { margin-top: 10px; }
.nav-group-toggle {
  display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 8px;
  background: none; border: none; cursor: pointer; padding: 8px 12px 4px; font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.06em; color: #8b86b8;
}
.nav-group-toggle:hover { color: #c7c3e6; }
.nav-group-toggle .chevron { font-size: 0.65rem; transition: transform .15s; flex-shrink: 0; }
.nav-group.collapsed .nav-group-toggle .chevron { transform: rotate(-90deg); }
.nav-group.collapsed .nav-group-links { display: none; }
.nav-group-links { display: flex; flex-direction: column; gap: 2px; }
.nav-group-links a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: #c7c3e6; font-size: 0.92rem; font-weight: 500;
}
.nav-group-links a:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.nav-group-links a.active { background: rgba(255,255,255,0.12); color: #fff; }
.nav-icon { flex-shrink: 0; width: 1.1em; text-align: center; }

/* ---------- Fully-collapsed sidebar (icon rail) ---------- */
.app-sidebar.sidebar-collapsed { width: 68px; padding-left: 10px; padding-right: 10px; }
.app-sidebar.sidebar-collapsed .brand-name,
.app-sidebar.sidebar-collapsed .nav-label,
.app-sidebar.sidebar-collapsed .nav-group-toggle { display: none; }
.app-sidebar.sidebar-collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }
.app-sidebar.sidebar-collapsed .nav-group-links { display: flex !important; }
.app-sidebar.sidebar-collapsed .app-nav > a,
.app-sidebar.sidebar-collapsed .nav-group-links a { justify-content: center; padding: 10px; }
.app-sidebar.sidebar-collapsed .sidebar-collapse-toggle .icon-collapse { display: none; }
.app-sidebar.sidebar-collapsed .sidebar-collapse-toggle .icon-expand { display: inline; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 28px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.app-content { padding: 28px; flex: 1; }
.mobile-nav-toggle { display: none; }
.app-footer { padding: 20px 28px; color: var(--text-muted); font-size: 0.8rem; }

.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--violet-100); color: var(--violet-600);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem;
}

/* ---------- Guest (auth) layout ---------- */
.guest-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 15% 10%, var(--violet-100), var(--bg) 55%);
  padding: 24px;
}
.guest-card {
  width: 100%; max-width: 420px; background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 36px 32px; border: 1px solid var(--border);
}
.guest-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }

/* ---------- Cards / surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px; box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 18px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.grid { display: grid; gap: 18px; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 860px) {
  .grid-cols-2, .grid-cols-3 { grid-template-columns: 1fr; }
  /* Off-canvas nav (Phase 13, real gap: this used to just be `display:none`
     below 860px with no way to reopen it — every module link past whatever
     page you landed on was unreachable on a phone). Hidden off-screen by
     default, slid in by the hamburger button's `is-open` toggle. */
  .app-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: auto; z-index: 50; max-width: 82vw; width: 248px;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  .app-sidebar.is-open { transform: translateX(0); }
  /* The icon-rail collapse is a desktop convenience — off-canvas mobile nav is
     already hidden until opened, so there's nothing useful left to collapse. */
  .app-sidebar.sidebar-collapsed { width: 248px; }
  .app-sidebar.sidebar-collapsed .brand-name, .app-sidebar.sidebar-collapsed .nav-label { display: initial; }
  .app-sidebar.sidebar-collapsed .nav-group-toggle { display: flex; }
  .sidebar-collapse-toggle { display: none; }
  .mobile-nav-toggle { display: inline-flex; }
  .app-topbar { padding: 14px 16px; }
  .app-topbar > div:first-child { min-width: 0; flex-shrink: 1; }
  .app-topbar strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; display: inline-block; vertical-align: middle; }
  .app-content { padding: 18px; }
  .hide-mobile { display: none; }
}

.stat-tile { display: flex; flex-direction: column; gap: 4px; }
.stat-tile .value { font-size: 1.8rem; font-weight: 700; color: var(--ink-900); }
.stat-tile .label { color: var(--text-muted); font-size: 0.85rem; }

/* ---------- Dashboard: quick actions ---------- */
.quick-actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.quick-action-card {
  display: flex; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); transition: border-color .15s, box-shadow .15s; color: inherit;
}
.quick-action-card:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); text-decoration: none; }
.quick-action-card .icon {
  width: 40px; height: 40px; border-radius: 10px; background: var(--violet-100); color: var(--violet-600);
  display: flex; align-items: center; justify-content: center; font-size: 1.15rem; flex-shrink: 0;
}
.quick-action-card .title { font-weight: 650; color: var(--ink-900); font-size: 0.92rem; }
.quick-action-card .desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* ---------- Dashboard: attendance trend (dependency-free CSS bar chart) ---------- */
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 160px; }
.bar-chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-chart .bar-count { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 4px; }
.bar-chart .bar { width: 100%; max-width: 28px; background: var(--violet-500); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-chart .bar-label { font-size: 0.68rem; color: var(--text-muted); margin-top: 6px; white-space: nowrap; }

/* ---------- Dashboard: demographics donut (CSS conic-gradient, no JS/SVG) ---------- */
.donut-wrap { display: flex; flex-direction: column; align-items: center; }
.donut { width: 150px; height: 150px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.donut-hole { width: 100px; height: 100px; border-radius: 50%; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-hole .value { font-size: 1.3rem; font-weight: 700; color: var(--ink-900); }
.donut-hole .label { font-size: 0.72rem; color: var(--text-muted); }
.donut-legend { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; width: 100%; }
.donut-legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.donut-legend-item .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.donut-legend-item .count { margin-left: auto; color: var(--text-muted); }

/* ---------- Dashboard: list rows (upcoming events, celebrants) ---------- */
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row .title { font-weight: 600; font-size: 0.9rem; color: var(--ink-900); }
.list-row .meta { font-size: 0.78rem; color: var(--text-muted); }

/* ---------- Forms ---------- */
label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; color: var(--ink-800); }
.field { margin-bottom: 16px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date],
select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--slate-300); border-radius: var(--radius-sm);
  font-size: 0.92rem; font-family: var(--font); background: #fff; color: var(--text); transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--violet-100); }
.field-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.field-error { font-size: 0.8rem; color: var(--danger); margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px;
  border-radius: var(--radius-sm); font-weight: 600; font-size: 0.9rem; cursor: pointer; border: 1px solid transparent;
  transition: transform .04s, background .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn-secondary { background: #fff; border-color: var(--slate-300); color: var(--ink-800); }
.btn-secondary:hover { border-color: var(--slate-500); text-decoration: none; }
.btn-danger { background: var(--red-100); color: var(--red-600); }
.btn-danger:hover { background: #f6d8d3; text-decoration: none; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }

/* ---------- Badges / alerts ---------- */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-success { background: var(--green-100); color: var(--green-600); }
.badge-warning { background: var(--amber-100); color: #93590f; }
.badge-danger { background: var(--red-100); color: var(--red-600); }
.badge-neutral { background: var(--slate-100); color: var(--slate-600); }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 0.88rem; border: 1px solid transparent; }
.alert-success { background: var(--green-100); color: #145436; border-color: #bfe6d1; }
.alert-error { background: var(--red-100); color: #8c2c1e; border-color: #f0c1b8; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 2rem; margin-bottom: 10px; }

/* ---------- Steps (onboarding) ---------- */
.steps { display: flex; gap: 8px; margin-bottom: 26px; }
.steps .step { flex: 1; height: 4px; border-radius: 4px; background: var(--slate-200); }
.steps .step.done, .steps .step.active { background: var(--primary); }

.roadmap-note {
  border: 1px dashed var(--slate-300); border-radius: var(--radius); padding: 14px 16px;
  color: var(--text-muted); font-size: 0.85rem; background: var(--slate-50);
}

/* ---------- View tabs (People: All Contacts / Members / New Converts) ---------- */
.view-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-top: 16px; }
.view-tabs a { padding: 10px 4px; margin-right: 18px; font-size: 0.9rem; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; }
.view-tabs a:hover { color: var(--ink-900); text-decoration: none; }
.view-tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.toolbar .field { margin-bottom: 0; }
.toolbar-spacer { flex: 1; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; gap: 6px; margin-top: 18px; justify-content: center; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px;
  border-radius: var(--radius-sm); font-size: 0.85rem; padding: 0 8px; color: var(--ink-800);
}
.pagination a:hover { background: var(--slate-100); text-decoration: none; }
.pagination .current { background: var(--primary); color: #fff; font-weight: 600; }
.pagination .disabled { color: var(--slate-300); }

/* ---------- Tag pills ---------- */
.tag-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; background: var(--violet-100); color: var(--violet-600);
}
.tag-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.tag-pill form { display: inline; }
.tag-pill button { background: none; border: none; cursor: pointer; color: inherit; opacity: .6; font-size: .8rem; padding: 0; }
.tag-pill button:hover { opacity: 1; }

/* ---------- Person profile ---------- */
.profile-header { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; }
.avatar-lg {
  width: 64px; height: 64px; border-radius: 50%; background: var(--violet-100); color: var(--violet-600);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.4rem;
  overflow: hidden; flex-shrink: 0;
}
.avatar-lg img { width: 100%; height: 100%; object-fit: cover; }

.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: none; }
.timeline-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex-shrink: 0; }
.timeline-item .when { font-size: 0.75rem; color: var(--text-muted); }

.detail-list { display: grid; grid-template-columns: 140px 1fr; row-gap: 10px; font-size: 0.9rem; }
.detail-list dt { color: var(--text-muted); }
.detail-list dd { margin: 0; }
