/* ---------------------------------------------------------------------------
   In-app notification bell + panel (pb_hooks/notifications_lib.js).

   z-index: the panel must clear the bottom tab bar (100) and the "…" post menu
   (120), but stay BELOW the drawer backdrop/panel (150/151) so opening the side
   menu covers it rather than fighting with it. Hence 130.

   Colours come from the CSS variables /theme.css overrides, so the staff
   retheme feature applies here too -- no hard-coded brand colours below except
   the white-on-header bell glyph, which lives on the fixed navy gradient.
   --------------------------------------------------------------------------- */

.topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.notif-bell {
  position: relative;
  display: inline-flex;
}

/* At least a 40px tap target on mobile, sitting beside the ☰ toggle. */
.notif-bell-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  background: none;
  border: none;
  color: #fff;
  line-height: 1;
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
}
.notif-bell-btn:hover { background: rgba(255, 255, 255, 0.12); }
.notif-bell-btn:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* The icon inherits the topbar's colour through currentColor, so /theme.css
   changes flow through to both the outline and the filled variant. */
.notif-bell-icon {
  display: inline-flex;
  color: currentColor;
}
.notif-bell-svg { display: block; }

.notif-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

/* The panel is fixed, not absolute: .topbar is a flex row and several page
   containers clip overflow, which would crop a panel positioned inside it. */
.notif-panel {
  position: fixed;
  top: 56px;
  right: 8px;
  z-index: 130;
  width: min(340px, calc(100vw - 16px));
  max-height: min(60vh, 460px);
  overflow-y: auto;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(13, 36, 71, 0.22);
}
.notif-panel[hidden] { display: none; }

.notif-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card);
}
.notif-panel-title { font-weight: 700; font-size: 0.95rem; }

.notif-action {
  background: none;
  border: none;
  color: var(--amber-700);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 6px;
}
.notif-action:hover { background: var(--amber-100); }

.notif-list { display: block; }

.notif-item-form { margin: 0; }

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  color: var(--text);
}
.notif-item:hover { background: var(--amber-100); }

/* Unread is signalled twice -- a tinted row AND a dot -- so it does not rely
   on colour alone. */
.notif-item.unread { background: var(--amber-100); }
.notif-item.unread .notif-item-title { font-weight: 700; }

.notif-item-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: transparent;
}
.notif-item.unread .notif-item-dot { background: var(--amber-700); }

.notif-item-text {
  flex: 1 1 auto;
  min-width: 0;
  display: block;
}
.notif-item-title {
  display: block;
  font-size: 0.88rem;
  line-height: 1.3;
}
.notif-item-body {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-top: 2px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.notif-item-time {
  flex: 0 0 auto;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding-top: 2px;
}

.notif-empty {
  margin: 0;
  padding: 22px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.notif-panel-foot {
  padding: 10px 12px;
  text-align: center;
}
.notif-settings-link { font-size: 0.8rem; font-weight: 600; }

/* --- staff "notification reach" table on /admin/notify ------------------- */
.reach-summary {
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--amber-100);
  font-size: 0.9rem;
}
.reach-summary strong { font-size: 1rem; }
.reach-note {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.reach-list { list-style: none; margin: 0; padding: 0; }
.reach-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.reach-row:last-child { border-bottom: none; }
.reach-name { flex: 1 1 auto; min-width: 0; }
.reach-tag {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.reach-tag.ok { background: #dcfce7; border-color: #86efac; color: #166534; }
.reach-tag.no { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }

/* ---------------------------------------------------------------------------
   "Turn on notifications" call to action inside the bell panel.

   Shown ONLY when the person has no push_subscriptions row. Without it the
   panel reads as broken for exactly the members we most need to reach: an
   empty list with no explanation and no way forward. With a subscription the
   CTA is absent -- nagging someone who is already set up is the fastest way
   to teach them to ignore the bell.
   --------------------------------------------------------------------------- */
.notif-setup-cta {
  display: block;
  margin: 8px 10px 4px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--amber-100);
  border: 1px solid var(--amber-200);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.4;
  min-height: 44px;
}
.notif-setup-cta:hover { background: var(--amber-200); text-decoration: none; }
.notif-setup-cta strong { display: block; color: var(--amber-700); margin-bottom: 2px; }
