/*
 * Platform sidebar — the one navigation component.
 *
 * dashboard.html and admin/manage.html each grew their own copy of this, which
 * is how the admin panel drifted into looking like a different product. Any page
 * that needs the platform nav should load this file plus /js/platform-sidebar.js
 * rather than hand-rolling a third copy.
 *
 * Depends on /styles/variables.css for its tokens.
 */

.app-layout {
  display: flex;
  min-height: calc(100vh - 80px);
}

.sidebar {
  width: 260px;
  background-color: var(--white);
  border-right: 1px solid var(--border-light);
  padding-bottom: var(--space-2);
  position: fixed;
  height: calc(100vh - 80px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4);
  padding-bottom: 100px;
  overflow-y: auto;
}

.nav-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
}

.nav-section-title:first-child { margin-top: 0; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  font-size: var(--text-sm);
  margin-bottom: var(--space-1);
  min-width: 0;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.sidebar-nav .nav-link > span { flex-shrink: 0; }

.sidebar-nav .nav-link > span:nth-child(2) {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav .nav-link:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.sidebar-nav .nav-link.active {
  background-color: var(--sage-soft, #EAF3F0);
  color: var(--primary, #2B6B5F);
  font-weight: 600;
}

.sidebar-nav .nav-link.active span:first-child { filter: none; }

.sidebar-nav .nav-link span:first-child {
  font-size: 18px;
  width: 20px;
  text-align: center;
}

.main-area {
  flex: 1;
  margin-left: 260px;
  min-width: 0;
  overflow-x: hidden;
}

.sidebar-close-btn {
  display: none;
  width: 100%;
  text-align: right;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.85rem 1.25rem;
  cursor: pointer;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 80px; left: 0; right: 0; bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9998;
}
.sidebar-overlay.show { display: block !important; }

.brand-header .mobile-menu-btn,
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  color: var(--text-primary);
}

/* Below 1024px the sidebar is a drawer, so the hamburger appears there. */
@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    left: -260px;
    top: 80px;
    width: 260px;
    max-width: 84vw;
    height: calc(100vh - 80px);
    transition: left 0.3s ease;
    z-index: 9999;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
  }
  .sidebar.open {
    left: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
    display: flex !important;
  }
  .main-area { margin-left: 0; }
  .sidebar-close-btn { display: block; }
  .brand-header .mobile-menu-btn,
  .mobile-menu-btn { display: inline-flex !important; }
}

/*
 * Content container inside .main-area.
 *
 * Pages each picked their own container (.wrap, .container, .page-content) and
 * most centred it with `margin: 0 auto`. Beside a fixed 260px sidebar that
 * produced a different left gutter on every page. One rule, left-aligned
 * against the sidebar, so the content column starts in the same place
 * everywhere. Specificity (0,2,0) beats a page's own bare `.wrap { }`.
 */
.main-area .page-content,
.main-area .wrap,
.main-area .container {
  max-width: 1400px;
  margin-left: 0;
  margin-right: 0;
  padding: var(--space-6);
}

@media (max-width: 767px) {
  .main-area .page-content,
  .main-area .wrap,
  .main-area .container {
    padding: var(--space-4);
  }
}

/*
 * Platform header. Also defined inline in dashboard.html, admin/manage.html and
 * church-analytics.html, which is how gift-results ended up with a teal bar and
 * dna-members with a thin white one. Pages loading this file get the shared
 * version; the inline copies should be removed as those pages are touched.
 */
.brand-header {
  background: #fff;
  border-bottom: 1px solid #e5e5e7;
  padding: 1rem 1.5rem;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 101;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.brand-header .brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-header .brand-logo img { height: 50px; width: auto; }

.brand-logo-content { display: flex; flex-direction: column; gap: 0.125rem; }

.brand-logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1d1d1f;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.brand-tagline {
  font-size: 0.6875rem;
  font-weight: 500;
  color: #86868b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1;
}

.brand-header .header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: #86868b;
}

/* Header identity chip, so every page shows who is signed in the same way. */
.ph-user { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.ph-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary, #2B6B5F); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700;
}
.ph-who { min-width: 0; }
.ph-name { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.ph-role { font-size: 0.75rem; color: var(--text-tertiary); text-transform: capitalize; line-height: 1.2; }
@media (max-width: 640px) { .ph-who { display: none; } }

/* Shared metric tile. Same anatomy as the admin Overview so a stat looks the
   same wherever it appears: tinted icon square, label + sub-label, trend pill,
   large number beneath. */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-6); }
.stat-tile {
  background: var(--white); border: 1px solid transparent; border-radius: 16px;
  padding: var(--space-5); text-align: left;
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.06);
}
.stat-tile .st-top { display: flex; align-items: flex-start; gap: 0.7rem; }
.stat-tile .st-ico {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.stat-tile .st-label { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); line-height: 1.3; }
.stat-tile .st-sub { font-size: 0.76rem; color: var(--text-tertiary); margin-top: 0.1rem; }
.stat-tile .st-n {
  font-size: 2rem; font-weight: 700; line-height: 1; color: var(--text-primary);
  margin-top: var(--space-4); letter-spacing: -0.02em;
}

/*
 * Touch targets.
 *
 * Chips, gift tags and small toggles measured 18-31px tall on a phone, under
 * every touch guideline. A first attempt grew the hit area with an absolutely
 * positioned ::after; a hit test showed the pads of stacked chips OVERLAPPING,
 * so tapping just under one tag activated the next one. An invisible mis-tap is
 * worse than a small target, so on touch devices the controls get real height
 * and real spacing instead.
 */
@media (pointer: coarse) {
  .chip,
  .view-btn,
  .toggle-btn,
  .outreach-btn,
  .ov-action,
  #adminDnaContent .chip,
  #adminDnaContent .view-btn,
  #adminGiftsContent .view-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .info-i { min-width: 32px; min-height: 32px; }

  a.tag,
  a.gift-chip,
  a.who-chip,
  #adminDnaContent a.tag,
  #adminDnaContent a.who-chip,
  #adminGiftsContent a.gift-chip {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
  }

  /* Inline call-to-action links inside note blocks and panels (e.g. "Show just
     those people", "What each spiritual gift means") are otherwise line-height tall. */
  .note a, .ov-card a, .panel-link,
  #adminDnaContent .note a { display: inline-block; min-height: 32px; line-height: 32px; }

  /* Spacing, not invisible overlays, is what separates the targets. */
  .wiring, .asmt,
  #adminDnaContent .wiring, #adminDnaContent .asmt { row-gap: 0.5rem; column-gap: 0.4rem; }
}
